1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpeclipse.wiki.editor;
13 import net.sourceforge.phpeclipse.wiki.editor.model.WikipediaOutlineParser;
14 import net.sourceforge.phpeclipse.wiki.editor.model.WikipediaSection;
16 import org.eclipse.core.runtime.IProgressMonitor;
17 import org.eclipse.jface.text.IDocument;
18 import org.eclipse.jface.text.IRegion;
19 import org.eclipse.jface.text.reconciler.DirtyRegion;
20 import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
21 import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
22 import org.eclipse.swt.widgets.Shell;
26 public class WikiReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension {
28 private WikiEditor fEditor;
29 private IDocument fDocument;
30 private IProgressMonitor fProgressMonitor;
32 private WikipediaOutlineParser fParser;
33 private WikiFoldingStructureProvider fFoldingStructureProvider;
35 public WikiReconcilingStrategy(WikiEditor editor) {
37 fParser= new WikipediaOutlineParser();
38 fFoldingStructureProvider= new WikiFoldingStructureProvider(editor);
41 public void setDocument(IDocument document) {
43 fFoldingStructureProvider.setDocument(fDocument);
46 public void setProgressMonitor(IProgressMonitor monitor) {
47 fProgressMonitor= monitor;
48 fFoldingStructureProvider.setProgressMonitor(fProgressMonitor);
51 public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
55 public void reconcile(IRegion partition) {
59 public void initialReconcile() {
63 private void reconcile() {
64 final WikipediaSection section= fParser.parse(fDocument);
68 Shell shell= fEditor.getSite().getShell();
69 if (shell == null || shell.isDisposed())
72 shell.getDisplay().asyncExec(new Runnable() {
74 fEditor.setSection(section);
77 fFoldingStructureProvider.updateFoldingRegions(section);