Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 153647 Details for
Bug 247221
[api] Non-validation annotations for the StructuredTextEditor
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch with listener in editor
247221.sse.reconciling_listeners_editor.patch (text/plain), 13.83 KB, created by
Nick Sandonato
on 2009-12-02 14:34:48 EST
(
hide
)
Description:
patch with listener in editor
Filename:
MIME Type:
Creator:
Nick Sandonato
Created:
2009-12-02 14:34:48 EST
Size:
13.83 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.wst.sse.ui >Index: src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java,v >retrieving revision 1.23 >diff -u -r1.23 DocumentRegionProcessor.java >--- src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java 28 Sep 2009 14:54:44 -0000 1.23 >+++ src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentRegionProcessor.java 2 Dec 2009 19:37:46 -0000 >@@ -14,8 +14,12 @@ > import java.io.IOException; > import java.io.StringReader; > import java.util.ArrayList; >+import java.util.Arrays; >+import java.util.HashSet; > import java.util.List; >+import java.util.Set; > >+import org.eclipse.core.runtime.NullProgressMonitor; > import org.eclipse.core.runtime.Platform; > import org.eclipse.core.runtime.content.IContentDescription; > import org.eclipse.core.runtime.content.IContentType; >@@ -26,6 +30,7 @@ > import org.eclipse.jface.text.Region; > import org.eclipse.jface.text.reconciler.DirtyRegion; > import org.eclipse.jface.text.reconciler.IReconcilingStrategy; >+import org.eclipse.jface.text.source.IAnnotationModel; > import org.eclipse.jface.text.source.ISourceViewer; > import org.eclipse.wst.sse.ui.internal.ExtendedConfigurationBuilder; > import org.eclipse.wst.sse.ui.internal.IReleasable; >@@ -45,7 +50,6 @@ > * validator strategies - DirtyRegion processing logic. > */ > public class DocumentRegionProcessor extends DirtyRegionProcessor { >- > private static final boolean DEBUG_VALIDATORS = Boolean.TRUE.toString().equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/reconcilerValidators")); //$NON-NLS-1$ > > /** >@@ -60,6 +64,8 @@ > */ > private ValidatorStrategy fValidatorStrategy; > >+ private ISourceReconcilingListener[] fReconcileListeners = new ISourceReconcilingListener[0]; >+ > private IReconcilingStrategy fSemanticHighlightingStrategy; > > /** >@@ -74,13 +80,24 @@ > * false otherwise > */ > private boolean fValidationEnabled; >- >+ >+ public void addReconcilingListener(ISourceReconcilingListener listener) { >+ Set listeners = new HashSet(Arrays.asList(fReconcileListeners)); >+ listeners.add(listener); >+ fReconcileListeners = (ISourceReconcilingListener[]) listeners.toArray(new ISourceReconcilingListener[listeners.size()]); >+ } >+ > protected void beginProcessing() { > super.beginProcessing(); > ValidatorStrategy validatorStrategy = getValidatorStrategy(); > if (validatorStrategy != null) { > validatorStrategy.beginProcessing(); > } >+ if ((getTextViewer() instanceof ISourceViewer)) { >+ for (int i = 0; i < fReconcileListeners.length; i++) { >+ fReconcileListeners[i].aboutToBeReconciled(); >+ } >+ } > } > > protected void endProcessing() { >@@ -100,6 +117,18 @@ > if (semanticHighlightingStrategy != null && document != null) { > semanticHighlightingStrategy.reconcile(new Region(0, document.getLength())); > } >+ >+ if ((getTextViewer() instanceof ISourceViewer)) { >+ ISourceViewer sourceViewer = (ISourceViewer) getTextViewer(); >+ IAnnotationModel annotationModel = sourceViewer.getAnnotationModel(); >+ for (int i = 0; i < fReconcileListeners.length; i++) { >+ fReconcileListeners[i].reconciled(document, annotationModel, false, new NullProgressMonitor()); >+ } >+ } >+ } >+ >+ public void forceReconciling() { >+ super.forceReconciling(); > } > > protected String getContentType(IDocument doc) { >@@ -282,6 +311,13 @@ > getFoldingStrategy().reconcile(dirtyRegion, null); > } > } >+ >+ public void removeReconcilingListener(ISourceReconcilingListener listener) { >+ Set listeners = new HashSet(Arrays.asList(fReconcileListeners)); >+ listeners.remove(listener); >+ fReconcileListeners = (ISourceReconcilingListener[]) listeners.toArray(new ISourceReconcilingListener[listeners.size()]); >+ } >+ > > public void setDocument(IDocument doc) { > super.setDocument(doc); >@@ -332,7 +368,7 @@ > */ > public void install(ITextViewer textViewer) { > super.install(textViewer); >- >+ > //determine if validation is enabled > this.fValidationEnabled = SSEUIPlugin.getInstance().getPreferenceStore().getBoolean( > CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS); >@@ -357,6 +393,8 @@ > fSpellcheckStrategy.setDocument(null); > fSpellcheckStrategy = null; > } >+ >+ fReconcileListeners = new ISourceReconcilingListener[0]; > } > super.uninstall(); > } >Index: src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java,v >retrieving revision 1.35 >diff -u -r1.35 DirtyRegionProcessor.java >--- src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java 20 Oct 2009 14:19:40 -0000 1.35 >+++ src/org/eclipse/wst/sse/ui/internal/reconcile/DirtyRegionProcessor.java 2 Dec 2009 19:37:46 -0000 >@@ -267,6 +267,7 @@ > /** The job should be reset because of document changes */ > private boolean fReset = false; > private boolean fIsCanceled = false; >+ private boolean fHasReconciled = false; > private Object LOCK = new Object(); > > /** >@@ -636,6 +637,11 @@ > if (!PlatformUI.isWorkbenchRunning()) > return status; > >+ if (!fHasReconciled) { >+ initialReconcile(); >+ fHasReconciled = true; >+ } >+ > Thread.currentThread().setPriority(Thread.MIN_PRIORITY); > boolean processed = false; > try { >@@ -708,6 +714,12 @@ > } > > /** >+ * This method is called before the initial reconciling of the document. >+ */ >+ protected void initialReconcile() { >+ } >+ >+ /** > * Sets the document partitioning for this reconciler. > * > * @param partitioning >@@ -718,6 +730,16 @@ > } > > /** >+ * Forces reconciling of the entire document. >+ */ >+ protected void forceReconciling() { >+ if (!fHasReconciled) >+ return; >+ >+ setEntireDocumentDirty(getDocument()); >+ } >+ >+ /** > * Basically means process the entire document. > * > * @param document >Index: src/org/eclipse/wst/sse/ui/StructuredTextEditor.java >=================================================================== >RCS file: /cvsroot/webtools/sourceediting/plugins/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java,v >retrieving revision 1.111 >diff -u -r1.111 StructuredTextEditor.java >--- src/org/eclipse/wst/sse/ui/StructuredTextEditor.java 1 Dec 2009 15:54:07 -0000 1.111 >+++ src/org/eclipse/wst/sse/ui/StructuredTextEditor.java 2 Dec 2009 19:37:46 -0000 >@@ -102,9 +102,11 @@ > import org.eclipse.ui.IEditorSite; > import org.eclipse.ui.IFileEditorInput; > import org.eclipse.ui.IPageLayout; >+import org.eclipse.ui.IPartListener; > import org.eclipse.ui.ISharedImages; > import org.eclipse.ui.IStorageEditorInput; > import org.eclipse.ui.IWorkbenchActionConstants; >+import org.eclipse.ui.IWorkbenchPart; > import org.eclipse.ui.PartInitException; > import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.contexts.IContextService; >@@ -181,6 +183,7 @@ > import org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.NullSourceEditingTextTools; > import org.eclipse.wst.sse.ui.internal.provisional.preferences.CommonEditorPreferenceNames; > import org.eclipse.wst.sse.ui.internal.reconcile.DocumentRegionProcessor; >+import org.eclipse.wst.sse.ui.internal.reconcile.ISourceReconcilingListener; > import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory; > import org.eclipse.wst.sse.ui.internal.style.SemanticHighlightingManager; > import org.eclipse.wst.sse.ui.internal.text.DocumentRegionEdgeMatcher; >@@ -803,6 +806,37 @@ > } > } > >+ private class PartListener implements IPartListener { >+ >+ ITextEditor fEditor; >+ >+ public PartListener(ITextEditor editor) { >+ fEditor = editor; >+ } >+ >+ public void partActivated(IWorkbenchPart part) { >+ if (part.getAdapter(ITextEditor.class) == fEditor) { >+ IReconciler reconciler = getSourceViewerConfiguration().getReconciler(getSourceViewer()); >+ if (reconciler instanceof DocumentRegionProcessor) { >+ ((DocumentRegionProcessor) reconciler).forceReconciling(); >+ } >+ } >+ } >+ >+ public void partBroughtToTop(IWorkbenchPart part) { >+ } >+ >+ public void partClosed(IWorkbenchPart part) { >+ } >+ >+ public void partDeactivated(IWorkbenchPart part) { >+ } >+ >+ public void partOpened(IWorkbenchPart part) { >+ } >+ >+ } >+ > /** > * Not API. May be removed in the future. > */ >@@ -855,7 +889,12 @@ > private OutlinePageListener fOutlinePageListener = null; > /** This editor's projection support */ > private ProjectionSupport fProjectionSupport; >+ > private IPropertySheetPage fPropertySheetPage; >+ >+ private ISourceReconcilingListener[] fReconcilingListeners = new ISourceReconcilingListener[0]; >+ private IPartListener fPartListener; >+ > private String fRememberTitle; > /** The ruler context menu to be disposed. */ > private Menu fRulerContextMenu; >@@ -1285,7 +1324,9 @@ > fInformationPresenter = new InformationPresenter(informationControlCreator); > fInformationPresenter.setSizeConstraints(60, 10, true, true); > fInformationPresenter.install(getSourceViewer()); >- >+ addReconcilingListeners(getSourceViewerConfiguration(), getTextViewer()); >+ fPartListener = new PartListener(this); >+ getSite().getWorkbenchWindow().getPartService().addPartListener(fPartListener); > installSemanticHighlighting(); > > >@@ -1529,7 +1570,12 @@ > > if (fDropTarget != null) > fDropTarget.dispose(); >- >+ >+ if (fPartListener != null) { >+ getSite().getWorkbenchWindow().getPartService().removePartListener(fPartListener); >+ fPartListener = null; >+ } >+ > uninstallSemanticHighlighting(); > > setPreferenceStore(null); >@@ -2650,18 +2696,49 @@ > * that viewer configuration could be set after editor part was created. > */ > protected void setSourceViewerConfiguration(SourceViewerConfiguration config) { >+ SourceViewerConfiguration oldSourceViewerConfiguration = getSourceViewerConfiguration(); > super.setSourceViewerConfiguration(config); > StructuredTextViewer stv = getTextViewer(); > if (stv != null) { >- // there should be no need to unconfigure >- // before configure because >- // configure will >- // also unconfigure before configuring >+ /* >+ * There should be no need to unconfigure before configure because >+ * configure will also unconfigure before configuring >+ */ >+ removeReconcilingListeners(oldSourceViewerConfiguration, stv); > stv.unconfigure(); > stv.configure(config); >+ addReconcilingListeners(config, stv); > } > } > >+ private void removeReconcilingListeners(SourceViewerConfiguration config, StructuredTextViewer stv) { >+ IReconciler reconciler = config.getReconciler(stv); >+ if (reconciler instanceof DocumentRegionProcessor) { >+ for (int i = 0; i < fReconcilingListeners.length; i++) { >+ ((DocumentRegionProcessor) reconciler).removeReconcilingListener(fReconcilingListeners[i]); >+ } >+ } >+ } >+ >+ private void addReconcilingListeners(SourceViewerConfiguration config, StructuredTextViewer stv) { >+ try { >+ List reconcilingListeners = new ArrayList(fReconcilingListeners.length); >+ String[] ids = getConfigurationPoints(); >+ for (int i = 0; i < ids.length; i++) { >+ reconcilingListeners.addAll(ExtendedConfigurationBuilder.getInstance().getConfigurations("sourceReconcilingListener", ids[i])); //$NON-NLS-1$ >+ } >+ fReconcilingListeners = (ISourceReconcilingListener[]) reconcilingListeners.toArray(new ISourceReconcilingListener[reconcilingListeners.size()]); >+ } >+ catch (ClassCastException e) { >+ Logger.log(Logger.ERROR, "Configuration has a reconciling listener that does not implement ISourceReconcilingListener."); //$NON-NLS-1$ >+ } >+ >+ IReconciler reconciler = config.getReconciler(stv); >+ if (reconciler instanceof DocumentRegionProcessor) { >+ for (int i = 0; i < fReconcilingListeners.length; i++) >+ ((DocumentRegionProcessor) reconciler).addReconcilingListener(fReconcilingListeners[i]); >+ } >+ } > /* > * (non-Javadoc) > * >Index: src/org/eclipse/wst/sse/ui/internal/reconcile/ISourceReconcilingListener.java >=================================================================== >RCS file: src/org/eclipse/wst/sse/ui/internal/reconcile/ISourceReconcilingListener.java >diff -N src/org/eclipse/wst/sse/ui/internal/reconcile/ISourceReconcilingListener.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/wst/sse/ui/internal/reconcile/ISourceReconcilingListener.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,44 @@ >+/******************************************************************************* >+ * Copyright (c) 2009 IBM Corporation and others. >+ * All rights reserved. This program and the accompanying materials >+ * are made available under the terms of the Eclipse Public License v1.0 >+ * which accompanies this distribution, and is available at >+ * http://www.eclipse.org/legal/epl-v10.html >+ * >+ * Contributors: >+ * IBM Corporation - initial API and implementation >+ *******************************************************************************/ >+ >+package org.eclipse.wst.sse.ui.internal.reconcile; >+ >+import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.jface.text.IDocument; >+import org.eclipse.jface.text.source.IAnnotationModel; >+ >+/** >+ * A course listener for source viewer "reconciling" of a document >+ * >+ */ >+public interface ISourceReconcilingListener { >+ >+ /** >+ * Called before reconciling is started. >+ */ >+ void aboutToBeReconciled(); >+ >+ /** >+ * Called after reconciling has been finished. >+ * >+ * @param document >+ * the text document or <code>null</code> if reconciliation has >+ * been cancelled >+ * @param model >+ * the annotation model that was changed or <code>null</code> >+ * if reconciliation has been cancelled >+ * @param forced >+ * <code>true</code> iff this reconciliation was forced >+ * @param progressMonitor >+ * the progress monitor >+ */ >+ void reconciled(IDocument document, IAnnotationModel model, boolean forced, IProgressMonitor progressMonitor); >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 247221
:
142080
|
149474
|
149476
|
150321
|
152754
| 153647