X-Git-Url: http://git.phpeclipse.com
diff --git a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
index 43295c7..a4f0ef5 100644
--- a/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
+++ b/net.sourceforge.phpeclipse/src/net/sourceforge/phpeclipse/phpeditor/PHPEditor.java
@@ -27,6 +27,8 @@ import net.sourceforge.phpdt.core.ISourceReference;
import net.sourceforge.phpdt.core.JavaCore;
import net.sourceforge.phpdt.core.JavaModelException;
import net.sourceforge.phpdt.internal.ui.actions.CompositeActionGroup;
+import net.sourceforge.phpdt.internal.ui.actions.FoldingActionGroup;
+import net.sourceforge.phpdt.internal.ui.text.CustomSourceInformationControl;
import net.sourceforge.phpdt.internal.ui.text.HTMLTextPresenter;
import net.sourceforge.phpdt.internal.ui.text.IPHPPartitions;
import net.sourceforge.phpdt.internal.ui.text.PHPPairMatcher;
@@ -36,6 +38,7 @@ import net.sourceforge.phpdt.ui.JavaUI;
import net.sourceforge.phpdt.ui.PreferenceConstants;
import net.sourceforge.phpdt.ui.actions.GotoMatchingBracketAction;
import net.sourceforge.phpdt.ui.text.JavaTextTools;
+import net.sourceforge.phpdt.ui.text.folding.IJavaFoldingStructureProvider;
import net.sourceforge.phpeclipse.PHPeclipsePlugin;
import org.eclipse.core.resources.IMarker;
@@ -81,6 +84,8 @@ import org.eclipse.jface.text.source.ISourceViewer;
import org.eclipse.jface.text.source.IVerticalRuler;
import org.eclipse.jface.text.source.OverviewRuler;
import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.text.source.projection.ProjectionSupport;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.viewers.ISelection;
@@ -125,8 +130,8 @@ import org.eclipse.ui.actions.ActionGroup;
import org.eclipse.ui.editors.text.DefaultEncodingSupport;
import org.eclipse.ui.editors.text.IEncodingSupport;
import org.eclipse.ui.part.IShowInTargetList;
+import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
import org.eclipse.ui.texteditor.DefaultRangeIndicator;
-import org.eclipse.ui.texteditor.ExtendedTextEditor;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IEditorStatusLine;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -140,7 +145,7 @@ import org.eclipse.ui.views.tasklist.TaskList;
/**
* PHP specific text editor.
*/
-public abstract class PHPEditor extends ExtendedTextEditor implements IViewPartInputProvider {
+public abstract class PHPEditor extends AbstractDecoratedTextEditor implements IViewPartInputProvider {
//extends StatusTextEditor implements IViewPartInputProvider { // extends TextEditor {
/**
* "Smart" runnable for updating the outline page's selection.
@@ -1159,6 +1164,23 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
protected CompositeActionGroup fActionGroups;
protected CompositeActionGroup fContextMenuGroup;
+ /**
+ * This editor's projection support
+ * @since 3.0
+ */
+ private ProjectionSupport fProjectionSupport;
+ /**
+ * This editor's projection model updater
+ * @since 3.0
+ */
+ private IJavaFoldingStructureProvider fProjectionModelUpdater;
+ /**
+ * The action group for folding.
+ *
+ * @since 3.0
+ */
+ private FoldingActionGroup fFoldingGroup;
+
/** The information presenter. */
private InformationPresenter fInformationPresenter;
/** The annotation access */
@@ -1262,6 +1284,9 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
super.doSetSelection(selection);
synchronizeOutlinePageSelection();
}
+ boolean isFoldingEnabled() {
+ return PHPeclipsePlugin.getDefault().getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_FOLDING_ENABLED);
+ }
/*
* @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.
* widgets.Composite)
@@ -1271,9 +1296,27 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
//fSourceViewerDecorationSupport.install(getPreferenceStore());
- Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
+ ProjectionViewer projectionViewer= (ProjectionViewer) getSourceViewer();
+
+ fProjectionSupport= new ProjectionSupport(projectionViewer, getAnnotationAccess(), getSharedColors());
+ fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.error"); //$NON-NLS-1$
+ fProjectionSupport.addSummarizableAnnotationType("org.eclipse.ui.workbench.texteditor.warning"); //$NON-NLS-1$
+ fProjectionSupport.setHoverControlCreator(new IInformationControlCreator() {
+ public IInformationControl createInformationControl(Shell shell) {
+ return new CustomSourceInformationControl(shell, IDocument.DEFAULT_CONTENT_TYPE);
+ }
+ });
+ fProjectionSupport.install();
+
+ fProjectionModelUpdater= PHPeclipsePlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+ if (fProjectionModelUpdater != null)
+ fProjectionModelUpdater.install(this, projectionViewer);
+
+ if (isFoldingEnabled())
+ projectionViewer.doOperation(ProjectionViewer.TOGGLE);
+ Preferences preferences = PHPeclipsePlugin.getDefault().getPluginPreferences();
preferences.addPropertyChangeListener(fPropertyChangeListener);
-
+
IInformationControlCreator informationControlCreator = new IInformationControlCreator() {
public IInformationControl createInformationControl(Shell parent) {
boolean cutDown = false;
@@ -1323,9 +1366,11 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
protected void createActions() {
super.createActions();
+ fFoldingGroup= new FoldingActionGroup(this, getViewer());
+
ResourceAction resAction= new TextOperationAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", this, ISourceViewer.INFORMATION, true); //$NON-NLS-1$
resAction= new InformationDispatchAction(PHPEditorMessages.getResourceBundle(), "ShowJavaDoc.", (TextOperationAction) resAction); //$NON-NLS-1$
- resAction.setActionDefinitionId(PHPEditorActionDefinitionIds.SHOW_JAVADOC);
+ resAction.setActionDefinitionId(net.sourceforge.phpdt.ui.actions.PHPEditorActionDefinitionIds.SHOW_JAVADOC);
setAction("ShowJavaDoc", resAction); //$NON-NLS-1$
// WorkbenchHelp.setHelp(resAction, IJavaHelpContextIds.SHOW_JAVADOC_ACTION);
@@ -1389,17 +1434,50 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
// add annotation actions
action= new JavaSelectMarkerRulerAction2(PHPEditorMessages.getResourceBundle(), "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
setAction("AnnotationAction", action); //$NON-NLS-1$
-
- // add annotation actions
- action= new JavaSelectMarkerRulerAction2(PHPEditorMessages.getResourceBundle(), "Editor.RulerAnnotationSelection.", this); //$NON-NLS-1$
- setAction("AnnotationAction", action); //$NON-NLS-1$
}
+ private void internalDoSetInput(IEditorInput input) throws CoreException {
+ super.doSetInput(input);
+
+ if (fEncodingSupport != null)
+ fEncodingSupport.reset();
+
+ setOutlinePageInput(fOutlinePage, input);
+
+ if (fProjectionModelUpdater != null)
+ fProjectionModelUpdater.initialize();
+
+// if (isShowingOverrideIndicators())
+// installOverrideIndicator(true);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#setPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)
+ * @since 3.0
+ */
+ protected void setPreferenceStore(IPreferenceStore store) {
+ super.setPreferenceStore(store);
+ if (getSourceViewerConfiguration() instanceof PHPSourceViewerConfiguration) {
+ JavaTextTools textTools= PHPeclipsePlugin.getDefault().getJavaTextTools();
+ setSourceViewerConfiguration(new PHPSourceViewerConfiguration(textTools.getColorManager(), store, this, IPHPPartitions.PHP_PARTITIONING));
+ }
+ if (getSourceViewer() instanceof JavaSourceViewer)
+ ((JavaSourceViewer)getSourceViewer()).setPreferenceStore(store);
+ }
/** The PHPEditor
implementation of this
* AbstractTextEditor
method performs any extra
* disposal actions required by the php editor.
*/
public void dispose() {
+ if (fProjectionModelUpdater != null) {
+ fProjectionModelUpdater.uninstall();
+ fProjectionModelUpdater= null;
+ }
+
+ if (fProjectionSupport != null) {
+ fProjectionSupport.dispose();
+ fProjectionSupport= null;
+ }
// PHPEditorEnvironment.disconnect(this);
if (fOutlinePage != null)
fOutlinePage.setInput(null);
@@ -1774,7 +1852,12 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
};
}
-
+ if (fProjectionSupport != null) {
+ Object adapter= fProjectionSupport.getAdapter(getSourceViewer(), required);
+ if (adapter != null)
+ return adapter;
+ }
+
return super.getAdapter(required);
}
// public Object getAdapter(Class required) {
@@ -1950,8 +2033,9 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
if (PreferenceConstants.EDITOR_DISABLE_OVERWRITE_MODE.equals(property)) {
if (event.getNewValue() instanceof Boolean) {
Boolean disable= (Boolean) event.getNewValue();
- configureInsertMode(OVERWRITE, !disable.booleanValue());
+ enableOverwriteMode(!disable.booleanValue());
}
+ return;
}
// if (PreferenceConstants.EDITOR_MARK_OCCURRENCES.equals(property)) {
@@ -1978,7 +2062,19 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
// }
// }
// }
-
+ if (PreferenceConstants.EDITOR_FOLDING_PROVIDER.equals(property)) {
+ if (sourceViewer instanceof ProjectionViewer) {
+ ProjectionViewer projectionViewer= (ProjectionViewer) sourceViewer;
+ if (fProjectionModelUpdater != null)
+ fProjectionModelUpdater.uninstall();
+ // either freshly enabled or provider changed
+ fProjectionModelUpdater= PHPeclipsePlugin.getDefault().getFoldingStructureProviderRegistry().getCurrentFoldingProvider();
+ if (fProjectionModelUpdater != null) {
+ fProjectionModelUpdater.install(this, projectionViewer);
+ }
+ }
+ return;
+ }
} finally {
super.handlePreferenceStoreChanged(event);
}
@@ -2129,7 +2225,14 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
if (!isEditingScriptRunning() && fUpdater != null)
fUpdater.post();
}
-
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#handleElementContentReplaced()
+ */
+ protected void handleElementContentReplaced() {
+ super.handleElementContentReplaced();
+ if (fProjectionModelUpdater != null)
+ fProjectionModelUpdater.initialize();
+ }
/**
* Initializes the given line number ruler column from the preference store.
* @param rulerColumn the ruler column to be initialized
@@ -2429,7 +2532,7 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
List segmentation = new ArrayList();
for (int i = 0; i < linePartitioning.length; i++) {
- if (IPHPPartitions.PHP_STRING.equals(linePartitioning[i].getType()))
+ if (IPHPPartitions.PHP_STRING_DQ.equals(linePartitioning[i].getType()))
segmentation.add(linePartitioning[i]);
}
@@ -2508,45 +2611,6 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
return getSourceViewer();
}
- protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
- ISourceViewer viewer= createJavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
-
- StyledText text= viewer.getTextWidget();
- text.addBidiSegmentListener(new BidiSegmentListener() {
- public void lineGetSegments(BidiSegmentEvent event) {
- event.segments= getBidiLineSegments(event.lineOffset, event.lineText);
- }
- });
-
-// JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
-
- // ensure source viewer decoration support has been created and configured
- getSourceViewerDecorationSupport(viewer);
-
- return viewer;
-
-// ISharedTextColors sharedColors = PHPeclipsePlugin.getDefault().getJavaTextTools().getColorManager();
-//
-// fOverviewRuler = new OverviewRuler(fAnnotationAccess, VERTICAL_RULER_WIDTH, sharedColors);
-// fOverviewRuler.addHeaderAnnotationType(AnnotationType.WARNING);
-// fOverviewRuler.addHeaderAnnotationType(AnnotationType.ERROR);
-//
-// ISourceViewer viewer = createJavaSourceViewer(parent, verticalRuler, fOverviewRuler, isOverviewRulerVisible(), styles);
-//
-// StyledText text = viewer.getTextWidget();
-// text.addBidiSegmentListener(new BidiSegmentListener() {
-// public void lineGetSegments(BidiSegmentEvent event) {
-// event.segments = getBidiLineSegments(event.lineOffset, event.lineText);
-// }
-// });
-//
-// // JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
-//
-// fSourceViewerDecorationSupport = new SourceViewerDecorationSupport(viewer, fOverviewRuler, fAnnotationAccess, sharedColors);
-// configureSourceViewerDecorationSupport();
-//
-// return viewer;
- }
// protected void showOverviewRuler() {
// if (fOverviewRuler != null) {
@@ -2579,13 +2643,39 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
// int styles) {
// return new SourceViewer(parent, ruler, overviewRuler, isOverviewRulerVisible(), styles);
// }
-
+ /*
+ * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
+ */
+ protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles, IPreferenceStore store) {
+ return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, store);
+ }
/*
* @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
*/
- protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) {
- return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
+ protected final ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
+
+ ISourceViewer viewer= createJavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles, getPreferenceStore());
+
+ StyledText text= viewer.getTextWidget();
+ text.addBidiSegmentListener(new BidiSegmentListener() {
+ public void lineGetSegments(BidiSegmentEvent event) {
+ event.segments= getBidiLineSegments(event.lineOffset, event.lineText);
+ }
+ });
+
+// JavaUIHelp.setHelp(this, text, IJavaHelpContextIds.JAVA_EDITOR);
+
+ // ensure source viewer decoration support has been created and configured
+ getSourceViewerDecorationSupport(viewer);
+
+ return viewer;
}
+ /*
+ * @see AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
+ */
+// protected ISourceViewer createJavaSourceViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean isOverviewRulerVisible, int styles) {
+// return new JavaSourceViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
+// }
/*
* @see AbstractTextEditor#affectsTextPresentation(PropertyChangeEvent)
*/
@@ -2708,4 +2798,59 @@ public abstract class PHPEditor extends ExtendedTextEditor implements IViewPart
fOccurrenceAnnotations= null;
}
}
+// protected void uninstallOverrideIndicator() {
+// if (fOverrideIndicatorManager != null) {
+// fOverrideIndicatorManager.removeAnnotations();
+// fOverrideIndicatorManager= null;
+// }
+//}
+
+protected void installOverrideIndicator(boolean waitForReconcilation) {
+// uninstallOverrideIndicator();
+ IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+// IJavaElement inputElement= getInputJavaElement();
+
+// if (model == null || inputElement == null)
+// return;
+
+// CompilationUnit ast= PHPeclipsePlugin.getDefault().getASTProvider().getAST(inputElement, true, null);
+// fOverrideIndicatorManager= new OverrideIndicatorManager(model, inputElement, ast);
+}
+
+/**
+ * Tells whether override indicators are shown.
+ *
+ * @return true
if the override indicators are shown
+ * @since 3.0
+ */
+//protected boolean isShowingOverrideIndicators() {
+// AnnotationPreference preference= getAnnotationPreferenceLookup().getAnnotationPreference(OverrideIndicatorManager.ANNOTATION_TYPE);
+// IPreferenceStore store= getPreferenceStore();
+// return getBoolean(store, preference.getHighlightPreferenceKey())
+// || getBoolean(store, preference.getVerticalRulerPreferenceKey())
+// || getBoolean(store, preference.getOverviewRulerPreferenceKey())
+// || getBoolean(store, preference.getTextPreferenceKey());
+//}
+
+/**
+ * Returns the boolean preference for the given key.
+ *
+ * @param store the preference store
+ * @param key the preference key
+ * @return true
if the key exists in the store and its value is true
+ * @since 3.0
+ */
+private boolean getBoolean(IPreferenceStore store, String key) {
+ return key != null && store.getBoolean(key);
+}
+
+ /**
+ * Returns the folding action group, or null
if there is none.
+ *
+ * @return the folding action group, or null
if there is none
+ * @since 3.0
+ */
+ protected FoldingActionGroup getFoldingActionGroup() {
+ return fFoldingGroup;
+ }
}