Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2004-04-29 16:36:01 +0000
committerKai Maetzel2004-04-29 16:36:01 +0000
commit53c5e287ed07c2abe65072cd9a719f8c264a4389 (patch)
treed531dcd47043e9eb0b4ba130d24a1df9db5f8fc0
parentfb68c2b9f8eb62993cc08bf4186e8df246b42f20 (diff)
downloadeclipse.platform.text-53c5e287ed07c2abe65072cd9a719f8c264a4389.tar.gz
eclipse.platform.text-53c5e287ed07c2abe65072cd9a719f8c264a4389.tar.xz
eclipse.platform.text-53c5e287ed07c2abe65072cd9a719f8c264a4389.zip
headless annotation model support
-rw-r--r--org.eclipse.core.filebuffers/plugin.properties1
-rw-r--r--org.eclipse.core.filebuffers/plugin.xml4
-rw-r--r--org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd123
-rw-r--r--org.eclipse.core.filebuffers/schema/documentCreation.exsd2
-rw-r--r--org.eclipse.core.filebuffers/schema/documentSetup.exsd2
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java33
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java42
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java8
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java9
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java112
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java8
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java31
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java55
-rw-r--r--org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java14
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/ISynchronizable.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/ISynchronizable.java)0
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/Annotation.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java)107
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationMap.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationMap.java)0
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java)16
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java)0
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationMap.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationMap.java)0
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModel.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java)0
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java)0
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java)0
-rw-r--r--org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java (renamed from org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java)0
-rw-r--r--org.eclipse.ui.editors/plugin.xml14
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java16
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java26
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java46
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModelFactory.java34
29 files changed, 529 insertions, 174 deletions
diff --git a/org.eclipse.core.filebuffers/plugin.properties b/org.eclipse.core.filebuffers/plugin.properties
index 23d210cea8b..053aa022c8a 100644
--- a/org.eclipse.core.filebuffers/plugin.properties
+++ b/org.eclipse.core.filebuffers/plugin.properties
@@ -12,4 +12,5 @@ pluginName= File Buffers
providerName= Eclipse.org
documentCreationPoint= Document Creation
documentSetupPoint= Document Setup
+annotationModelCreationPoint= Annotation Model Creation
defaultDocumentFactory= Default Document Factory
diff --git a/org.eclipse.core.filebuffers/plugin.xml b/org.eclipse.core.filebuffers/plugin.xml
index 5d5802fd4a4..e1f786cbca5 100644
--- a/org.eclipse.core.filebuffers/plugin.xml
+++ b/org.eclipse.core.filebuffers/plugin.xml
@@ -14,7 +14,7 @@
</library>
</runtime>
<requires>
- <import plugin="org.eclipse.core.runtime"/>
+ <import plugin="org.eclipse.core.runtime"/>
<import plugin="org.eclipse.core.resources"/>
<import plugin="org.eclipse.text"/>
</requires>
@@ -22,6 +22,7 @@
<extension-point id="documentCreation" name="%documentCreationPoint" schema="schema/documentCreation.exsd"/>
<extension-point id="documentSetup" name="%documentSetupPoint" schema="schema/documentSetup.exsd"/>
+ <extension-point id="annotationModelCreation" name="%annotationModelCreationPoint" schema="schema/annotationModelCreation.exsd"/>
<extension
id="DefaultDocumentFactory"
@@ -32,4 +33,5 @@
class="org.eclipse.core.internal.filebuffers.DefaultDocumentFactory">
</factory>
</extension>
+
</plugin>
diff --git a/org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd b/org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd
new file mode 100644
index 00000000000..47e2ef989c5
--- /dev/null
+++ b/org.eclipse.core.filebuffers/schema/annotationModelCreation.exsd
@@ -0,0 +1,123 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.core.filebuffers">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.core.filebuffers" id="annotationModelCreation" name="Annotation Model Creation"/>
+ </appInfo>
+ <documentation>
+ This extension point is interesting for your if you want the file buffer manager to instantiate a specific annotation models for certain file content types, file extensions, or file names.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="factory"/>
+ </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="factory">
+ <complexType>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java" basedOn="org.eclipse.core.filebuffers.IAnnotationModelFactory"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="extensions" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="fileNames" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="contentTypeId" 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.core.filebuffers/schema/documentCreation.exsd b/org.eclipse.core.filebuffers/schema/documentCreation.exsd
index 0c797012349..3313b8a89d8 100644
--- a/org.eclipse.core.filebuffers/schema/documentCreation.exsd
+++ b/org.eclipse.core.filebuffers/schema/documentCreation.exsd
@@ -6,7 +6,7 @@
<meta.schema plugin="org.eclipse.core.filebuffers" id="documentCreation" name="Document Creation"/>
</appInfo>
<documentation>
- This extension point is interesting for your if you want the file buffer manager to instantiate a specific document implementation for certain file extensions or file names.
+ This extension point is interesting for your if you want the file buffer manager to instantiate a specific document implementation for certain file content types, file extensions, or file names.
</documentation>
</annotation>
diff --git a/org.eclipse.core.filebuffers/schema/documentSetup.exsd b/org.eclipse.core.filebuffers/schema/documentSetup.exsd
index d53189ccadb..0c84681aff8 100644
--- a/org.eclipse.core.filebuffers/schema/documentSetup.exsd
+++ b/org.eclipse.core.filebuffers/schema/documentSetup.exsd
@@ -6,7 +6,7 @@
<meta.schema plugin="org.eclipse.core.filebuffers" id="documentSetup" name="Document Setup"/>
</appInfo>
<documentation>
- This extension point is interesting if you want to install specific partitioners etc. on documents created by the file buffer manager for certain file extensions or file names.
+ This extension point is interesting if you want to install specific partitioners etc. on documents created by the file buffer manager for certain file content types, file extensions, or file names.
</documentation>
</annotation>
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java
new file mode 100644
index 00000000000..22866c1c9fa
--- /dev/null
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IAnnotationModelFactory.java
@@ -0,0 +1,33 @@
+/**********************************************************************
+Copyright (c) 2000, 2003 IBM Corp. and others.
+All rights reserved. This program and the accompanying materials
+are made available under the terms of the Common Public License v1.0
+which accompanies this distribution, and is available at
+http://www.eclipse.org/legal/cpl-v10.html
+
+Contributors:
+ IBM Corporation - Initial implementation
+**********************************************************************/
+package org.eclipse.core.filebuffers;
+
+
+import org.eclipse.core.runtime.IPath;
+
+import org.eclipse.jface.text.source.IAnnotationModel;
+
+
+/**
+ * Factory for text file buffer annotation models. Used by the text file buffer
+ * manager to create the annotation model for a new text file buffer.
+ *
+ * @since 3.0
+ */
+public interface IAnnotationModelFactory {
+
+ /**
+ * Creates and returns a new annotation model.
+ *
+ * @return a new annotation model
+ */
+ IAnnotationModel createAnnotationModel(IPath location);
+}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java
new file mode 100644
index 00000000000..11a4a9a5ec8
--- /dev/null
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/IPersistableAnnotationModel.java
@@ -0,0 +1,42 @@
+/*******************************************************************************
+ * 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.core.filebuffers;
+
+
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jface.text.IDocument;
+
+
+
+/**
+ * Interface implemented by <code>IAnnotationModel</code> implementers that offer
+ * persistable state.
+ *
+ * @since 3.0
+ */
+public interface IPersistableAnnotationModel {
+
+ /**
+ * @param document
+ */
+ void commit(IDocument document) throws CoreException;
+
+ /**
+ * @param document
+ */
+ void revert(IDocument document) throws CoreException;
+
+ /**
+ * @param document
+ */
+ void reinitialize(IDocument document) throws CoreException;
+}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
index d5676f67776..2bdd4b5bcf7 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBuffer.java
@@ -12,6 +12,7 @@ package org.eclipse.core.filebuffers;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.IAnnotationModel;
/**
* A text file buffer is a file buffer for text files. The contents of a text file buffe is
@@ -45,4 +46,11 @@ public interface ITextFileBuffer extends IFileBuffer {
* @param encoding the encoding
*/
void setEncoding(String encoding);
+
+ /**
+ * Returns the annotation model of this text file buffer.
+ *
+ * @return the annotation model of this text file buffer
+ */
+ IAnnotationModel getAnnotationModel();
}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
index 6897cdf56fa..74dd895c979 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/filebuffers/ITextFileBufferManager.java
@@ -14,6 +14,7 @@ package org.eclipse.core.filebuffers;
import org.eclipse.core.runtime.IPath;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.IAnnotationModel;
/**
@@ -61,4 +62,12 @@ public interface ITextFileBufferManager extends IFileBufferManager {
* @return a new empty document
*/
IDocument createEmptyDocument(IPath location);
+
+ /**
+ * Creates a new annotation for the given location.
+ *
+ * @param location the location
+ * @return the newly created annotation model
+ */
+ IAnnotationModel createAnnotationModel(IPath location);
}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
index 83999e4d6bd..ca0c77e13c6 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ExtensionsRegistry.java
@@ -22,7 +22,6 @@ import java.util.Set;
import java.util.StringTokenizer;
import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionPoint;
@@ -35,6 +34,8 @@ import org.eclipse.core.runtime.content.IContentDescription;
import org.eclipse.core.runtime.content.IContentType;
import org.eclipse.core.runtime.content.IContentTypeManager;
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.IAnnotationModelFactory;
import org.eclipse.core.filebuffers.IDocumentFactory;
import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
@@ -102,15 +103,19 @@ public class ExtensionsRegistry {
private final static String WILDCARD= "*"; //$NON-NLS-1$
- /** The mapping between name extensions and configuration elements describing document factories. */
+ /** The mapping between file attributes and configuration elements describing document factories. */
private Map fFactoryDescriptors= new HashMap();
/** The mapping between configuration elements for document factories and instantiated document factories. */
private Map fFactories= new HashMap();
- /** The mapping between name extensions and configuration elements describing document setup participants. */
+ /** The mapping between file attributes and configuration elements describing document setup participants. */
private Map fSetupParticipantDescriptors= new HashMap();
/** The mapping between configuration elements for setup participants and instantiated setup participants. */
private Map fSetupParticipants= new HashMap();
-
+ /** The mapping between file attributes and configuration elements describing annotation model factories. */
+ private Map fAnnotationModelFactoryDescriptors= new HashMap();
+ /** The mapping between configuration elements for annotation model factories */
+ private Map fAnnotationModelFactories= new HashMap();
+ /** The content type manager. */
private IContentTypeManager fContentTypeManager= Platform.getContentTypeManager();
@@ -120,11 +125,15 @@ public class ExtensionsRegistry {
*/
public ExtensionsRegistry() {
initialize("documentCreation", "contentTypeId", true, fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentCreation", "fileNames", fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentCreation", "extensions", fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentSetup", "contentTypeId", fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentSetup", "fileNames", fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
- initialize("documentSetup", "extensions", fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("documentCreation", "fileNames", false, fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("documentCreation", "extensions", false, fFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("documentSetup", "contentTypeId", true, fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("documentSetup", "fileNames", false, fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("documentSetup", "extensions", false, fSetupParticipantDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("annotationModelCreation", "contentTypeId", true, fAnnotationModelFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("annotationModelCreation", "fileNames", false, fAnnotationModelFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+ initialize("annotationModelCreation", "extensions", false, fAnnotationModelFactoryDescriptors); //$NON-NLS-1$ //$NON-NLS-2$
+
}
/**
@@ -186,19 +195,6 @@ public class ExtensionsRegistry {
ILog log= Platform.getPlugin(FileBuffersPlugin.PLUGIN_ID).getLog();
log.log(status);
}
-
- /**
- * Initializes this registry. It retrieves all implementers of the given
- * extension point and remembers those implementers based on the
- * file name extensions in the given map.
- *
- * @param extensionPointName the name of the extension point
- * @param childElementName the name of the child elements
- * @param descriptors the map to be filled
- */
- private void initialize(String extensionPointName, String childElementName, Map descriptors) {
- initialize(extensionPointName, childElementName, false, descriptors);
- }
/**
* Initializes this registry. It retrieves all implementers of the given
@@ -271,13 +267,13 @@ public class ExtensionsRegistry {
}
/**
- * Returns a sharable document factory for the given file name extension.
+ * Returns a sharable document factory for the given file name or file extension.
*
- * @param extension the name extension to be used for lookup
+ * @param nameOrExtension the name or extension to be used for lookup
* @return the sharable document factory or <code>null</code>
*/
- private IDocumentFactory getDocumentFactory(String extension) {
- Set set= (Set) fFactoryDescriptors.get(extension);
+ private IDocumentFactory getDocumentFactory(String nameOrExtension) {
+ Set set= (Set) fFactoryDescriptors.get(nameOrExtension);
if (set != null) {
IConfigurationElement entry= selectConfigurationElement(set);
return (IDocumentFactory) getExtension(entry, fFactories, IDocumentFactory.class);
@@ -306,13 +302,13 @@ public class ExtensionsRegistry {
}
/**
- * Returns the set of setup participants for the given file name.
+ * Returns the set of setup participants for the given file name or extension.
*
- * @param extension the name extension to be used for lookup
+ * @param nameOrExtension the name or extension to be used for lookup
* @return the sharable set of document setup participants
*/
- private List getDocumentSetupParticipants(String extension) {
- Set set= (Set) fSetupParticipantDescriptors.get(extension);
+ private List getDocumentSetupParticipants(String nameOrExtension) {
+ Set set= (Set) fSetupParticipantDescriptors.get(nameOrExtension);
if (set == null)
return null;
@@ -355,8 +351,45 @@ public class ExtensionsRegistry {
return participants;
}
+ /**
+ * Returns a sharable annotation model factory for the given content types.
+ *
+ * @param contentTypes the content types used to find the factory
+ * @return the sharable annotation model factory or <code>null</code>
+ */
+ private IAnnotationModelFactory getAnnotationModelFactory(IContentType[] contentTypes) {
+ Set set= null;
+ int i= 0;
+ while (i < contentTypes.length && set == null) {
+ set= (Set) fAnnotationModelFactoryDescriptors.get(new ContentTypeAdapter(contentTypes[i++]));
+ }
+
+ if (set != null) {
+ IConfigurationElement entry= selectConfigurationElement(set);
+ return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
+ }
+ return null;
+ }
+
+ /**
+ * Returns a sharable annotation model factory for the given file name or file extension.
+ *
+ * @param extension the name or extension to be used for lookup
+ * @return the sharable document factory or <code>null</code>
+ */
+ private IAnnotationModelFactory getAnnotationModelFactory(String extension) {
+ Set set= (Set) fAnnotationModelFactoryDescriptors.get(extension);
+ if (set != null) {
+ IConfigurationElement entry= selectConfigurationElement(set);
+ return (IAnnotationModelFactory) getExtension(entry, fAnnotationModelFactories, IAnnotationModelFactory.class);
+ }
+ return null;
+ }
+
private IContentType[] findContentTypes(IPath path) {
- IFile file= ResourcesPlugin.getWorkspace().getRoot().getFile(path);
+ IFile file= FileBuffers.getWorkspaceFileAtLocation(path);
+ if (file == null)
+ return new IContentType[0];
IContentDescription contentDescription;
try {
@@ -420,4 +453,21 @@ public class ExtensionsRegistry {
participants.toArray(result);
return result;
}
+
+ /**
+ * Returns the sharable annotation model factory for the given location.
+ *
+ * @param location the location for which to look up the factory
+ * @return the sharable annotation model factory
+ */
+ public IAnnotationModelFactory getAnnotationModelFactory(IPath location) {
+ IAnnotationModelFactory factory= getAnnotationModelFactory(findContentTypes(location));
+ if (factory == null)
+ factory= getAnnotationModelFactory(location.lastSegment());
+ if (factory == null)
+ factory= getAnnotationModelFactory(location.getFileExtension());
+ if (factory == null)
+ factory= getAnnotationModelFactory(WILDCARD);
+ return factory;
+ }
}
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
index d4b05920b3f..5adcde2bd49 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/JavaTextFileBuffer.java
@@ -32,6 +32,7 @@ import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.source.IAnnotationModel;
/**
* @since 3.0
@@ -95,6 +96,13 @@ public class JavaTextFileBuffer extends JavaFileBuffer implements ITextFileBuffe
public IDocument getDocument() {
return fDocument;
}
+
+ /*
+ * @see org.eclipse.core.filebuffers.ITextFileBuffer#getAnnotationModel()
+ */
+ public IAnnotationModel getAnnotationModel() {
+ return null;
+ }
/*
* @see org.eclipse.core.buffer.text.IBufferedTextFile#getEncoding()
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
index d28d10ba04e..347643fc026 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceFileBuffer.java
@@ -235,19 +235,38 @@ public abstract class ResourceFileBuffer extends AbstractFileBuffer {
public void connect() {
++ fReferenceCount;
if (fReferenceCount == 1)
- fFileSynchronizer.install();
+ connected();
}
+ /**
+ * Called when this file buffer has been connected. This is the case when
+ * there is exactly one connection.
+ * <p>
+ * Clients may extend this method.
+ */
+ protected void connected() {
+ fFileSynchronizer.install();
+ }
+
public void disconnect() throws CoreException {
-- fReferenceCount;
- if (fReferenceCount == 0) {
- if (fFileSynchronizer != null)
- fFileSynchronizer.uninstall();
- fFileSynchronizer= null;
- }
+ if (fReferenceCount == 0)
+ disconnected();
}
/**
+ * Called when this file buffer has been disconnected. This is the case when
+ * the number of connections drops to <code>0</code>.
+ * <p>
+ * Clients may extend this method.
+ */
+ protected void disconnected() {
+ if (fFileSynchronizer != null)
+ fFileSynchronizer.uninstall();
+ fFileSynchronizer= null;
+ }
+
+ /**
* Returns whether this file buffer has already been disposed.
*
* @return <code>true</code> if already disposed, <code>false</code> otherwise
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
index 9a3535835a5..36f3c0c6887 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/ResourceTextFileBuffer.java
@@ -17,6 +17,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.Reader;
+import org.eclipse.core.filebuffers.IPersistableAnnotationModel;
import org.eclipse.core.filebuffers.ITextFileBuffer;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResourceStatus;
@@ -30,6 +31,7 @@ import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.source.IAnnotationModel;
/**
*
@@ -84,7 +86,8 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
protected String fEncoding;
/** Internal document listener */
protected IDocumentListener fDocumentListener= new DocumentListener();
-
+ /** The element's annotation model */
+ protected IAnnotationModel fAnnotationModel;
public ResourceTextFileBuffer(TextFileBufferManager manager) {
@@ -97,6 +100,13 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
public IDocument getDocument() {
return fDocument;
}
+
+ /*
+ * @see org.eclipse.core.filebuffers.ITextFileBuffer#getAnnotationModel()
+ */
+ public IAnnotationModel getAnnotationModel() {
+ return fAnnotationModel;
+ }
/*
* @see org.eclipse.core.buffer.text.IBufferedTextFile#getEncoding()
@@ -167,7 +177,12 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
if (replaceContents)
fManager.fireBufferContentReplaced(this);
-
+
+ if (fAnnotationModel instanceof IPersistableAnnotationModel) {
+ IPersistableAnnotationModel persistableModel= (IPersistableAnnotationModel) fAnnotationModel;
+ persistableModel.revert(fDocument);
+ }
+
fManager.fireDirtyStateChanged(this, fCanBeSaved);
}
}
@@ -212,8 +227,12 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
} else {
fEncoding= fFile.getCharset();
}
+
fDocument= fManager.createEmptyDocument(fFile.getLocation());
setDocumentContent(fDocument, fFile.getContents(), fEncoding);
+
+ fAnnotationModel= fManager.createAnnotationModel(fFile.getLocation());
+
} catch (CoreException x) {
fDocument= fManager.createEmptyDocument(fFile.getLocation());
fStatus= x.getStatus();
@@ -221,6 +240,24 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
}
/*
+ * @see org.eclipse.core.internal.filebuffers.ResourceFileBuffer#connected()
+ */
+ protected void connected() {
+ super.connected();
+ if (fAnnotationModel != null)
+ fAnnotationModel.connect(fDocument);
+ }
+
+ /*
+ * @see org.eclipse.core.internal.filebuffers.ResourceFileBuffer#disconnected()
+ */
+ protected void disconnected() {
+ if (fAnnotationModel != null)
+ fAnnotationModel.disconnect(fDocument);
+ super.disconnected();
+ }
+
+ /*
* @see org.eclipse.core.internal.filebuffers.FileBuffer#commitFileBufferContent(org.eclipse.core.runtime.IProgressMonitor, boolean)
*/
protected void commitFileBufferContent(IProgressMonitor monitor, boolean overwrite) throws CoreException {
@@ -244,7 +281,10 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
// set synchronization stamp to know whether the file synchronizer must become active
fSynchronizationStamp= fFile.getModificationStamp();
- // TODO if there is an annotation model update it here
+ if (fAnnotationModel instanceof IPersistableAnnotationModel) {
+ IPersistableAnnotationModel persistableModel= (IPersistableAnnotationModel) fAnnotationModel;
+ persistableModel.commit(fDocument);
+ }
} else {
@@ -297,6 +337,15 @@ public class ResourceTextFileBuffer extends ResourceFileBuffer implements ITextF
fManager.fireBufferContentReplaced(this);
+ if (fAnnotationModel instanceof IPersistableAnnotationModel) {
+ IPersistableAnnotationModel persistableModel= (IPersistableAnnotationModel) fAnnotationModel;
+ try {
+ persistableModel.reinitialize(fDocument);
+ } catch (CoreException x) {
+ fStatus= status;
+ }
+ }
+
} else {
removeFileBufferContentListeners();
diff --git a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
index e2685562031..3e967111dec 100644
--- a/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
+++ b/org.eclipse.core.filebuffers/src/org/eclipse/core/internal/filebuffers/TextFileBufferManager.java
@@ -24,6 +24,7 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.IAnnotationModelFactory;
import org.eclipse.core.filebuffers.IDocumentFactory;
import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
import org.eclipse.core.filebuffers.IFileBuffer;
@@ -35,6 +36,7 @@ import org.eclipse.core.filebuffers.ITextFileBufferManager;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.source.IAnnotationModel;
/**
* @since 3.0
@@ -158,6 +160,18 @@ public class TextFileBufferManager implements ITextFileBufferManager {
}
/*
+ * @see org.eclipse.core.filebuffers.ITextFileBufferManager#createAnnotationModel(org.eclipse.core.runtime.IPath)
+ */
+ public IAnnotationModel createAnnotationModel(IPath location) {
+ Assert.isNotNull(location);
+ location= FileBuffers.normalizeLocation(location);
+ IAnnotationModelFactory factory= fRegistry.getAnnotationModelFactory(location);
+ if (factory != null)
+ return factory.createAnnotationModel(location);
+ return null;
+ }
+
+ /*
* @see org.eclipse.core.filebuffers.IFileBufferManager#addFileBufferListener(org.eclipse.core.filebuffers.IFileBufferListener)
*/
public void addFileBufferListener(IFileBufferListener listener) {
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/ISynchronizable.java b/org.eclipse.text/src/org/eclipse/jface/text/ISynchronizable.java
index f604aee6631..f604aee6631 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/ISynchronizable.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/ISynchronizable.java
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java b/org.eclipse.text/src/org/eclipse/jface/text/source/Annotation.java
index 71b6c7532e0..9ece8375e48 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/Annotation.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/Annotation.java
@@ -12,13 +12,6 @@ package org.eclipse.jface.text.source;
-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;
-
/**
* Annotation managed by an <code>IAnnotationModel</code>.
* Annotations are considered being located at layers and are considered being painted
@@ -34,73 +27,9 @@ public class Annotation {
* Constant for unknown annotation types.
* @since 3.0
*/
- public final static String TYPE_UNKNOWN= "org.eclipse.text.annotation.unknown"; //$NON-NLS-1$
-
- /**
- * Convenience method for drawing an image aligned inside a rectangle.
- *
- * @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
- */
- protected 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);
- }
- }
-
- /**
- * Convenience method for drawing an image aligned inside a rectangle.
- *
- * @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
- */
- protected static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int align) {
- drawImage(image, gc, canvas, r, align, SWT.CENTER);
- }
+ public final static String TYPE_UNKNOWN= "org.eclipse.text.annotation.unknown"; //$NON-NLS-1$
-
- /** The layer of this annotation. */
- private int fLayer;
/**
* The type of this annotation.
* @since 3.0
@@ -123,7 +52,6 @@ public class Annotation {
private String fText;
-
/**
* Creates a new annotation that is not persistent and type less.
*/
@@ -228,37 +156,4 @@ public class Annotation {
public String getText() {
return fText;
}
-
- /**
- * Sets the layer of this annotation.
- *
- * @param layer the layer of this annotation
- * @deprecated since 3.0
- */
- protected void setLayer(int layer) {
- fLayer= layer;
- }
-
- /**
- * Returns the annotations drawing layer.
- *
- * @return the annotations drawing layer
- * @deprecated use <code>IAnnotationAccessExtension.getLayer(Annotation)</code>
- */
- public int getLayer() {
- return fLayer;
- }
-
- /**
- * Implement this method to draw a graphical representation
- * of this annotation within the given bounds. This default implementation
- * does nothing.
- *
- * @param gc the drawing GC
- * @param canvas the canvas to draw on
- * @param bounds the bounds inside the canvas to draw on
- * @deprecated use <code>IAnnotationAccessExtension.paint(Annotation, GC, Canvas, Rectangle)</code>
- */
- public void paint(GC gc, Canvas canvas, Rectangle bounds) {
- }
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationMap.java b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationMap.java
index 6fa57e17556..6fa57e17556 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationMap.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationMap.java
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java
index 524c5223960..d3bd809b40e 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModel.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModel.java
@@ -479,15 +479,21 @@ public class AnnotationModel implements IAnnotationModel, IAnnotationModelExtens
/** The current iterator. */
private Iterator fCurrent= (Iterator) iter.next(); // there is at least one.
+ /** The current element. */
+ private Object fCurrentElement;
public void remove() {
throw new UnsupportedOperationException();
}
public boolean hasNext() {
- if (fCurrent.hasNext())
+ if (fCurrentElement != null)
return true;
- else if (iter.hasNext()) {
+
+ if (fCurrent.hasNext()) {
+ fCurrentElement= fCurrent.next();
+ return true;
+ } else if (iter.hasNext()) {
fCurrent= (Iterator) iter.next();
return hasNext();
} else
@@ -497,8 +503,10 @@ public class AnnotationModel implements IAnnotationModel, IAnnotationModelExtens
public Object next() {
if (!hasNext())
throw new NoSuchElementException();
- else
- return fCurrent.next();
+
+ Object element= fCurrentElement;
+ fCurrentElement= null;
+ return element;
}
};
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
index 775251e6779..775251e6779 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/AnnotationModelEvent.java
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationMap.java b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationMap.java
index b16b753a709..b16b753a709 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationMap.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationMap.java
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
index 509d0da6975..509d0da6975 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModel.java
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
index eeb1bdb6b4c..eeb1bdb6b4c 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelExtension.java
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
index db9708baaca..db9708baaca 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListener.java
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
index 6e3042fbe19..6e3042fbe19 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
+++ b/org.eclipse.text/src/org/eclipse/jface/text/source/IAnnotationModelListenerExtension.java
diff --git a/org.eclipse.ui.editors/plugin.xml b/org.eclipse.ui.editors/plugin.xml
index 922e48ca716..eca4f093948 100644
--- a/org.eclipse.ui.editors/plugin.xml
+++ b/org.eclipse.ui.editors/plugin.xml
@@ -19,7 +19,7 @@
<import plugin="org.eclipse.ui.workbench.texteditor"/>
<import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.core.filebuffers"/>
+ <import plugin="org.eclipse.core.filebuffers" export="true"/>
<import plugin="org.eclipse.core.resources"/>
</requires>
@@ -558,7 +558,8 @@
</specification>
</extension>
- <extension point="org.eclipse.ui.editors.annotationTypes">
+ <extension
+ point="org.eclipse.ui.editors.annotationTypes">
<type
name="org.eclipse.ui.workbench.texteditor.error"
markerType="org.eclipse.core.resources.problemmarker"
@@ -583,5 +584,12 @@
markerType="org.eclipse.core.resources.bookmark">
</type>
</extension>
-
+
+ <extension
+ point="org.eclipse.core.filebuffers.annotationModelCreation">
+ <factory
+ extensions="*"
+ class="org.eclipse.ui.texteditor.ResourceMarkerAnnotationModelFactory">
+ </factory>
+ </extension>
</plugin>
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java
index 25f3a4edc68..98a889f7f2e 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java
@@ -67,13 +67,14 @@ import org.eclipse.ui.texteditor.IDocumentProviderExtension3;
import org.eclipse.ui.texteditor.IElementStateListener;
import org.eclipse.ui.texteditor.IElementStateListenerExtension;
import org.eclipse.ui.texteditor.ISchedulingRuleProvider;
-import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
-import org.eclipse.ui.internal.editors.text.*;
+
+import org.eclipse.ui.internal.editors.text.UISynchronizationContext;
+import org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner;
/**
* @since 3.0
*/
-public class TextFileDocumentProvider implements IDocumentProvider, IDocumentProviderExtension, IDocumentProviderExtension2, IDocumentProviderExtension3, IStorageDocumentProvider {
+public class TextFileDocumentProvider implements IDocumentProvider, IDocumentProviderExtension, IDocumentProviderExtension2, IDocumentProviderExtension3, IStorageDocumentProvider {
/**
* Operation created by the document provider and to be executed by the providers runnable context.
@@ -487,7 +488,7 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPr
}
protected IAnnotationModel createAnnotationModel(IFile file) {
- return new ResourceMarkerAnnotationModel(file);
+ return null;
}
/*
@@ -749,8 +750,11 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPr
*/
public IAnnotationModel getAnnotationModel(Object element) {
FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fModel;
+ if (info != null) {
+ if (info.fModel != null)
+ return info.fModel;
+ return info.fTextFileBuffer.getAnnotationModel();
+ }
return getParentProvider().getAnnotationModel(element);
}
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 de78420c953..6292f2c4466 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
@@ -25,6 +25,7 @@ import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.core.filebuffers.IPersistableAnnotationModel;
import org.eclipse.jface.text.Assert;
import org.eclipse.jface.text.BadLocationException;
@@ -61,7 +62,7 @@ import org.eclipse.ui.PlatformUI;
*
* @since 3.0
*/
-public abstract class AbstractMarkerAnnotationModel extends AnnotationModel {
+public abstract class AbstractMarkerAnnotationModel extends AnnotationModel implements IPersistableAnnotationModel {
/** List of annotations whose text range became invalid because of document changes */
private List fDeletedAnnotations= new ArrayList(2);
@@ -584,7 +585,7 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel {
*/
public void resetMarkers() {
- // reinitializes the positions from the markers
+ // re-initializes the positions from the markers
for (Iterator e= getAnnotationIterator(false); e.hasNext();) {
Object o= e.next();
if (o instanceof MarkerAnnotation) {
@@ -620,4 +621,25 @@ public abstract class AbstractMarkerAnnotationModel extends AnnotationModel {
// fire annotation model changed
fireModelChanged();
}
+
+ /*
+ * @see org.eclipse.jface.text.source.IPersistableAnnotationModel#commit(org.eclipse.jface.text.IDocument)
+ */
+ public void commit(IDocument document) throws CoreException {
+ updateMarkers(document);
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IPersistableAnnotationModel#revert(org.eclipse.jface.text.IDocument)
+ */
+ public void revert(IDocument document) {
+ resetMarkers();
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IPersistableAnnotationModel#reinitialize(org.eclipse.jface.text.IDocument)
+ */
+ public void reinitialize(IDocument document) {
+ resetMarkers();
+ }
}
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 d378b42c417..a93ffb236d0 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
@@ -42,14 +42,14 @@ import org.eclipse.ui.model.IWorkbenchAdapter;
* This class may be instantiated or be subclassed.
*
* @see org.eclipse.core.resources.IMarker
- * @deprecated use <code>SimpleMarkerAnnotation</code> in connection with <code>IAnnotationPresentation</code> instead
*/
public class MarkerAnnotation extends SimpleMarkerAnnotation {
/**
* The layer in which markers representing problem are located.
* @since 2.0
- * @deprecated as of 3.0
+ * @deprecated since 3.0, use <code>IAnnotationAccessExtension</code> instead
+
*/
public final static int PROBLEM_LAYER= 5;
@@ -57,10 +57,15 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
private static Map fgImageRegistry;
/**
- * Returns an image for the given display as specified by the given image descriptor.
+ * Returns an image for the given display as specified by the given image
+ * descriptor.
+ *
* @param display the display
* @param descriptor the image descriptor
* @return an image for the display as specified by the descriptor
+ * @deprecated since 3.0, visual presentation is no longer supported,
+ * annotation with a visible presentation should implement
+ * <code>IAnnotationPresentation</code>
*/
protected static Image getImage(Display display, ImageDescriptor descriptor) {
Map map= getImageRegistry(display);
@@ -78,6 +83,9 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
*
* @param display the display
* @return the image registry for the given display
+ * @deprecated since 3.0, visual presentation is no longer supported, annotation with a
+ * visible presentation should implement
+ * <code>IAnnotationPresentation</code>
*/
protected static Map getImageRegistry(Display display) {
if (fgImageRegistry == null) {
@@ -131,8 +139,11 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
/**
* Sets the marker image to the given image.
- *
+ *
* @param image the new marker image
+ * @deprecated since 3.0, visual presentation is no longer supported,
+ * annotation with a visible presentation should implement
+ * <code>IAnnotationPresentation</code>
*/
protected void setImage(Image image) {
fImage= image;
@@ -141,6 +152,10 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
/**
* Initializes the annotation's icon representation and its drawing layer
* based upon the properties of the underlying marker.
+ *
+ * @deprecated since 3.0, visual presentation is no longer supported,
+ * annotation with a visible presentation should implement
+ * <code>IAnnotationPresentation</code>
*/
protected void initialize() {
IMarker marker= getMarker();
@@ -196,7 +211,9 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
* Note: This is only for backward compatibility.
*
* @param layer the layer of this annotation
- * @deprecated since 3.0
+ * @deprecated since 3.0, annotation with a visible presentation should
+ * implement <code>IAnnotationPresentation</code>
+ *
* @since 3.0
*/
protected void setLayer(int layer) {
@@ -233,12 +250,15 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
}
/**
- * Returns the name of an image used to visually represent markers of
+ * Returns the name of an image used to visually represent markers of
* unknown type. This implementation returns <code>null</code>.
* Subclasses may replace this method.
- *
+ *
* @param marker the marker of unknown type
* @return the name of an image for markers of unknown type.
+ * @deprecated since 3.0, visual presentation is no longer supported,
+ * annotation with a visible presentation should implement
+ * <code>IAnnotationPresentation</code>
*/
protected String getUnknownImageName(IMarker marker) {
return null;
@@ -251,6 +271,9 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
*
* @param name the name of the requested image
* @return the image or <code>null</code> if there is no such image
+ * @deprecated since 3.0, visual presentation is no longer supported,
+ * annotation with a visible presentation should implement
+ * <code>IAnnotationPresentation</code>
*/
protected Image getImage(String name) {
if (name != null)
@@ -259,12 +282,15 @@ public class MarkerAnnotation extends SimpleMarkerAnnotation {
}
/**
- * Returns an image for this annotation. It first consults the workbench adapter
- * for this annotation's marker. If none is defined, it tries to find an image for
- * the image name of this annotation.
+ * Returns an image for this annotation. It first consults the workbench
+ * adapter for this annotation's marker. If none is defined, it tries to
+ * find an image for the image name of this annotation.
*
* @param display the display for which the image is requested
* @return the image for this annotation
+ * @deprecated since 3.0, visual presentation is no longer supported,
+ * annotation with a visible presentation should implement
+ * <code>IAnnotationPresentation</code>
*/
protected Image getImage(Display display) {
if (fImage == null) {
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModelFactory.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModelFactory.java
new file mode 100644
index 00000000000..ead33d9e18d
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModelFactory.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.core.resources.IFile;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.filebuffers.FileBuffers;
+import org.eclipse.core.filebuffers.IAnnotationModelFactory;
+import org.eclipse.jface.text.source.IAnnotationModel;
+
+/**
+ * An annotation model factory for resource marker annotation models.
+ * @since 3.0
+ */
+public class ResourceMarkerAnnotationModelFactory implements IAnnotationModelFactory {
+
+ /*
+ * @see org.eclipse.core.filebuffers.IAnnotationModelFactory#createAnnotationModel(org.eclipse.core.runtime.IPath)
+ */
+ public IAnnotationModel createAnnotationModel(IPath location) {
+ IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
+ if (file != null)
+ return new ResourceMarkerAnnotationModel(file);
+ return null;
+ }
+}

Back to the top