diff options
author | Kai Maetzel | 2003-03-06 10:41:43 +0000 |
---|---|---|
committer | Kai Maetzel | 2003-03-06 10:41:43 +0000 |
commit | 162cb7f13ff1aed4224789e28820a2f8cf7c0b2c (patch) | |
tree | 8b76425bd5d1ad83eca3c4f21e4bb578bbe29f61 | |
parent | 32dd7af663d874f8ad93bca6e87999dcc1f21dcd (diff) | |
download | eclipse.platform.text-162cb7f13ff1aed4224789e28820a2f8cf7c0b2c.tar.gz eclipse.platform.text-162cb7f13ff1aed4224789e28820a2f8cf7c0b2c.tar.xz eclipse.platform.text-162cb7f13ff1aed4224789e28820a2f8cf7c0b2c.zip |
#32456
12 files changed, 782 insertions, 436 deletions
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java index 9ea21c9d99d..e55739a78ff 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java @@ -14,6 +14,8 @@ package org.eclipse.ui.editors.text; import java.lang.reflect.InvocationTargetException; import java.text.MessageFormat; +import java.util.Iterator; +import java.util.List; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.widgets.Composite; @@ -56,12 +58,15 @@ import org.eclipse.ui.dialogs.SaveAsDialog; import org.eclipse.ui.internal.editors.text.*; import org.eclipse.ui.part.FileEditorInput; import org.eclipse.ui.texteditor.AddTaskAction; +import org.eclipse.ui.texteditor.AnnotationPreference; import org.eclipse.ui.texteditor.ConvertLineDelimitersAction; +import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess; import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds; import org.eclipse.ui.texteditor.IDocumentProvider; import org.eclipse.ui.texteditor.ITextEditorActionConstants; import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; +import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; import org.eclipse.ui.texteditor.ResourceAction; import org.eclipse.ui.texteditor.SourceViewerDecorationSupport; import org.eclipse.ui.texteditor.StatusTextEditor; @@ -88,50 +93,12 @@ public class TextEditor extends StatusTextEditor { private final static String LINE_NUMBER_COLOR= TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR; /** Preference key for showing the overview ruler */ private final static String OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER; - /** Preference key for error indication in overview ruler */ - private final static String ERROR_INDICATION_IN_OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER; - /** Preference key for warning indication in overview ruler */ - private final static String WARNING_INDICATION_IN_OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER; - /** Preference key for info indication in overview ruler */ - private final static String INFO_INDICATION_IN_OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_INFO_INDICATION_IN_OVERVIEW_RULER; - /** Preference key for task indication in overview ruler */ - private final static String TASK_INDICATION_IN_OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER; - /** Preference key for bookmark indication in overview ruler */ - private final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER; - /** Preference key for search result indication in overview ruler */ - private final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER; /** Preference key for unknown annotation indication in overview ruler */ private final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER= TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER; - - /** Preference key for error indication */ - private final static String ERROR_INDICATION= TextEditorPreferenceConstants.EDITOR_PROBLEM_INDICATION; - /** Preference key for error color */ - private final static String ERROR_INDICATION_COLOR= TextEditorPreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR; - /** Preference key for warning indication */ - private final static String WARNING_INDICATION= TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION; - /** Preference key for warning color */ - private final static String WARNING_INDICATION_COLOR= TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION_COLOR; - /** Preference key for info indication */ - private final static String INFO_INDICATION= TextEditorPreferenceConstants.EDITOR_INFO_INDICATION; - /** Preference key for info color */ - private final static String INFO_INDICATION_COLOR= TextEditorPreferenceConstants.EDITOR_INFO_INDICATION_COLOR; - /** Preference key for task indication */ - private final static String TASK_INDICATION= TextEditorPreferenceConstants.EDITOR_TASK_INDICATION; - /** Preference key for task color */ - private final static String TASK_INDICATION_COLOR= TextEditorPreferenceConstants.EDITOR_TASK_INDICATION_COLOR; - /** Preference key for bookmark indication */ - private final static String BOOKMARK_INDICATION= TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION; - /** Preference key for bookmark color */ - private final static String BOOKMARK_INDICATION_COLOR= TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR; - /** Preference key for search result indication */ - private final static String SEARCH_RESULT_INDICATION= TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION; - /** Preference key for search result color */ - private final static String SEARCH_RESULT_INDICATION_COLOR= TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR; /** Preference key for unknown annotation indication */ private final static String UNKNOWN_INDICATION= TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION; /** Preference key for unknown annotation color */ private final static String UNKNOWN_INDICATION_COLOR= TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR; - /** Preference key for highlighting current line */ private final static String CURRENT_LINE= TextEditorPreferenceConstants.EDITOR_CURRENT_LINE; /** Preference key for highlight color of current line */ @@ -168,6 +135,11 @@ public class TextEditor extends StatusTextEditor { * @since 2.0 */ protected DefaultEncodingSupport fEncodingSupport; + /** + * The annotation preferences. + * @since 2.1 + */ + private MarkerAnnotationPreferences fAnnotationPreferences; /** @@ -176,6 +148,7 @@ public class TextEditor extends StatusTextEditor { public TextEditor() { super(); initializeEditor(); + fAnnotationPreferences= new MarkerAnnotationPreferences(); } /** @@ -204,6 +177,9 @@ public class TextEditor extends StatusTextEditor { fSourceViewerDecorationSupport= null; } + fAnnotationPreferences= null; + fAnnotationAccess= null; + super.dispose(); } @@ -491,11 +467,17 @@ public class TextEditor extends StatusTextEditor { * @see org.eclipse.ui.texteditor.AbstractTextEditor#createSourceViewer(org.eclipse.swt.widgets.Composite, org.eclipse.jface.text.source.IVerticalRuler, int) */ protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { + fAnnotationAccess= createAnnotationAccess(); ISharedTextColors sharedColors= EditorsPlugin.getDefault().getSharedTextColors(); + fOverviewRuler= new OverviewRuler(fAnnotationAccess, VERTICAL_RULER_WIDTH, sharedColors); - fOverviewRuler.addHeaderAnnotationType(AnnotationType.WARNING); - fOverviewRuler.addHeaderAnnotationType(AnnotationType.ERROR); + Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator(); + while (e.hasNext()) { + AnnotationPreference preference= (AnnotationPreference) e.next(); + if (preference.contributesToHeader()) + fOverviewRuler.addHeaderAnnotationType(preference.getAnnotationType()); + } ISourceViewer sourceViewer= new SourceViewer(parent, ruler, fOverviewRuler, isOverviewRulerVisible(), styles); fSourceViewerDecorationSupport= new SourceViewerDecorationSupport(sourceViewer, fOverviewRuler, fAnnotationAccess, sharedColors); @@ -509,22 +491,18 @@ public class TextEditor extends StatusTextEditor { * @return the created annotation access */ protected IAnnotationAccess createAnnotationAccess() { - return new AnnotationAccess(); + return new DefaultMarkerAnnotationAccess(fAnnotationPreferences); } protected void configureSourceViewerDecorationSupport() { - - fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(AnnotationType.UNKNOWN, UNKNOWN_INDICATION_COLOR, UNKNOWN_INDICATION, UNKNOWN_INDICATION_IN_OVERVIEW_RULER, 0); - fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(AnnotationType.BOOKMARK, BOOKMARK_INDICATION_COLOR, BOOKMARK_INDICATION, BOOKMARK_INDICATION_IN_OVERVIEW_RULER, 1); - fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(AnnotationType.TASK, TASK_INDICATION_COLOR, TASK_INDICATION, TASK_INDICATION_IN_OVERVIEW_RULER, 2); - fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(AnnotationType.SEARCH, SEARCH_RESULT_INDICATION_COLOR, SEARCH_RESULT_INDICATION, SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER, 3); - fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(AnnotationType.INFO, INFO_INDICATION_COLOR, INFO_INDICATION, INFO_INDICATION_IN_OVERVIEW_RULER, 4); - fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(AnnotationType.WARNING, WARNING_INDICATION_COLOR, WARNING_INDICATION, WARNING_INDICATION_IN_OVERVIEW_RULER, 5); - fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(AnnotationType.ERROR, ERROR_INDICATION_COLOR, ERROR_INDICATION, ERROR_INDICATION_IN_OVERVIEW_RULER, 6); + + Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator(); + while (e.hasNext()) + fSourceViewerDecorationSupport.setAnnotationPreference((AnnotationPreference) e.next()); + fSourceViewerDecorationSupport.setAnnotationPainterPreferenceKeys(DefaultMarkerAnnotationAccess.UNKNOWN, UNKNOWN_INDICATION_COLOR, UNKNOWN_INDICATION, UNKNOWN_INDICATION_IN_OVERVIEW_RULER, 0); fSourceViewerDecorationSupport.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR); fSourceViewerDecorationSupport.setMarginPainterPreferenceKeys(PRINT_MARGIN, PRINT_MARGIN_COLOR, PRINT_MARGIN_COLUMN); - fSourceViewerDecorationSupport.setSymbolicFontName(getFontPropertyPreferenceKey()); } diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationAccess.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationAccess.java deleted file mode 100644 index 75f29e78634..00000000000 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationAccess.java +++ /dev/null @@ -1,81 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation -**********************************************************************/ - -package org.eclipse.ui.internal.editors.text; - -import org.eclipse.core.resources.IMarker; -import org.eclipse.core.runtime.CoreException; - -import org.eclipse.jface.text.source.Annotation; -import org.eclipse.jface.text.source.IAnnotationAccess; - -import org.eclipse.ui.texteditor.MarkerAnnotation; - -/** - * AnnotationAccess.java - */ -public class AnnotationAccess implements IAnnotationAccess { - - public AnnotationAccess() { - super(); - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationAccess#getType(org.eclipse.jface.text.source.Annotation) - */ - public Object getType(Annotation annotation) { - AnnotationType result= AnnotationType.UNKNOWN; - if (annotation instanceof MarkerAnnotation) { - IMarker marker= ((MarkerAnnotation) annotation).getMarker(); - if (marker != null && marker.exists()) { - try { - if (marker.isSubtypeOf(IMarker.BOOKMARK)) { - result= AnnotationType.BOOKMARK; - } else if (marker.isSubtypeOf(IMarker.TASK)) { - result= AnnotationType.TASK; - } else if (marker.isSubtypeOf(IMarker.PROBLEM)) { - int severity= marker.getAttribute(IMarker.SEVERITY, -1); - switch (severity) { - case IMarker.SEVERITY_ERROR: - result= AnnotationType.ERROR; - break; - case IMarker.SEVERITY_WARNING: - result= AnnotationType.WARNING; - break; - case IMarker.SEVERITY_INFO: - result= AnnotationType.INFO; - break; - } -// } else if (marker.isSubtypeOf(SearchUI.SEARCH_MARKER)) { -// result= AnnotationType.SEARCH; - } - } catch (CoreException e) { - } - } - } - return result; - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationAccess#isMultiLine(org.eclipse.jface.text.source.Annotation) - */ - public boolean isMultiLine(Annotation annotation) { - return true; - } - - /* - * @see org.eclipse.jface.text.source.IAnnotationAccess#isTemporary(org.eclipse.jface.text.source.Annotation) - */ - public boolean isTemporary(Annotation annotation) { - return false; - } - -} diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationType.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationType.java deleted file mode 100644 index 41f98dc7b9a..00000000000 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationType.java +++ /dev/null @@ -1,25 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation -**********************************************************************/ -package org.eclipse.ui.internal.editors.text; - -final public class AnnotationType { - - public final static AnnotationType UNKNOWN= new AnnotationType(); - public final static AnnotationType BOOKMARK= new AnnotationType(); - public final static AnnotationType TASK= new AnnotationType(); - public final static AnnotationType ERROR= new AnnotationType(); - public final static AnnotationType WARNING= new AnnotationType(); - public final static AnnotationType INFO= new AnnotationType(); - public final static AnnotationType SEARCH= new AnnotationType(); - - private AnnotationType() { - } -} diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java index 65e9cde440a..5ea50bfcc2d 100644 --- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java +++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java @@ -45,74 +45,22 @@ import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.editors.text.ITextEditorHelpContextIds; import org.eclipse.ui.editors.text.TextEditorPreferenceConstants; import org.eclipse.ui.help.WorkbenchHelp; +import org.eclipse.ui.texteditor.AnnotationPreference; +import org.eclipse.ui.texteditor.MarkerAnnotationPreferences; /* * The page for setting the editor options. */ public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbenchPreferencePage { - - public final OverlayPreferenceStore.OverlayKey[] fKeys= new OverlayPreferenceStore.OverlayKey[] { - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_CURRENT_LINE), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_PROBLEM_INDICATION), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_INFO_INDICATION_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_INFO_INDICATION), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_TASK_INDICATION_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_TASK_INDICATION), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_INFO_INDICATION_IN_OVERVIEW_RULER), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER), - -// new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS), - - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR), - new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER), - }; - private final String[][] fAppearanceColorListModel= new String[][] { {TextEditorMessages.getString("TextEditorPreferencePage.lineNumberForegroundColor"), TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, //$NON-NLS-1$ {TextEditorMessages.getString("TextEditorPreferencePage.currentLineHighlighColor"), TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, //$NON-NLS-1$ {TextEditorMessages.getString("TextEditorPreferencePage.printMarginColor"), TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, //$NON-NLS-1$ }; - private final String[][] fAnnotationColorListModel= new String[][] { - {TextEditorMessages.getString("TextEditorPreferencePage.annotations.errors"), TextEditorPreferenceConstants.EDITOR_PROBLEM_INDICATION_COLOR, TextEditorPreferenceConstants.EDITOR_PROBLEM_INDICATION, TextEditorPreferenceConstants.EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER }, //$NON-NLS-1$ - {TextEditorMessages.getString("TextEditorPreferencePage.annotations.warnings"), TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION_COLOR, TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION, TextEditorPreferenceConstants.EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER }, //$NON-NLS-1$ - {TextEditorMessages.getString("TextEditorPreferencePage.annotations.infos"), TextEditorPreferenceConstants.EDITOR_INFO_INDICATION_COLOR, TextEditorPreferenceConstants.EDITOR_INFO_INDICATION, TextEditorPreferenceConstants.EDITOR_INFO_INDICATION_IN_OVERVIEW_RULER }, //$NON-NLS-1$ - {TextEditorMessages.getString("TextEditorPreferencePage.annotations.tasks"), TextEditorPreferenceConstants.EDITOR_TASK_INDICATION_COLOR, TextEditorPreferenceConstants.EDITOR_TASK_INDICATION, TextEditorPreferenceConstants.EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER }, //$NON-NLS-1$ - {TextEditorMessages.getString("TextEditorPreferencePage.annotations.searchResults"), TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_COLOR, TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION, TextEditorPreferenceConstants.EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER }, //$NON-NLS-1$ - {TextEditorMessages.getString("TextEditorPreferencePage.annotations.bookmarks"), TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION_COLOR, TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION, TextEditorPreferenceConstants.EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER }, //$NON-NLS-1$ - {TextEditorMessages.getString("TextEditorPreferencePage.annotations.others"), TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER } //$NON-NLS-1$ - }; + private final String[][] fAnnotationColorListModel; private OverlayPreferenceStore fOverlayStore; @@ -151,7 +99,54 @@ public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbe public TextEditorPreferencePage2() { setDescription(TextEditorMessages.getString("TextEditorPreferencePage.description")); //$NON-NLS-1$ setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore()); - fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), fKeys); + + MarkerAnnotationPreferences preferences= new MarkerAnnotationPreferences(); + fOverlayStore= createOverlayStore(preferences); + fAnnotationColorListModel= createAnnotationTypeListModel(preferences); + } + + private OverlayPreferenceStore createOverlayStore(MarkerAnnotationPreferences preferences) { + + ArrayList overlayKeys= new ArrayList(); + Iterator e= preferences.getAnnotationPreferences().iterator(); + while (e.hasNext()) { + AnnotationPreference info= (AnnotationPreference) e.next(); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey())); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey())); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey())); + } + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_CURRENT_LINE)); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_PRINT_MARGIN)); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER)); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER)); + + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR)); + overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, TextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER)); + + OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; + overlayKeys.toArray(keys); + return new OverlayPreferenceStore(getPreferenceStore(), keys); + } + + private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) { + ArrayList listModelItems= new ArrayList(); + Iterator e= preferences.getAnnotationPreferences().iterator(); + while (e.hasNext()) { + AnnotationPreference info= (AnnotationPreference) e.next(); + listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey()}); + } + String[][] items= new String[listModelItems.size()][]; + listModelItems.toArray(items); + return items; } /* @@ -296,12 +291,7 @@ public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbe Composite composite= new Composite(parent, SWT.NULL); GridLayout layout= new GridLayout(); layout.numColumns= 2; composite.setLayout(layout); - -// String text= TextEditorMessages.getString("TextEditorPreferencePage.analyseAnnotationsWhileTyping"); //$NON-NLS-1$ -// addCheckBox(composite, text, TextEditorPreferenceConstants.EDITOR_EVALUTE_TEMPORARY_PROBLEMS, 0); -// -// addFiller(composite); - + Label label= new Label(composite, SWT.LEFT); label.setText(TextEditorMessages.getString("TextEditorPreferencePage.annotationPresentationOptions")); //$NON-NLS-1$ GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); @@ -405,15 +395,7 @@ public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbe return composite; } - -// private void addFiller(Composite composite) { -// Label filler= new Label(composite, SWT.LEFT ); -// GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL); -// gd.horizontalSpan= 2; -// gd.heightHint= convertHeightInCharsToPixels(1) / 2; -// filler.setLayoutData(gd); -// } - + /* * @see PreferencePage#createContents(Composite) */ @@ -624,5 +606,4 @@ public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbe break; } } - }
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml index 5d5f0426d2c..dabb2021e0a 100644 --- a/org.eclipse.ui.workbench.texteditor/plugin.xml +++ b/org.eclipse.ui.workbench.texteditor/plugin.xml @@ -8,58 +8,139 @@ <runtime> <library name="texteditor.jar"> - <export name="*"/> - <packages prefixes="org.eclipse.ui.texteditor,org.eclipse.ui.internal.texteditor"/> + <export name="*"/> + <packages prefixes="org.eclipse.ui.texteditor,org.eclipse.ui.internal.texteditor"/> </library> </runtime> - <requires> <import plugin="org.eclipse.text"/> <import plugin="org.eclipse.jface"/> <import plugin="org.eclipse.jface.text"/> <import plugin="org.eclipse.ui.workbench"/> - <import plugin="org.eclipse.core.resources"/> + <import plugin="org.eclipse.core.resources"/> </requires> -<!-- action definitions --> - -<extension point="org.eclipse.ui.actionDefinitions"> - <actionDefinition - id="org.eclipse.ui.edit.text.gotoLastEditPosition" - name= "%goToLastEditPosition.label" - description="%goToLastEditPosition.description" - /> -</extension> -<extension point="org.eclipse.ui.acceleratorSets"> - <acceleratorSet scopeId="org.eclipse.ui.globalScope" configurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> - <accelerator key="Ctrl+Q" id="org.eclipse.ui.edit.text.gotoLastEditPosition" /> - </acceleratorSet> - - <acceleratorSet scopeId="org.eclipse.ui.globalScope" configurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> - <accelerator key="Ctrl+Q" id="org.eclipse.ui.edit.text.gotoLastEditPosition" /> - </acceleratorSet> -</extension> + <extension-point id="markerAnnotationSpecification" name="Marker Annotation Specification" schema="schema/markerAnnotationSpecification.exsd"/> +<!-- action definitions --> + <extension + point="org.eclipse.ui.actionDefinitions"> + <actionDefinition + name="%goToLastEditPosition.label" + description="%goToLastEditPosition.description" + id="org.eclipse.ui.edit.text.gotoLastEditPosition"> + </actionDefinition> + </extension> + <extension + point="org.eclipse.ui.acceleratorSets"> + <acceleratorSet + scopeId="org.eclipse.ui.globalScope" + configurationId="org.eclipse.ui.defaultAcceleratorConfiguration"> + <accelerator + key="Ctrl+Q" + id="org.eclipse.ui.edit.text.gotoLastEditPosition"> + </accelerator> + </acceleratorSet> + <acceleratorSet + scopeId="org.eclipse.ui.globalScope" + configurationId="org.eclipse.ui.emacsAcceleratorConfiguration"> + <accelerator + key="Ctrl+Q" + id="org.eclipse.ui.edit.text.gotoLastEditPosition"> + </accelerator> + </acceleratorSet> + </extension> <!-- action sets --> - -<extension point="org.eclipse.ui.actionSets"> - <actionSet - id="org.eclipse.ui.edit.text.actionSet.navigation" - label="%textEditorNavigationActionSet.label" - visible="true"> - - <action id="gotoLastEditPosition" - definitionId="org.eclipse.ui.edit.text.gotoLastEditPosition" - toolbarPath="org.eclipse.ui.workbench.navigate/history.group" - menubarPath="navigate/" - label="%goToLastEditPosition.label" - tooltip="%goToLastEditPosition.tooltip" - disabledIcon="icons/full/dtool16/last_edit_pos.gif" - hoverIcon="icons/full/ctool16/last_edit_pos.gif" - icon="icons/full/etool16/last_edit_pos.gif" - class="org.eclipse.ui.internal.texteditor.GotoLastEditPositionAction"/> - </actionSet> -</extension> - + <extension + point="org.eclipse.ui.actionSets"> + <actionSet + label="%textEditorNavigationActionSet.label" + visible="true" + id="org.eclipse.ui.edit.text.actionSet.navigation"> + <action + toolbarPath="org.eclipse.ui.workbench.navigate/history.group" + id="gotoLastEditPosition" + hoverIcon="icons/full/ctool16/last_edit_pos.gif" + class="org.eclipse.ui.internal.texteditor.GotoLastEditPositionAction" + definitionId="org.eclipse.ui.edit.text.gotoLastEditPosition" + disabledIcon="icons/full/dtool16/last_edit_pos.gif" + icon="icons/full/etool16/last_edit_pos.gif" + label="%goToLastEditPosition.label" + menubarPath="navigate/" + tooltip="%goToLastEditPosition.tooltip"> + </action> + </actionSet> + </extension> +<!-- marker annotation types --> + <extension + point="org.eclipse.ui.workbench.texteditor.markerAnnotationSpecification"> + <specification + annotationType="org.eclipse.ui.workbench.texteditor.error" + label="Problems" + markerType="org.eclipse.core.resources.problemmarker" + markerSeverity="2" + textPreferenceKey="errorIndication" + textPreferenceValue="true" + overviewRulerPreferenceKey="errorIndicationInOverviewRuler" + overviewRulerPreferenceValue="true" + colorPreferenceKey="errorIndicationColor" + colorPreferenceValue="255,0,128" + presentationLayer="6" + contributesToHeader="true"> + </specification> + <specification + annotationType="org.eclipse.ui.workbench.texteditor.warning" + label="Warnings" + markerType="org.eclipse.core.resources.problemmarker" + markerSeverity="1" + textPreferenceKey="warningIndication" + textPreferenceValue="true" + overviewRulerPreferenceKey="warningIndicationInOverviewRuler" + overviewRulerPreferenceValue="true" + colorPreferenceKey="warningIndicationColor" + colorPreferenceValue="244,200,45" + presentationLayer="5" + contributesToHeader="true"> + </specification> + <specification + annotationType="org.eclipse.ui.workbench.texteditor.info" + label="Infos" + markerType="org.eclipse.core.resources.problemmarker" + textPreferenceKey="infoIndication" + textPreferenceValue="true" + overviewRulerPreferenceKey="infoIndicationInOverviewRuler" + overviewRulerPreferenceValue="true" + colorPreferenceKey="infoIndicationColor" + colorPreferenceValue="244,200,45" + presentationLayer="4" + contributesToHeader="false"> + </specification> + <specification + annotationType="org.eclipse.ui.workbench.texteditor.task" + label="Tasks" + markerType="org.eclipse.core.resources.taskmarker" + textPreferenceKey="taskIndication" + textPreferenceValue="true" + overviewRulerPreferenceKey="taskIndicationInOverviewRuler" + overviewRulerPreferenceValue="true" + colorPreferenceKey="taskIndicationColor" + colorPreferenceValue="0,128,255" + presentationLayer="2" + contributesToHeader="false"> + </specification> + <specification + annotationType="org.eclipse.ui.workbench.texteditor.bookmark" + label="Bookmarks" + markerType="org.eclipse.core.resources.bookmark" + textPreferenceKey="bookmarkIndication" + textPreferenceValue="true" + overviewRulerPreferenceKey="bookmarkIndicationInOverviewRuler" + overviewRulerPreferenceValue="true" + colorPreferenceKey="bookmarkIndicationColor" + colorPreferenceValue="34,164,99" + presentationLayer="1" + contributesToHeader="false"> + </specification> + </extension> </plugin> diff --git a/org.eclipse.ui.workbench.texteditor/schema/markerAnnotationSpecification.exsd b/org.eclipse.ui.workbench.texteditor/schema/markerAnnotationSpecification.exsd new file mode 100644 index 00000000000..c271eddc19b --- /dev/null +++ b/org.eclipse.ui.workbench.texteditor/schema/markerAnnotationSpecification.exsd @@ -0,0 +1,186 @@ +<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.workbench.texteditor">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ui.workbench.texteditor" id="markerAnnotationSpecification" name="Marker Annotation Specification"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="specification"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="specification">
+ <complexType>
+ <attribute name="markerType" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="colorPreferenceKey" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="overviewRulerPreferenceKey" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="textPreferenceKey" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="markerSeverity">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="0">
+ </enumeration>
+ <enumeration value="1">
+ </enumeration>
+ <enumeration value="2">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="colorPreferenceValue" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="presentationLayer" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="overviewRulerPreferenceValue" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="textPreferenceValue" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="annotationType" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="contributesToHeader" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ [Enter the first release in which this extension point appears.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ [Enter extension point usage example here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ [Enter API information here.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+ [Enter information about supplied implementation of this extension point.]
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/IDocumentProviderExtension.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/IDocumentProviderExtension.java deleted file mode 100644 index 9ca77d7971b..00000000000 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/IDocumentProviderExtension.java +++ /dev/null @@ -1,114 +0,0 @@ -/********************************************************************** -Copyright (c) 2000, 2002 IBM Corp. and others. -All rights reserved. This program and the accompanying materials -are made available under the terms of the Common Public License v1.0 -which accompanies this distribution, and is available at -http://www.eclipse.org/legal/cpl-v10.html - -Contributors: - IBM Corporation - Initial implementation -**********************************************************************/ - -package org.eclipse.ui.internal.texteditor; - - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - - -/** - * Extension interface for <code>IDocumentProvider</code>. It adds the following - * functions: - * <ul> - * <li> dealing with immutable domain elements - * <li> state validation - * <li> persistent status of domain element operations - * <li> extended synchronization support - * </ul> - * @since 2.0 - */ -public interface IDocumentProviderExtension { - - /** - * Returns whether the document provider thinks that the given element is read-only. - * If this method returns <code>true</code>, <code>saveDocument</code> could fail. - * This method does not say anything about the document constructed from the given - * element. If the given element is not connected to this document provider, the return - * value is undefined. Document providers are allowed to use a cache to answer this - * question, i.e. there can be a difference between the "real" state of the element and - * the return value. - * - * @param element the element - * @return <code>true</code> if the given element is read-only, <code>false</code> otherwise - */ - boolean isReadOnly(Object element); - - /** - * Returns whether the document provider thinks that the given element can persistently be modified. - * This is orthogonal to <code>isReadOnly</code> as read-only elements may be modifiable and - * writable elements may not be modifiable. If the given element is not connected to this document - * provider, the result is undefined. Document providers are allowed to use a cache to answer this - * question, i.e. there can be a difference between the "real" state of the element and the return - * value. - * - * @param element the element - * @return <code>true</code> if the given element is modifiable, <code>false</code> otherwise - */ - boolean isModifiable(Object element); - - /** - * Validates the state of the given element. This method may change the "real" state of the - * element. If using, it also updates the internal caches, so that this method may also change - * the results returned by <code>isReadOnly</code> and <code>isModifiable</code>. If the - * given element is not connected to this document provider, the effect is undefined. - * - * @param element the element - * @param computationContext the context in which the computation is performed, e.g., a SWT shell - * @exception CoreException if validating fails - */ - void validateState(Object element, Object computationContext) throws CoreException; - - /** - * Returns whether the state of the given element has been validated. - * - * @param element the element - */ - boolean isStateValidated(Object element); - - /** - * Updates the state cache for the given element. This method may change the result returned - * by <code>isReadOnly</code> and <code>isModifiable</code>. If the given element is not - * connected to this document provider, the effect is undefined. - * - * @param element the element - * @exception CoreException if validating fails - */ - void updateStateCache(Object element) throws CoreException; - - /** - * Marks the document managed for the given element as saveable. I.e. - * <code>canBeSaved(element)</code> will return <code>true</code> - * afterwards. - * - * @param element the element - */ - void setCanSaveDocument(Object element); - - /** - * Returns the status of the given element. - * - * @param element the element - * @return the status of the given element - */ - IStatus getStatus(Object element); - - /** - * Synchronizes the document provided for the given element with the - * given element. After that call <code>getSynchronizationTimeStamp</code> - * and <code>getModificationTimeStamp</code> return the same value. - * - * @param element the element - * @exception CoreException if the synchronization could not be performed - */ - void synchronize(Object element) throws CoreException; -}
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java index 22f27271104..04b7cef99cf 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java @@ -1,13 +1,13 @@ -/* - * Copyright (c) 2000, 2002 IBM Corp. and others.. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Common Public License v0.5 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/cpl-v05.html - * - * Contributors: - * IBM Corporation - initial API and implementation - */ +/********************************************************************** +Copyright (c) 2000, 2003 IBM Corp. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation +**********************************************************************/ package org.eclipse.ui.internal.texteditor; import java.util.HashSet; @@ -17,6 +17,7 @@ import java.util.Set; import org.eclipse.core.runtime.IPluginDescriptor; import org.eclipse.jface.action.IAction; + import org.eclipse.jface.text.Assert; import org.eclipse.ui.plugin.AbstractUIPlugin; diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java new file mode 100644 index 00000000000..d8a7910e12a --- /dev/null +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java @@ -0,0 +1,147 @@ +/********************************************************************** +Copyright (c) 2000, 2003 IBM Corp. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation +**********************************************************************/ +package org.eclipse.ui.texteditor; + +import org.eclipse.swt.graphics.RGB; + + +/** + * @since 2.1 + */ +public class AnnotationPreference { + + private Object fAnnotationType; + private String fPreferenceLabel; + private String fMarkerType; + private int fSeverity; + private String fColorKey; + private RGB fColorValue; + private String fTextKey; + private boolean fTextValue; + private String fOverviewRulerKey; + private boolean fOverviewRulerValue; + private int fPresentationLayer; + private boolean fContributesToHeader; + + + public AnnotationPreference() { + } + + public AnnotationPreference(Object annotationType, String colorKey, String textKey, String overviewRulerKey, int presentationLayer) { + fAnnotationType= annotationType; + fColorKey= colorKey; + fTextKey= textKey; + fOverviewRulerKey= overviewRulerKey; + fPresentationLayer= presentationLayer; + } + + public boolean isPreferenceKey(String key) { + if (key == null) + return false; + return key.equals(fColorKey) || key.equals(fOverviewRulerKey) || key.equals(fTextKey); + } + + public Object getAnnotationType() { + return fAnnotationType; + } + + public String getMarkerType() { + return fMarkerType; + } + + public String getColorPreferenceKey() { + return fColorKey; + } + + public RGB getColorPreferenceValue() { + return fColorValue; + } + + public String getPreferenceLabel() { + return fPreferenceLabel; + } + + public String getOverviewRulerPreferenceKey() { + return fOverviewRulerKey; + } + + public boolean getOverviewRulerPreferenceValue() { + return fOverviewRulerValue; + } + + public int getPresentationLayer() { + return fPresentationLayer; + } + + public int getSeverity() { + return fSeverity; + } + + public String getTextPreferenceKey() { + return fTextKey; + } + + public boolean getTextPreferenceValue() { + return fTextValue; + } + + public boolean contributesToHeader() { + return fContributesToHeader; + } + + public void setAnnotationType(Object annotationType) { + fAnnotationType= annotationType; + } + + public void setMarkerType(String markerType) { + fMarkerType= markerType; + } + + public void setColorPreferenceKey(String colorKey) { + fColorKey= colorKey; + } + + public void setColorPreferenceValue(RGB colorValue) { + fColorValue= colorValue; + } + + public void setPreferenceLabel(String label) { + fPreferenceLabel= label; + } + + public void setOverviewRulerPreferenceKey(String overviewRulerKey) { + fOverviewRulerKey= overviewRulerKey; + } + + public void setOverviewRulerPreferenceValue(boolean overviewRulerValue) { + fOverviewRulerValue= overviewRulerValue; + } + + public void setPresentationLayer(int presentationLayer) { + fPresentationLayer= presentationLayer; + } + + public void setSeverity(int severity) { + fSeverity= severity; + } + + public void setTextPreferenceKey(String textKey) { + fTextKey= textKey; + } + + public void setTextPreferenceValue(boolean textValue) { + fTextValue= textValue; + } + + public void setContributesToHeader(boolean contributesToHeader) { + fContributesToHeader= contributesToHeader; + } +} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java new file mode 100644 index 00000000000..0f7c2fbcb10 --- /dev/null +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java @@ -0,0 +1,84 @@ +/********************************************************************** +Copyright (c) 2000, 2003 IBM Corp. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation +**********************************************************************/ +package org.eclipse.ui.texteditor; + +import java.util.Iterator; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.CoreException; + +import org.eclipse.jface.text.source.Annotation; +import org.eclipse.jface.text.source.IAnnotationAccess; + +import org.eclipse.ui.internal.texteditor.TextEditorPlugin; + + +/** + * @since 2.1 + */ +public class DefaultMarkerAnnotationAccess implements IAnnotationAccess { + + public final static String UNKNOWN= TextEditorPlugin.PLUGIN_ID + ".unknown"; //$NON-NLS-1$ + + protected MarkerAnnotationPreferences fMarkerAnnotationPreferences; + + public DefaultMarkerAnnotationAccess(MarkerAnnotationPreferences markerAnnotationPreferences) { + fMarkerAnnotationPreferences= markerAnnotationPreferences; + } + + private AnnotationPreference getAnnotationPreference(IMarker marker) { + + try { + + int severity= marker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO); + + Iterator e= fMarkerAnnotationPreferences.getAnnotationPreferences().iterator(); + while (e.hasNext()) { + AnnotationPreference info= (AnnotationPreference) e.next(); + if (marker.isSubtypeOf(info.getMarkerType()) && severity == info.getSeverity()) + return info; + } + + } catch (CoreException x) { + } + + return null; + } + /* + * @see org.eclipse.jface.text.source.IAnnotationAccess#getType(org.eclipse.jface.text.source.Annotation) + */ + public Object getType(Annotation annotation) { + if (annotation instanceof MarkerAnnotation) { + MarkerAnnotation markerAnnotation= (MarkerAnnotation) annotation; + IMarker marker= markerAnnotation.getMarker(); + if (marker != null && marker.exists()) { + AnnotationPreference preference= getAnnotationPreference(marker); + if (preference != null) + return preference.getAnnotationType(); + } + } + return UNKNOWN; + } + + /* + * @see org.eclipse.jface.text.source.IAnnotationAccess#isMultiLine(org.eclipse.jface.text.source.Annotation) + */ + public boolean isMultiLine(Annotation annotation) { + return true; + } + + /* + * @see org.eclipse.jface.text.source.IAnnotationAccess#isTemporary(org.eclipse.jface.text.source.Annotation) + */ + public boolean isTemporary(Annotation annotation) { + return false; + } +} diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java new file mode 100644 index 00000000000..b175db8a8f4 --- /dev/null +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java @@ -0,0 +1,115 @@ +/********************************************************************** +Copyright (c) 2000, 2003 IBM Corp. and others. +All rights reserved. This program and the accompanying materials +are made available under the terms of the Common Public License v1.0 +which accompanies this distribution, and is available at +http://www.eclipse.org/legal/cpl-v10.html + +Contributors: + IBM Corporation - Initial implementation +**********************************************************************/ + +package org.eclipse.ui.texteditor; + + +import java.util.ArrayList; +import java.util.List; + +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionPoint; +import org.eclipse.core.runtime.Platform; + +import org.eclipse.swt.graphics.RGB; + +import org.eclipse.jface.resource.StringConverter; + +import org.eclipse.ui.internal.texteditor.TextEditorPlugin; + + +/** + * @since 2.1 + */ +public class MarkerAnnotationPreferences { + + private List fPreferences; + + public MarkerAnnotationPreferences() { + } + + public List getAnnotationPreferences() { + if (fPreferences == null) + initialize(); + return fPreferences; + } + + private void initialize() { + + // initialize lists - indicates that the initialization happened + fPreferences= new ArrayList(2); + + // populate list + IExtensionPoint extensionPoint= Platform.getPluginRegistry().getExtensionPoint(TextEditorPlugin.PLUGIN_ID, "markerAnnotationSpecification"); //$NON-NLS-1$ + if (extensionPoint != null) { + IConfigurationElement[] elements= extensionPoint.getConfigurationElements(); + for (int i= 0; i < elements.length; i++) { + AnnotationPreference spec= createSpec(elements[i]); + if (spec != null) + fPreferences.add(createSpec(elements[i])); + } + } + } + + private AnnotationPreference createSpec(IConfigurationElement element) { + + String s; + int i; + boolean b; + + AnnotationPreference info= new AnnotationPreference(); + + s= element.getAttribute("annotationType"); //$NON-NLS-1$ + if (s == null || s.trim().length() == 0) return null; + info.setAnnotationType(s); + + s= element.getAttribute("label"); //$NON-NLS-1$ + if (s == null || s.trim().length() == 0) return null; + info.setPreferenceLabel(s); + + s= element.getAttribute("markerType"); //$NON-NLS-1$ + if (s == null || s.trim().length() == 0) return null; + info.setMarkerType(s); + + i= StringConverter.asInt(element.getAttribute("markerSeverity"), IMarker.SEVERITY_INFO); //$NON-NLS-1$ + info.setSeverity(i); + + s= element.getAttribute("textPreferenceKey"); //$NON-NLS-1$ + if (s == null || s.trim().length() == 0) return null; + info.setTextPreferenceKey(s); + + b= StringConverter.asBoolean(element.getAttribute("textPreferenceValue"), false); //$NON-NLS-1$ + info.setTextPreferenceValue(b); + + s= element.getAttribute("overviewRulerPreferenceKey"); //$NON-NLS-1$ + if (s == null || s.trim().length() == 0) return null; + info.setOverviewRulerPreferenceKey(s); + + b= StringConverter.asBoolean(element.getAttribute("overviewRulerPreferenceValue"), false); //$NON-NLS-1$ + info.setOverviewRulerPreferenceValue(b); + + s= element.getAttribute("colorPreferenceKey"); //$NON-NLS-1$ + if (s == null || s.trim().length() == 0) return null; + info.setColorPreferenceKey(s); + + RGB rgb= StringConverter.asRGB(element.getAttribute("colorPreferenceValue"), new RGB(0, 0, 0)); //$NON-NLS-1$ + info.setColorPreferenceValue(rgb); + + i= StringConverter.asInt(element.getAttribute("presentationLayer"), 0); //$NON-NLS-1$ + info.setPresentationLayer(i); + + b= StringConverter.asBoolean(element.getAttribute("contributesToHeader"), false); //$NON-NLS-1$ + info.setContributesToHeader(b); + + return info; + } +}
\ No newline at end of file diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java index eecf9692dbf..0c6884914e6 100644 --- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java +++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java @@ -43,14 +43,6 @@ import org.eclipse.jface.util.PropertyChangeEvent; public class SourceViewerDecorationSupport { - static class AnnotationTypePreferenceInfo { - public Object fAnnotationType; - public String fColorKey; - public String fOverviewRulerKey; - public String fEditorKey; - public int fLayer; - }; - private class FontPropertyChangeListener implements IPropertyChangeListener { /* * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent) @@ -238,13 +230,16 @@ public class SourceViewerDecorationSupport { * overview ruler */ public void setAnnotationPainterPreferenceKeys(Object type, String colorKey, String editorKey, String overviewRulerKey, int layer) { - AnnotationTypePreferenceInfo info= new AnnotationTypePreferenceInfo(); - info.fAnnotationType= type; - info.fColorKey= colorKey; - info.fEditorKey= editorKey; - info.fOverviewRulerKey= overviewRulerKey; - info.fLayer= layer; - fAnnotationTypeKeyMap.put(info.fAnnotationType, info); + AnnotationPreference info= new AnnotationPreference(type, colorKey, editorKey, overviewRulerKey, layer); + fAnnotationTypeKeyMap.put(type, info); + } + + /** + * Sets the preference info for the annotation painter. + * @param info the preference info to be set + */ + public void setAnnotationPreference(AnnotationPreference info) { + fAnnotationTypeKeyMap.put(info.getAnnotationType(), info); } /** @@ -290,14 +285,12 @@ public class SourceViewerDecorationSupport { fSymbolicFontName= symbolicFontName; } - private AnnotationTypePreferenceInfo getAnnotationTypePreferenceInfo(String preferenceKey) { + private AnnotationPreference getAnnotationPreferenceInfo(String preferenceKey) { Iterator e= fAnnotationTypeKeyMap.values().iterator(); while (e.hasNext()) { - AnnotationTypePreferenceInfo info= (AnnotationTypePreferenceInfo) e.next(); - if (info != null) { - if (preferenceKey.equals(info.fColorKey) || preferenceKey.equals(info.fEditorKey) || preferenceKey.equals(info.fOverviewRulerKey)) - return info; - } + AnnotationPreference info= (AnnotationPreference) e.next(); + if (info != null && info.isPreferenceKey(preferenceKey)) + return info; } return null; } @@ -362,32 +355,32 @@ public class SourceViewerDecorationSupport { return; } - AnnotationTypePreferenceInfo info= getAnnotationTypePreferenceInfo(p); + AnnotationPreference info= getAnnotationPreferenceInfo(p); if (info != null) { - if (info.fColorKey.equals(p)) { - Color color= getColor(info.fColorKey); + if (info.getColorPreferenceKey().equals(p)) { + Color color= getColor(info.getColorPreferenceKey()); if (fAnnotationPainter != null) { - fAnnotationPainter.setAnnotationTypeColor(info.fAnnotationType, color); + fAnnotationPainter.setAnnotationTypeColor(info.getAnnotationType(), color); fAnnotationPainter.paint(IPainter.CONFIGURATION); } - setAnnotationOverviewColor(info.fAnnotationType, color); + setAnnotationOverviewColor(info.getAnnotationType(), color); return; } - if (info.fEditorKey.equals(p)) { - if (areAnnotationsShown(info.fAnnotationType)) - showAnnotations(info.fAnnotationType); + if (info.getTextPreferenceKey().equals(p)) { + if (areAnnotationsShown(info.getAnnotationType())) + showAnnotations(info.getAnnotationType()); else - hideAnnotations(info.fAnnotationType); + hideAnnotations(info.getAnnotationType()); return; } - if (info.fOverviewRulerKey.equals(p)) { - if (isAnnotationOverviewShown(info.fAnnotationType)) - showAnnotationOverview(info.fAnnotationType); + if (info.getOverviewRulerPreferenceKey().equals(p)) { + if (isAnnotationOverviewShown(info.getAnnotationType())) + showAnnotationOverview(info.getAnnotationType()); else - hideAnnotationOverview(info.fAnnotationType); + hideAnnotationOverview(info.getAnnotationType()); return; } } @@ -407,16 +400,16 @@ public class SourceViewerDecorationSupport { } private Color getAnnotationTypeColor(Object annotationType) { - AnnotationTypePreferenceInfo info= (AnnotationTypePreferenceInfo) fAnnotationTypeKeyMap.get(annotationType); + AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); if (info != null) - return getColor( info.fColorKey); + return getColor( info.getColorPreferenceKey()); return null; } private int getAnnotationTypeLayer(Object annotationType) { - AnnotationTypePreferenceInfo info= (AnnotationTypePreferenceInfo) fAnnotationTypeKeyMap.get(annotationType); + AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); if (info != null) - return info.fLayer; + return info.getPresentationLayer(); return 0; } @@ -551,9 +544,9 @@ public class SourceViewerDecorationSupport { private boolean areAnnotationsShown(Object annotationType) { if (fPreferenceStore != null) { - AnnotationTypePreferenceInfo info= (AnnotationTypePreferenceInfo) fAnnotationTypeKeyMap.get(annotationType); + AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); if (info != null) - return fPreferenceStore.getBoolean(info.fEditorKey); + return fPreferenceStore.getBoolean(info.getTextPreferenceKey()); } return false; } @@ -561,9 +554,9 @@ public class SourceViewerDecorationSupport { private boolean isAnnotationOverviewShown(Object annotationType) { if (fPreferenceStore != null) { if (fOverviewRuler != null) { - AnnotationTypePreferenceInfo info= (AnnotationTypePreferenceInfo) fAnnotationTypeKeyMap.get(annotationType); + AnnotationPreference info= (AnnotationPreference) fAnnotationTypeKeyMap.get(annotationType); if (info != null) - return fPreferenceStore.getBoolean(info.fOverviewRulerKey); + return fPreferenceStore.getBoolean(info.getOverviewRulerPreferenceKey()); } } return false; |