Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2003-12-09 17:52:28 +0000
committerKai Maetzel2003-12-09 17:52:28 +0000
commitacbc0cf96f03c5e398170db644c619339166aad6 (patch)
treef9e2422a3b10d8b0461edd296d8fc4c29759f256 /org.eclipse.ui.editors
parenta99a29812d4816e33a48d52c755e7aaea3769da2 (diff)
downloadeclipse.platform.text-acbc0cf96f03c5e398170db644c619339166aad6.tar.gz
eclipse.platform.text-acbc0cf96f03c5e398170db644c619339166aad6.tar.xz
eclipse.platform.text-acbc0cf96f03c5e398170db644c619339166aad6.zip
Diffstat (limited to 'org.eclipse.ui.editors')
-rw-r--r--org.eclipse.ui.editors/plugin.xml122
-rw-r--r--org.eclipse.ui.editors/schema/annotationTypes.exsd130
-rw-r--r--org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd76
-rw-r--r--org.eclipse.ui.editors/schema/markerAnnotations.exsd86
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java48
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java50
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java103
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationType.java54
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeHierarchy.java109
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java207
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultAnnotation.java52
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java270
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DelegatingAnnotationPreference.java248
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditor.java26
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java86
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java52
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java216
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java150
18 files changed, 1780 insertions, 305 deletions
diff --git a/org.eclipse.ui.editors/plugin.xml b/org.eclipse.ui.editors/plugin.xml
index a6de92bede2..3304e97bc9a 100644
--- a/org.eclipse.ui.editors/plugin.xml
+++ b/org.eclipse.ui.editors/plugin.xml
@@ -23,9 +23,11 @@
<import plugin="org.eclipse.core.resources"/>
</requires>
+
<extension-point id="documentProviders" name="%ExtPoint.documentProviders" schema="schema/documentProviders.exsd"/>
<extension-point id="markerUpdaters" name="%ExtPoint.markerUpdaters" schema="schema/markerUpdaters.exsd"/>
<extension-point id="markerAnnotationSpecification" name="%ExtPoint.markerAnnotationSpecification" schema="schema/markerAnnotationSpecification.exsd"/>
+ <extension-point id="annotationTypes" schema="schema/annotationTypes.exsd"/>
<extension
point="org.eclipse.ui.commands">
@@ -79,14 +81,14 @@
</command>
<command
name="%openExternalFile.label"
- description="%openExternalFile.description"
category="org.eclipse.ui.category.file"
+ description="%openExternalFile.description"
id="org.eclipse.ui.edit.text.openExternalFile">
</command>
<command
name="%ActionDefinition.quickDiff.name"
- description="%ActionDefinition.quickDiff.description"
category="org.eclipse.ui.category.edit"
+ description="%ActionDefinition.quickDiff.description"
id="org.eclipse.quickdiff.toggle">
</command>
<keyBinding
@@ -96,19 +98,17 @@
configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
</keyBinding>
</extension>
-
<extension
point="org.eclipse.ui.editors">
<editor
name="%Editors.DefaultTextEditor"
- icon="icons/full/obj16/file_obj.gif"
extensions="txt"
- contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
+ icon="icons/full/obj16/file_obj.gif"
class="org.eclipse.ui.editors.text.TextEditor"
+ contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
id="org.eclipse.ui.DefaultTextEditor">
</editor>
</extension>
-
<extension
point="org.eclipse.ui.preferencePages">
<page
@@ -118,7 +118,6 @@
id="org.eclipse.ui.preferencePages.TextEditor">
</page>
</extension>
-
<extension
point="org.eclipse.ui.editors.documentProviders">
<provider
@@ -127,7 +126,6 @@
id="org.eclipse.ui.editors.text.StorageDocumentProvider">
</provider>
</extension>
-
<extension
point="org.eclipse.ui.editors.documentProviders">
<provider
@@ -136,7 +134,6 @@
id="org.eclipse.ui.editors.text.ExternalFileDocumentProvider">
</provider>
</extension>
-
<extension
point="org.eclipse.ui.editors.markerUpdaters">
<updater
@@ -144,17 +141,15 @@
id="org.eclipse.ui.texteditor.BasicMarkerUpdater">
</updater>
</extension>
-
<extension
point="org.eclipse.ui.workbench.texteditor.quickDiffReferenceProvider">
<referenceprovider
- label="%lastSaveReferenceProvider.label"
default="true"
+ label="%lastSaveReferenceProvider.label"
class="org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider"
id="org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider">
</referenceprovider>
</extension>
-
<extension
point="org.eclipse.ui.popupMenus">
<viewerContribution
@@ -163,16 +158,16 @@
<action
label="%AddTask.label"
helpContextId="org.eclipse.ui.AddTask_action_context"
- tooltip="%AddTask.tooltip"
class="org.eclipse.ui.texteditor.TaskRulerAction"
+ tooltip="%AddTask.tooltip"
menubarPath="additions"
id="org.eclipse.ui.texteditor.TaskRulerAction">
</action>
<action
label="%AddBookmark.label"
helpContextId="org.eclipse.ui.bookmark_action_context"
- tooltip="%AddBookmark.tooltip"
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+ tooltip="%AddBookmark.tooltip"
menubarPath="additions"
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
</action>
@@ -191,16 +186,16 @@
<action
label="%AddTask.label"
helpContextId="org.eclipse.ui.AddTask_action_context"
- tooltip="%AddTask.tooltip"
class="org.eclipse.ui.texteditor.TaskRulerAction"
+ tooltip="%AddTask.tooltip"
menubarPath="additions"
id="org.eclipse.ui.texteditor.TaskRulerAction">
</action>
<action
label="%AddBookmark.label"
helpContextId="org.eclipse.ui.bookmark_action_context"
- tooltip="%AddBookmark.tooltip"
class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+ tooltip="%AddBookmark.tooltip"
menubarPath="additions"
id="org.eclipse.ui.texteditor.BookmarkRulerAction">
</action>
@@ -214,7 +209,6 @@
</action>
</viewerContribution>
</extension>
-
<extension
point="org.eclipse.ui.editorActions">
<editorContribution
@@ -245,7 +239,6 @@
</action>
</editorContribution>
</extension>
-
<extension
point="org.eclipse.ui.actionSets">
<actionSet
@@ -256,8 +249,8 @@
definitionId="org.eclipse.ui.edit.text.openExternalFile"
label="%openExternalFile.label"
helpContextId="open_text_editor_action_context"
- tooltip="%openExternalFile.description"
class="org.eclipse.ui.internal.editors.text.OpenExternalFileAction"
+ tooltip="%openExternalFile.description"
menubarPath="file/new.ext"
id="org.eclipse.ui.edit.text.openExternalFile">
</action>
@@ -269,8 +262,8 @@
<action
allowLabelUpdate="true"
style="pulldown"
- toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
id="org.eclipse.ui.edit.text.gotoPreviousAnnotation"
+ toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
hoverIcon="icons/full/ctool16/prev_nav.gif"
class="org.eclipse.ui.internal.editors.text.PreviousPulldownActionDelegate"
definitionId="org.eclipse.ui.navigate.previous"
@@ -283,8 +276,8 @@
<action
allowLabelUpdate="true"
style="pulldown"
- toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
id="org.eclipse.ui.edit.text.gotoNextAnnotation"
+ toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
hoverIcon="icons/full/ctool16/next_nav.gif"
class="org.eclipse.ui.internal.editors.text.NextPulldownActionDelegate"
definitionId="org.eclipse.ui.navigate.next"
@@ -296,27 +289,25 @@
</action>
</actionSet>
</extension>
-
<extension
point="org.eclipse.ui.editors.markerAnnotationSpecification">
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.error"
textPreferenceKey="errorIndication"
presentationLayer="6"
+ highlightPreferenceValue="false"
showInNextPrevDropdownToolbarAction="true"
textPreferenceValue="true"
isGoToPreviousNavigationTargetKey="isErrorGoToPreviousNavigationTarget"
label="%errors.label"
- markerType="org.eclipse.core.resources.problemmarker"
colorPreferenceKey="errorIndicationColor"
- markerSeverity="2"
showInNextPrevDropdownToolbarActionKey="showErrorInNextPrevDropdownToolbarAction"
- annotationType="org.eclipse.ui.workbench.texteditor.error"
+ symbolicIcon="error"
isGoToNextNavigationTargetKey="isErrorGoToNextNavigationTarget"
isGoToNextNavigationTarget="true"
overviewRulerPreferenceKey="errorIndicationInOverviewRuler"
verticalRulerPreferenceValue="true"
highlightPreferenceKey="errorIndicationHighlighting"
- highlightPreferenceValue="false"
isGoToPreviousNavigationTarget="true"
verticalRulerPreferenceKey="errorIndicationInVerticalRuler"
contributesToHeader="true"
@@ -324,23 +315,22 @@
overviewRulerPreferenceValue="true">
</specification>
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.warning"
textPreferenceKey="warningIndication"
presentationLayer="5"
+ highlightPreferenceValue="false"
showInNextPrevDropdownToolbarAction="true"
textPreferenceValue="true"
isGoToPreviousNavigationTargetKey="isWarningGoToPreviousNavigationTarget"
label="%warnings.label"
- markerType="org.eclipse.core.resources.problemmarker"
colorPreferenceKey="warningIndicationColor"
- markerSeverity="1"
showInNextPrevDropdownToolbarActionKey="showWarningInNextPrevDropdownToolbarAction"
- annotationType="org.eclipse.ui.workbench.texteditor.warning"
+ symbolicIcon="warning"
isGoToNextNavigationTargetKey="isWarningGoToNextNavigationTarget"
isGoToNextNavigationTarget="true"
overviewRulerPreferenceKey="warningIndicationInOverviewRuler"
verticalRulerPreferenceValue="true"
highlightPreferenceKey="warningIndicationHighlighting"
- highlightPreferenceValue="false"
isGoToPreviousNavigationTarget="true"
verticalRulerPreferenceKey="warningIndicationInVerticalRuler"
contributesToHeader="true"
@@ -348,22 +338,22 @@
overviewRulerPreferenceValue="true">
</specification>
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.info"
textPreferenceKey="infoIndication"
presentationLayer="4"
+ highlightPreferenceValue="false"
showInNextPrevDropdownToolbarAction="true"
textPreferenceValue="false"
isGoToPreviousNavigationTargetKey="isInfoGoToPreviousNavigationTarget"
label="%infos.label"
- markerType="org.eclipse.core.resources.problemmarker"
colorPreferenceKey="infoIndicationColor"
showInNextPrevDropdownToolbarActionKey="showInfoInNextPrevDropdownToolbarAction"
- annotationType="org.eclipse.ui.workbench.texteditor.info"
+ symbolicIcon="info"
isGoToNextNavigationTargetKey="isInfoGoToNextNavigationTarget"
isGoToNextNavigationTarget="false"
overviewRulerPreferenceKey="infoIndicationInOverviewRuler"
verticalRulerPreferenceValue="true"
highlightPreferenceKey="infoIndicationHighlighting"
- highlightPreferenceValue="false"
isGoToPreviousNavigationTarget="false"
verticalRulerPreferenceKey="infoIndicationInVerticalRuler"
contributesToHeader="false"
@@ -371,22 +361,22 @@
overviewRulerPreferenceValue="true">
</specification>
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.task"
textPreferenceKey="taskIndication"
presentationLayer="2"
+ highlightPreferenceValue="false"
showInNextPrevDropdownToolbarAction="true"
textPreferenceValue="false"
isGoToPreviousNavigationTargetKey="isTaskGoToPreviousNavigationTarget"
label="%tasks.label"
- markerType="org.eclipse.core.resources.taskmarker"
colorPreferenceKey="taskIndicationColor"
showInNextPrevDropdownToolbarActionKey="showTaskInNextPrevDropdownToolbarAction"
- annotationType="org.eclipse.ui.workbench.texteditor.task"
+ symbolicIcon="task"
isGoToNextNavigationTargetKey="isTaskGoToNextNavigationTarget"
isGoToNextNavigationTarget="false"
overviewRulerPreferenceKey="taskIndicationInOverviewRuler"
verticalRulerPreferenceValue="true"
highlightPreferenceKey="taskIndicationHighlighting"
- highlightPreferenceValue="false"
isGoToPreviousNavigationTarget="false"
verticalRulerPreferenceKey="taskIndicationInVerticalRuler"
contributesToHeader="false"
@@ -394,22 +384,22 @@
overviewRulerPreferenceValue="true">
</specification>
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.bookmark"
textPreferenceKey="bookmarkIndication"
presentationLayer="1"
+ highlightPreferenceValue="false"
showInNextPrevDropdownToolbarAction="true"
textPreferenceValue="false"
isGoToPreviousNavigationTargetKey="isBookmarkGoToPreviousNavigationTarget"
label="%bookmarks.label"
- markerType="org.eclipse.core.resources.bookmark"
colorPreferenceKey="bookmarkIndicationColor"
showInNextPrevDropdownToolbarActionKey="showBookmarkInNextPrevDropdownToolbarAction"
- annotationType="org.eclipse.ui.workbench.texteditor.bookmark"
+ symbolicIcon="bookmark"
isGoToNextNavigationTargetKey="isBookmarkGoToNextNavigationTarget"
isGoToNextNavigationTarget="false"
overviewRulerPreferenceKey="bookmarkIndicationInOverviewRuler"
verticalRulerPreferenceValue="true"
highlightPreferenceKey="bookmarkIndicationHighlighting"
- highlightPreferenceValue="false"
isGoToPreviousNavigationTarget="false"
verticalRulerPreferenceKey="bookmarkIndicationInVerticalRuler"
contributesToHeader="false"
@@ -417,61 +407,85 @@
overviewRulerPreferenceValue="true">
</specification>
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.quickdiffChange"
colorPreferenceValue="204,163,205"
isGoToPreviousNavigationTarget="false"
isGoToPreviousNavigationTargetKey="isChangeGoToPreviousNavigationTarget"
showInNextPrevDropdownToolbarAction="true"
- annotationType="org.eclipse.ui.workbench.texteditor.quickdiffChange"
isGoToNextNavigationTarget="false"
- showInNextPrevDropdownToolbarActionKey="showChangeInNextPrevDropdownToolbarAction"
- colorPreferenceKey="changeIndicationColor"
isGoToNextNavigationTargetKey="isChangeGoToNextNavigationTarget"
+ colorPreferenceKey="changeIndicationColor"
+ showInNextPrevDropdownToolbarActionKey="showChangeInNextPrevDropdownToolbarAction"
contributesToHeader="false"
overviewRulerPreferenceValue="false"
- markerType="org.eclipse.quickdiff.changeindication"
presentationLayer="2"
- textPreferenceValue="false"
label="%changes.label"
+ textPreferenceValue="false"
textPreferenceKey="changeIndication"
overviewRulerPreferenceKey="changeIndicationInOverviewRuler">
</specification>
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.quickdiffAddition"
colorPreferenceValue="188,188,222"
isGoToPreviousNavigationTarget="false"
isGoToPreviousNavigationTargetKey="isAdditionGoToPreviousNavigationTarget"
showInNextPrevDropdownToolbarAction="false"
- annotationType="org.eclipse.ui.workbench.texteditor.quickdiffAddition"
isGoToNextNavigationTarget="false"
- showInNextPrevDropdownToolbarActionKey="showAdditionInNextPrevDropdownToolbarAction"
- colorPreferenceKey="additionIndicationColor"
isGoToNextNavigationTargetKey="isAdditionGoToNextNavigationTarget"
+ colorPreferenceKey="additionIndicationColor"
+ showInNextPrevDropdownToolbarActionKey="showAdditionInNextPrevDropdownToolbarAction"
contributesToHeader="false"
overviewRulerPreferenceValue="false"
- markerType="org.eclipse.quickdiff.additionindication"
presentationLayer="2"
- textPreferenceValue="false"
label="%additions.label"
+ textPreferenceValue="false"
textPreferenceKey="additionIndication"
overviewRulerPreferenceKey="additionIndicationInOverviewRuler">
</specification>
<specification
+ annotationType="org.eclipse.ui.workbench.texteditor.quickdiffDeletion"
colorPreferenceValue="0,0,0"
isGoToPreviousNavigationTarget="false"
isGoToPreviousNavigationTargetKey="isDeletionGoToPreviousNavigationTarget"
showInNextPrevDropdownToolbarAction="false"
- annotationType="org.eclipse.ui.workbench.texteditor.quickdiffDeletion"
isGoToNextNavigationTarget="false"
- showInNextPrevDropdownToolbarActionKey="showDeletionInNextPrevDropdownToolbarAction"
- colorPreferenceKey="deletionIndicationColor"
isGoToNextNavigationTargetKey="isDeletionGoToNextNavigationTarget"
+ colorPreferenceKey="deletionIndicationColor"
+ showInNextPrevDropdownToolbarActionKey="showDeletionInNextPrevDropdownToolbarAction"
contributesToHeader="false"
overviewRulerPreferenceValue="false"
- markerType="org.eclipse.quickdiff.deletionindication"
presentationLayer="2"
- textPreferenceValue="false"
label="%deletions.label"
+ textPreferenceValue="false"
textPreferenceKey="deletionIndication"
overviewRulerPreferenceKey="deletionIndicationInOverviewRuler">
</specification>
</extension>
+
+ <extension point="org.eclipse.ui.editors.annotationTypes">
+ <type
+ name="org.eclipse.ui.workbench.texteditor.error"
+ markerType="org.eclipse.core.resources.problemmarker"
+ markerSeverity="2">
+ </type>
+ <type
+ name="org.eclipse.ui.workbench.texteditor.warning"
+ markerType="org.eclipse.core.resources.problemmarker"
+ markerSeverity="1">
+ </type>
+ <type
+ name="org.eclipse.ui.workbench.texteditor.info"
+ markerType="org.eclipse.core.resources.problemmarker"
+ markerSeverity="0">
+ </type>
+ <type
+ name="org.eclipse.ui.workbench.texteditor.task"
+ markerType="org.eclipse.core.resources.taskmarker">
+ </type>
+ <type
+ name="org.eclipse.ui.workbench.texteditor.bookmark"
+ markerType="org.eclipse.core.resources.bookmark">
+ </type>
+ </extension>
+
</plugin>
diff --git a/org.eclipse.ui.editors/schema/annotationTypes.exsd b/org.eclipse.ui.editors/schema/annotationTypes.exsd
new file mode 100644
index 00000000000..59d2df6da8c
--- /dev/null
+++ b/org.eclipse.ui.editors/schema/annotationTypes.exsd
@@ -0,0 +1,130 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.editors">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ui.editors" id="annotationTypes" name="annotationTypes"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="type"/>
+ </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="type">
+ <complexType>
+ <attribute name="name" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="markerType" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="super" type="string">
+ <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>
+ </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.editors/schema/markerAnnotationSpecification.exsd b/org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd
index 4009ee63d04..ef5d7d89c36 100644
--- a/org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd
+++ b/org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd
@@ -41,21 +41,21 @@
<element name="specification">
<complexType>
- <attribute name="markerType" type="string" use="required">
+ <attribute name="annotationType" type="string" use="required">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
- <attribute name="colorPreferenceKey" type="string" use="required">
+ <attribute name="colorPreferenceKey" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
- <attribute name="overviewRulerPreferenceKey" type="string" use="required">
+ <attribute name="overviewRulerPreferenceKey" type="string">
<annotation>
<documentation>
@@ -70,14 +70,14 @@ since: 3.0
</documentation>
</annotation>
</attribute>
- <attribute name="textPreferenceKey" type="string" use="required">
+ <attribute name="textPreferenceKey" type="string">
<annotation>
<documentation>
</documentation>
</annotation>
</attribute>
- <attribute name="label" type="string" use="required">
+ <attribute name="label" type="string">
<annotation>
<documentation>
@@ -92,6 +92,20 @@ since: 3.0
</documentation>
</annotation>
</attribute>
+ <attribute name="markerType" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="colorPreferenceValue" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
<attribute name="markerSeverity">
<annotation>
<documentation>
@@ -109,13 +123,6 @@ since: 3.0
</restriction>
</simpleType>
</attribute>
- <attribute name="colorPreferenceValue" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
<attribute name="presentationLayer" type="string">
<annotation>
<documentation>
@@ -153,13 +160,6 @@ since: 3.0
</documentation>
</annotation>
</attribute>
- <attribute name="annotationType" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
<attribute name="contributesToHeader" type="boolean">
<annotation>
<documentation>
@@ -215,6 +215,44 @@ since: 3.0
</documentation>
</annotation>
</attribute>
+ <attribute name="icon" type="string">
+ <annotation>
+ <documentation>
+ The path to the icon to be drawn for annotations of this annotation type.
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="symbolicIcon">
+ <annotation>
+ <documentation>
+ The symbolic name of the image that should be drawn to represent annotation of this annotation type. The image is only used when there is no vertical ruler icon specified for this annotation type. Possible values are: &quot;error&quot;, &quot;warning&quot;, &quot;info&quot;, &quot;task&quot;, &quot;bookmark&quot;.
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="error">
+ </enumeration>
+ <enumeration value="warning">
+ </enumeration>
+ <enumeration value="info">
+ </enumeration>
+ <enumeration value="task">
+ </enumeration>
+ <enumeration value="bookmark">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="annotationImageProvider" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
</complexType>
</element>
diff --git a/org.eclipse.ui.editors/schema/markerAnnotations.exsd b/org.eclipse.ui.editors/schema/markerAnnotations.exsd
new file mode 100644
index 00000000000..e0f1f2e2f7f
--- /dev/null
+++ b/org.eclipse.ui.editors/schema/markerAnnotations.exsd
@@ -0,0 +1,86 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.editors">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ui.editors" id="markerAnnotations" name="markerAnnotations"/>
+ </appInfo>
+ <documentation>
+ [Enter description of this extension point.]
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ </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>
+
+ <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.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java
index 8f792f7b731..47a8e7071be 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java
@@ -25,6 +25,9 @@ import org.eclipse.jface.text.source.ISharedTextColors;
import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
+import org.eclipse.ui.texteditor.AnnotationTypeHierarchy;
+import org.eclipse.ui.texteditor.AnnotationTypeLookup;
import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
/**
@@ -71,6 +74,9 @@ public class EditorsPlugin extends AbstractUIPlugin {
private FileEditorInputAdapterFactory fFileEditorInputAdapterFactory;
private ISharedTextColors fSharedTextColors;
+ private AnnotationTypeLookup fAnnotationTypeLookup;
+ private AnnotationPreferenceLookup fAnnotationPreferenceLookup;
+ private AnnotationTypeHierarchy fAnnotationTypeHierarchy;
public EditorsPlugin(IPluginDescriptor descriptor) {
@@ -109,18 +115,58 @@ public class EditorsPlugin extends AbstractUIPlugin {
fSharedTextColors= null;
}
+ fAnnotationTypeLookup= null;
+ fAnnotationPreferenceLookup= null;
+ fAnnotationTypeHierarchy= null;
+
super.shutdown();
}
/**
* Returns the shared text colors of this plug-in.
*
- * @since 3.0
* @return the shared text colors
+ * @since 3.0
*/
public ISharedTextColors getSharedTextColors() {
if (fSharedTextColors == null)
fSharedTextColors= new SharedTextColors();
return fSharedTextColors;
}
+
+ /**
+ * Returns the annotation type lookup of this plug-in.
+ *
+ * @return the annotation type lookup
+ * @since 3.0
+ */
+ public AnnotationTypeLookup getAnnotationTypeLookup() {
+ if (fAnnotationTypeLookup == null)
+ fAnnotationTypeLookup= new AnnotationTypeLookup();
+ return fAnnotationTypeLookup;
+ }
+
+ /**
+ * Returns the annotation preference lookup of this plug-in.
+ *
+ * @return the annotation preference lookup
+ * @since 3.0
+ */
+ public AnnotationPreferenceLookup getAnnotationPreferenceLookup() {
+ if (fAnnotationPreferenceLookup == null)
+ fAnnotationPreferenceLookup= new AnnotationPreferenceLookup();
+ return fAnnotationPreferenceLookup;
+ }
+
+ /**
+ * Returns the annotation type hierarchy for this plug-in.
+ *
+ * @return the annotation type hierarchy
+ * @since 3.0
+ */
+ public AnnotationTypeHierarchy getAnnotationTypeHierarchy() {
+ if (fAnnotationTypeHierarchy == null)
+ fAnnotationTypeHierarchy= new AnnotationTypeHierarchy();
+ return fAnnotationTypeHierarchy;
+ }
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
index e0ca3980242..8b50b76ba93 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
@@ -149,6 +149,30 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel {
protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
return new MarkerAnnotation(marker);
}
+
+ /**
+ * Determines the annotation type for the given marker.
+ *
+ * @param marker the marker for which to determine the annotation type
+ * @return the annotation type for an annotation for the given marker
+ * @since 3.0
+ */
+ protected String computeAnnotationType(IMarker marker) {
+ AnnotationTypeLookup lookup= getAnnotationTypeLookup();
+ if (lookup != null)
+ return lookup.getAnnotationType(marker);
+ return null;
+ }
+
+ /**
+ * Returns the annotation type lookup used by this annotation model.
+ *
+ * @return the annotation type lookup
+ * @since 3.0
+ */
+ protected AnnotationTypeLookup getAnnotationTypeLookup() {
+ return EditorsPlugin.getDefault().getAnnotationTypeLookup();
+ }
/**
* Handles an unanticipated <code>CoreException</code> in
@@ -218,7 +242,15 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel {
Position p= createPositionFromMarker(marker);
if (p != null)
try {
- addAnnotation(createMarkerAnnotation(marker), p, false);
+ MarkerAnnotation annotation= createMarkerAnnotation(marker);
+ if (annotation != null) {
+
+ String annotationType= computeAnnotationType(marker);
+ if (annotationType != null)
+ annotation.setType(annotationType);
+
+ addAnnotation(annotation, p, false);
+ }
} catch (BadLocationException e) {
// ignore invalid position
}
@@ -310,16 +342,12 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel {
protected void modifyMarkerAnnotation(IMarker marker) {
MarkerAnnotation a= getMarkerAnnotation(marker);
if (a != null) {
-
- // update annotation presentation
- a.update();
-
- // update annotation position
- Position p1= createPositionFromMarker(marker);
- if (p1 != null) {
- Position p0= (Position) fAnnotations.get(a);
- p0.setOffset(p1.getOffset());
- p0.setLength(p1.getLength());
+ Position p= createPositionFromMarker(marker);
+ if (p != null) {
+ String annotationType= computeAnnotationType(marker);
+ if (annotationType != null && !annotationType.equals(a.getType()))
+ a.setType(annotationType);
+ modifyAnnotation(a, p);
}
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java
new file mode 100644
index 00000000000..60e8b1eb2eb
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java
@@ -0,0 +1,103 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.jface.text.source.Annotation;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
+/**
+ * Provides the strategy for finding the annotation preference for a given
+ * annotation.
+ *
+ * @since 3.0
+ */
+public class AnnotationPreferenceLookup {
+
+ /** The map between annotation types and annotation preference fragments. */
+ private Map fFragments;
+
+ /**
+ * Creates a new annotation preference lookup object.
+ */
+ public AnnotationPreferenceLookup() {
+ }
+
+ /**
+ * Returns the annotation preference of a given annotation.
+ *
+ * @param annotation the annotation
+ * @return the annotation preference for the given annotation or <code>null</code>
+ */
+ public AnnotationPreference getAnnotationPreference(Annotation annotation) {
+ String typeName= annotation.getType();
+ if (typeName == null)
+ return null;
+
+ AnnotationTypeHierarchy hierarchy= getAnnotationTypeHierarchy();
+ AnnotationType type= hierarchy.getAnnotationType(typeName);
+ AnnotationPreference preference= type.getPreference();
+ if (preference == null) {
+ preference= new DelegatingAnnotationPreference(type, this);
+ type.setAnnotationPreference(preference);
+ }
+
+ return preference;
+ }
+
+ /**
+ * Returns the annotation preference fragment defined for the given annotation type.
+ *
+ * @param annotationType the annotation type
+ * @return the defined annotation preference fragment
+ */
+ public AnnotationPreference getAnnotationPreferenceFragment(String annotationType) {
+ Map fragments= getPreferenceFragments();
+ return (AnnotationPreference) fragments.get(annotationType);
+ }
+
+ /**
+ * Returns the annotation type hierarchy and creates it when not yet done.
+ *
+ * @return the annotation type hierarchy
+ */
+ private AnnotationTypeHierarchy getAnnotationTypeHierarchy() {
+ return EditorsPlugin.getDefault().getAnnotationTypeHierarchy();
+ }
+
+ /**
+ * Returns a map between annotation type names and annotation preference
+ * fragements and creates it if not yet done.
+ *
+ * @return the map between annotation type names and annotation preference fragments
+ */
+ private Map getPreferenceFragments() {
+ if (fFragments == null) {
+ fFragments= new HashMap();
+ MarkerAnnotationPreferences p= new MarkerAnnotationPreferences();
+ Iterator e= p.getAnnotationPreferenceFragments().iterator();
+ while (e.hasNext()) {
+ AnnotationPreference fragment= (AnnotationPreference) e.next();
+ Object annotationType = fragment.getAnnotationType();
+ AnnotationPreference preference= (AnnotationPreference) fFragments.get(annotationType);
+ if (preference == null)
+ fFragments.put(annotationType, fragment);
+ else
+ preference.merge(fragment);
+ }
+ }
+ return fFragments;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationType.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationType.java
new file mode 100644
index 00000000000..2d9d2739f81
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationType.java
@@ -0,0 +1,54 @@
+/*******************************************************************************
+ * 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;
+
+
+public class AnnotationType {
+ private String fType;
+ private String[] fSuperTypes;
+ private AnnotationPreference fPreference;
+
+ public AnnotationType(String type, String[] superTypes) {
+ fType= type;
+ fSuperTypes= superTypes;
+ }
+
+ public String getType() {
+ return fType;
+ }
+
+ public String[] getSuperTypes() {
+ return fSuperTypes;
+ }
+
+ public AnnotationPreference getPreference() {
+ return fPreference;
+ }
+
+ public void setAnnotationPreference(AnnotationPreference preference) {
+ fPreference= preference;
+ }
+
+ public boolean isSubtype(String superType) {
+ if (fSuperTypes == null || superType == null)
+ return false;
+
+ if (superType.equals(fType))
+ return true;
+
+ for (int i= fSuperTypes.length -1; i > -1; i--) {
+ if (superType.equals(fSuperTypes[i]))
+ return true;
+ }
+
+ return false;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeHierarchy.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeHierarchy.java
new file mode 100644
index 00000000000..94c823ab6c0
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeHierarchy.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
+
+/**
+ * Internal annotation super type hierarchy cache.
+ * TODO this cache is currently unbound, i.e. only limited by the number of annotation types
+ *
+ * @since 3.0
+ */
+public class AnnotationTypeHierarchy {
+
+ private Map fTypeMap;
+ private Map fTypesCache= new HashMap();
+
+ public AnnotationTypeHierarchy() {
+ }
+
+ public AnnotationType getAnnotationType(String typeName) {
+ AnnotationType type= (AnnotationType) fTypesCache.get(typeName);
+ if (type == null) {
+ String[] superTypes= computeSuperTypes(typeName);
+ type= new AnnotationType(typeName, superTypes);
+ fTypesCache.put(typeName, type);
+ }
+ return type;
+ }
+
+ public boolean isSubtype(String superType, String subtypeCandidate) {
+ AnnotationType type= getAnnotationType(subtypeCandidate);
+ return type.isSubtype(superType);
+ }
+
+ private String[] computeSuperTypes(String typeName) {
+ ArrayList types= new ArrayList();
+ append(types, getDirectSuperType(typeName));
+ int index= 0;
+ while (index < types.size()) {
+ String type= (String) types.get(index++);
+ append(types, getDirectSuperType(type));
+ }
+
+ String[] superTypes= new String[types.size()];
+ types.toArray(superTypes);
+ return superTypes;
+ }
+
+ private String getDirectSuperType(String typeName) {
+ return (String) getTypeMap().get(typeName);
+ }
+
+ private void append(List list, String string) {
+ if (string == null || string.trim().length() == 0)
+ return;
+
+ if (!list.contains(string))
+ list.add(string);
+ }
+
+ private Map getTypeMap() {
+ if (fTypeMap == null)
+ fTypeMap= readTypes();
+ return fTypeMap;
+ }
+
+ private Map readTypes() {
+ HashMap allTypes= new HashMap();
+
+ IExtensionPoint extensionPoint= Platform.getPluginRegistry().getExtensionPoint(EditorsPlugin.getPluginId(), "annotationTypes");
+ if (extensionPoint != null) {
+ IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
+ for (int i= 0; i < elements.length; i++) {
+ IConfigurationElement element= elements[i];
+
+ String name= element.getAttribute("name"); //$NON-NLS-1$
+ if (name == null || name.trim().length() == 0)
+ continue;
+
+ String parent= element.getAttribute("super"); //$NON-NLS-1$
+ if (parent == null || parent.trim().length() == 0)
+ parent= "";
+
+ allTypes.put(name, parent);
+ }
+ }
+
+ return allTypes;
+ }
+} \ No newline at end of file
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
new file mode 100644
index 00000000000..f3bcc0c4a0c
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+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.jface.resource.StringConverter;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
+/**
+ * Provides the strategy for determining annotation types for given markers.
+ *
+ * @since 3.0
+ */
+public class AnnotationTypeLookup {
+
+ /**
+ * Record representing an annotation type mapping.
+ */
+ private static class AnnotationTypeMapping {
+
+ final static int UNDEFINED= -1;
+
+ String fAnnotationType;
+ String fMarkerType;
+ int fMarkerSeverity= UNDEFINED;
+
+ boolean isMarkerSeverityDefined() {
+ return fMarkerSeverity != UNDEFINED;
+ }
+ }
+
+ /** The lookup table for marker to annotation type mappings. */
+ private Map fMapping;
+
+ /**
+ * Creates a new annotation lookup object.
+ */
+ public AnnotationTypeLookup() {
+ }
+
+ /**
+ * Computes the annotation type that corresponds to the state of
+ * the given marker.
+ *
+ * @param marker the marker
+ * @return the annotation type or <code>null</code>
+ */
+ public String getAnnotationType(IMarker marker) {
+ String markerType= MarkerUtilities.getMarkerType(marker);
+ if (markerType != null) {
+ int severity= MarkerUtilities.getSeverity(marker);
+ return getAnnotationType(markerType, severity);
+ }
+ return null;
+ }
+
+ /**
+ * Computes the annotation type that corresponds to the given marker type and
+ * the given marker severity.
+ *
+ * @param markerType the marker type
+ * @param markerSeverity the marker severity
+ * @return the annotation type or <code>null</code>
+ */
+ public String getAnnotationType(String markerType, int markerSeverity) {
+ String annotationType= lookupAnnotationType(markerType, markerSeverity);
+ if (annotationType != null)
+ return annotationType;
+ String[] superTypes= MarkerUtilities.getSuperTypes(markerType);
+ for (int i= 0; i < superTypes.length; i++) {
+ annotationType= lookupAnnotationType(superTypes[i], markerSeverity);
+ if (annotationType != null)
+ return annotationType;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the annotation type for the given marker type and the given
+ * marker severity.
+ *
+ * @param markerType the marker type
+ * @param severity the marker severity
+ * @return the annotation type
+ */
+ private String lookupAnnotationType(String markerType, int severity) {
+ if (fMapping == null)
+ initializeMapping();
+
+ Object value= fMapping.get(markerType);
+
+ if (value instanceof String)
+ return (String) value;
+
+ if (value instanceof Map) {
+ Map severityMap= (Map) value;
+ return (String) severityMap.get(new Integer(severity));
+ }
+
+ return null;
+ }
+
+ /**
+ * Initializes the mapping between markers and their property values and
+ * annotation types.
+ */
+ private void initializeMapping() {
+ fMapping= new HashMap();
+ List mappings= getAnnotationTypeMappings();
+ for (int i= 0, l= mappings.size(); i < l; i++) {
+ AnnotationTypeMapping atm= (AnnotationTypeMapping) mappings.get(i);
+ if (atm.isMarkerSeverityDefined()) {
+ Object severityMap= fMapping.get(atm.fMarkerType);
+ if (!(severityMap instanceof Map)) {
+ severityMap= new HashMap();
+ fMapping.put(atm.fMarkerType, severityMap);
+ }
+ Map map= (Map) severityMap;
+ map.put(new Integer(atm.fMarkerSeverity), atm.fAnnotationType);
+ } else {
+ fMapping.put(atm.fMarkerType, atm.fAnnotationType);
+ }
+ }
+ }
+
+ /**
+ * Returns the list of annotation type mappings generated from the
+ * extensions provided for the annotation type extension point.
+ *
+ * @return a list of annotation type mappings
+ */
+ private List getAnnotationTypeMappings() {
+ List annotationTypeMappings= new ArrayList();
+ // read compatibility mode
+ readExtensionPoint(annotationTypeMappings, "markerAnnotationSpecification", "annotationType");
+ // read new extension point
+ readExtensionPoint(annotationTypeMappings, "annotationTypes", "name");
+ return annotationTypeMappings;
+ }
+
+ /**
+ * Reads the extensions provided for the given extension point name. Uses
+ * the given type attribute name to create annotation type mappings that
+ * are appended to the given list.
+ *
+ * @param annotationTypeMappings the list to be populated
+ * @param extensionPointName the name of the extension point to read
+ * @param typeAttributeName the name of attribute specifying the annotation
+ * type
+ */
+ private void readExtensionPoint(List annotationTypeMappings, String extensionPointName, String typeAttributeName) {
+ IExtensionPoint extensionPoint= Platform.getPluginRegistry().getExtensionPoint(EditorsPlugin.getPluginId(), extensionPointName);
+ if (extensionPoint != null) {
+ IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
+ for (int i= 0; i < elements.length; i++) {
+ AnnotationTypeMapping mapping= createMapping(elements[i], typeAttributeName);
+ if (mapping != null)
+ annotationTypeMappings.add(mapping);
+ }
+ }
+ }
+
+ /**
+ * Creates an annotation type mapping from the given configuration element.
+ *
+ * @param element the configuration element
+ * @param typeAttributeName the name of the attribute specifying the
+ * annotation type
+ * @return the annotation type mapping or <code>null</code>
+ */
+ private AnnotationTypeMapping createMapping(IConfigurationElement element, String typeAttributeName) {
+
+ AnnotationTypeMapping mapping= new AnnotationTypeMapping();
+
+ String s= element.getAttribute(typeAttributeName); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ mapping.fAnnotationType= s;
+
+ s= element.getAttribute("markerType"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ mapping.fMarkerType= s;
+
+ s= element.getAttribute("markerSeverity"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ mapping.fMarkerSeverity= StringConverter.asInt(s, AnnotationTypeMapping.UNDEFINED);
+
+ return mapping;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultAnnotation.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultAnnotation.java
index 98d56c9f6d4..1114545bf3c 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultAnnotation.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultAnnotation.java
@@ -32,6 +32,7 @@ import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationPresentation;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -39,6 +40,8 @@ import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.model.IWorkbenchAdapter;
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
/**
* Default annotation.
* This class may be instantiated or be subclassed.
@@ -46,8 +49,9 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
* XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
* </p>
* @since 3.0
+ * @deprecated use Annotation and ImageUtilities, stay with layer definitions until new home found for them
*/
-public class DefaultAnnotation extends Annotation implements IAnnotationExtension {
+public class DefaultAnnotation extends Annotation implements IAnnotationPresentation {
/**
* The layer in which task annotations are located.
@@ -85,8 +89,6 @@ public class DefaultAnnotation extends Annotation implements IAnnotationExtensio
protected String fImageName;
private int fSeverity;
- private boolean fIsTemporary;
- private String fMessage;
private String fMarkerType;
private boolean fIsInitialized= false;
@@ -151,7 +153,7 @@ public class DefaultAnnotation extends Annotation implements IAnnotationExtensio
}
/**
- * Creates a new editor annotation.
+ * Creates a new annotation.
*
* @param markerType the marker type of this annotation
* @param severity the severity of this annotation
@@ -159,11 +161,24 @@ public class DefaultAnnotation extends Annotation implements IAnnotationExtensio
* @param message the message of this annotation
*/
public DefaultAnnotation(String markerType, int severity, boolean isTemporary, String message) {
+ super(!isTemporary);
Assert.isTrue(severity == IMarker.SEVERITY_INFO || severity == IMarker.SEVERITY_WARNING || severity == IMarker.SEVERITY_ERROR);
fSeverity= severity;
- fIsTemporary= isTemporary;
- fMessage= message;
fMarkerType= markerType;
+ setText(message);
+ setType(computeAnnotationType(markerType, severity));
+ }
+
+ /**
+ * Computes the annotation type based on marker type and marker severity.
+ *
+ * @param markerType the marker type
+ * @param severity the marker severity
+ * @return the corresponding annotation type
+ */
+ private String computeAnnotationType(String markerType, int severity) {
+ AnnotationTypeLookup lookup= EditorsPlugin.getDefault().getAnnotationTypeLookup();
+ return lookup.getAnnotationType(markerType, severity);
}
/**
@@ -306,29 +321,4 @@ public class DefaultAnnotation extends Annotation implements IAnnotationExtensio
return fImage;
}
-
- /*
- * @see IAnnotationExtension#getMessage()
- */
- public String getMessage() {
- return fMessage;
- }
-
- public String getMarkerType() {
- return fMarkerType;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#getSeverity()
- */
- public int getSeverity() {
- return fSeverity;
- }
-
- /*
- * @see IAnnotationExtension#isTemporary()
- */
- public boolean isTemporary() {
- return fIsTemporary;
- }
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
index e0e4ae3d8de..457fba2f265 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
@@ -10,18 +10,26 @@
*******************************************************************************/
package org.eclipse.ui.texteditor;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
+import java.util.HashMap;
+import java.util.Map;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+
import org.eclipse.jface.text.source.Annotation;
import org.eclipse.jface.text.source.IAnnotationAccess;
import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+import org.eclipse.jface.text.source.IAnnotationPresentation;
+
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
@@ -31,59 +39,88 @@ import org.eclipse.ui.internal.editors.text.EditorsPlugin;
*/
public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnotationAccessExtension {
- /** Constant for the unknown marker type */
- public final static String UNKNOWN= EditorsPlugin.getPluginId() + ".unknown"; //$NON-NLS-1$
+ /**
+ * Constant for the unknown marker type
+ * @deprecated use Annotation.TYPE_UNKNOWN instead
+ */
+ public final static String UNKNOWN= Annotation.TYPE_UNKNOWN;
+
+ /**
+ * Constant for the error system image.
+ * Value: <code>error</code>
+ *
+ * @since 3.0
+ */
+ public final static String ERROR_SYSTEM_IMAGE= "error";
+ /**
+ * Constant for the warning system image.
+ * Value: <code>warning</code>
+ *
+ * @since 3.0
+ */
+ public final static String WARNING_SYSTEM_IMAGE= "warning";
+ /**
+ * Constant for the info system image.
+ * Value: <code>info</code>
+ *
+ * @since 3.0
+ */
+ public final static String INFO_SYSTEM_IMAGE= "info";
+ /**
+ * Constant for the task system image.
+ * Value: <code>task</code>
+ *
+ * @since 3.0
+ */
+ public final static String TASK_SYSTEM_IMAGE= "task";
+ /**
+ * Constant for the bookmark system image.
+ * Value: <code>bookmark</code>
+ *
+ * @since 3.0
+ */
+ public final static String BOOKMARK_SYSTEM_IMAGE= "bookmark";
- /** The marker annotation preferences */
+ /**
+ * The mapping between external and internal symbolic system image names.
+ * @since 3.0
+ */
+ private final static Map MAPPING;
+
+ static {
+ MAPPING= new HashMap();
+ MAPPING.put(ERROR_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_ERROR_TSK);
+ MAPPING.put(WARNING_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_WARN_TSK);
+ MAPPING.put(INFO_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_INFO_TSK);
+ MAPPING.put(TASK_SYSTEM_IMAGE, IDE.SharedImages.IMG_OBJS_TASK_TSK);
+ MAPPING.put(BOOKMARK_SYSTEM_IMAGE, IDE.SharedImages.IMG_OBJS_BKMRK_TSK);
+ }
+
+
+ /**
+ * The marker annotation preferences
+ * @deprecated since 3.0
+ */
protected MarkerAnnotationPreferences fMarkerAnnotationPreferences;
/**
* Returns a new default marker annotation access with the given preferences.
*
* @param markerAnnotationPreferences
+ * @deprecated use <code>DefaultMarkerAnnotationAccess()</code> instead
*/
public DefaultMarkerAnnotationAccess(MarkerAnnotationPreferences markerAnnotationPreferences) {
fMarkerAnnotationPreferences= markerAnnotationPreferences;
}
-
- /**
- * Returns the annotation preference for the given marker.
- *
- * @param marker
- * @return the annotation preference or <code>null</code> if none
- */
- private AnnotationPreference getAnnotationPreference(IMarker marker) {
- Iterator e= fMarkerAnnotationPreferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- Integer severity;
- boolean isSubtype;
- AnnotationPreference info= (AnnotationPreference) e.next();
- try {
- severity= (Integer)marker.getAttribute(IMarker.SEVERITY);
- isSubtype= marker.isSubtypeOf(info.getMarkerType());
- } catch (CoreException x) {
- return null;
- }
- if (isSubtype && (severity == null || severity.intValue() == info.getSeverity()))
- return info;
- }
- return null;
- }
-
+
/**
- * Returns the annotation preference for the given marker.
+ * Creates a new default marker annotation access using the standard
+ * preference lookup strategy which is the one provided by the enclosing
+ * plug-in.
*
- * @param marker
- * @return the annotation preference or <code>null</code> if none
- */
- private AnnotationPreference getAnnotationPreference(String markerType, int severity) {
- Iterator e= fMarkerAnnotationPreferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
- if (info.getMarkerType().equals(markerType) && severity == info.getSeverity())
- return info;
- }
- return null;
+ * @since 3.0
+ */
+ public DefaultMarkerAnnotationAccess() {
}
/**
@@ -93,24 +130,27 @@ public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnota
* @return the annotation preference for the given annotation or <code>null</code>
*/
private AnnotationPreference getAnnotationPreference(Annotation annotation) {
- if (annotation instanceof MarkerAnnotation) {
- MarkerAnnotation markerAnnotation= (MarkerAnnotation) annotation;
- IMarker marker= markerAnnotation.getMarker();
- if (marker != null && marker.exists())
- return getAnnotationPreference(marker);
- } else if (annotation instanceof IAnnotationExtension) {
- IAnnotationExtension annotationExtension= (IAnnotationExtension)annotation;
- return getAnnotationPreference(annotationExtension.getMarkerType(), annotationExtension.getSeverity());
- }
+ AnnotationPreferenceLookup lookup= getAnnotationPreferenceLookup();
+ if (lookup != null)
+ return lookup.getAnnotationPreference(annotation);
return null;
}
+ /**
+ * Returns the annotation preference lookup used by this annotation access.
+ *
+ * @return the annotation preference lookup
+ * @since 3.0
+ */
+ protected AnnotationPreferenceLookup getAnnotationPreferenceLookup() {
+ return EditorsPlugin.getDefault().getAnnotationPreferenceLookup();
+ }
+
/*
* @see org.eclipse.jface.text.source.IAnnotationAccess#getType(org.eclipse.jface.text.source.Annotation)
*/
public Object getType(Annotation annotation) {
- AnnotationPreference preference= getAnnotationPreference(annotation);
- return preference != null ? preference.getAnnotationType() : UNKNOWN;
+ return annotation.getType();
}
/*
@@ -124,13 +164,12 @@ public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnota
* @see org.eclipse.jface.text.source.IAnnotationAccess#isTemporary(org.eclipse.jface.text.source.Annotation)
*/
public boolean isTemporary(Annotation annotation) {
- if (annotation instanceof IAnnotationExtension)
- return ((IAnnotationExtension)annotation).isTemporary();
- return false;
+ return !annotation.isPersistent();
}
/*
* @see org.eclipse.jface.text.source.IAnnotationAccessExtension#getLabel(org.eclipse.jface.text.source.Annotation)
+ * @since 3.0
*/
public String getTypeLabel(Annotation annotation) {
AnnotationPreference preference= getAnnotationPreference(annotation);
@@ -139,16 +178,129 @@ public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnota
/*
* @see org.eclipse.jface.text.source.IAnnotationAccessExtension#getLayer(org.eclipse.jface.text.source.Annotation)
+ * @since 3.0
*/
public int getLayer(Annotation annotation) {
+ if (annotation instanceof IAnnotationPresentation) {
+ IAnnotationPresentation presentation= (IAnnotationPresentation) annotation;
+ return presentation.getLayer();
+ }
AnnotationPreference preference= getAnnotationPreference(annotation);
return preference != null ? preference.getPresentationLayer() : IAnnotationAccessExtension.DEFAULT_LAYER;
}
/*
* @see org.eclipse.jface.text.source.IAnnotationAccessExtension#paint(org.eclipse.jface.text.source.Annotation, org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
+ * @since 3.0
*/
public void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds) {
- annotation.paint(gc, canvas, bounds);
+ if (annotation instanceof IAnnotationPresentation) {
+
+ IAnnotationPresentation presentation= (IAnnotationPresentation) annotation;
+ presentation.paint(gc, canvas, bounds);
+
+ } else {
+
+ AnnotationPreference preference= getAnnotationPreference(annotation);
+ if (preference == null)
+ return;
+
+ Object type= getType(annotation);
+ String annotationType= (type == null ? null : type.toString());
+ Image image= getImage(annotation, preference, annotationType);
+ if (image != null)
+ ImageUtilities.drawImage(image, gc, canvas, bounds, SWT.CENTER, SWT.TOP);
+ }
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#isSubtype(java.lang.Object, java.lang.Object)
+ */
+ public boolean isSubtype(Object annotationType, Object potentialSupertype) {
+ AnnotationTypeHierarchy hierarchy= getAnnotationTypeHierarchy();
+ return hierarchy.isSubtype(potentialSupertype.toString(), annotationType.toString());
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#getSupertypes(java.lang.Object)
+ */
+ public Object[] getSupertypes(Object annotationType) {
+ AnnotationTypeHierarchy hierarchy= getAnnotationTypeHierarchy();
+ AnnotationType type= hierarchy.getAnnotationType(annotationType.toString());
+ return type.getSuperTypes();
+ }
+
+ /**
+ * Returns the annotation type hierarchy used by this annotation access.
+ *
+ * @return the annotation type hierarchy
+ * @since 3.0
+ */
+ protected AnnotationTypeHierarchy getAnnotationTypeHierarchy() {
+ return EditorsPlugin.getDefault().getAnnotationTypeHierarchy();
+ }
+
+ /**
+ * Translates the given symbolic image name into the according symbolic image name
+ * the <code>ISharedImages</code> understands.
+ *
+ * @param symbolicImageName the symbolic system image name to be translated
+ * @since 3.0
+ */
+ private String translateSymbolicImageName(String symbolicImageName) {
+ return (String) MAPPING.get(symbolicImageName);
+ }
+
+ /**
+ * Retuns the image for the given annotation and the given annotation preferences or
+ * <code>null</code> if there is no such image.
+ *
+ * @param annotation the annotation
+ * @param preference the annotation preference
+ * @param annotationType the annotation type
+ * @return the image or <code>null</code>
+ * @since 3.0
+ */
+ private Image getImage(Annotation annotation, AnnotationPreference preference, String annotationType) {
+
+ ImageRegistry registry= EditorsPlugin.getDefault().getImageRegistry();
+
+ IAnnotationImageProvider annotationImageProvider = preference.getAnnotationImageProvider();
+ if (annotationImageProvider != null) {
+
+ Image image= annotationImageProvider.getManagedImage(annotation);
+ if (image != null)
+ return image;
+
+ String id= annotationImageProvider.getImageDescriptorId(annotation);
+ if (id != null) {
+ image= registry.get(id);
+ if (image == null) {
+ ImageDescriptor descriptor= annotationImageProvider.getImageDescriptor(id);
+ registry.put(id, descriptor);
+ image= registry.get(id);
+ }
+ return image;
+ }
+ }
+
+ if (annotationType == null)
+ return null;
+
+ Image image= registry.get(annotationType);
+ if (image == null) {
+ ImageDescriptor descriptor= preference.getImageDescriptor();
+ if (descriptor != null) {
+ registry.put(annotationType, descriptor);
+ image= registry.get(annotationType);
+ } else {
+ String key= translateSymbolicImageName(preference.getSymbolicImageName());
+ if (key != null) {
+ ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages();
+ image= sharedImages.getImage(key);
+ }
+ }
+ }
+ return image;
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DelegatingAnnotationPreference.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DelegatingAnnotationPreference.java
new file mode 100644
index 00000000000..c940c9f95df
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DelegatingAnnotationPreference.java
@@ -0,0 +1,248 @@
+/*******************************************************************************
+ * 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;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+
+
+class DelegatingAnnotationPreference extends AnnotationPreference {
+
+ private AnnotationType fType;
+ private AnnotationPreferenceLookup fLookup;
+ private Set fCache= new HashSet();
+
+ public DelegatingAnnotationPreference(AnnotationType type, AnnotationPreferenceLookup lookup) {
+ fType= type;
+ fLookup= lookup;
+ }
+
+ private boolean isCached(Object attribute) {
+ return fCache.contains(attribute);
+ }
+
+ private void markCached(Object attribute) {
+ fCache.add(attribute);
+ }
+
+ private AnnotationPreference getDefiningPreference(Object attribute) {
+
+ AnnotationPreference p= fLookup.getAnnotationPreferenceFragment(fType.getType());
+ if (p != null && p.hasValue(attribute))
+ return p;
+
+ String[] superTypes= fType.getSuperTypes();
+ for (int i= 0; i < superTypes.length; i++) {
+ p= fLookup.getAnnotationPreferenceFragment(superTypes[i]);
+ if (p != null && p.hasValue(attribute))
+ return p;
+ }
+
+ return null;
+ }
+
+ private Object getAttributeValue(Object attribute) {
+ if (!isCached(attribute)) {
+ AnnotationPreference preference= getDefiningPreference(attribute);
+ if (preference != null)
+ setValue(attribute, preference.getValue(attribute));
+ markCached(attribute);
+ }
+ return getValue(attribute);
+ }
+
+ private boolean getBooleanAttributeValue(Object attribute) {
+ Object value= getAttributeValue(attribute);
+ if (value instanceof Boolean)
+ return ((Boolean) value).booleanValue();
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getAnnotationType()
+ */
+ public Object getAnnotationType() {
+ return fType.getType();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#contributesToHeader()
+ */
+ public boolean contributesToHeader() {
+ return getBooleanAttributeValue(HEADER_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getAnnotationImageProvider()
+ */
+ public IAnnotationImageProvider getAnnotationImageProvider() {
+ if (!isCached(IMAGE_PROVIDER)) {
+ AnnotationPreference preference= getDefiningPreference(IMAGE_PROVIDER);
+ if (preference != null) {
+ fAnnotationImageProvider= preference.fAnnotationImageProvider;
+ fAnnotationImageProviderAttribute= preference.fAnnotationImageProviderAttribute;
+ fConfigurationElement= preference.fConfigurationElement;
+ }
+ markCached(IMAGE_PROVIDER);
+ }
+ return super.getAnnotationImageProvider();
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getColorPreferenceKey()
+ */
+ public String getColorPreferenceKey() {
+ return (String) getAttributeValue(COLOR_PREFERENCE_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getColorPreferenceValue()
+ */
+ public RGB getColorPreferenceValue() {
+ return (RGB) getAttributeValue(COLOR_PREFERENCE_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getHighlightPreferenceKey()
+ */
+ public String getHighlightPreferenceKey() {
+ return (String) getAttributeValue(HIGHLIGHT_PREFERENCE_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getHighlightPreferenceValue()
+ */
+ public boolean getHighlightPreferenceValue() {
+ return getBooleanAttributeValue(HIGHLIGHT_PREFERENCE_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getImageDescriptor()
+ */
+ public ImageDescriptor getImageDescriptor() {
+ return (ImageDescriptor) getAttributeValue(IMAGE_DESCRIPTOR);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getIsGoToNextNavigationTargetKey()
+ */
+ public String getIsGoToNextNavigationTargetKey() {
+ return (String) getAttributeValue(IS_GO_TO_NEXT_TARGET_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getIsGoToPreviousNavigationTargetKey()
+ */
+ public String getIsGoToPreviousNavigationTargetKey() {
+ return (String) getAttributeValue(IS_GO_TO_PREVIOUS_TARGET_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getOverviewRulerPreferenceKey()
+ */
+ public String getOverviewRulerPreferenceKey() {
+ return (String) getAttributeValue(OVERVIEW_RULER_PREFERENCE_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getOverviewRulerPreferenceValue()
+ */
+ public boolean getOverviewRulerPreferenceValue() {
+ return getBooleanAttributeValue(OVERVIEW_RULER_PREFERENCE_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getPreferenceLabel()
+ */
+ public String getPreferenceLabel() {
+ return (String) getAttributeValue(PREFERENCE_LABEL);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getPresentationLayer()
+ */
+ public int getPresentationLayer() {
+ Object value= getAttributeValue(PRESENTATION_LAYER);
+ if (value instanceof Integer)
+ return ((Integer) value).intValue();
+ return IAnnotationAccessExtension.DEFAULT_LAYER;
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getShowInNextPrevDropdownToolbarActionKey()
+ */
+ public String getShowInNextPrevDropdownToolbarActionKey() {
+ return (String) getAttributeValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getSymbolicImageName()
+ */
+ public String getSymbolicImageName() {
+ return (String) getAttributeValue(SYMBOLIC_IMAGE_NAME);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getTextPreferenceKey()
+ */
+ public String getTextPreferenceKey() {
+ return (String) getAttributeValue(TEXT_PREFERENCE_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getTextPreferenceValue()
+ */
+ public boolean getTextPreferenceValue() {
+ return getBooleanAttributeValue(TEXT_PREFERENCE_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getVerticalRulerPreferenceKey()
+ */
+ public String getVerticalRulerPreferenceKey() {
+ return (String) getAttributeValue(VERTICAL_RULER_PREFERENCE_KEY);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#getVerticalRulerPreferenceValue()
+ */
+ public boolean getVerticalRulerPreferenceValue() {
+ return getBooleanAttributeValue(VERTICAL_RULER_PREFERENCE_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#isGoToNextNavigationTarget()
+ */
+ public boolean isGoToNextNavigationTarget() {
+ return getBooleanAttributeValue(IS_GO_TO_NEXT_TARGET_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#isGoToPreviousNavigationTarget()
+ */
+ public boolean isGoToPreviousNavigationTarget() {
+ return getBooleanAttributeValue(IS_GO_TO_PREVIOUS_TARGET_VALUE);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AnnotationPreference#isShowInNextPrevDropdownToolbarAction()
+ */
+ public boolean isShowInNextPrevDropdownToolbarAction() {
+ return getBooleanAttributeValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE);
+ }
+
+} \ No newline at end of file
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditor.java
index 5c27afbcb52..71dbfe44d6e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditor.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditor.java
@@ -255,7 +255,7 @@ public abstract class ExtendedTextEditor extends StatusTextEditor {
* @return the created annotation access
*/
protected IAnnotationAccess createAnnotationAccess() {
- return new DefaultMarkerAnnotationAccess(fAnnotationPreferences);
+ return new DefaultMarkerAnnotationAccess();
}
/**
@@ -549,13 +549,13 @@ public abstract class ExtendedTextEditor extends StatusTextEditor {
while (iter.hasNext()) {
AnnotationPreference pref= (AnnotationPreference) iter.next();
- if ("org.eclipse.quickdiff.changeindication".equals(pref.getMarkerType())) { //$NON-NLS-1$
+ if ("org.eclipse.ui.workbench.texteditor.quickdiffChange".equals(pref.getAnnotationType())) { //$NON-NLS-1$
RGB rgb= getColorPreference(store, pref);
changeColumn.setChangedColor(sharedColors.getColor(rgb));
- } else if ("org.eclipse.quickdiff.additionindication".equals(pref.getMarkerType())) { //$NON-NLS-1$
+ } else if ("org.eclipse.ui.workbench.texteditor.quickdiffAddition".equals(pref.getAnnotationType())) { //$NON-NLS-1$
RGB rgb= getColorPreference(store, pref);
changeColumn.setAddedColor(sharedColors.getColor(rgb));
- } else if ("org.eclipse.quickdiff.deletionindication".equals(pref.getMarkerType())) { //$NON-NLS-1$
+ } else if ("org.eclipse.ui.workbench.texteditor.quickdiffDeletion".equals(pref.getAnnotationType())) { //$NON-NLS-1$
RGB rgb= getColorPreference(store, pref);
changeColumn.setDeletedColor(sharedColors.getColor(rgb));
}
@@ -754,10 +754,11 @@ public abstract class ExtendedTextEditor extends StatusTextEditor {
if (pref != null) {
IChangeRulerColumn column= getChangeColumn();
if (column != null) {
- if ("org.eclipse.quickdiff.changeindication".equals(pref.getMarkerType()) //$NON-NLS-1$
- || "org.eclipse.quickdiff.additionindication".equals(pref.getMarkerType()) //$NON-NLS-1$
- || "org.eclipse.quickdiff.deletionindication".equals(pref.getMarkerType())) { //$NON-NLS-1$
- initializeChangeRulerColumn(column);
+ Object type= pref.getAnnotationType();
+ if (type instanceof String) {
+ String annotationType= (String) type;
+ if (annotationType.startsWith("org.eclipse.ui.workbench.texteditor.quickdiff"))
+ initializeChangeRulerColumn(column);
}
}
}
@@ -845,6 +846,15 @@ public abstract class ExtendedTextEditor extends StatusTextEditor {
fAnnotationAccess= createAnnotationAccess();
return fAnnotationAccess;
}
+
+ /**
+ * Returns the annotation preference lookup.
+ *
+ * @return the annotation preference lookup
+ */
+ protected AnnotationPreferenceLookup getAnnotationPreferenceLookup() {
+ return EditorsPlugin.getDefault().getAnnotationPreferenceLookup();
+ }
/**
* Returns the overview ruler.
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java
new file mode 100644
index 00000000000..4ec1cad272e
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java
@@ -0,0 +1,86 @@
+/*******************************************************************************
+ * 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;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.FontMetrics;
+import org.eclipse.swt.graphics.GC;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Rectangle;
+import org.eclipse.swt.widgets.Canvas;
+
+/**
+ * Provides methods for drawing images onto a canvas.
+ * @since 3.0
+ */
+public class ImageUtilities {
+
+ /**
+ * Draws an image aligned inside the given rectangle on the given canvas.
+ *
+ * @param image the image to be drawn
+ * @param GC the drawing GC
+ * @param canvas the canvas on which to draw
+ * @param r the clipping rectangle
+ * @param halign the horizontal alignment of the image to be drawn
+ * @param valign the vertical alignment of the image to be drawn
+ */
+ public static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int halign, int valign) {
+ if (image != null) {
+
+ Rectangle bounds= image.getBounds();
+
+ int x= 0;
+ switch(halign) {
+ case SWT.LEFT:
+ break;
+ case SWT.CENTER:
+ x= (r.width - bounds.width) / 2;
+ break;
+ case SWT.RIGHT:
+ x= r.width - bounds.width;
+ break;
+ }
+
+ int y= 0;
+ switch (valign) {
+ case SWT.TOP: {
+ FontMetrics fontMetrics= gc.getFontMetrics();
+ y= (fontMetrics.getHeight() - bounds.height)/2;
+ break;
+ }
+ case SWT.CENTER:
+ y= (r.height - bounds.height) / 2;
+ break;
+ case SWT.BOTTOM: {
+ FontMetrics fontMetrics= gc.getFontMetrics();
+ y= r.height - (fontMetrics.getHeight() + bounds.height)/2;
+ break;
+ }
+ }
+
+ gc.drawImage(image, r.x+x, r.y+y);
+ }
+ }
+
+ /**
+ * Draws an image aligned inside the given rectangle on the given canvas.
+ *
+ * @param image the image to be drawn
+ * @param GC the drawing GC
+ * @param canvas the canvas on which to draw
+ * @param r the clipping rectangle
+ * @param align the alignment of the image to be drawn
+ */
+ public static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int align) {
+ drawImage(image, gc, canvas, r, align, SWT.CENTER);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
index 00fc3cb15a3..de556268654 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
@@ -17,7 +17,6 @@ import java.util.Iterator;
import java.util.Map;
import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
@@ -43,7 +42,7 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
*
* @see org.eclipse.core.resources.IMarker
*/
-public class MarkerAnnotation extends Annotation implements IAnnotationExtension {
+public class MarkerAnnotation extends Annotation {
/**
* The layer in which markers representing problem are located.
@@ -112,6 +111,18 @@ public class MarkerAnnotation extends Annotation implements IAnnotationExtension
* @param marker the marker
*/
public MarkerAnnotation(IMarker marker) {
+ this(null, marker);
+ }
+
+ /**
+ * Creaets a new annotation of the given type for the given marker.
+ *
+ * @param annotationType the annotation type
+ * @param marker the marker
+ * @since 3.0
+ */
+ public MarkerAnnotation(String annotationType, IMarker marker) {
+ super(annotationType, true, null);
Assert.isNotNull(marker);
fMarker= marker;
initialize();
@@ -170,7 +181,7 @@ public class MarkerAnnotation extends Annotation implements IAnnotationExtension
name= IDE.SharedImages.IMG_OBJS_BKMRK_TSK;
layer= DefaultAnnotation.BOOKMARK_LAYER;
} else if (MarkerUtilities.isMarkerType(fMarker, IMarker.PROBLEM)) {
- switch (fMarker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO)) {
+ switch (MarkerUtilities.getSeverity(fMarker)) {
case IMarker.SEVERITY_INFO:
name= ISharedImages.IMG_OBJS_INFO_TSK;
layer= 3;
@@ -263,38 +274,9 @@ public class MarkerAnnotation extends Annotation implements IAnnotationExtension
}
/*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#getMarkerType()
- * @since 3.0
- */
- public String getMarkerType() {
- try {
- return fMarker.getType();
- } catch (CoreException e) {
- return null;
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#getSeverity()
- * @since 3.0
- */
- public int getSeverity() {
- return fMarker.getAttribute(IMarker.SEVERITY, IMarker.SEVERITY_INFO);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#isTemporary()
- * @since 3.0
- */
- public boolean isTemporary() {
- return false;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IAnnotationExtension#getMessage()
- * @since 3.0
+ * @see org.eclipse.jface.text.source.Annotation#getText()
*/
- public String getMessage() {
- return fMarker.getAttribute(IMarker.MESSAGE, null);
+ public String getText() {
+ return MarkerUtilities.getMessage(fMarker);
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
index 97954faedea..8c2978b198f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
@@ -12,6 +12,8 @@
package org.eclipse.ui.texteditor;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
@@ -22,12 +24,14 @@ 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.IPluginDescriptor;
import org.eclipse.core.runtime.Platform;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.resource.StringConverter;
import org.eclipse.ui.internal.editors.text.EditorsPlugin;
@@ -41,6 +45,37 @@ import org.eclipse.ui.internal.editors.text.EditorsPlugin;
*/
public class MarkerAnnotationPreferences {
+ /**
+ * Initializes the given preference store with the default marker annotation values.
+ *
+ * @param store the preference store to be initialized
+ * @since 3.0
+ */
+ public static void initializeDefaultValues(IPreferenceStore store) {
+ MarkerAnnotationPreferences preferences= new MarkerAnnotationPreferences();
+ Iterator e= preferences.getAnnotationPreferences().iterator();
+ while (e.hasNext()) {
+ AnnotationPreference info= (AnnotationPreference) e.next();
+ store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue());
+ store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue());
+ if (info.getVerticalRulerPreferenceKey() != null)
+ store.setDefault(info.getVerticalRulerPreferenceKey(), info.getVerticalRulerPreferenceValue());
+ PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue());
+ if (info.getShowInNextPrevDropdownToolbarActionKey() != null)
+ store.setDefault(info.getShowInNextPrevDropdownToolbarActionKey(), info.isShowInNextPrevDropdownToolbarAction());
+ if (info.getIsGoToNextNavigationTargetKey() != null)
+ store.setDefault(info.getIsGoToNextNavigationTargetKey(), info.isGoToNextNavigationTarget());
+ if (info.getIsGoToPreviousNavigationTargetKey() != null)
+ store.setDefault(info.getIsGoToPreviousNavigationTargetKey(), info.isGoToPreviousNavigationTarget());
+ if (info.getHighlightPreferenceKey() != null)
+ store.setDefault(info.getHighlightPreferenceKey(), info.getHighlightPreferenceValue());
+ }
+ }
+
+
+
+ /** The list of extension fragments */
+ private List fFragments;
/** The list of extensions */
private List fPreferences;
@@ -58,17 +93,32 @@ public class MarkerAnnotationPreferences {
public List getAnnotationPreferences() {
if (fPreferences == null)
initialize();
-
return fPreferences;
}
/**
+ * Returns all extensions provided for the <code>markerAnnotationSpecification</code>
+ * extension point including fragments. Fragments share the preference part
+ * with a marker annotation specifications provided for a super type but do
+ * change the presentation part.
+ *
+ * @return all extensions provided for the <code>markerAnnotationSpecification</code>
+ * extension point including fragments
+ */
+ public List getAnnotationPreferenceFragments() {
+ if (fFragments == null)
+ initialize();
+ return fFragments;
+ }
+
+ /**
* Reads all extensions provided for the <code>markerAnnotationSpecification</code> extension point and
* translates them into <code>AnnotationPreference</code> objects.
*/
private void initialize() {
// initialize lists - indicates that the initialization happened
+ fFragments= new ArrayList(2);
fPreferences= new ArrayList(2);
// populate list
@@ -78,12 +128,14 @@ public class MarkerAnnotationPreferences {
for (int i= 0; i < elements.length; i++) {
AnnotationPreference spec= createSpec(elements[i]);
if (spec != null)
- fPreferences.add(createSpec(elements[i]));
+ fFragments.add(spec);
+ if (spec.getColorPreferenceKey() != null)
+ fPreferences.add(spec);
}
}
final Collator collator= Collator.getInstance();
- Collections.sort(fPreferences, new Comparator() {
+ Collections.sort(fFragments, new Comparator() {
/*
* @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
*/
@@ -130,143 +182,141 @@ public class MarkerAnnotationPreferences {
info.setAnnotationType(s);
s= element.getAttribute("label"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
- info.setPreferenceLabel(s);
+ if (s != null && s.trim().length() > 0)
+ info.setPreferenceLabel(s);
s= element.getAttribute("markerType"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
- info.setMarkerType(s);
+ if (s != null && s.trim().length() > 0)
+ info.setMarkerType(s);
- i= IMarker.SEVERITY_INFO;
s= element.getAttribute("markerSeverity"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
i= StringConverter.asInt(s, IMarker.SEVERITY_INFO);
- info.setSeverity(i);
+ info.setSeverity(i);
+ }
s= element.getAttribute("textPreferenceKey"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
- info.setTextPreferenceKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setTextPreferenceKey(s);
- b= false;
s= element.getAttribute("textPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, false);
- info.setTextPreferenceValue(b);
+ info.setTextPreferenceValue(b);
+ }
s= element.getAttribute("highlightPreferenceKey"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0)
- s= null;
- info.setHighlightPreferenceKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setHighlightPreferenceKey(s);
- b= false;
s= element.getAttribute("highlightPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, false);
- info.setHighlightPreferenceValue(b);
+ info.setHighlightPreferenceValue(b);
+ }
s= element.getAttribute("overviewRulerPreferenceKey"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
- info.setOverviewRulerPreferenceKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setOverviewRulerPreferenceKey(s);
- b= false;
s= element.getAttribute("overviewRulerPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, false);
- info.setOverviewRulerPreferenceValue(b);
+ info.setOverviewRulerPreferenceValue(b);
+ }
s= element.getAttribute("verticalRulerPreferenceKey"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0)
- s= null;
- info.setVerticalRulerPreferenceKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setVerticalRulerPreferenceKey(s);
- b= false;
s= element.getAttribute("verticalRulerPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, true);
- info.setVerticalRulerPreferenceValue(b);
+ info.setVerticalRulerPreferenceValue(b);
+ }
s= element.getAttribute("colorPreferenceKey"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
- info.setColorPreferenceKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setColorPreferenceKey(s);
- RGB rgb= null;
s= element.getAttribute("colorPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
- rgb= StringConverter.asRGB(s);
- info.setColorPreferenceValue(rgb == null ? new RGB(0, 0, 0) : rgb);
+ if (s != null && s.trim().length() > 0) {
+ RGB rgb= StringConverter.asRGB(s);
+ info.setColorPreferenceValue(rgb == null ? new RGB(0,0,0) : rgb);
+ }
- i= 0;
s= element.getAttribute("presentationLayer"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
i= StringConverter.asInt(s, 0);
- info.setPresentationLayer(i);
+ info.setPresentationLayer(i);
+ }
- b= false;
s= element.getAttribute("contributesToHeader"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, false);
- info.setContributesToHeader(b);
+ info.setContributesToHeader(b);
+ }
s= element.getAttribute("showInNextPrevDropdownToolbarActionKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() == 0)
- s= null;
- info.setShowInNextPrevDropdownToolbarActionKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setShowInNextPrevDropdownToolbarActionKey(s);
- b= false;
s= element.getAttribute("showInNextPrevDropdownToolbarAction"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, false);
- info.setShowInNextPrevDropdownToolbarAction(b);
+ info.setShowInNextPrevDropdownToolbarAction(b);
+ }
s= element.getAttribute("isGoToNextNavigationTargetKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() == 0)
- s= null;
- info.setIsGoToNextNavigationTargetKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setIsGoToNextNavigationTargetKey(s);
- b= false;
s= element.getAttribute("isGoToNextNavigationTarget"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, false);
- info.setIsGoToNextNavigationTarget(b);
+ info.setIsGoToNextNavigationTarget(b);
+ }
s= element.getAttribute("isGoToPreviousNavigationTargetKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() == 0)
- s= null;
- info.setIsGoToPreviousNavigationTargetKey(s);
+ if (s != null && s.trim().length() > 0)
+ info.setIsGoToPreviousNavigationTargetKey(s);
- b= false;
s= element.getAttribute("isGoToPreviousNavigationTarget"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
+ if (s != null && s.trim().length() > 0) {
b= StringConverter.asBoolean(s, false);
- info.setIsGoToPreviousNavigationTarget(b);
+ info.setIsGoToPreviousNavigationTarget(b);
+ }
+
+ s= element.getAttribute("symbolicIcon"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ info.setSymbolicImageName(s);
+
+ s= element.getAttribute("icon"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ info.setImageDescriptor(getImageDescriptor(s, element));
+
+ s= element.getAttribute("annotationImageProvider"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ info.setAnnotationImageProviderData(element, "annotationImageProvider"); //$NON-NLS-1$
return info;
}
-
+
/**
- * Initializes the given preference store with the default marker annotation values.
+ * Returns the image descritor for the icon path specified by the given configuration
+ * element.
*
- * @param store the preference store to be initialized
+ * @param iconPath the icon path
+ * @param element the configuration element
* @since 3.0
*/
- public static void initializeDefaultValues(IPreferenceStore store) {
- MarkerAnnotationPreferences preferences= new MarkerAnnotationPreferences();
- Iterator e= preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
- store.setDefault(info.getTextPreferenceKey(), info.getTextPreferenceValue());
- store.setDefault(info.getOverviewRulerPreferenceKey(), info.getOverviewRulerPreferenceValue());
- if (info.getVerticalRulerPreferenceKey() != null)
- store.setDefault(info.getVerticalRulerPreferenceKey(), info.getVerticalRulerPreferenceValue());
- PreferenceConverter.setDefault(store, info.getColorPreferenceKey(), info.getColorPreferenceValue());
- if (info.getShowInNextPrevDropdownToolbarActionKey() != null)
- store.setDefault(info.getShowInNextPrevDropdownToolbarActionKey(), info.isShowInNextPrevDropdownToolbarAction());
- if (info.getIsGoToNextNavigationTargetKey() != null)
- store.setDefault(info.getIsGoToNextNavigationTargetKey(), info.isGoToNextNavigationTarget());
- if (info.getIsGoToPreviousNavigationTargetKey() != null)
- store.setDefault(info.getIsGoToPreviousNavigationTargetKey(), info.isGoToPreviousNavigationTarget());
- if (info.getHighlightPreferenceKey() != null)
- store.setDefault(info.getHighlightPreferenceKey(), info.getHighlightPreferenceValue());
+ private ImageDescriptor getImageDescriptor(String iconPath, IConfigurationElement element) {
+ IPluginDescriptor descriptor = element.getDeclaringExtension().getDeclaringPluginDescriptor();
+ try {
+ return ImageDescriptor.createFromURL(new URL(descriptor.getInstallURL(), iconPath));
+ } catch (MalformedURLException x) {
+ EditorsPlugin.log(x);
}
+ return null;
}
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
index 5cec2e37875..4f0e90e5dbe 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
@@ -12,13 +12,20 @@
package org.eclipse.ui.texteditor;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionPoint;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.Platform;
@@ -38,6 +45,87 @@ import org.eclipse.ui.PlatformUI;
public final class MarkerUtilities {
/**
+ * Internal marker super type hierarchy cache.
+ * TODO this cache is currently unbound, i.e. only limited by the number of marker types
+ */
+ private static class MarkerTypeHierarchy {
+
+ private Map fTypeMap;
+ private Map fSuperTypesCache= new HashMap();
+
+ public String[] getSuperTypes(String typeName) {
+ String[] cachedTypes= (String[]) fSuperTypesCache.get(typeName);
+ if (cachedTypes == null) {
+ cachedTypes= computeSuperTypes(typeName);
+ fSuperTypesCache.put(typeName, cachedTypes);
+ }
+ return cachedTypes;
+ }
+
+ private String[] computeSuperTypes(String typeName) {
+ ArrayList types= new ArrayList();
+ appendAll(types, getDirectSuperTypes(typeName));
+ int index= 0;
+ while (index < types.size()) {
+ String type= (String) types.get(index++);
+ appendAll(types, getDirectSuperTypes(type));
+ }
+
+ String[] superTypes= new String[types.size()];
+ types.toArray(superTypes);
+ return superTypes;
+ }
+
+ private String[] getDirectSuperTypes(String typeName) {
+ return (String[]) getTypeMap().get(typeName);
+ }
+
+ private void appendAll(List list, Object[] objects) {
+ for (int i= 0; i < objects.length; i++) {
+ Object o= objects[i];
+ if (!list.contains(o))
+ list.add(o);
+ }
+ }
+
+ private Map getTypeMap() {
+ if (fTypeMap == null)
+ fTypeMap= readTypes();
+ return fTypeMap;
+ }
+
+ private Map readTypes() {
+ HashMap allTypes= new HashMap();
+ IExtensionPoint point= Platform.getPluginRegistry().getExtensionPoint(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PT_MARKERS);
+ if (point != null) {
+ IExtension[] extensions = point.getExtensions();
+ for (int i= 0; i < extensions.length; i++) {
+ IExtension extension= extensions[i];
+ ArrayList types= new ArrayList();
+ IConfigurationElement[] configElements= extension.getConfigurationElements();
+ for (int j= 0; j < configElements.length; ++j) {
+ IConfigurationElement element= configElements[j];
+ if (element.getName().equalsIgnoreCase("super")) { //$NON-NLS-1$
+ String type = element.getAttribute("type"); //$NON-NLS-1$
+ if (type != null) {
+ types.add(type);
+ }
+ }
+ }
+ String[] superTypes= new String[types.size()];
+ types.toArray(superTypes);
+ allTypes.put(extension.getUniqueIdentifier(), superTypes);
+ }
+ }
+ return allTypes;
+ }
+ }
+
+ private static MarkerTypeHierarchy fgMarkerTypeHierarchy;
+
+
+
+ /**
* Don't allow instantiation.
*/
private MarkerUtilities() {
@@ -101,6 +189,19 @@ public final class MarkerUtilities {
public static int getPriority(IMarker marker) {
return getIntAttribute(marker, IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
}
+
+ /**
+ * Returns the severity of the given marker.
+ *
+ * @param marker the marker
+ * @return the priority, or <code>IMarker.SEVERITY_INFO</code> if not set
+ * @see IMarker#SEVERITY
+ * @see IMarker#SEVERITY_INFO
+ * @see IMarker#getAttribute(java.lang.String,int)
+ */
+ public static int getSeverity(IMarker marker) {
+ return getIntAttribute(marker, IMarker.SEVERITY, IMarker.SEVERITY_INFO);
+ }
/**
* Handles a core exception which occurs when accessing marker attributes.
@@ -120,14 +221,42 @@ public final class MarkerUtilities {
if (marker != null) {
try {
return marker.exists() && marker.isSubtypeOf(type);
- } catch (CoreException e) {
- handleCoreException(e);
+ } catch (CoreException x) {
+ handleCoreException(x);
}
}
return false;
}
/**
+ * Returns the marker type of the given marker or <code>null</code> if
+ * the type could not be determined.
+ *
+ * @param marker the marker
+ * @return the marker type
+ * @since 3.0
+ */
+ public static String getMarkerType(IMarker marker) {
+ try {
+ return marker.getType();
+ } catch (CoreException x) {
+ handleCoreException(x);
+ }
+ return null;
+ }
+
+ /**
+ * Returns the message associated with the given marker.
+ *
+ * @param marker the marker
+ * @return the message associated with the marker or <code>null</code>
+ * @since 3.0
+ */
+ public static String getMessage(IMarker marker) {
+ return marker.getAttribute(IMarker.MESSAGE, null);
+ }
+
+ /**
* Sets the ending character offset of the given marker.
*
* @param marker the marker
@@ -244,14 +373,27 @@ public final class MarkerUtilities {
* @see IResource#createMarker
*/
public static void createMarker(final IResource resource, final Map attributes, final String markerType) throws CoreException {
-
+
IWorkspaceRunnable r= new IWorkspaceRunnable() {
public void run(IProgressMonitor monitor) throws CoreException {
IMarker marker= resource.createMarker(markerType);
marker.setAttributes(attributes);
}
};
-
+
resource.getWorkspace().run(r, null,IWorkspace.AVOID_UPDATE, null);
}
+
+ /**
+ * Returns the list of super types for the given marker.
+ * The list is a depth first list and maintains the sequence in which
+ * the super types are listed in the marker specification.
+ *
+ * @return a depth-first list of all super types of the given marker type
+ */
+ public static String[] getSuperTypes(String markerType) {
+ if (fgMarkerTypeHierarchy == null)
+ fgMarkerTypeHierarchy= new MarkerTypeHierarchy();
+ return fgMarkerTypeHierarchy.getSuperTypes(markerType);
+ }
}

Back to the top