Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortod2003-12-12 18:55:17 +0000
committertod2003-12-12 18:55:17 +0000
commite7ee304f2eb5b143aa305705a39abdb94ddaddff (patch)
tree3bb8c4ad87eb66264e4d811f7f1c981bdeeaa887
parent83105987cee8bb83d8de957dd42d8c48c1146302 (diff)
downloadeclipse.platform.text-e7ee304f2eb5b143aa305705a39abdb94ddaddff.tar.gz
eclipse.platform.text-e7ee304f2eb5b143aa305705a39abdb94ddaddff.tar.xz
eclipse.platform.text-e7ee304f2eb5b143aa305705a39abdb94ddaddff.zip
Merge 20031212
-rw-r--r--org.eclipse.ui.workbench.texteditor/.cvsignore3
-rw-r--r--org.eclipse.ui.workbench.texteditor/.project13
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java59
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java2
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java529
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java4
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationExtension.java68
8 files changed, 417 insertions, 265 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/.cvsignore b/org.eclipse.ui.workbench.texteditor/.cvsignore
index 89608e2b5..c5e82d745 100644
--- a/org.eclipse.ui.workbench.texteditor/.cvsignore
+++ b/org.eclipse.ui.workbench.texteditor/.cvsignore
@@ -1,2 +1 @@
-bin
-workbenchtext-new.jarworkbenchtext-new.jar \ No newline at end of file
+bin \ No newline at end of file
diff --git a/org.eclipse.ui.workbench.texteditor/.project b/org.eclipse.ui.workbench.texteditor/.project
index e9aee2354..ba6f6a379 100644
--- a/org.eclipse.ui.workbench.texteditor/.project
+++ b/org.eclipse.ui.workbench.texteditor/.project
@@ -3,8 +3,6 @@
<name>org.eclipse.ui.workbench.texteditor</name>
<comment></comment>
<projects>
- <project>org.eclipse.core.boot</project>
- <project>org.eclipse.core.runtime</project>
<project>org.eclipse.core.runtime.compatibility</project>
<project>org.eclipse.jface.text</project>
<project>org.eclipse.ui</project>
@@ -25,17 +23,6 @@
<arguments>
</arguments>
</buildCommand>
- <buildCommand>
- <name>org.eclipse.ui.externaltools.ExternalToolBuilder</name>
- <arguments>
- <dictionary>
- <key>LaunchConfigHandle</key>
- <value>&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
-&lt;launchConfiguration local=&quot;false&quot; path=&quot;/org.eclipse.ui.workbench.texteditor/.externalToolBuilders/Build New Look jar.launch&quot;/&gt;
-</value>
- </dictionary>
- </arguments>
- </buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.PluginNature</nature>
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
index 98bff553d..1c9b11871 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
@@ -23,10 +23,6 @@ import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
import org.eclipse.jface.util.Assert;
import org.eclipse.jface.text.BadLocationException;
@@ -45,7 +41,6 @@ import org.eclipse.jface.text.source.IAnnotationModelListenerExtension;
import org.eclipse.jface.text.source.ILineDiffInfo;
import org.eclipse.jface.text.source.ILineDiffer;
-import org.eclipse.ui.texteditor.IAnnotationExtension;
import org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider;
import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
@@ -76,12 +71,13 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
* The local implementation of <code>ILineDiffInfo</code>. As instances are also <code>Annotation</code>s,
* they can be used in <code>DocumentLineDiffer</code>s <code>IAnnotationModel</code> protocol.
*/
- private final class DiffRegion extends Annotation implements ILineDiffInfo, IAnnotationExtension {
+ private final class DiffRegion extends Annotation implements ILineDiffInfo {
private RangeDifference fDifference;
private int fOffset;
DiffRegion(RangeDifference difference, int offset) {
+ super("org.eclipse.quickdiff.changeindication", false, null);
fOffset= offset;
fDifference= difference;
}
@@ -91,7 +87,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
*/
public int getRemovedLinesBelow() {
if (fOffset == fDifference.rightLength() - 1) {
- if (getType() != UNCHANGED) {
+ if (getChangeType() != UNCHANGED) {
return Math.max(fDifference.leftLength() - fDifference.rightLength(), 0);
} else {
for (ListIterator it= fDifferences.listIterator(); it.hasNext();) {
@@ -111,9 +107,9 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
}
/*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getType()
+ * @see org.eclipse.jface.text.source.ILineDiffInfo#getChangeType()
*/
- public int getType() {
+ public int getChangeType() {
if (fDifference.kind() == RangeDifference.NOCHANGE)
return UNCHANGED;
else {
@@ -128,7 +124,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
* @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesAbove()
*/
public int getRemovedLinesAbove() {
- if (getType() != UNCHANGED || fOffset != 0)
+ if (getChangeType() != UNCHANGED || fOffset != 0)
return 0;
else {
for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
@@ -143,19 +139,12 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
return 0;
}
}
-
- /*
- * @see org.eclipse.jface.text.source.Annotation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
- */
- public void paint(GC gc, Canvas canvas, Rectangle bounds) {
- // oh nothing painting is done by the line number bar...
- }
-
+
/*
* @see org.eclipse.jface.text.source.ILineDiffInfo#hasChanges()
*/
public boolean hasChanges() {
- return getType() != UNCHANGED || getRemovedLinesAbove() > 0 || getRemovedLinesBelow() > 0;
+ return getChangeType() != UNCHANGED || getRemovedLinesAbove() > 0 || getRemovedLinesBelow() > 0;
}
/*
@@ -171,7 +160,7 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
int endLine= startLine + getRemovedLinesBelow();
- if (getType() == UNCHANGED)
+ if (getChangeType() == UNCHANGED)
startLine++;
String[] ret= new String[endLine - startLine + 1];
@@ -192,35 +181,9 @@ public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnno
}
/*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#getMarkerType()
- */
- public String getMarkerType() {
- switch (getType()) {
- case ILineDiffInfo.UNCHANGED:
- return null; // we're no marker...
- default:
- return "org.eclipse.quickdiff.changeindication"; //$NON-NLS-1$
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#getSeverity()
- */
- public int getSeverity() {
- return 0; // same as IMarker.SEVERITY_INFO;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#isTemporary()
- */
- public boolean isTemporary() {
- return true;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#getMessage()
+ * @see org.eclipse.jface.text.source.Annotation#getText()
*/
- public String getMessage() {
+ public String getText() {
int r= fDifference.rightLength();
int l= fDifference.leftLength();
int c= Math.min(r, l);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java
index 0e310d0a8..1f67d0713 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java
@@ -58,7 +58,7 @@ public class RevertBlockAction extends QuickDiffRestoreAction {
if (differ == null)
return;
ILineDiffInfo info= differ.getLineInfo(fLine);
- if (info != null && info.getType() != ILineDiffInfo.UNCHANGED) {
+ if (info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED) {
boolean hasBlock= false;
if (fLine > 0) {
info= differ.getLineInfo(fLine - 1);
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java
index 1514127e1..ecf4e64ba 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java
@@ -62,8 +62,8 @@ public class RevertLineAction extends QuickDiffRestoreAction {
if (differ == null)
return;
ILineDiffInfo info= differ.getLineInfo(fLine);
- if (info != null && info.getType() != ILineDiffInfo.UNCHANGED) {
- if (info.getType() == ILineDiffInfo.ADDED)
+ if (info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED) {
+ if (info.getChangeType() == ILineDiffInfo.ADDED)
setText(QuickDiffMessages.getString(DELETE_KEY));
else
setText(QuickDiffMessages.getString(REVERT_KEY));
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
index 9caa7aca1..88ea55b30 100644
--- 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
@@ -10,8 +10,20 @@
*******************************************************************************/
package org.eclipse.ui.texteditor;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IPluginDescriptor;
+
import org.eclipse.swt.graphics.RGB;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+
+import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
+
/**
* An annotation preference provides all the information required for handing the preferences for the presentation of annotations of a specified type.
@@ -33,110 +45,241 @@ import org.eclipse.swt.graphics.RGB;
* <li> the preference key for go to next navigation enablement
* <li> the default value for go to next navigation enablement
* <li> the preference key for got to previous navigation enablement
- * <li> the default value for got to previous navigation enablement
+ * <li> the default value for got to previous navigation enablement
+ * <li> the image descriptor
+ * <li> the symbolic image name
* </ul>
*
* @since 2.1
*/
public class AnnotationPreference {
+ /** IDs for presentation preference attributes */
+
+ /** The image to be used for drawing in the vertical ruler. */
+ protected final static Object IMAGE_DESCRIPTOR= new Object();
+ /** The preference label */
+ protected final static Object PREFERENCE_LABEL= new Object();
+ /** The presentation layer */
+ protected final static Object PRESENTATION_LAYER= new Object();
+ /** The symbolic name of the image to be drawn in the vertical ruler. */
+ protected final static Object SYMBOLIC_IMAGE_NAME= new Object();
+ /** Indicates whether the annotation type contributed to the overview ruler's header */
+ protected final static Object HEADER_VALUE= new Object();
+ /** The annotation image provider. */
+ protected final static Object IMAGE_PROVIDER= new Object();
+
+ /** IDs for preference store access and initialization */
+
+ /** The preference key for the visibility inside text */
+ protected final static Object TEXT_PREFERENCE_KEY= new Object();
+ /** The visibility inside text */
+ protected final static Object TEXT_PREFERENCE_VALUE= new Object();
+ /** The preference key for the presentation color */
+ protected final static Object COLOR_PREFERENCE_KEY= new Object();
+ /** The presentation color */
+ protected final static Object COLOR_PREFERENCE_VALUE= new Object();
+ /** The preference key for highlighting inside text. */
+ protected final static Object HIGHLIGHT_PREFERENCE_KEY= new Object();
+ /** The value for highlighting inside text. */
+ protected final static Object HIGHLIGHT_PREFERENCE_VALUE= new Object();
+ /** The preference key for go to next navigation enablement. */
+ protected final static Object IS_GO_TO_NEXT_TARGET_KEY= new Object();
+ /** The value for go to next navigation enablement. */
+ protected final static Object IS_GO_TO_NEXT_TARGET_VALUE= new Object();
+ /** The preference key for go to previous navigation enablement. */
+ protected final static Object IS_GO_TO_PREVIOUS_TARGET_KEY= new Object();
+ /** The value for go to previous navigation enablement. */
+ protected final static Object IS_GO_TO_PREVIOUS_TARGET_VALUE= new Object();
+ /** The preference key for the visibility in the vertical ruler. */
+ protected final static Object VERTICAL_RULER_PREFERENCE_KEY= new Object();
+ /** The visibility in the vertical ruler. */
+ protected final static Object VERTICAL_RULER_PREFERENCE_VALUE= new Object();
+ /** The preference key for the visibility in the overview ruler */
+ protected final static Object OVERVIEW_RULER_PREFERENCE_KEY= new Object();
+ /** The visibility in the overview ruler */
+ protected final static Object OVERVIEW_RULER_PREFERENCE_VALUE= new Object();
+ /** The preference key for the visibility in the next/previous drop down toolbar action. */
+ protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_KEY= new Object();
+ /** The value for the visibility in the next/previous drop down toolbar action. */
+ protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_VALUE= new Object();
+
+ /**
+ * Array of all supported attributes.
+ */
+ protected final static Object[] ATTRIBUTES= new Object[] {
+ IMAGE_DESCRIPTOR,
+ PREFERENCE_LABEL,
+ PRESENTATION_LAYER,
+ SYMBOLIC_IMAGE_NAME,
+ HEADER_VALUE,
+ IMAGE_PROVIDER,
+ TEXT_PREFERENCE_KEY,
+ TEXT_PREFERENCE_VALUE,
+ COLOR_PREFERENCE_KEY,
+ COLOR_PREFERENCE_VALUE,
+ HIGHLIGHT_PREFERENCE_KEY,
+ HIGHLIGHT_PREFERENCE_VALUE,
+ IS_GO_TO_NEXT_TARGET_KEY,
+ IS_GO_TO_NEXT_TARGET_VALUE,
+ IS_GO_TO_PREVIOUS_TARGET_KEY,
+ IS_GO_TO_PREVIOUS_TARGET_VALUE,
+ VERTICAL_RULER_PREFERENCE_KEY,
+ VERTICAL_RULER_PREFERENCE_VALUE,
+ OVERVIEW_RULER_PREFERENCE_KEY,
+ OVERVIEW_RULER_PREFERENCE_VALUE,
+ SHOW_IN_NAVIGATION_DROPDOWN_KEY,
+ SHOW_IN_NAVIGATION_DROPDOWN_VALUE
+ };
+
/** The annotation type */
private Object fAnnotationType;
- /** The preference label */
- private String fPreferenceLabel;
/** The marker type */
private String fMarkerType;
/** The marker severity */
private int fSeverity;
- /** The preference key for the presentation color */
- private String fColorKey;
- /** The default presentation color */
- private RGB fColorValue;
- /** The preference key for the visibility inside text */
- private String fTextKey;
- /** The default visibility inside text */
- private boolean fTextValue;
- /** The preference key for the visibility in the overview ruler */
- private String fOverviewRulerKey;
- /** The default visibility in the overview ruler */
- private boolean fOverviewRulerValue;
- /** The presentation layer */
- private int fPresentationLayer;
- /** Indicates whether the annotation type contributed to the overview ruler's header */
- private boolean fContributesToHeader;
/**
- * The preference key for highlighting inside text.
+ * The annotation image provider.
* @since 3.0
*/
- private String fHighlightKey;
+ public IAnnotationImageProvider fAnnotationImageProvider;
/**
- * The default value for highlighting inside text.
+ * The configuration element from which to create the annotation image provider.
* @since 3.0
*/
- private boolean fHighlightValue;
+ public IConfigurationElement fConfigurationElement;
/**
- * The preference key for the visibility in the vertical ruler.
+ * The name of the attribute used to load the annotation image provider
+ * from the configuration element.
* @since 3.0
*/
- private String fVerticalRulerKey;
+ public String fAnnotationImageProviderAttribute;
/**
- * The default visibility in the vertical ruler.
+ * The map of attributes.
* @since 3.0
*/
- private boolean fVerticalRulerValue;
+ private Map fAttributes= new HashMap();
+
+
+
+ /**
+ * Creates a new uninitialized annotation preference.
+ */
+ public AnnotationPreference() {
+ }
+
/**
- * The preference key for the visibility in the next/previous drop down toolbar action.
+ * Creates a new annotation preference for the given annotation type.
+ *
+ * @param annotationType the annotation type
+ * @param colorKey the preference key for the presentation color
+ * @param textKey the preference key for the visibility inside text
+ * @param overviewRulerKey the preference key for the visibility in the overview ruler
+ * @param presentationLayer the presentation layer
+ */
+ public AnnotationPreference(Object annotationType, String colorKey, String textKey, String overviewRulerKey, int presentationLayer) {
+ fAnnotationType= annotationType;
+ setValue(COLOR_PREFERENCE_KEY, colorKey);
+ setValue(TEXT_PREFERENCE_KEY, textKey);
+ setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey);
+ setValue(PRESENTATION_LAYER, presentationLayer);
+ }
+
+ /**
+ * Sets the given value for the given attribute.
+ *
+ * @param attribute the attribute
+ * @param value the attribute value
* @since 3.0
*/
- private String fShowInNextPrevDropdownToolbarActionKey;
+ protected void setValue(Object attribute, Object value) {
+ fAttributes.put(attribute, value);
+ }
+
/**
- * The default value for the visibility in the next/previous drop down toolbar action.
+ * Sets the given value for the given attribute.
+ *
+ * @param attribute the attribute
+ * @param value the attribute value
* @since 3.0
*/
- private boolean fShowInNextPrevDropdownToolbarAction;
+ protected void setValue(Object attribute, int value) {
+ fAttributes.put(attribute, new Integer(value));
+ }
+
/**
- * The preference key for go to next navigation enablement.
+ * Sets the given value for the given attribute.
+ *
+ * @param attribute the attribute
+ * @param value the attribute value
* @since 3.0
*/
- private String fIsGoToNextNavigationTargetKey;
+ protected void setValue(Object attribute, boolean value) {
+ fAttributes.put(attribute, value ? Boolean.TRUE : Boolean.FALSE);
+ }
+
/**
- * The default value for go to next navigation enablement.
+ * Returns the value of the given attribute as string.
+ *
+ * @param attribute the attribute
+ * @return the attribute value
* @since 3.0
*/
- private boolean fIsGoToNextNavigationTarget;
+ protected String getStringValue(Object attribute) {
+ Object value= fAttributes.get(attribute);
+ if (value instanceof String)
+ return (String) value;
+ return null;
+ }
+
/**
- * The preference key for go to previous navigation enablement.
+ * Returns the value of the given attribute as boolean.
+ *
+ * @param attribute the attribute
+ * @return the attribute value
* @since 3.0
*/
- private String fIsGoToPreviousNavigationTargetKey;
+ protected boolean getBooleanValue(Object attribute) {
+ Object value= fAttributes.get(attribute);
+ if (value instanceof Boolean)
+ return ((Boolean) value).booleanValue();
+ return false;
+ }
+
/**
- * The default value for go to previous navigation enablement.
+ * Returns the value of the given attribute as integer.
+ *
+ * @param attribute the attribute
+ * @return the attribute value
* @since 3.0
*/
- private boolean fIsGoToPreviousNavigationTarget;
+ protected int getIntegerValue(Object attribute) {
+ Object value= fAttributes.get(attribute);
+ if (value instanceof Integer)
+ return ((Integer) value).intValue();
+ return 0;
+ }
-
/**
- * Creates a new uninitialized annotation preference.
+ * Returns the value of the given attribute.
+ *
+ * @param attribute the attribute
+ * @return the attribute value
+ * @since 3.0
*/
- public AnnotationPreference() {
+ public Object getValue(Object attribute) {
+ return fAttributes.get(attribute);
}
-
+
/**
- * Creates a new annotation preference for the given annotation type.
+ * Returns whether the given attribute is defined.
*
- * @param annotationType the annotation type
- * @param colorKey the preference key for the presentation color
- * @param textKey the preference key for the visibility inside text
- * @param overviewRulerKey the preference key for the visibility in the overview ruler
- * @param presentationLayer the presentation layer
+ * @param attribute the attribute
+ * @return <code>true</code> if the attribute has a value <code>false</code> otherwise
+ * @since 3.0
*/
- public AnnotationPreference(Object annotationType, String colorKey, String textKey, String overviewRulerKey, int presentationLayer) {
- fAnnotationType= annotationType;
- fColorKey= colorKey;
- fTextKey= textKey;
- fOverviewRulerKey= overviewRulerKey;
- fPresentationLayer= presentationLayer;
+ public boolean hasValue(Object attribute) {
+ return fAttributes.get(attribute) != null;
}
/**
@@ -148,7 +291,12 @@ public class AnnotationPreference {
public boolean isPreferenceKey(String key) {
if (key == null)
return false;
- return key.equals(fColorKey) || key.equals(fOverviewRulerKey) || key.equals(fTextKey) || key.equals(fHighlightKey) || key.equals(fVerticalRulerKey);
+
+ return key.equals(getStringValue(COLOR_PREFERENCE_KEY)) ||
+ key.equals(getStringValue(OVERVIEW_RULER_PREFERENCE_KEY)) ||
+ key.equals(getStringValue(TEXT_PREFERENCE_KEY)) ||
+ key.equals(getStringValue(HIGHLIGHT_PREFERENCE_KEY)) ||
+ key.equals(getStringValue(VERTICAL_RULER_PREFERENCE_KEY));
}
/**
@@ -164,10 +312,48 @@ public class AnnotationPreference {
* Returns the marker type.
*
* @return the marker type
+ * @deprecated since 3.0
*/
public String getMarkerType() {
return fMarkerType;
}
+
+ /**
+ * Returns the marker severity.
+ *
+ * @return the marker severity
+ * @deprecated since 3.0
+ */
+ public int getSeverity() {
+ return fSeverity;
+ }
+
+ /**
+ * Sets the annotation type.
+ *
+ * @param annotationType the annotation type
+ */
+ public void setAnnotationType(Object annotationType) {
+ fAnnotationType= annotationType;
+ }
+
+ /**
+ * Sets the marker type.
+ *
+ * @param markerType the marker type
+ */
+ public void setMarkerType(String markerType) {
+ fMarkerType= markerType;
+ }
+
+ /**
+ * Sets the marker serverity.
+ *
+ * @param severity the marker severity
+ */
+ public void setSeverity(int severity) {
+ fSeverity= severity;
+ }
/**
* Returns the preference key for the presentation color.
@@ -175,7 +361,7 @@ public class AnnotationPreference {
* @return the preference key for the presentation color
*/
public String getColorPreferenceKey() {
- return fColorKey;
+ return getStringValue(COLOR_PREFERENCE_KEY);
}
/**
@@ -184,7 +370,7 @@ public class AnnotationPreference {
* @return the default presentation color.
*/
public RGB getColorPreferenceValue() {
- return fColorValue;
+ return (RGB) getValue(COLOR_PREFERENCE_VALUE);
}
/**
@@ -193,7 +379,7 @@ public class AnnotationPreference {
* @return the presentation string for this annotation type
*/
public String getPreferenceLabel() {
- return fPreferenceLabel;
+ return getStringValue(PREFERENCE_LABEL);
}
/**
@@ -202,7 +388,7 @@ public class AnnotationPreference {
* @return the preference key for the visibility in the overview ruler
*/
public String getOverviewRulerPreferenceKey() {
- return fOverviewRulerKey;
+ return getStringValue(OVERVIEW_RULER_PREFERENCE_KEY);
}
/**
@@ -211,7 +397,7 @@ public class AnnotationPreference {
* @return the default visibility in the overview ruler
*/
public boolean getOverviewRulerPreferenceValue() {
- return fOverviewRulerValue;
+ return getBooleanValue(OVERVIEW_RULER_PREFERENCE_VALUE);
}
/**
@@ -221,7 +407,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public String getVerticalRulerPreferenceKey() {
- return fVerticalRulerKey;
+ return getStringValue(VERTICAL_RULER_PREFERENCE_KEY);
}
/**
@@ -231,7 +417,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public boolean getVerticalRulerPreferenceValue() {
- return fVerticalRulerValue;
+ return getBooleanValue(VERTICAL_RULER_PREFERENCE_VALUE);
}
/**
@@ -240,16 +426,7 @@ public class AnnotationPreference {
* @return the presentation layer
*/
public int getPresentationLayer() {
- return fPresentationLayer;
- }
-
- /**
- * Returns the marker severity.
- *
- * @return the marker severity
- */
- public int getSeverity() {
- return fSeverity;
+ return getIntegerValue(PRESENTATION_LAYER);
}
/**
@@ -258,7 +435,7 @@ public class AnnotationPreference {
* @return the preference key for the visibility inside text
*/
public String getTextPreferenceKey() {
- return fTextKey;
+ return getStringValue(TEXT_PREFERENCE_KEY);
}
/**
@@ -267,7 +444,7 @@ public class AnnotationPreference {
* @return the default visibility inside text
*/
public boolean getTextPreferenceValue() {
- return fTextValue;
+ return getBooleanValue(TEXT_PREFERENCE_VALUE);
}
/**
@@ -277,7 +454,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public String getHighlightPreferenceKey() {
- return fHighlightKey;
+ return getStringValue(HIGHLIGHT_PREFERENCE_KEY);
}
/**
@@ -287,7 +464,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public boolean getHighlightPreferenceValue() {
- return fHighlightValue;
+ return getBooleanValue(HIGHLIGHT_PREFERENCE_VALUE);
}
/**
@@ -296,25 +473,7 @@ public class AnnotationPreference {
* @return <code>true</code> if the annotation type contributes to the header of the overview ruler
*/
public boolean contributesToHeader() {
- return fContributesToHeader;
- }
-
- /**
- * Sets the annotation type.
- *
- * @param annotationType the annotation type
- */
- public void setAnnotationType(Object annotationType) {
- fAnnotationType= annotationType;
- }
-
- /**
- * Sets the marker type.
- *
- * @param markerType the marker type
- */
- public void setMarkerType(String markerType) {
- fMarkerType= markerType;
+ return getBooleanValue(HEADER_VALUE);
}
/**
@@ -323,7 +482,7 @@ public class AnnotationPreference {
* @param colorKey the preference key
*/
public void setColorPreferenceKey(String colorKey) {
- fColorKey= colorKey;
+ setValue(COLOR_PREFERENCE_KEY, colorKey);
}
/**
@@ -332,7 +491,7 @@ public class AnnotationPreference {
* @param colorValue the default color
*/
public void setColorPreferenceValue(RGB colorValue) {
- fColorValue= colorValue;
+ setValue(COLOR_PREFERENCE_VALUE, colorValue);
}
/**
@@ -341,7 +500,7 @@ public class AnnotationPreference {
* @param label the presentation label
*/
public void setPreferenceLabel(String label) {
- fPreferenceLabel= label;
+ setValue(PREFERENCE_LABEL, label);
}
/**
@@ -350,7 +509,7 @@ public class AnnotationPreference {
* @param overviewRulerKey the preference key
*/
public void setOverviewRulerPreferenceKey(String overviewRulerKey) {
- fOverviewRulerKey= overviewRulerKey;
+ setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey);
}
/**
@@ -359,7 +518,7 @@ public class AnnotationPreference {
* @param overviewRulerValue <code>true</code> if visible by default, <code>false</code> otherwise
*/
public void setOverviewRulerPreferenceValue(boolean overviewRulerValue) {
- fOverviewRulerValue= overviewRulerValue;
+ setValue(OVERVIEW_RULER_PREFERENCE_VALUE, overviewRulerValue);
}
/**
@@ -369,7 +528,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setVerticalRulerPreferenceKey(String verticalRulerKey) {
- fVerticalRulerKey= verticalRulerKey;
+ setValue(VERTICAL_RULER_PREFERENCE_KEY, verticalRulerKey);
}
/**
@@ -379,7 +538,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setVerticalRulerPreferenceValue(boolean verticalRulerValue) {
- fVerticalRulerValue= verticalRulerValue;
+ setValue(VERTICAL_RULER_PREFERENCE_VALUE, verticalRulerValue);
}
/**
@@ -388,16 +547,7 @@ public class AnnotationPreference {
* @param presentationLayer the presentation layer
*/
public void setPresentationLayer(int presentationLayer) {
- fPresentationLayer= presentationLayer;
- }
-
- /**
- * Sets the marker serverity.
- *
- * @param severity the marker severity
- */
- public void setSeverity(int severity) {
- fSeverity= severity;
+ setValue(PRESENTATION_LAYER, presentationLayer);
}
/**
@@ -406,7 +556,7 @@ public class AnnotationPreference {
* @param textKey the preference key
*/
public void setTextPreferenceKey(String textKey) {
- fTextKey= textKey;
+ setValue(TEXT_PREFERENCE_KEY, textKey);
}
/**
@@ -415,7 +565,7 @@ public class AnnotationPreference {
* @param textValue <code>true</code> if visible by default, <code>false</code> otherwise
*/
public void setTextPreferenceValue(boolean textValue) {
- fTextValue= textValue;
+ setValue(TEXT_PREFERENCE_VALUE, textValue);
}
/**
@@ -425,7 +575,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setHighlightPreferenceKey(String highlightKey) {
- fHighlightKey= highlightKey;
+ setValue(HIGHLIGHT_PREFERENCE_KEY, highlightKey);
}
/**
@@ -435,7 +585,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setHighlightPreferenceValue(boolean highlightValue) {
- fHighlightValue= highlightValue;
+ setValue(HIGHLIGHT_PREFERENCE_VALUE, highlightValue);
}
/**
@@ -444,7 +594,7 @@ public class AnnotationPreference {
* @param contributesToHeader <code>true</code> if in header, <code>false</code> otherwise
*/
public void setContributesToHeader(boolean contributesToHeader) {
- fContributesToHeader= contributesToHeader;
+ setValue(HEADER_VALUE, contributesToHeader);
}
/**
@@ -454,7 +604,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public boolean isGoToNextNavigationTarget() {
- return fIsGoToNextNavigationTarget;
+ return getBooleanValue(IS_GO_TO_NEXT_TARGET_VALUE);
}
/**
@@ -464,7 +614,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setIsGoToNextNavigationTarget(boolean isGoToNextNavigationTarget) {
- fIsGoToNextNavigationTarget= isGoToNextNavigationTarget;
+ setValue(IS_GO_TO_NEXT_TARGET_VALUE, isGoToNextNavigationTarget);
}
/**
@@ -474,7 +624,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public String getIsGoToNextNavigationTargetKey() {
- return fIsGoToNextNavigationTargetKey;
+ return getStringValue(IS_GO_TO_NEXT_TARGET_KEY);
}
/**
@@ -484,7 +634,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setIsGoToNextNavigationTargetKey(String isGoToNextNavigationTargetKey) {
- fIsGoToNextNavigationTargetKey= isGoToNextNavigationTargetKey;
+ setValue(IS_GO_TO_NEXT_TARGET_KEY, isGoToNextNavigationTargetKey);
}
/**
@@ -494,7 +644,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public boolean isGoToPreviousNavigationTarget() {
- return fIsGoToPreviousNavigationTarget;
+ return getBooleanValue(IS_GO_TO_PREVIOUS_TARGET_VALUE);
}
/**
@@ -504,7 +654,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setIsGoToPreviousNavigationTarget(boolean isGoToPreviousNavigationTarget) {
- fIsGoToPreviousNavigationTarget= isGoToPreviousNavigationTarget;
+ setValue(IS_GO_TO_PREVIOUS_TARGET_VALUE, isGoToPreviousNavigationTarget);
}
/**
@@ -514,7 +664,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public String getIsGoToPreviousNavigationTargetKey() {
- return fIsGoToPreviousNavigationTargetKey;
+ return getStringValue(IS_GO_TO_PREVIOUS_TARGET_KEY);
}
/**
@@ -524,7 +674,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setIsGoToPreviousNavigationTargetKey(String isGoToPreviousNavigationTargetKey) {
- fIsGoToPreviousNavigationTargetKey= isGoToPreviousNavigationTargetKey;
+ setValue(IS_GO_TO_PREVIOUS_TARGET_KEY, isGoToPreviousNavigationTargetKey);
}
/**
@@ -534,7 +684,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public String getShowInNextPrevDropdownToolbarActionKey() {
- return fShowInNextPrevDropdownToolbarActionKey;
+ return getStringValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY);
}
/**
@@ -544,7 +694,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setShowInNextPrevDropdownToolbarActionKey(String showInNextPrevDropdownToolbarActionKey) {
- fShowInNextPrevDropdownToolbarActionKey= showInNextPrevDropdownToolbarActionKey;
+ setValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY, showInNextPrevDropdownToolbarActionKey);
}
/**
@@ -554,7 +704,7 @@ public class AnnotationPreference {
* @since 3.0
*/
public boolean isShowInNextPrevDropdownToolbarAction() {
- return fShowInNextPrevDropdownToolbarAction;
+ return getBooleanValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE);
}
/**
@@ -564,6 +714,125 @@ public class AnnotationPreference {
* @since 3.0
*/
public void setShowInNextPrevDropdownToolbarAction(boolean showInNextPrevDropdownToolbarAction) {
- fShowInNextPrevDropdownToolbarAction= showInNextPrevDropdownToolbarAction;
+ setValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE, showInNextPrevDropdownToolbarAction);
+ }
+
+ /**
+ * Returns the image descriptor for the image to be drawn in the vertical ruler. The provided
+ * image is only used, if <code>getAnnotationImageProvider</code> returns <code>null</code>.
+ *
+ * @return the image descriptor or <code>null</code>
+ * @since 3.0
+ **/
+ public ImageDescriptor getImageDescriptor() {
+ return (ImageDescriptor) getValue(IMAGE_DESCRIPTOR);
+ }
+
+ /**
+ * Sets the image descriptor for the image to be drawn in the vertical ruler.
+ *
+ * @param descriptor the image descriptor
+ * @since 3.0
+ */
+ public void setImageDescriptor(ImageDescriptor descriptor) {
+ setValue(IMAGE_DESCRIPTOR, descriptor);
+ }
+
+ /**
+ * Returns the symbolic name of the image to be drawn in the vertical ruler.
+ * The image is only used if <code>getImageDescriptor</code> returns <code>null</code>.
+ *
+ * @return the symbolic name of the image or <code>null</code>
+ * @since 3.0
+ */
+ public String getSymbolicImageName() {
+ return getStringValue(SYMBOLIC_IMAGE_NAME);
+ }
+
+ /**
+ * Sets the symbolic name of the image to be drawn in the vertical ruler.
+ *
+ * @param symbolicImageName the symbolic image name
+ * @since 3.0
+ */
+ public void setSymbolicImageName(String symbolicImageName) {
+ setValue(SYMBOLIC_IMAGE_NAME, symbolicImageName);
+ }
+
+ /**
+ * Returns the annotation image provider. If no default annotation image
+ * provider has been set, this method checks whether the annotation image
+ * provider data has been set. If so, an annotation image provider is
+ * created if the configuration element's plug-in is loaded. When an
+ * annotation image provider has been created successfully, it is set as
+ * the default annotation image provider.
+ *
+ * @return the annotation image provider
+ * @since 3.0
+ */
+ public IAnnotationImageProvider getAnnotationImageProvider() {
+ if (fAnnotationImageProvider == null) {
+ if (fConfigurationElement != null && fAnnotationImageProviderAttribute != null) {
+ IPluginDescriptor descriptor = fConfigurationElement.getDeclaringExtension().getDeclaringPluginDescriptor();
+ if (descriptor.isPluginActivated()) {
+ try {
+ fAnnotationImageProvider= (IAnnotationImageProvider) fConfigurationElement.createExecutableExtension(fAnnotationImageProviderAttribute);
+ } catch (CoreException x) {
+ TextEditorPlugin.getDefault().getLog().log(x.getStatus());
+ }
+ }
+ }
+ }
+ return fAnnotationImageProvider;
+ }
+
+ /**
+ * Sets the annotation image provider who provides images for annotations
+ * of the specified annotation type.
+ *
+ * @param provider the annotation image provider
+ * @since 3.0
+ */
+ public void setAnnotationImageProvider(IAnnotationImageProvider provider) {
+ fAnnotationImageProvider= provider;
+ setValue(IMAGE_PROVIDER, provider != null);
+ }
+
+ /**
+ * Sets the data needed to create the annotation image provider.
+ *
+ * @param configurationElement the configuration element
+ * @param annotationImageProviderAttribute the atrribute of the
+ * configuration element
+ * @since 3.0
+ */
+ public void setAnnotationImageProviderData(IConfigurationElement configurationElement, String annotationImageProviderAttribute) {
+ fConfigurationElement= configurationElement;
+ fAnnotationImageProviderAttribute= annotationImageProviderAttribute;
+ setValue(IMAGE_PROVIDER, annotationImageProviderAttribute != null);
+ }
+
+ /**
+ * Merges the values of the given preference into this preference. Existing
+ * values will not be overwritten. Subclasses may extend.
+ *
+ * @param preference the preference to merge into this preference
+ * @since 3.0
+ */
+ public void merge(AnnotationPreference preference) {
+ if (!getAnnotationType().equals(preference.getAnnotationType()))
+ return;
+
+ for (int i= 0; i < ATTRIBUTES.length; i++) {
+ if (!hasValue(ATTRIBUTES[i]))
+ setValue(ATTRIBUTES[i], preference.getValue(ATTRIBUTES[i]));
+ }
+
+ if (fAnnotationImageProvider == null)
+ fAnnotationImageProvider= preference.fAnnotationImageProvider;
+ if (fConfigurationElement == null)
+ fConfigurationElement= preference.fConfigurationElement;
+ if (fAnnotationImageProviderAttribute == null)
+ fAnnotationImageProviderAttribute= preference.fAnnotationImageProviderAttribute;
}
}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
index 6f4d9e4ce..a7f261164 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
@@ -13,6 +13,8 @@ package org.eclipse.ui.texteditor;
import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationPresentation;
+
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
@@ -36,7 +38,7 @@ import org.eclipse.swt.widgets.Display;
* This class is instantiated automatically by <code>AbstractTextEditor</code>.
* </p>
*/
-public class DefaultRangeIndicator extends Annotation {
+public class DefaultRangeIndicator extends Annotation implements IAnnotationPresentation {
/** The color palette data of this range indicator */
private static PaletteData fgPaletteData;
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationExtension.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationExtension.java
deleted file mode 100644
index 37d04fd0f..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationExtension.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation 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 API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-
-/**
- * Extension interface for <code>Annotation</code>. It adds the following
- * functions:
- * <ul>
- * <li> marker type
- * <li> annotation severity
- * <li> notion of temporary annotation
- * <li> an optional message
- * </ul>
- * <p>
- * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
- * </p>
- *
- * @see org.eclipse.core.resources.IMarker
- * @see org.eclipse.jface.text.source.Annotation
- * @since 3.0
- */
-public interface IAnnotationExtension {
-
- /**
- * Returns the marker type of the given annotation.
- *
- * @return the marker type of the given annotation or <code>null</code> if it has none.
- */
- String getMarkerType();
-
- /**
- * Severity marker attribute. A number from the set of error, warning and info
- * severities defined by the plaform.
- *
- * XXX: This needs to be redefined when RCP work is being done.
- *
- * @see #SEVERITY_ERROR
- * @see #SEVERITY_WARNING
- * @see #SEVERITY_INFO
- * @see #getAttribute
- */
- int getSeverity();
-
- /**
- * Returns whether the given annotation is temporary rather than persistent.
- *
- * @return <code>true</code> if the annotation is temporary,
- * <code>false</code> otherwise
- */
- boolean isTemporary();
-
- /**
- * Returns the message of this annotation.
- *
- * @return the message of this annotation or <code>null</code> if none
- */
- String getMessage();
-}

Back to the top