Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Maetzel2003-11-06 09:03:01 +0000
committerKai Maetzel2003-11-06 09:03:01 +0000
commitdd5c35e242fba6655845ee56fcb8628169fd1a6d (patch)
treed4ab4d1c65744b898c26a2deff6769ed306d4887 /org.eclipse.ui.editors
parent825ff6c29f4434deeb73d96a652ffad4ac6ba001 (diff)
downloadeclipse.platform.text-dd5c35e242fba6655845ee56fcb8628169fd1a6d.tar.gz
eclipse.platform.text-dd5c35e242fba6655845ee56fcb8628169fd1a6d.tar.xz
eclipse.platform.text-dd5c35e242fba6655845ee56fcb8628169fd1a6d.zip
RCP changes
Diffstat (limited to 'org.eclipse.ui.editors')
-rw-r--r--org.eclipse.ui.editors/.classpath31
-rw-r--r--org.eclipse.ui.editors/.project2
-rw-r--r--org.eclipse.ui.editors/build.properties3
-rw-r--r--org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryDocumentProvider.java370
-rw-r--r--org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryEditor.java168
-rw-r--r--org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.java64
-rw-r--r--org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.properties56
-rw-r--r--org.eclipse.ui.editors/icons/full/ctool16/next_nav.gifbin0 -> 105 bytes
-rw-r--r--org.eclipse.ui.editors/icons/full/ctool16/prev_nav.gifbin0 -> 132 bytes
-rw-r--r--org.eclipse.ui.editors/icons/full/dtool16/next_nav.gifbin0 -> 82 bytes
-rw-r--r--org.eclipse.ui.editors/icons/full/dtool16/prev_nav.gifbin0 -> 82 bytes
-rw-r--r--org.eclipse.ui.editors/icons/full/etool16/next_nav.gifbin0 -> 101 bytes
-rw-r--r--org.eclipse.ui.editors/icons/full/etool16/prev_nav.gifbin0 -> 102 bytes
-rw-r--r--org.eclipse.ui.editors/plugin.properties53
-rw-r--r--org.eclipse.ui.editors/plugin.xml446
-rw-r--r--org.eclipse.ui.editors/schema/documentProviders.exsd147
-rw-r--r--org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd281
-rw-r--r--org.eclipse.ui.editors/schema/markerUpdaters.exsd142
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java60
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java17
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java9
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java68
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java7
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java5
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/WorkspaceOperationRunner.java62
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java23
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java189
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPulldownActionDelegate.java29
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PreviousPulldownActionDelegate.java30
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java76
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java591
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java324
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java98
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BookmarkRulerAction.java31
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultAnnotation.java334
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java144
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java301
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditor.java1010
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java205
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java59
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java300
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java272
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java428
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerInfoAction.java31
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUpdater.java65
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java256
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java152
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties28
48 files changed, 6187 insertions, 780 deletions
diff --git a/org.eclipse.ui.editors/.classpath b/org.eclipse.ui.editors/.classpath
index 144b19a40..7041457e7 100644
--- a/org.eclipse.ui.editors/.classpath
+++ b/org.eclipse.ui.editors/.classpath
@@ -1,18 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src/"/>
- <classpathentry kind="src" path="extensions"/>
- <classpathentry kind="src" path="/org.eclipse.text"/>
- <classpathentry kind="src" path="/org.eclipse.jface"/>
- <classpathentry kind="src" path="/org.eclipse.core.resources"/>
- <classpathentry kind="src" path="/org.eclipse.update.core"/>
- <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
- <classpathentry kind="src" path="/org.eclipse.core.boot"/>
- <classpathentry kind="src" path="/org.eclipse.jface.text"/>
- <classpathentry kind="src" path="/org.eclipse.ui.workbench"/>
- <classpathentry kind="src" path="/org.eclipse.ui.views"/>
- <classpathentry kind="src" path="/org.eclipse.ui.workbench.texteditor"/>
- <classpathentry kind="src" path="/org.eclipse.core.filebuffers"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="src" path="/org.eclipse.text"/>
+ <classpathentry kind="src" path="/org.eclipse.ui.views"/>
+ <classpathentry kind="src" path="/org.eclipse.ui.workbench"/>
+ <classpathentry kind="src" path="/org.eclipse.ui.win32"/>
+ <classpathentry kind="src" path="/org.eclipse.ui.workbench.texteditor"/>
+ <classpathentry kind="src" path="/org.eclipse.jface"/>
+ <classpathentry kind="src" path="/org.eclipse.jface.text"/>
+ <classpathentry kind="src" path="/org.eclipse.core.resources"/>
+ <classpathentry kind="src" path="/org.eclipse.update.core"/>
+ <classpathentry kind="src" path="/org.eclipse.core.filebuffers"/>
+ <classpathentry kind="src" path="/org.eclipse.ui.ide"/>
+ <classpathentry kind="src" path="/org.eclipse.core.boot"/>
+ <classpathentry kind="src" path="/org.eclipse.core.runtime"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="bin"/>
</classpath>
diff --git a/org.eclipse.ui.editors/.project b/org.eclipse.ui.editors/.project
index 2bd93caa2..62f160ee6 100644
--- a/org.eclipse.ui.editors/.project
+++ b/org.eclipse.ui.editors/.project
@@ -10,7 +10,9 @@
<project>org.eclipse.jface</project>
<project>org.eclipse.jface.text</project>
<project>org.eclipse.text</project>
+ <project>org.eclipse.ui.ide</project>
<project>org.eclipse.ui.views</project>
+ <project>org.eclipse.ui.win32</project>
<project>org.eclipse.ui.workbench</project>
<project>org.eclipse.ui.workbench.texteditor</project>
<project>org.eclipse.update.core</project>
diff --git a/org.eclipse.ui.editors/build.properties b/org.eclipse.ui.editors/build.properties
index 77d509f20..86da97cdd 100644
--- a/org.eclipse.ui.editors/build.properties
+++ b/org.eclipse.ui.editors/build.properties
@@ -1,5 +1,4 @@
-source.editors.jar = src/,\
- extensions/
+source.editors.jar = src/
bin.includes = *.jar,\
plugin.xml,\
plugin.properties,\
diff --git a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryDocumentProvider.java b/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryDocumentProvider.java
deleted file mode 100644
index 140b57398..000000000
--- a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryDocumentProvider.java
+++ /dev/null
@@ -1,370 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.internal;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Properties;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.eclipse.core.boot.BootLoader;
-import org.eclipse.core.boot.IPlatformConfiguration;
-import org.eclipse.core.boot.IPlatformConfiguration.IFeatureEntry;
-import org.eclipse.core.internal.plugins.PluginDescriptor;
-import org.eclipse.core.internal.runtime.InternalPlatform;
-import org.eclipse.core.internal.runtime.PreferenceExporter;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.model.PluginFragmentModel;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.texteditor.AbstractDocumentProvider;
-import org.eclipse.update.configuration.IActivity;
-import org.eclipse.update.configuration.IInstallConfiguration;
-import org.eclipse.update.configuration.ILocalSite;
-import org.eclipse.update.core.SiteManager;
-
-/**
- * The <code>SystemSummaryDocumentProvider</code> creates diagnostic
- * information about the Eclipse instance in which it is running.
- */
-class SystemSummaryDocumentProvider extends AbstractDocumentProvider {
- /**
- * @see AbstractDocumentProvider#isDeleted(Object)
- */
- public boolean isDeleted(Object element) {
- return false;
- }
-
- /**
- * @see AbstractDocumentProvider#getSynchronizationStamp(Object)
- */
- public long getSynchronizationStamp(Object element) {
- return 0;
- }
-
- /**
- * @see AbstractDocumentProvider#getModificationStamp(Object)
- */
- public long getModificationStamp(Object element) {
- return 0;
- }
-
- /**
- * @see AbstractDocumentProvider#doSaveDocument(IProgressMonitor, Object, IDocument, boolean)
- */
- protected void doSaveDocument(
- IProgressMonitor arg0,
- Object arg1,
- IDocument arg2,
- boolean arg3)
- throws CoreException {
- }
-
- /**
- * @see AbstractDocumentProvider#createDocument(Object)
- */
- protected IDocument createDocument(Object element) throws CoreException {
- Document doc= new Document();
- doc.set(createDiagnostics());
- return doc;
- }
-
- /**
- * @see AbstractDocumentProvider#createAnnotationModel(Object)
- */
- protected IAnnotationModel createAnnotationModel(Object element)
- throws CoreException {
- return null;
- }
-
- /*
- * Returns a <code>String</code> of diagnostics information.
- */
- private String createDiagnostics() {
- StringWriter out = new StringWriter();
- PrintWriter writer = new PrintWriter(out);
- appendTimestamp(writer);
- appendProperties(writer);
- appendFeatures(writer);
- appendRegistry(writer);
- appendUserPreferences(writer);
- appendUpdateManagerLog(writer);
- appendLog(writer);
- writer.close();
- return out.toString();
- }
-
- /*
- * Appends a timestamp.
- */
- private void appendTimestamp(PrintWriter writer) {
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.timeStamp", new Date())); //$NON-NLS-1$
- }
-
- /*
- * Appends the <code>System</code> properties.
- */
- private void appendProperties(PrintWriter writer) {
- writer.println();
- writer.println(SystemSummaryMessages.getString("SystemSummary.systemProperties")); //$NON-NLS-1$
- Properties properties= System.getProperties();
- SortedSet set= new TreeSet(new Comparator() {
- public int compare(Object o1, Object o2) {
- String s1= (String)o1;
- String s2= (String)o2;
- return s1.compareTo(s2);
- }
- });
- set.addAll(properties.keySet());
- Iterator i= set.iterator();
- while(i.hasNext()) {
- Object key= i.next();
- writer.print(key);
- writer.print('=');
- writer.println(properties.get(key));
- }
- }
-
- /*
- * Appends the installed, configured features.
- */
- private void appendFeatures(PrintWriter writer) {
- writer.println();
- writer.println(SystemSummaryMessages.getString("SystemSummary.features")); //$NON-NLS-1$
-
- IPlatformConfiguration platformConfiguration = BootLoader.getCurrentPlatformConfiguration();
- IPlatformConfiguration.IFeatureEntry[] featuresArray = platformConfiguration.getConfiguredFeatureEntries();
-
- Arrays.sort(featuresArray, (new Comparator() {
- public int compare(Object o1, Object o2) {
- String s1= ((IFeatureEntry)o1).getFeatureIdentifier();
- String s2= ((IFeatureEntry)o2).getFeatureIdentifier();
- return s1.compareTo(s2);
- }
- }));
-
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- for (int i = 0; i < featuresArray.length; i++) {
- IFeatureEntry info = featuresArray[i];
- String pluginID = info.getFeaturePluginIdentifier();
- if (pluginID != null) {
- IPluginDescriptor descriptor= pluginRegistry.getPluginDescriptor(pluginID);
- pluginID = descriptor.getLabel();
- if ("".equals(pluginID)) { //$NON-NLS-1$
- pluginID = SystemSummaryMessages.getString("SystemSummary.notSpecified"); //$NON-NLS-1$
- }
- } else {
- pluginID = SystemSummaryMessages.getString("SystemSummary.notSpecified"); //$NON-NLS-1$
- }
-
- String[] args= new String[] {info.getFeatureIdentifier(), info.getFeatureVersion(), pluginID};
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.featureVersion", args)); //$NON-NLS-1$
- }
- }
-
- /*
- * Appends the contents of the Plugin Registry.
- */
- private void appendRegistry(PrintWriter writer) {
- writer.println();
- writer.println(SystemSummaryMessages.getString("SystemSummary.pluginRegistry")); //$NON-NLS-1$
- IPluginDescriptor[] descriptors= Platform.getPluginRegistry().getPluginDescriptors();
- SortedSet set= new TreeSet(new Comparator() {
- public int compare(Object o1, Object o2) {
- String s1= ((IPluginDescriptor)o1).getUniqueIdentifier();
- String s2= ((IPluginDescriptor)o2).getUniqueIdentifier();
- return s1.compareTo(s2);
- }
- });
- for(int i= 0, length= descriptors.length; i < length; i++) {
- set.add(descriptors[i]);
- }
- Iterator i= set.iterator();
- while(i.hasNext()) {
- PluginDescriptor descriptor= (PluginDescriptor)i.next();
- String[] args= new String[] {descriptor.getUniqueIdentifier(), descriptor.getVersionIdentifier().toString(), descriptor.getLabel()};
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.descriptorIdVersion", args)); //$NON-NLS-1$
- PluginFragmentModel[] fragments= descriptor.getFragments();
- if (fragments != null) {
- for(int j= 0, length= fragments.length; j < length; j++) {
- PluginFragmentModel fragment= fragments[j];
- writer.print('\t');
- args= new String[] {fragment.getId(), fragment.getVersion(), fragment.getName()};
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.fragmentIdVersion", args)); //$NON-NLS-1$
- }
- }
- }
- }
-
- /*
- * Appends the preferences
- */
- private void appendUserPreferences(PrintWriter writer) {
- String tmpFile = ".tmpPrefFile"; //$NON-NLS-1$
- IPath path = new Path(InternalPlatform.getMetaArea().getLocation().append(tmpFile).toOSString());
- File file = path.toFile();
- file.delete();
-
- try {
- PreferenceExporter.exportPreferences(path);
- } catch (CoreException e) {
- writer.println("Error exporting user preferences " + e.toString()); //$NON-NLS-1$
- }
- writer.println();
- writer.println(SystemSummaryMessages.getString("SystemSummary.userPreferences")); //$NON-NLS-1$
-
- BufferedReader reader = null;
- try {
- FileInputStream in = new FileInputStream(file);
- reader = new BufferedReader(new InputStreamReader(in, "8859_1")); //$NON-NLS-1$
- char[] chars= new char[8192];
- int read= reader.read(chars);
- while (read > 0) {
- writer.write(chars, 0, read);
- read= reader.read(chars);
- }
- reader.close();
- reader= null;
- } catch (IOException e) {
- writer.println("Error reading user preference file " + e.toString()) ;//$NON-NLS-1$
- }
-
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- writer.println("Error closing user preference file " + e.toString()); //$NON-NLS-1$
- }
- }
- file.delete();
- }
-
- /*
- * Appends the contents of the Plugin Registry.
- */
- private void appendUpdateManagerLog(PrintWriter writer) {
- writer.println();
- writer.println(SystemSummaryMessages.getString("SystemSummary.updateManagerLog")); //$NON-NLS-1$
- ILocalSite site;
- try {
- site = SiteManager.getLocalSite();
- } catch (CoreException e) {
- e.printStackTrace(writer);
- return;
- }
- IInstallConfiguration[] configurations = site.getConfigurationHistory();
- for (int i = 0; i < configurations.length; i++) {
- writer.println();
- if (i>0)
- writer.println("----------------------------------------------------"); //$NON-NLS-1$
-
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.configuration", configurations[i].getLabel())); //$NON-NLS-1$
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.isCurrentConfiguration", "" + configurations[i].isCurrent())); //$NON-NLS-1$ //$NON-NLS-2$
- IActivity[] activities = configurations[i].getActivities();
- for (int j = 0; j < activities.length; j++) {
- writer.println();
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.date", activities[j].getDate())); //$NON-NLS-1$
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.target", activities[j].getLabel())); //$NON-NLS-1$
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.action", getActionLabel(activities[j]))); //$NON-NLS-1$
- writer.println(SystemSummaryMessages.getFormattedString("SystemSummary.status", getStatusLabel(activities[j]))); //$NON-NLS-1$
- }
- }
- }
-
- /*
- * Appends the contents of the .log file
- */
- private void appendLog(PrintWriter writer) {
- File log= new File(InternalPlatform.getMetaArea().getLogLocation().toOSString());
- if (log.exists()) {
- writer.println();
- writer.println(SystemSummaryMessages.getString("SystemSummary.errorLog")); //$NON-NLS-1$
-
- BufferedReader reader = null;
- try {
- FileInputStream in = new FileInputStream(log);
- reader = new BufferedReader(new InputStreamReader(in, "UTF-8")); //$NON-NLS-1$
- char[] chars= new char[8192];
- int read= reader.read(chars);
- while (read > 0) {
- writer.write(chars, 0, read);
- read= reader.read(chars);
- }
- reader.close();
- reader= null;
- } catch (IOException e) {
- writer.println("Error reading .log file"); //$NON-NLS-1$
- }
- if (reader != null) {
- try {
- reader.close();
- } catch (IOException e) {
- writer.println("Error reading .log file"); //$NON-NLS-1$
- }
- }
- }
- }
-
- private String getActionLabel(IActivity activity) {
- int action = activity.getAction();
- switch (action) {
- case IActivity.ACTION_CONFIGURE:
- return SystemSummaryMessages.getString("SystemSummary.activity.enabled"); //$NON-NLS-1$
- case IActivity.ACTION_FEATURE_INSTALL:
- return SystemSummaryMessages.getString("SystemSummary.activity.featureInstalled"); //$NON-NLS-1$
- case IActivity.ACTION_FEATURE_REMOVE:
- return SystemSummaryMessages.getString("SystemSummary.activity.featureRemoved"); //$NON-NLS-1$
- case IActivity.ACTION_SITE_INSTALL:
- return SystemSummaryMessages.getString("SystemSummary.activity.siteInstalled"); //$NON-NLS-1$
- case IActivity.ACTION_SITE_REMOVE:
- return SystemSummaryMessages.getString("SystemSummary.activity.siteRemoved"); //$NON-NLS-1$
- case IActivity.ACTION_UNCONFIGURE:
- return SystemSummaryMessages.getString("SystemSummary.activity.disabled"); //$NON-NLS-1$
- case IActivity.ACTION_REVERT:
- return SystemSummaryMessages.getString("SystemSummary.activity.revert"); //$NON-NLS-1$
- case IActivity.ACTION_RECONCILIATION:
- return SystemSummaryMessages.getString("SystemSummary.activity.reconcile"); //$NON-NLS-1$
- case IActivity.ACTION_ADD_PRESERVED:
- return SystemSummaryMessages.getString("SystemSummary.activity.preserved"); //$NON-NLS-1$
- default:
- return SystemSummaryMessages.getString("SystemSummary.activity.unknown"); //$NON-NLS-1$
- }
- }
-
- private String getStatusLabel(IActivity activity) {
- switch (activity.getStatus()) {
- case IActivity.STATUS_OK:
- return SystemSummaryMessages.getString("SystemSummary.activity.status.success"); //$NON-NLS-1$
- case IActivity.STATUS_NOK:
- return SystemSummaryMessages.getString("SystemSummary.activity.status.failure"); //$NON-NLS-1$
- }
- return SystemSummaryMessages.getString("SystemSummary.activity.status.unknown"); //$NON-NLS-1$
- }
-}
-
diff --git a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryEditor.java b/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryEditor.java
deleted file mode 100644
index fdbd937ab..000000000
--- a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryEditor.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-
-import java.io.BufferedWriter;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-import java.io.Writer;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.IDialogSettings;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-
-/**
- * The <code>SystemSummaryEditor</code> displays diagnostics information
- * about the Eclipse platform in which it is running.
- */
-public class SystemSummaryEditor extends AbstractTextEditor {
- /*
- * The Editor ID
- */
- static final String ID= WorkbenchPlugin.getDefault().getDescriptor().getUniqueIdentifier() + ".SystemSummaryEditor"; //$NON-NLS-1$
-
- /*
- * The name of the dialog setting property used to store
- * the last file the user selected to write to.
- */
- public static final String LAST_FILE="last_file"; //$NON-NLS-1$
-
- /*
- * The string with which all other defined ids are prefixed to construct help context ids.
- * Value: <code>"org.eclipse.ui."</code>
- */
- private static final String PREFIX= PlatformUI.PLUGIN_ID + "."; //$NON-NLS-1$
-
- /*
- * Id for the system summary editor.
- * Default value: <code>"system_summary_editor_context"</code>.
- */
- private static final String SYSTEM_SUMMARY_TEXT_EDITOR= PREFIX + "system_summary_editor_context"; //$NON-NLS-1$
-
- /**
- * Creates a new text editor.
- */
- public SystemSummaryEditor() {
- super();
- setHelpContextId(SYSTEM_SUMMARY_TEXT_EDITOR);
- setDocumentProvider(new SystemSummaryDocumentProvider());
- }
-
- /**
- * Allow save so that "save as" is enabled.
- *
- * @see AbstractTextEditor#isSaveAsAllowed()
- */
- public boolean isSaveAsAllowed() {
- return true;
- }
-
- /**
- * Disallow editing.
- *
- * @see AbstractTextEditor#isEditable()
- */
- public boolean isEditable() {
- return false;
- }
-
- /**
- * Saves the contents of the editor to a file system file.
- *
- * @see AbstractTextEditor#performSaveAs(IProgressMonitor)
- */
- protected void performSaveAs(IProgressMonitor progressMonitor) {
- String filename= getFilename();
- if (filename == null)
- return;
- String contents= getDocumentProvider().getDocument(getEditorInput()).get();
-
- Writer writer = null;
- try {
- writer =
- new BufferedWriter(new OutputStreamWriter(new FileOutputStream(filename, false), "UTF-8"));//$NON-NLS-1$
- writer.write(contents);
- writer.close();
- writer = null;
- } catch (IOException ioe) {
- MessageDialog.openError(
- getSite().getShell(),
- SystemSummaryMessages.getString("SystemSummary.saveErrorTitle"), //$NON-NLS-1$
- SystemSummaryMessages.getFormattedString("SystemSummary.saveErrorMessage", new Object[]{filename, ioe.getMessage() == null ? "" : ioe.getMessage()})); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (writer != null) {
- try {
- writer.close();
- } catch (IOException e) {
- // silent
- }
- }
-
- }
-
- /*
- * Prompts the user to select a file
- */
- private String getFilename() {
- String lastUsedPath= getDialogSettings().get(LAST_FILE);
- if (lastUsedPath == null) {
- lastUsedPath= ""; //$NON-NLS-1$
- }
- FileDialog dialog= new FileDialog(getEditorSite().getShell(), SWT.SINGLE);
- dialog.setText(SystemSummaryMessages.getString("SystemSummary.dialogTitle")); //$NON-NLS-1$
- dialog.setFilterPath(lastUsedPath);
- String filename= dialog.open();
- if (filename != null)
- getDialogSettings().put(LAST_FILE, filename);
- return filename;
- }
-
- /*
- * Answers the dialog settings for the DiagnosticsPrinterPlugin plugin
- */
- private IDialogSettings getDialogSettings() {
- return WorkbenchPlugin.getDefault().getDialogSettings();
- }
-
- /**
- * Override the default implementation to only show
- * copy, select all, print, find and goto line.
- *
- * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
- */
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
- menu.add(new Separator(ITextEditorActionConstants.GROUP_COPY));
- addAction(menu, ITextEditorActionConstants.COPY);
- addAction(menu, ITextEditorActionConstants.SELECT_ALL);
-
- menu.add(new Separator(ITextEditorActionConstants.GROUP_PRINT));
- addAction(menu, ITextEditorActionConstants.PRINT);
-
- menu.add(new Separator(ITextEditorActionConstants.GROUP_FIND));
- addAction(menu, ITextEditorActionConstants.FIND);
- addAction(menu, ITextEditorActionConstants.GOTO_LINE);
-
- menu.add(new Separator(ITextEditorActionConstants.MB_ADDITIONS));
- }
-
-
-
-
-}
diff --git a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.java b/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.java
deleted file mode 100644
index 2d16be2db..000000000
--- a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2003 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class SystemSummaryMessages {
-
- private static final String RESOURCE_BUNDLE= SystemSummaryMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private SystemSummaryMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the argument
- *
- * @param key the string used to get the bundle value, must not be null
- */
- public static String getFormattedString(String key, Object arg) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- if (arg == null)
- arg= ""; //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { arg });
- }
-}
diff --git a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.properties b/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.properties
deleted file mode 100644
index df5f50453..000000000
--- a/org.eclipse.ui.editors/extensions/org/eclipse/ui/internal/SystemSummaryMessages.properties
+++ /dev/null
@@ -1,56 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2003 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Common Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/cpl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-# System Summary Editor
-SystemSummary.dialogTitle= Save As
-SystemSummary.saveErrorTitle= Error
-SystemSummary.saveErrorMessage= An error occurred saving to file {0}\n\n{1}.
-
-# paramter 0 is the feature name, parameter 1 is the version and parameter 2 is the Id
-SystemSummary.featureVersion= {0} ({1}) "{2}"
-
-# parameter 0 is the fragment name, parameter 1 is the version and parameter 2 is the Id
-SystemSummary.fragmentIdVersion= {0} ({1}) "{2}"
-
-# parameter 0 is the description name, parameter 1 is the version and parameter 2 is the Id
-SystemSummary.descriptorIdVersion= {0} ({1}) "{2}"
-
-SystemSummary.configuration= Configuration={0}
-SystemSummary.isCurrentConfiguration= Is current configuration={0}
-
-SystemSummary.date= Date={0}
-SystemSummary.target= Activities={0}
-SystemSummary.status= Status={0}
-SystemSummary.action= Action={0}
-
-SystemSummary.activity.enabled= Enabled
-SystemSummary.activity.disabled= Disabled
-SystemSummary.activity.revert= Revert
-SystemSummary.activity.reconcile= Reconcile
-SystemSummary.activity.preserved= Preserved
-SystemSummary.activity.unknown= Unknown
-SystemSummary.activity.featureInstalled= Feature installed
-SystemSummary.activity.featureRemoved= Feature removed
-SystemSummary.activity.siteInstalled= Site installed
-SystemSummary.activity.siteRemoved= Site removed
-
-SystemSummary.activity.status.unknown= Unknown
-SystemSummary.activity.status.success= Success
-SystemSummary.activity.status.failure= Failure
-
-SystemSummary.timeStamp= *** Date: {0}
-SystemSummary.systemProperties= *** System properties:
-SystemSummary.features= *** Features:
-SystemSummary.pluginRegistry= *** Plug-in Registry:
-SystemSummary.userPreferences= *** User Preferences:
-SystemSummary.updateManagerLog= *** Update Manager Log:
-SystemSummary.errorLog= *** Error Log:
-SystemSummary.notSpecified= Not Specified
diff --git a/org.eclipse.ui.editors/icons/full/ctool16/next_nav.gif b/org.eclipse.ui.editors/icons/full/ctool16/next_nav.gif
new file mode 100644
index 000000000..8392f3345
--- /dev/null
+++ b/org.eclipse.ui.editors/icons/full/ctool16/next_nav.gif
Binary files differ
diff --git a/org.eclipse.ui.editors/icons/full/ctool16/prev_nav.gif b/org.eclipse.ui.editors/icons/full/ctool16/prev_nav.gif
new file mode 100644
index 000000000..9b278e6fa
--- /dev/null
+++ b/org.eclipse.ui.editors/icons/full/ctool16/prev_nav.gif
Binary files differ
diff --git a/org.eclipse.ui.editors/icons/full/dtool16/next_nav.gif b/org.eclipse.ui.editors/icons/full/dtool16/next_nav.gif
new file mode 100644
index 000000000..6cbeced26
--- /dev/null
+++ b/org.eclipse.ui.editors/icons/full/dtool16/next_nav.gif
Binary files differ
diff --git a/org.eclipse.ui.editors/icons/full/dtool16/prev_nav.gif b/org.eclipse.ui.editors/icons/full/dtool16/prev_nav.gif
new file mode 100644
index 000000000..a3441a062
--- /dev/null
+++ b/org.eclipse.ui.editors/icons/full/dtool16/prev_nav.gif
Binary files differ
diff --git a/org.eclipse.ui.editors/icons/full/etool16/next_nav.gif b/org.eclipse.ui.editors/icons/full/etool16/next_nav.gif
new file mode 100644
index 000000000..03b7af342
--- /dev/null
+++ b/org.eclipse.ui.editors/icons/full/etool16/next_nav.gif
Binary files differ
diff --git a/org.eclipse.ui.editors/icons/full/etool16/prev_nav.gif b/org.eclipse.ui.editors/icons/full/etool16/prev_nav.gif
new file mode 100644
index 000000000..dd65c5235
--- /dev/null
+++ b/org.eclipse.ui.editors/icons/full/etool16/prev_nav.gif
Binary files differ
diff --git a/org.eclipse.ui.editors/plugin.properties b/org.eclipse.ui.editors/plugin.properties
index fd05ae559..5e5630bef 100644
--- a/org.eclipse.ui.editors/plugin.properties
+++ b/org.eclipse.ui.editors/plugin.properties
@@ -11,10 +11,57 @@
pluginName= Default Text Editor
providerName= Eclipse.org
-lastSaveReferenceProvider.label= Version on &Disk
+ExtPoint.markerUpdater= Marker Updater
+ExtPoint.documentProvider= Document Provider
+ExtPoint.markerAnnotationSpecification= Marker Annotation Specification
+
+command.custom.description = Change the encoding to a custom encoding
+command.custom.name = Custom Encoding
+command.iso_8859_1.description = Change the encoding to ISO-8859-1
+command.iso_8859_1.name = ISO-8859-1 Encoding
+command.system.description = Change the encoding to the system encoding
+command.system.name = System Encoding
+command.us_ascii.description = Change the encoding to US ASCII
+command.us_ascii.name = US ASCII Encoding
+command.utf_16.description = Change the encoding to UTF-16
+command.utf_16.name = UTF-16 Encoding
+command.utf_16be.description = Change the encoding to UTF-16BE
+command.utf_16be.name = UTF-16BE Encoding
+command.utf_16le.description = Change the encoding to UTF-16LE
+command.utf_16le.name = UTF-16LE Encoding
+command.utf_8.description = Change the encoding to UTF-8
+command.utf_8.name = UTF-8 Encoding
+openExternalFile.label= Open External File...
+openExternalFile.description= Opens an External File
+ActionDefinition.quickDiff.name= Quick Diff Toggle
+ActionDefinition.quickDiff.description= Toggles display of quick diff information on the line number ruler
+Editors.DefaultTextEditor= Text Editor
PreferencePages.TextEditor= Text Editor
+lastSaveReferenceProvider.label= Version on &Disk
+
+AddTask.label=Add &Task...
+AddTask.tooltip=Add Task...
+AddBookmark.label=Add Boo&kmark...
+AddBookmark.tooltip=Add Bookmark...
+quickdiff.toggle.enable= Enable &QuickDiff
+
+Dummy.label=
+
openExternalFileActionSet.label= Open External Files
-openExternalFile.label= Open External File...
-openExternalFile.description= Opens an External File \ No newline at end of file
+textEditorAnnotationNavigationActionSet.label= Annotation Navigation
+
+goToPreviousAnnotation.label= Go to Previous Annotation
+goToPreviousAnnotation.tooltip= Go to Previous Annotation
+goToNextAnnotation.label= Go to Next Annotation
+goToNextAnnotation.tooltip= Go to Next Annotation
+
+errors.label= Errors
+warnings.label= Warnings
+infos.label= Infos
+tasks.label= Tasks
+bookmarks.label= Bookmarks
+changes.label= Diff Changes
+additions.label= Diff Additions
+deletions.label= Diff Deletions
diff --git a/org.eclipse.ui.editors/plugin.xml b/org.eclipse.ui.editors/plugin.xml
index c360da9c3..3d8895230 100644
--- a/org.eclipse.ui.editors/plugin.xml
+++ b/org.eclipse.ui.editors/plugin.xml
@@ -9,52 +9,143 @@
<runtime>
<library name="editors.jar">
- <export name="*"/>
- <packages prefixes="org.eclipse.ui.texteditor,org.eclipse.ui.editors.text,org.eclipse.ui.internal,org.eclipse.ui.internal.editors.quickdiff"/>
+ <export name="*"/>
+ <packages prefixes="org.eclipse.ui.texteditor,org.eclipse.ui.editors.text,org.eclipse.ui.internal,org.eclipse.ui.internal.editors.quickdiff"/>
</library>
</runtime>
<requires>
- <import plugin="org.eclipse.text"/>
- <import plugin="org.eclipse.ui.views"/>
- <import plugin="org.eclipse.ui.workbench"/>
+ <import plugin="org.eclipse.ui.ide"/>
<import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.jface"/>
+ <import plugin="org.eclipse.ui"/>
<import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.update.core"/>
<import plugin="org.eclipse.core.filebuffers"/>
+ <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="org.eclipse.ui.commands">
+ <command
+ name="%command.us_ascii.name"
+ description="%command.us_ascii.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.us-ascii">
+ </command>
+ <command
+ name="%command.iso_8859_1.name"
+ description="%command.iso_8859_1.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.iso-8859-1">
+ </command>
+ <command
+ name="%command.utf_8.name"
+ description="%command.utf_8.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.utf-8">
+ </command>
+ <command
+ name="%command.utf_16be.name"
+ description="%command.utf_16be.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.utf-16be">
+ </command>
+ <command
+ name="%command.utf_16le.name"
+ description="%command.utf_16le.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.utf-16le">
+ </command>
+ <command
+ name="%command.utf_16.name"
+ description="%command.utf_16.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.utf-16">
+ </command>
+ <command
+ name="%command.system.name"
+ description="%command.system.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.system">
+ </command>
+ <command
+ name="%command.custom.name"
+ description="%command.custom.description"
+ categoryId="org.eclipse.ui.category.edit"
+ id="org.eclipse.ui.edit.text.encoding.custom">
+ </command>
+ <command
+ name="%openExternalFile.label"
+ description="%openExternalFile.description"
+ category="org.eclipse.ui.category.file"
+ id="org.eclipse.ui.edit.text.openExternalFile">
+ </command>
+ <command
+ name="%ActionDefinition.quickDiff.name"
+ description="%ActionDefinition.quickDiff.description"
+ category="org.eclipse.ui.category.edit"
+ id="org.eclipse.quickdiff.toggle">
+ </command>
+ <keyBinding
+ string="Ctrl+Shift+Q"
+ scope="org.eclipse.ui.textEditorScope"
+ command="org.eclipse.quickdiff.toggle"
+ 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"
+ class="org.eclipse.ui.editors.text.TextEditor"
+ id="org.eclipse.ui.DefaultTextEditor">
+ </editor>
+ </extension>
+
<extension
- point="org.eclipse.ui.preferencePages">
+ point="org.eclipse.ui.preferencePages">
<page
- name="%PreferencePages.TextEditor"
- category="org.eclipse.ui.preferencePages.Editors"
- class="org.eclipse.ui.internal.editors.text.TextEditorPreferencePage2"
- id="org.eclipse.ui.preferencePages.TextEditor">
+ name="%PreferencePages.TextEditor"
+ category="org.eclipse.ui.preferencePages.Editors"
+ class="org.eclipse.ui.internal.editors.text.TextEditorPreferencePage2"
+ id="org.eclipse.ui.preferencePages.TextEditor">
</page>
</extension>
-
+
<extension
- point="org.eclipse.ui.documentProviders">
+ point="org.eclipse.ui.editors.documentProviders">
<provider
class="org.eclipse.ui.editors.text.TextFileDocumentProvider"
inputTypes="org.eclipse.ui.IStorageEditorInput"
id="org.eclipse.ui.editors.text.StorageDocumentProvider">
</provider>
</extension>
-
+
<extension
- point="org.eclipse.ui.documentProviders">
+ point="org.eclipse.ui.editors.documentProviders">
<provider
class="org.eclipse.ui.editors.text.TextFileDocumentProvider"
inputTypes="org.eclipse.ui.internal.editors.text.JavaFileEditorInput"
id="org.eclipse.ui.editors.text.ExternalFileDocumentProvider">
</provider>
</extension>
-
+
<extension
- point="org.eclipse.ui.workbench.texteditor.quickDiffReferenceProvider">
+ point="org.eclipse.ui.editors.markerUpdaters">
+ <updater
+ class="org.eclipse.ui.texteditor.BasicMarkerUpdater"
+ id="org.eclipse.ui.texteditor.BasicMarkerUpdater">
+ </updater>
+ </extension>
+
+ <extension
+ point="org.eclipse.ui.workbench.texteditor.quickDiffReferenceProvider">
<referenceprovider
label="%lastSaveReferenceProvider.label"
default="true"
@@ -64,10 +155,54 @@
</extension>
<extension
- point="org.eclipse.ui.popupMenus">
+ point="org.eclipse.ui.popupMenus">
<viewerContribution
targetID="#TextRulerContext"
- id="org.eclipse.ui.quickdiff.TextEditorContribution">
+ id="org.eclipse.ui.texteditor.ruler.context.actions">
+ <action
+ label="%AddTask.label"
+ helpContextId="org.eclipse.ui.AddTask_action_context"
+ tooltip="%AddTask.tooltip"
+ class="org.eclipse.ui.texteditor.TaskRulerAction"
+ 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"
+ menubarPath="additions"
+ id="org.eclipse.ui.texteditor.BookmarkRulerAction">
+ </action>
+ <action
+ label="%quickdiff.toggle.enable"
+ style="push"
+ helpContextId="quickdiff.toggle"
+ class="org.eclipse.ui.texteditor.quickdiff.QuickDiffToggleAction"
+ menubarPath="quickdiff"
+ id="quickdiff.toggle">
+ </action>
+ </viewerContribution>
+ <viewerContribution
+ targetID="#RulerContext"
+ id="org.eclipse.ui.texteditor.ruler.context.actions">
+ <action
+ label="%AddTask.label"
+ helpContextId="org.eclipse.ui.AddTask_action_context"
+ tooltip="%AddTask.tooltip"
+ class="org.eclipse.ui.texteditor.TaskRulerAction"
+ 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"
+ menubarPath="additions"
+ id="org.eclipse.ui.texteditor.BookmarkRulerAction">
+ </action>
<action
label="%quickdiff.toggle.enable"
style="push"
@@ -80,31 +215,252 @@
</extension>
<extension
- point="org.eclipse.ui.commands">
- <command
- name="%openExternalFile.label"
- description="%openExternalFile.description"
- category="org.eclipse.ui.category.file"
- id="org.eclipse.ui.edit.text.openExternalFile">
- </command>
+ point="org.eclipse.ui.editorActions">
+ <editorContribution
+ targetID="org.eclipse.ui.DefaultTextEditor"
+ id="org.eclipse.ui.texteditor.ruler.actions">
+ <action
+ label="%Dummy.label"
+ helpContextId="org.eclipse.ui.bookmark_action_context"
+ class="org.eclipse.ui.texteditor.BookmarkRulerAction"
+ actionID="RulerDoubleClick"
+ id="org.eclipse.ui.texteditor.BookmarkRulerAction">
+ </action>
+ <action
+ label="%Dummy.label"
+ class="org.eclipse.ui.texteditor.SelectRulerAction"
+ actionID="RulerClick"
+ id="org.eclipse.ui.texteditor.SelectRulerAction">
+ </action>
+ </editorContribution>
+ <editorContribution
+ targetID="org.eclipse.ui.DefaultTextEditor"
+ id="org.eclipse.quickdiff.editoractions.texteditor">
+ <action
+ definitionId="org.eclipse.quickdiff.toggle"
+ label="%quickdiff.toggle.enable"
+ class="org.eclipse.ui.texteditor.quickdiff.QuickDiffToggleAction"
+ id="org.eclipse.ui.texteditor.quickdiff.QuickDiffToggleAction">
+ </action>
+ </editorContribution>
</extension>
-
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- label="%openExternalFileActionSet.label"
- visible="true"
- id="org.eclipse.ui.edit.text.actionSet.openExternalFile">
- <action
- id="org.eclipse.ui.edit.text.openExternalFile"
- label="%openExternalFile.label"
- tooltip="%openExternalFile.description"
- menubarPath="file/new.ext"
- class="org.eclipse.ui.internal.editors.text.OpenExternalFileAction"
- definitionId="org.eclipse.ui.edit.text.openExternalFile"
- helpContextId="open_text_editor_action_context"/>
- </actionSet>
- </extension>
+ <extension
+ point="org.eclipse.ui.actionSets">
+ <actionSet
+ label="%openExternalFileActionSet.label"
+ visible="true"
+ id="org.eclipse.ui.edit.text.actionSet.openExternalFile">
+ <action
+ 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"
+ menubarPath="file/new.ext"
+ id="org.eclipse.ui.edit.text.openExternalFile">
+ </action>
+ </actionSet>
+ <actionSet
+ label="%textEditorAnnotationNavigationActionSet.label"
+ visible="false"
+ id="org.eclipse.ui.edit.text.actionSet.annotationNavigation">
+ <action
+ allowLabelUpdate="true"
+ style="pulldown"
+ toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
+ id="org.eclipse.ui.edit.text.gotoPreviousAnnotation"
+ hoverIcon="icons/full/ctool16/prev_nav.gif"
+ class="org.eclipse.ui.internal.editors.text.PreviousPulldownActionDelegate"
+ definitionId="org.eclipse.ui.navigate.previous"
+ disabledIcon="icons/full/dtool16/prev_nav.gif"
+ icon="icons/full/etool16/prev_nav.gif"
+ label="%goToPreviousAnnotation.label"
+ retarget="true"
+ tooltip="%goToPreviousAnnotation.tooltip">
+ </action>
+ <action
+ allowLabelUpdate="true"
+ style="pulldown"
+ toolbarPath="org.eclipse.ui.workbench.navigate/history.group"
+ id="org.eclipse.ui.edit.text.gotoNextAnnotation"
+ hoverIcon="icons/full/ctool16/next_nav.gif"
+ class="org.eclipse.ui.internal.editors.text.NextPulldownActionDelegate"
+ definitionId="org.eclipse.ui.navigate.next"
+ disabledIcon="icons/full/dtool16/next_nav.gif"
+ icon="icons/full/etool16/next_nav.gif"
+ label="%goToNextAnnotation.label"
+ retarget="true"
+ tooltip="%goToNextAnnotation.tooltip">
+ </action>
+ </actionSet>
+ </extension>
+ <extension
+ point="org.eclipse.ui.editors.markerAnnotationSpecification">
+ <specification
+ textPreferenceKey="errorIndication"
+ presentationLayer="6"
+ 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"
+ isGoToNextNavigationTargetKey="isErrorGoToNextNavigationTarget"
+ isGoToNextNavigationTarget="true"
+ overviewRulerPreferenceKey="errorIndicationInOverviewRuler"
+ verticalRulerPreferenceValue="true"
+ isGoToPreviousNavigationTarget="true"
+ verticalRulerPreferenceKey="errorIndicationInVerticalRuler"
+ contributesToHeader="true"
+ colorPreferenceValue="255,0,128"
+ overviewRulerPreferenceValue="true">
+ </specification>
+ <specification
+ textPreferenceKey="warningIndication"
+ presentationLayer="5"
+ 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"
+ isGoToNextNavigationTargetKey="isWarningGoToNextNavigationTarget"
+ isGoToNextNavigationTarget="true"
+ overviewRulerPreferenceKey="warningIndicationInOverviewRuler"
+ verticalRulerPreferenceValue="true"
+ isGoToPreviousNavigationTarget="true"
+ verticalRulerPreferenceKey="warningIndicationInVerticalRuler"
+ contributesToHeader="true"
+ colorPreferenceValue="244,200,45"
+ overviewRulerPreferenceValue="true">
+ </specification>
+ <specification
+ textPreferenceKey="infoIndication"
+ presentationLayer="4"
+ 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"
+ isGoToNextNavigationTargetKey="isInfoGoToNextNavigationTarget"
+ isGoToNextNavigationTarget="false"
+ overviewRulerPreferenceKey="infoIndicationInOverviewRuler"
+ verticalRulerPreferenceValue="true"
+ isGoToPreviousNavigationTarget="false"
+ verticalRulerPreferenceKey="infoIndicationInVerticalRuler"
+ contributesToHeader="false"
+ colorPreferenceValue="244,200,45"
+ overviewRulerPreferenceValue="true">
+ </specification>
+ <specification
+ textPreferenceKey="taskIndication"
+ presentationLayer="2"
+ 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"
+ isGoToNextNavigationTargetKey="isTaskGoToNextNavigationTarget"
+ isGoToNextNavigationTarget="false"
+ overviewRulerPreferenceKey="taskIndicationInOverviewRuler"
+ verticalRulerPreferenceValue="true"
+ isGoToPreviousNavigationTarget="false"
+ verticalRulerPreferenceKey="taskIndicationInVerticalRuler"
+ contributesToHeader="false"
+ colorPreferenceValue="0,128,255"
+ overviewRulerPreferenceValue="true">
+ </specification>
+ <specification
+ textPreferenceKey="bookmarkIndication"
+ presentationLayer="1"
+ 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"
+ isGoToNextNavigationTargetKey="isBookmarkGoToNextNavigationTarget"
+ isGoToNextNavigationTarget="false"
+ overviewRulerPreferenceKey="bookmarkIndicationInOverviewRuler"
+ verticalRulerPreferenceValue="true"
+ isGoToPreviousNavigationTarget="false"
+ verticalRulerPreferenceKey="bookmarkIndicationInVerticalRuler"
+ contributesToHeader="false"
+ colorPreferenceValue="34,164,99"
+ overviewRulerPreferenceValue="true">
+ </specification>
+ <specification
+ 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"
+ contributesToHeader="false"
+ overviewRulerPreferenceValue="false"
+ markerType="org.eclipse.quickdiff.changeindication"
+ presentationLayer="2"
+ textPreferenceValue="false"
+ label="%changes.label"
+ textPreferenceKey="changeIndication"
+ overviewRulerPreferenceKey="changeIndicationInOverviewRuler">
+ </specification>
+ <specification
+ 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"
+ contributesToHeader="false"
+ overviewRulerPreferenceValue="false"
+ markerType="org.eclipse.quickdiff.additionindication"
+ presentationLayer="2"
+ textPreferenceValue="false"
+ label="%additions.label"
+ textPreferenceKey="additionIndication"
+ overviewRulerPreferenceKey="additionIndicationInOverviewRuler">
+ </specification>
+ <specification
+ 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"
+ contributesToHeader="false"
+ overviewRulerPreferenceValue="false"
+ markerType="org.eclipse.quickdiff.deletionindication"
+ presentationLayer="2"
+ textPreferenceValue="false"
+ label="%deletions.label"
+ textPreferenceKey="deletionIndication"
+ overviewRulerPreferenceKey="deletionIndicationInOverviewRuler">
+ </specification>
+ </extension>
</plugin>
diff --git a/org.eclipse.ui.editors/schema/documentProviders.exsd b/org.eclipse.ui.editors/schema/documentProviders.exsd
new file mode 100644
index 000000000..455e55ec1
--- /dev/null
+++ b/org.eclipse.ui.editors/schema/documentProviders.exsd
@@ -0,0 +1,147 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ui" id="documentProviders" name="Document Providers"/>
+ </appInfo>
+ <documentation>
+ This extension point is used to define mappings between file types and document providers or between types of editor inputs and document providers that can be used by editors. Document providers must implement the interface &lt;samp&gt;org.eclipse.ui.texteditor.IDocumentProvider&lt;/samp&gt;. Editor inputs must be instance of &lt;samp&gt;org.eclipse.ui.IEditorInput&lt;/samp&gt;.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="provider" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="provider">
+ <complexType>
+ <attribute name="extensions" type="string">
+ <annotation>
+ <documentation>
+ a comma separated list of file extensions
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="inputTypes" type="string">
+ <annotation>
+ <documentation>
+ a comma separated list of qualified editor input class names
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the qualified name of the document provider class
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the unique id of this provider
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ Release 1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.documentProviders&quot;&gt;
+ &lt;provider
+ extensions=&quot;.jav&quot;
+ class=&quot;org.eclipse.ui.examples.javaeditor.JavaDocumentProvider&quot;
+ id=&quot;org.eclipse.ui.examples.javaeditor.JavaDocumentProvider&quot;&gt;
+ &lt;/provider&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+&lt;p&gt;
+This example registers &lt;samp&gt;org.eclipse.ui.examples.javaeditor.JavaDocumentProvider&lt;/samp&gt; as the default provider for files with the extension &quot;.jav&quot;.
+&lt;p&gt;
+&lt;pre&gt;
+&lt;extension point=&quot;org.eclipse.ui.documentProviders&quot;&gt;
+ &lt;provider
+ inputTypes=&quot;org.eclipse.ui.IStorageEditorInput&quot;
+ class=&quot;org.eclipse.ui.editors.text.FileDocumentProvider&quot;
+ id=&quot;org.eclipse.ui.editors.text.FileDocumentProvider&quot;&gt;
+ &lt;/provider&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+&lt;/p&gt;
+This example registers &lt;samp&gt;org.eclipse.ui.editors.text.FileDocumentProvider&lt;/samp&gt; as the default provider for all editor inputs that are &lt;samp&gt;instance of org.eclipse.ui.IStorageEditorInput&lt;/samp&gt;.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ Document providers registered for a file extension have precedence over those registered for input types. Document providers must implement the interface &lt;samp&gt;org.eclipse.ui.texteditor.IDocumentProvider&lt;/samp&gt;. Editor inputs must be instance of &lt;samp&gt;org.eclipse.ui.IEditorInput&lt;/samp&gt;.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ &lt;a href=&quot;hglegal.htm&quot;&gt;
+&lt;img SRC=&quot;ngibmcpy.gif&quot; ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot; BORDER=0 height=14 width=324&gt;
+&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd b/org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd
new file mode 100644
index 000000000..192ecf245
--- /dev/null
+++ b/org.eclipse.ui.editors/schema/markerAnnotationSpecification.exsd
@@ -0,0 +1,281 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui.workbench.texteditor">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ui.workbench.texteditor" id="markerAnnotationSpecification" name="Marker Annotation Specification"/>
+ </appInfo>
+ <documentation>
+ This extension point is used to define presentation properties of markers. Extensions provided for this extension point can be accessed using org.eclipse.ui.texteditor.MarkerAnnotationPreferences.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="specification"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="specification">
+ <complexType>
+ <attribute name="markerType" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="colorPreferenceKey" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="overviewRulerPreferenceKey" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="verticalRulerPreferenceKey" type="string">
+ <annotation>
+ <documentation>
+ The preference key for the show in vertical ruler preference.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="textPreferenceKey" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="label" type="string" use="required">
+ <annotation>
+ <documentation>
+
+ <attribute name="highlightPreferenceKey" type="string">
+ <annotation>
+ <documentation>
+ The preference key for highlighting in text.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="markerSeverity">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ <simpleType>
+ <restriction base="string">
+ <enumeration value="0">
+ </enumeration>
+ <enumeration value="1">
+ </enumeration>
+ <enumeration value="2">
+ </enumeration>
+ </restriction>
+ </simpleType>
+ </attribute>
+ <attribute name="colorPreferenceValue" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="presentationLayer" type="string">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="overviewRulerPreferenceValue" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="verticalRulerPreferenceValue" type="boolean">
+ <annotation>
+ <documentation>
+ The default value for showing in vertical ruler.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="textPreferenceValue" type="boolean">
+ <annotation>
+ <documentation>
+
+ </documentation>
+ </annotation>
+ </attribute>
+
+ <attribute name="highlightPreferenceValue" type="boolean">
+ <annotation>
+ <documentation>
+ The default value for highlighting in text.
+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>
+
+ </documentation>
+ </annotation>
+ </attribute>
+
+ <attribute name="showInNextPrevDropdownToolbarActionKey" type="string">
+ <annotation>
+ <documentation>
+ The preference key for the visibility in the next/previous drop down toolbar action.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+
+ <attribute name="showInNextPrevDropdownToolbarAction" type="boolean">
+ <annotation>
+ <documentation>
+ The default value for the visibility in the next/previous drop down toolbar action.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+
+ <attribute name="isGoToNextNavigationTargetKey" type="string">
+ <annotation>
+ <documentation>
+ The preference key for go to next navigation enablement.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+
+ <attribute name="isGoToNextNavigationTarget" type="boolean">
+ <annotation>
+ <documentation>
+ The default value for go to next navigation enablement.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+
+ <attribute name="isGoToPreviousNavigationTargetKey" type="string">
+ <annotation>
+ <documentation>
+ The preference key for go to previous navigation enablement.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+
+ <attribute name="isGoToPreviousNavigationTarget" type="boolean">
+ <annotation>
+ <documentation>
+ The default value for go to previous navigation enablement.
+since: 3.0
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ &lt;p&gt;
+&lt;a href=&quot;hglegal.htm&quot;&gt;
+ &lt;img SRC=&quot;ngibmcpy.gif&quot;
+ ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ BORDER=0 height=14 width=324&gt;&lt;/a&gt;
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.editors/schema/markerUpdaters.exsd b/org.eclipse.ui.editors/schema/markerUpdaters.exsd
new file mode 100644
index 000000000..695e4fd83
--- /dev/null
+++ b/org.eclipse.ui.editors/schema/markerUpdaters.exsd
@@ -0,0 +1,142 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<!-- Schema file written by PDE -->
+<schema targetNamespace="org.eclipse.ui">
+<annotation>
+ <appInfo>
+ <meta.schema plugin="org.eclipse.ui" id="markerUpdaters" name="Marker Updaters"/>
+ </appInfo>
+ <documentation>
+ This extension point is used for registering marker update strategies with marker annotation models. A resource that is opened in a text editor is associated with a marker annotation model. For each marker attached to the resource this model manages a position that is updated with each change applied to the text in the editor. If the resource is saved, the text in the editor and the position managed for a marker are passed over to the registered marker update strategies. These strategies can then update the marker&apos;s attributes based on the text and the position. Marker update strategies are requested to implement the interface &lt;samp&gt;org.eclipse.ui.texteditor.IMarkerUpdater&lt;/samp&gt;. The update strategies can be registered either for a particular marker type or all marker types. The latter by omitting any marker type in the extension.
+ </documentation>
+ </annotation>
+
+ <element name="extension">
+ <complexType>
+ <sequence>
+ <element ref="updater" minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ <attribute name="point" type="string" use="required">
+ <annotation>
+ <documentation>
+ a fully qualified identifier of the target extension point
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="id" type="string">
+ <annotation>
+ <documentation>
+ an optional identifier of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="name" type="string">
+ <annotation>
+ <documentation>
+ an optional name of the extension instance
+ </documentation>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <element name="updater">
+ <complexType>
+ <attribute name="id" type="string" use="required">
+ <annotation>
+ <documentation>
+ the unique id of this provider
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="markerType" type="string">
+ <annotation>
+ <documentation>
+ the name of the marker type
+ </documentation>
+ </annotation>
+ </attribute>
+ <attribute name="class" type="string" use="required">
+ <annotation>
+ <documentation>
+ the qualified name of the marker updater class
+ </documentation>
+ <appInfo>
+ <meta.attribute kind="java"/>
+ </appInfo>
+ </annotation>
+ </attribute>
+ </complexType>
+ </element>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="since"/>
+ </appInfo>
+ <documentation>
+ Release 1.0
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="examples"/>
+ </appInfo>
+ <documentation>
+ &lt;pre&gt;
+&lt;extension point= &quot;org.eclipse.ui.markerUpdaters&quot;&gt;
+ &lt;updater
+ id=&quot;org.eclipse.jdt.ui.markerUpdaters.JavaSearchMarkerUpdater&quot;
+ class=&quot;org.eclipse.jdt.internal.ui.search.JavaSearchMarkerUpdater&quot;
+ markerType=&quot;org.eclipse.search.searchmarker&quot;&gt;
+ &lt;/updater&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+&lt;p&gt;
+This example registers &lt;samp&gt;org.eclipse.jdt.internal.ui.search.JavaSearchMarkerUpdater&lt;/samp&gt; as a marker updater for all markers of the
+type &lt;samp&gt;org.eclipse.search.searchmarker&lt;/samp&gt; including all its derived types.
+&lt;/p&gt;
+&lt;pre&gt;
+&lt;extension point= &quot;org.eclipse.ui.markerUpdaters&quot;&gt;
+ &lt;updater
+ id=&quot;org.eclipse.ui.texteditor.BasicMarkerUpdater&quot;
+ class=&quot;org.eclipse.ui.texteditor.BasicMarkerUpdater&quot;&gt;
+ &lt;/updater&gt;
+&lt;/extension&gt;
+&lt;/pre&gt;
+&lt;p&gt;
+This example registers &lt;samp&gt;org.eclipse.ui.texteditor.BasicMarkerUpdater&lt;/samp&gt; as a marker updater independent from the type of the marker.
+&lt;/p&gt;
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="apiInfo"/>
+ </appInfo>
+ <documentation>
+ Registered marker updaters have to implement the interface &lt;samp&gt;org.eclipse.ui.texteditor.IMarkerUpdater&lt;/samp&gt;.
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="implementation"/>
+ </appInfo>
+ <documentation>
+
+ </documentation>
+ </annotation>
+
+ <annotation>
+ <appInfo>
+ <meta.section type="copyright"/>
+ </appInfo>
+ <documentation>
+ &lt;a href=&quot;hglegal.htm&quot;&gt;
+ &lt;img SRC=&quot;ngibmcpy.gif&quot;
+ ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
+ BORDER=0 height=14 width=324&gt;&lt;/a&gt;
+ </documentation>
+ </annotation>
+
+</schema>
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
index 5683e8337..046d904d4 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
@@ -36,6 +36,8 @@ import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.jface.operation.IRunnableContext;
+
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IAnnotationModel;
@@ -46,6 +48,7 @@ import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.dialogs.ContainerGenerator;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
@@ -63,6 +66,11 @@ public class FileDocumentProvider extends StorageDocumentProvider {
* @since 2.1
*/
private static final QualifiedName ENCODING_KEY = new QualifiedName("org.eclipse.ui.editors", "encoding"); //$NON-NLS-1$ //$NON-NLS-2$
+ /**
+ * The runnable context for that provider.
+ * @since 3.0
+ */
+ private WorkspaceOperationRunner fOperationRunner;
/**
* Runnable encapsulating an element state change. This runnable ensures
@@ -391,10 +399,9 @@ public class FileDocumentProvider extends StorageDocumentProvider {
}
/*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#synchronize(Object)
- * @since 2.0
+ * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSynchronize(java.lang.Object)
*/
- public void synchronize(Object element) throws CoreException {
+ protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
if (element instanceof IFileEditorInput) {
IFileEditorInput input= (IFileEditorInput) element;
@@ -404,10 +411,10 @@ public class FileDocumentProvider extends StorageDocumentProvider {
if (info.fFileSynchronizer != null) {
info.fFileSynchronizer.uninstall();
- refreshFile(input.getFile());
+ refreshFile(input.getFile(), monitor);
info.fFileSynchronizer.install();
} else {
- refreshFile(input.getFile());
+ refreshFile(input.getFile(), monitor);
}
handleElementContentChanged((IFileEditorInput) element);
@@ -415,7 +422,7 @@ public class FileDocumentProvider extends StorageDocumentProvider {
return;
}
- super.synchronize(element);
+ super.doSynchronize(element, monitor);
}
/*
@@ -683,20 +690,25 @@ public class FileDocumentProvider extends StorageDocumentProvider {
}
/*
- * @see IDocumentProvider#resetDocument(Object)
- * @since 2.0
+ * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doResetDocument(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
*/
- public void resetDocument(Object element) throws CoreException {
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=19014
+ protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException {
if (element instanceof IFileEditorInput) {
IFileEditorInput input= (IFileEditorInput) element;
try {
- refreshFile(input.getFile());
+ refreshFile(input.getFile(), monitor);
} catch (CoreException x) {
handleCoreException(x,TextEditorMessages.getString("FileDocumentProvider.resetDocument")); //$NON-NLS-1$
}
}
- super.resetDocument(element);
+
+ super.doResetDocument(element, monitor);
+
+ IAnnotationModel model= getAnnotationModel(element);
+ if (model instanceof AbstractMarkerAnnotationModel) {
+ AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
+ markerModel.resetMarkers();
+ }
}
/**
@@ -707,8 +719,20 @@ public class FileDocumentProvider extends StorageDocumentProvider {
* @since 2.1
*/
protected void refreshFile(IFile file) throws CoreException {
+ refreshFile(file, getProgressMonitor());
+ }
+
+ /**
+ * Refreshes the given file resource.
+ *
+ * @param file the file to be refreshed
+ * @param monitor the progress monitor
+ * @throws a CoreException if the refresh fails
+ * @since 3.0
+ */
+ protected void refreshFile(IFile file, IProgressMonitor monitor) throws CoreException {
try {
- file.refreshLocal(IResource.DEPTH_INFINITE, getProgressMonitor());
+ file.refreshLocal(IResource.DEPTH_INFINITE, monitor);
} catch (OperationCanceledException x) {
}
}
@@ -764,4 +788,14 @@ public class FileDocumentProvider extends StorageDocumentProvider {
file.setPersistentProperty(ENCODING_KEY, encoding);
}
}
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getOperationRunner(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
+ if (fOperationRunner == null)
+ fOperationRunner = new WorkspaceOperationRunner();
+ fOperationRunner.setProgressMonitor(monitor);
+ return fOperationRunner;
+ }
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java
index 1b7a5db2d..d6270633b 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java
@@ -11,6 +11,7 @@
package org.eclipse.ui.editors.text;
+import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
/**
@@ -31,4 +32,20 @@ public interface ITextEditorHelpContextIds extends IAbstractTextEditorHelpContex
* Value: <code>"org.eclipse.ui.text_editor_context"</code>.
*/
public static final String TEXT_EDITOR= PREFIX + "text_editor_context"; //$NON-NLS-1$
+
+ /**
+ * Help context id for the Add Task action.
+ * Value: <code>"org.eclipse.ui.bookmark_action_context"</code>
+ *
+ * @since 3.0
+ */
+ public static final String BOOKMARK_ACTION= PREFIX + IDEActionFactory.ADD_TASK.getId() + ACTION_POSTFIX;
+
+ /**
+ * Help context id for the Bookmark action.
+ * Value: <code>"org.eclipse.ui.addTask_action_context"</code>
+ *
+ * @since 3.0
+ */
+ public static final String ADD_TASK_ACTION= PREFIX + IDEActionFactory.BOOKMARK.getId() + ACTION_POSTFIX;
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java
index 8129c095e..dea93845d 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java
@@ -27,6 +27,8 @@ import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Platform;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.operation.IRunnableContext;
+
import org.eclipse.jface.text.Document;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.source.IAnnotationModel;
@@ -408,4 +410,11 @@ public class StorageDocumentProvider extends AbstractDocumentProvider implements
protected void persistEncoding(Object element, String encoding) throws CoreException {
// Default is to do nothing
}
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getOperationRunner(org.eclipse.core.runtime.IProgressMonitor)
+ */
+ protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
+ return null;
+ }
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java
index c9b7484a7..ca9533a9f 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java
@@ -12,7 +12,6 @@
package org.eclipse.ui.editors.text;
-import java.lang.reflect.InvocationTargetException;
import java.text.MessageFormat;
import org.eclipse.core.resources.IFile;
@@ -27,15 +26,12 @@ import org.eclipse.swt.widgets.Shell;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
import org.eclipse.jface.window.Window;
import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
import org.eclipse.ui.dialogs.SaveAsDialog;
import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.AddTaskAction;
import org.eclipse.ui.texteditor.ConvertLineDelimitersAction;
import org.eclipse.ui.texteditor.ExtendedTextEditor;
import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
@@ -61,12 +57,14 @@ import org.eclipse.ui.internal.editors.text.EditorsPlugin;
* </p>
*/
public class TextEditor extends ExtendedTextEditor {
+
/**
* The encoding support for the editor.
* @since 2.0
*/
protected DefaultEncodingSupport fEncodingSupport;
-
+
+
/**
* Creates a new text editor.
*/
@@ -104,8 +102,8 @@ public class TextEditor extends ExtendedTextEditor {
*/
public void dispose() {
if (fEncodingSupport != null) {
- fEncodingSupport.dispose();
- fEncodingSupport= null;
+ fEncodingSupport.dispose();
+ fEncodingSupport= null;
}
super.dispose();
@@ -183,7 +181,7 @@ public class TextEditor extends ExtendedTextEditor {
*/
protected void performSaveAs(IProgressMonitor progressMonitor) {
Shell shell= getSite().getShell();
- IEditorInput input = getEditorInput();
+ IEditorInput input= getEditorInput();
SaveAsDialog dialog= new SaveAsDialog(shell);
@@ -221,45 +219,33 @@ public class TextEditor extends ExtendedTextEditor {
IWorkspace workspace= ResourcesPlugin.getWorkspace();
IFile file= workspace.getRoot().getFile(filePath);
final IEditorInput newInput= new FileEditorInput(file);
-
- WorkspaceModifyOperation op= new WorkspaceModifyOperation() {
- public void execute(final IProgressMonitor monitor) throws CoreException {
- getDocumentProvider().saveDocument(monitor, newInput, getDocumentProvider().getDocument(getEditorInput()), true);
- }
- };
-
+
boolean success= false;
try {
provider.aboutToChange(newInput);
- new ProgressMonitorDialog(shell).run(false, true, op);
+ provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true);
success= true;
- } catch (InterruptedException x) {
- } catch (InvocationTargetException x) {
-
- Throwable targetException= x.getTargetException();
+ } catch (CoreException x) {
String title= TextEditorMessages.getString("Editor.error.save.title"); //$NON-NLS-1$
- String msg= MessageFormat.format(TextEditorMessages.getString("Editor.error.save.message"), new Object[] { targetException.getMessage() }); //$NON-NLS-1$
+ String msg= MessageFormat.format(TextEditorMessages.getString("Editor.error.save.message"), new Object[] { x.getMessage() }); //$NON-NLS-1$
- if (targetException instanceof CoreException) {
- CoreException coreException= (CoreException) targetException;
- IStatus status= coreException.getStatus();
- if (status != null) {
- switch (status.getSeverity()) {
- case IStatus.INFO:
- MessageDialog.openInformation(shell, title, msg);
- break;
- case IStatus.WARNING:
- MessageDialog.openWarning(shell, title, msg);
- break;
- default:
- MessageDialog.openError(shell, title, msg);
- }
- } else {
- MessageDialog.openError(shell, title, msg);
+ IStatus status= x.getStatus();
+ if (status != null) {
+ switch (status.getSeverity()) {
+ case IStatus.INFO:
+ MessageDialog.openInformation(shell, title, msg);
+ break;
+ case IStatus.WARNING:
+ MessageDialog.openWarning(shell, title, msg);
+ break;
+ default:
+ MessageDialog.openError(shell, title, msg);
}
+ } else {
+ MessageDialog.openError(shell, title, msg);
}
} finally {
@@ -286,12 +272,7 @@ public class TextEditor extends ExtendedTextEditor {
protected void createActions() {
super.createActions();
- ResourceAction action= new AddTaskAction(TextEditorMessages.getResourceBundle(), "Editor.AddTask.", this); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.ADD_TASK_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.ADD_TASK);
- setAction(ITextEditorActionConstants.ADD_TASK, action);
-
- action= new ConvertLineDelimitersAction(TextEditorMessages.getResourceBundle(), "Editor.ConvertToWindows.", this, "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
+ ResourceAction action= new ConvertLineDelimitersAction(TextEditorMessages.getResourceBundle(), "Editor.ConvertToWindows.", this, "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$
action.setHelpContextId(IAbstractTextEditorHelpContextIds.CONVERT_LINE_DELIMITERS_TO_WINDOWS);
action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONVERT_LINE_DELIMITERS_TO_WINDOWS);
setAction(ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS, action);
@@ -382,5 +363,4 @@ public class TextEditor extends ExtendedTextEditor {
if (fEncodingSupport != null)
fEncodingSupport.reset();
}
-
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java
index f69331513..8b2b6b312 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java
@@ -18,6 +18,7 @@ import org.eclipse.jface.action.MenuManager;
import org.eclipse.ui.IActionBars;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.ide.IDEActionFactory;
import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
import org.eclipse.ui.texteditor.ITextEditor;
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
@@ -69,6 +70,12 @@ public class TextEditorActionContributor extends BasicTextEditorActionContributo
ITextEditor textEditor= null;
if (part instanceof ITextEditor)
textEditor= (ITextEditor) part;
+
+ IActionBars actionBars= getActionBars();
+ if (actionBars != null) {
+ actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
+ actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
+ }
// line delimiter conversion
fConvertToWindows.setAction(getAction(textEditor, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS));
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 47be742ed..a760bb4ca 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
@@ -52,6 +52,7 @@ import org.eclipse.ui.IEditorInput;
import org.eclipse.ui.IFileEditorInput;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
import org.eclipse.ui.texteditor.IDocumentProvider;
import org.eclipse.ui.texteditor.IDocumentProviderExtension;
import org.eclipse.ui.texteditor.IDocumentProviderExtension2;
@@ -501,6 +502,10 @@ public class TextFileDocumentProvider implements IDocumentProvider, IDocumentPr
FileInfo info= (FileInfo) fFileInfoMap.get(element);
if (info != null) {
info.fTextFileBuffer.commit(monitor, overwrite);
+ if (info.fModel instanceof AbstractMarkerAnnotationModel) {
+ AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;
+ model.updateMarkers(info.fTextFileBuffer.getDocument());
+ }
} else if (element instanceof IFileEditorInput) {
try {
monitor.beginTask("Saving", 2000);
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/WorkspaceOperationRunner.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/WorkspaceOperationRunner.java
new file mode 100644
index 000000000..f575d5778
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/WorkspaceOperationRunner.java
@@ -0,0 +1,62 @@
+/*******************************************************************************
+ * 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.editors.text;
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+
+import org.eclipse.jface.operation.IRunnableContext;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+
+import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
+
+/**
+ * @since 3.0
+ */
+public class WorkspaceOperationRunner implements IRunnableContext {
+
+ private IProgressMonitor fProgressMonitor;
+
+ public WorkspaceOperationRunner() {
+ }
+
+ /**
+ * Sets the progress monitor.
+ *
+ * @param progressMonitor the progress monitor to set
+ */
+ public void setProgressMonitor(IProgressMonitor progressMonitor) {
+ fProgressMonitor= progressMonitor;
+ }
+
+ /**
+ * Returns the progress monitor. It there is no progress monitor the monitor\
+ * is set to the <code>NullProgressMonitor</code>.
+ *
+ * @return the progress monitor
+ */
+ public IProgressMonitor getProgressMonitor() {
+ if (fProgressMonitor == null)
+ fProgressMonitor= new NullProgressMonitor();
+ return fProgressMonitor;
+ }
+
+ /*
+ * @see org.eclipse.jface.operation.IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
+ */
+ public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
+ WorkspaceModifyDelegatingOperation operation= new WorkspaceModifyDelegatingOperation(runnable);
+ operation.run(getProgressMonitor());
+ }
+}
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 510bd0648..8f792f7b7 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
@@ -21,8 +21,11 @@ import org.eclipse.core.runtime.Status;
import org.eclipse.jface.preference.IPreferenceStore;
+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.MarkerAnnotationPreferences;
/**
* Represents the editors plug-in. It provides a series of convenience methods such as
@@ -67,6 +70,7 @@ public class EditorsPlugin extends AbstractUIPlugin {
private FileEditorInputAdapterFactory fFileEditorInputAdapterFactory;
+ private ISharedTextColors fSharedTextColors;
public EditorsPlugin(IPluginDescriptor descriptor) {
@@ -79,6 +83,7 @@ public class EditorsPlugin extends AbstractUIPlugin {
* @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore)
*/
protected void initializeDefaultPreferences(IPreferenceStore store) {
+ MarkerAnnotationPreferences.initializeDefaultValues(store);
TextEditorPreferenceConstants.initializeDefaultValues(store);
}
@@ -98,6 +103,24 @@ public class EditorsPlugin extends AbstractUIPlugin {
public void shutdown() throws CoreException {
IAdapterManager manager= Platform.getAdapterManager();
manager.unregisterAdapters(fFileEditorInputAdapterFactory);
+
+ if (fSharedTextColors != null) {
+ fSharedTextColors.dispose();
+ fSharedTextColors= null;
+ }
+
super.shutdown();
}
+
+ /**
+ * Returns the shared text colors of this plug-in.
+ *
+ * @since 3.0
+ * @return the shared text colors
+ */
+ public ISharedTextColors getSharedTextColors() {
+ if (fSharedTextColors == null)
+ fSharedTextColors= new SharedTextColors();
+ return fSharedTextColors;
+ }
}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
new file mode 100644
index 000000000..63d33bd94
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
@@ -0,0 +1,189 @@
+/*******************************************************************************
+ * 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.internal.editors.text;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.ISelection;
+
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate2;
+import org.eclipse.ui.texteditor.AnnotationPreference;
+import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
+
+/**
+ * The abstract class for next and previous pulldown action delegates.
+ *
+ * @since 3.0
+ */
+public abstract class NextPreviousPulldownActionDelegate extends Action implements IMenuCreator, IWorkbenchWindowPulldownDelegate2 {
+
+ /** The cached menu. */
+ private Menu fMenu;
+
+ /** The preference store */
+ private IPreferenceStore fStore;
+
+ /** Action for handling menu item selection. */
+ private static class NavigationEnablementAction extends Action {
+
+ /** The preference store. */
+ private IPreferenceStore fStore;
+
+ /** The preference key for the value in the store. */
+ private String fKey;
+
+ /**
+ * Creates a named navigation enablement action.
+ *
+ * @param name the name of this action.
+ */
+ public NavigationEnablementAction(String name, IPreferenceStore store, String key) {
+ super(name, IAction.AS_CHECK_BOX);
+ fStore= store;
+ fKey= key;
+ setChecked(fStore.getBoolean(fKey));
+ }
+
+ /*
+ * @see IAction#run()
+ */
+ public void run() {
+ fStore.setValue(fKey, isChecked());
+ }
+ }
+
+ /**
+ * Returns the preference key to be used in the
+ * <code>NavigationEnablementAction</code>.
+ *
+ * @return the preference key or <code>null</code> if the key is not defined in XML
+ */
+ public abstract String getPreferenceKey(AnnotationPreference annotationPreference);
+
+ /*
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Control)
+ */
+ public Menu getMenu(Control parent) {
+ if (fMenu != null)
+ fMenu.dispose();
+
+ fMenu= new Menu(parent);
+ fillMenu(fMenu);
+
+ return fMenu;
+ }
+
+ /**
+ * Creates a next previous action delegate.
+ */
+ public NextPreviousPulldownActionDelegate() {
+ fStore= EditorsPlugin.getDefault().getPreferenceStore();
+ }
+
+ /*
+ * @see org.eclipse.jface.action.IMenuCreator#getMenu(org.eclipse.swt.widgets.Menu)
+ */
+ public Menu getMenu(Menu parent) {
+ if (fMenu == null) {
+ fMenu= new Menu(parent);
+ fillMenu(fMenu);
+ }
+
+ return fMenu;
+ }
+
+ /*
+ * @see org.eclipse.jface.action.IMenuCreator#dispose()
+ */
+ public void dispose() {
+ if (fMenu != null) {
+ fMenu.dispose();
+ fMenu= null;
+ }
+ }
+
+ /**
+ * Fills the given menu using marker
+ * annotation preferences.
+ *
+ * @param menu the menu to fill
+ */
+ private void fillMenu(Menu menu) {
+ IAction[] actions= getActionsFromDescriptors();
+
+ for (int i= 0; i < actions.length; i++) {
+ ActionContributionItem item= new ActionContributionItem(actions[i]);
+ item.fill(menu, -1);
+ }
+ }
+
+ /**
+ * Creates actions using marker
+ * annotation preferences.
+ *
+ * @return the navigation enablement actions
+ */
+ private IAction[] getActionsFromDescriptors() {
+ MarkerAnnotationPreferences fMarkerAnnotationPreferences= new MarkerAnnotationPreferences();
+ ArrayList containers= new ArrayList();
+
+ Iterator iter= fMarkerAnnotationPreferences.getAnnotationPreferences().iterator();
+ while (iter.hasNext()) {
+ AnnotationPreference preference= (AnnotationPreference)iter.next();
+ String key= preference.getShowInNextPrevDropdownToolbarActionKey();
+ if (key != null && fStore.getBoolean(key)) {
+ String preferenceKey= getPreferenceKey(preference);
+
+ /*
+ * Fixes bug 41689
+ * This code can be simplified if we decide that
+ * we don't allow to use different settings for go to
+ * previous and go to next annotation.
+ */
+ preferenceKey= preference.getIsGoToNextNavigationTargetKey();
+
+ if (preferenceKey != null)
+ containers.add(new NavigationEnablementAction(preference.getPreferenceLabel(), fStore, preferenceKey));
+ }
+ }
+
+ return (IAction[]) containers.toArray(new Action[containers.size()]);
+ }
+
+ /*
+ * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
+ */
+ public void init(IWorkbenchWindow window) {
+ }
+
+ /*
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ */
+ public void run(IAction action) {
+ }
+
+ /*
+ * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
+ */
+ public void selectionChanged(IAction action, ISelection selection) {
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPulldownActionDelegate.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPulldownActionDelegate.java
new file mode 100644
index 000000000..2ca4a1a44
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPulldownActionDelegate.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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.internal.editors.text;
+
+import org.eclipse.ui.texteditor.AnnotationPreference;
+
+/**
+ * The next pulldown action delegate.
+ *
+ * @since 3.0
+ */
+public class NextPulldownActionDelegate extends NextPreviousPulldownActionDelegate {
+
+ /*
+ * @see org.eclipse.ui.internal.texteditor.NextPreviousPulldownActionDelegate#getPreferenceKey(AnnotationPreference)
+ */
+ public String getPreferenceKey(AnnotationPreference annotationPreference) {
+ return annotationPreference.getIsGoToNextNavigationTargetKey();
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PreviousPulldownActionDelegate.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PreviousPulldownActionDelegate.java
new file mode 100644
index 000000000..812b58d4a
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PreviousPulldownActionDelegate.java
@@ -0,0 +1,30 @@
+/*******************************************************************************
+ * 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.internal.editors.text;
+
+import org.eclipse.ui.texteditor.AnnotationPreference;
+
+/**
+ * The previous pulldown action delegate.
+ *
+ * @since 3.0
+ */
+public class PreviousPulldownActionDelegate extends NextPreviousPulldownActionDelegate {
+
+ /*
+ * @see org.eclipse.ui.internal.texteditor.NextPreviousPulldownActionDelegate#getPreferenceKey(AnnotationPreference)
+ */
+ public String getPreferenceKey(AnnotationPreference annotationPreference) {
+ return annotationPreference.getIsGoToPreviousNavigationTargetKey();
+ }
+
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
new file mode 100644
index 000000000..5047227c1
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
@@ -0,0 +1,76 @@
+/*******************************************************************************
+ * 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.internal.editors.text;
+
+import java.util.Iterator;
+import org.eclipse.swt.widgets.Display;
+import java.util.Map;
+import java.util.HashMap;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.swt.graphics.RGB;
+
+/*
+ * @see org.eclipse.jface.text.source.ISharedTextColors
+ * @since 2.1
+ */
+class SharedTextColors implements ISharedTextColors {
+
+ /** The display table. */
+ private Map fDisplayTable;
+
+ /** Creates an returns a shared color manager. */
+ public SharedTextColors() {
+ super();
+ }
+
+ /*
+ * @see ISharedTextColors#getColor(RGB)
+ */
+ public Color getColor(RGB rgb) {
+ if (rgb == null)
+ return null;
+
+ if (fDisplayTable == null)
+ fDisplayTable= new HashMap(2);
+
+ Display display= Display.getCurrent();
+
+ Map colorTable= (Map) fDisplayTable.get(display);
+ if (colorTable == null) {
+ colorTable= new HashMap(10);
+ fDisplayTable.put(display, colorTable);
+ }
+
+ Color color= (Color) colorTable.get(rgb);
+ if (color == null) {
+ color= new Color(display, rgb);
+ colorTable.put(rgb, color);
+ }
+
+ return color;
+ }
+
+ /*
+ * @see ISharedTextColors#dispose()
+ */
+ public void dispose() {
+ if (fDisplayTable != null) {
+ Iterator j= fDisplayTable.values().iterator();
+ while (j.hasNext()) {
+ Iterator i= ((Map) j.next()).values().iterator();
+ while (i.hasNext())
+ ((Color) i.next()).dispose();
+ }
+ }
+ }
+
+}
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
new file mode 100644
index 000000000..e0ca39802
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
@@ -0,0 +1,591 @@
+/*******************************************************************************
+ * 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.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+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.jface.text.Assert;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.AnnotationModel;
+
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
+
+/**
+ * Abstract implementation of a marker-based annotation model.
+ * <p>
+ * Markers are provided by an underlying source (a subclass responsibility).
+ * Markers whose textual range gets deleted during text editing are removed
+ * from the model on save. The <code>updateMarkers</code> method can be used
+ * to force the model to update the source's markers with any changes to their
+ * locations due to edits. Clients can register <code>IMarkerUpdater</code>
+ * objects in order to define the process of marker updating. Registration can be done
+ * using the <code>"org.eclipse.ui.markerUpdaters"</code> extension point.</p>
+ * <p>
+ * Subclasses must implement the following methods:
+ * <ul>
+ * <li><code>retrieveMarkers</code></li>
+ * <li><code>isAcceptable</code></li>
+ * <li><code>deleteMarkers</code></li>
+ * <li><code>listenToMarkerChanges</code></li>
+ * </ul>
+ * </p>
+ */
+public abstract class AbstractMarkerAnnotationModel extends AnnotationModel {
+
+ /** List of annotations whose text range became invalid because of document changes */
+ private List fDeletedAnnotations= new ArrayList(2);
+ /** List of registered and instantiated marker updaters */
+ private List fInstantiatedMarkerUpdaters= null;
+ /** List of registered but not yet instantiated marker updaters */
+ private List fMarkerUpdaterSpecifications= null;
+
+
+ /**
+ * Retrieves all markers from this model.
+ * <p>
+ * Subclasses must implement this method.</p>
+ *
+ * @return the list of markers
+ * @exception CoreException if there is a problem getting the markers
+ */
+ protected abstract IMarker[] retrieveMarkers() throws CoreException;
+
+ /**
+ * Deletes the given markers from this model.
+ * <p>
+ * Subclasses must implement this method.</p>
+ *
+ * @param markers the array of markers
+ * @exception CoreException if there are problems deleting the markers
+ */
+ protected abstract void deleteMarkers(IMarker[] markers) throws CoreException;
+
+ /**
+ * Tells the model whether it should listen for marker changes.
+ * <p>
+ * Subclasses must implement this method.</p>
+ *
+ * @param listen <code>true</code> if this model should listen, and
+ * <code>false</code> otherwise
+ */
+ protected abstract void listenToMarkerChanges(boolean listen);
+
+ /**
+ * Determines whether the marker is acceptable as an addition to this model.
+ * If the marker, say, represents an aspect or range of no interest to this
+ * model, the marker is rejected.
+ * <p>
+ * Subclasses must implement this method.</p>
+ *
+ * @param marker the marker
+ * @return <code>true</code> if the marker is acceptable
+ */
+ protected abstract boolean isAcceptable(IMarker marker);
+
+ /**
+ * Creates a new annotation model. The annotation model does not manage any
+ * annotations and is not connected to any document.
+ */
+ protected AbstractMarkerAnnotationModel() {
+ }
+
+ /**
+ * Adds the given marker updater to this annotation model.
+ * It is the client's responsibility to ensure the consitency
+ * of the set of registered marker updaters.
+ *
+ * @param markerUpdater the marker updater to be added
+ */
+ protected void addMarkerUpdater(IMarkerUpdater markerUpdater) {
+ if (!fInstantiatedMarkerUpdaters.contains(markerUpdater))
+ fInstantiatedMarkerUpdaters.add(markerUpdater);
+ }
+
+ /**
+ * Removes the given marker updater from this annotation model.
+ *
+ * @param markerUpdater the marker updater to be removed
+ */
+ protected void removeMarkerUpdater(IMarkerUpdater markerUpdater) {
+ fInstantiatedMarkerUpdaters.remove(markerUpdater);
+ }
+
+ /**
+ * Creates a new annotation for the given marker.
+ * <p>
+ * Subclasses may override.</p>
+ *
+ * @param marker the marker
+ * @return the new marker annotation
+ */
+ protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
+ return new MarkerAnnotation(marker);
+ }
+
+ /**
+ * Handles an unanticipated <code>CoreException</code> in
+ * a standard manner.
+ *
+ * @param exception the exception
+ * @param message a message to aid debugging
+ */
+ protected void handleCoreException(CoreException exception, String message) {
+
+ ILog log= Platform.getPlugin(PlatformUI.PLUGIN_ID).getLog();
+
+ if (message != null)
+ log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, exception));
+ else
+ log.log(exception.getStatus());
+ }
+
+ /**
+ * Creates and returns the character position of the given marker based
+ * on its attributes.
+ * <p>
+ * Subclasses may override.</p>
+ *
+ * @param marker the marker
+ * @return the new position or <code>null</code> if the marker attributes do not specify a valid position
+ */
+ protected Position createPositionFromMarker(IMarker marker) {
+
+ int start= MarkerUtilities.getCharStart(marker);
+ int end= MarkerUtilities.getCharEnd(marker);
+
+ if (start > end) {
+ end= start + end;
+ start= end - start;
+ end= end - start;
+ }
+
+ if (start == -1 && end == -1) {
+ // marker line number is 1-based
+ int line= MarkerUtilities.getLineNumber(marker);
+ if (line > 0 && fDocument != null) {
+ try {
+ start= fDocument.getLineOffset(line - 1);
+ end= start;
+ } catch (BadLocationException x) {
+ }
+ }
+ }
+
+ if (start > -1 && end > -1)
+ return new Position(start, end - start);
+
+ return null;
+ }
+
+ /**
+ * Creates an annotation for the given marker and adds it to this model.
+ * Does nothing if the marker is not acceptable to this model.
+ *
+ * @param marker the marker
+ * @see #isAcceptable(IMarker)
+ */
+ protected final void addMarkerAnnotation(IMarker marker) {
+
+ if (isAcceptable(marker)) {
+ Position p= createPositionFromMarker(marker);
+ if (p != null)
+ try {
+ addAnnotation(createMarkerAnnotation(marker), p, false);
+ } catch (BadLocationException e) {
+ // ignore invalid position
+ }
+ }
+ }
+
+ /**
+ * Connects to the source of markers as marker change listener.
+ * @see AnnotationModel#connected()
+ */
+ protected void connected() {
+
+ listenToMarkerChanges(true);
+
+ try {
+ catchupWithMarkers();
+ } catch (CoreException x) {
+ if (x.getStatus().getCode() != IResourceStatus.RESOURCE_NOT_FOUND)
+ handleCoreException(x, TextEditorMessages.getString("AbstractMarkerAnnotationModel.connected")); //$NON-NLS-1$
+ }
+
+ fireModelChanged();
+ }
+
+ /**
+ * Installs all marker updaters for this marker annotation model.
+ */
+ private void installMarkerUpdaters() {
+
+ // initialize lists - indicates that the initialization happened
+ fMarkerUpdaterSpecifications= new ArrayList(2);
+ fInstantiatedMarkerUpdaters= new ArrayList(2);
+
+ // populate list
+ IExtensionPoint extensionPoint= Platform.getPluginRegistry().getExtensionPoint(EditorsPlugin.getPluginId(), "markerUpdaters"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
+ for (int i= 0; i < elements.length; i++)
+ fMarkerUpdaterSpecifications.add(elements[i]);
+ }
+ }
+
+ /**
+ * Uninstalls all marker updaters.
+ */
+ private void uninstallMarkerUpdaters() {
+ if (fInstantiatedMarkerUpdaters != null) {
+ fInstantiatedMarkerUpdaters.clear();
+ fInstantiatedMarkerUpdaters= null;
+ }
+
+ if (fMarkerUpdaterSpecifications != null) {
+ fMarkerUpdaterSpecifications.clear();
+ fMarkerUpdaterSpecifications= null;
+ }
+ }
+
+ /**
+ * Removes the marker change listener.
+ * @see AnnotationModel#disconnected()
+ */
+ protected void disconnected() {
+ listenToMarkerChanges(false);
+ uninstallMarkerUpdaters();
+ }
+
+ /**
+ * Returns the position known to this annotation model for the given marker.
+ *
+ * @param marker the marker
+ * @return the position, or <code>null</code> if none
+ */
+ public Position getMarkerPosition(IMarker marker) {
+ MarkerAnnotation a= getMarkerAnnotation(marker);
+ if (a != null) {
+ return (Position) fAnnotations.get(a);
+ }
+ return null;
+ }
+
+ /**
+ * Updates the annotation corresponding to the given marker which has changed
+ * in some way.
+ * <p>
+ * Subclasses may override.</p>
+ *
+ * @param marker the marker
+ */
+ 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());
+ }
+ }
+ }
+
+ /*
+ * @see AnnotationModel#removeAnnotations(List, boolean, boolean)
+ */
+ protected void removeAnnotations(List annotations, boolean fireModelChanged, boolean modelInitiated) {
+ if (annotations != null && annotations.size() > 0) {
+
+ List markerAnnotations= new ArrayList();
+ for (Iterator e= annotations.iterator(); e.hasNext();) {
+ Annotation a= (Annotation) e.next();
+ if (a instanceof MarkerAnnotation)
+ markerAnnotations.add(a);
+
+ // remove annotations from annotation model
+ removeAnnotation(a, false);
+ }
+
+ if (markerAnnotations.size() > 0) {
+
+ if (modelInitiated) {
+ // if model initiated also remove it from the marker manager
+
+ listenToMarkerChanges(false);
+ try {
+
+ IMarker[] m= new IMarker[markerAnnotations.size()];
+ for (int i= 0; i < m.length; i++) {
+ MarkerAnnotation ma = (MarkerAnnotation) markerAnnotations.get(i);
+ m[i]= ma.getMarker();
+ }
+ deleteMarkers(m);
+
+ } catch (CoreException x) {
+ handleCoreException(x, TextEditorMessages.getString("AbstractMarkerAnnotationModel.removeAnnotations")); //$NON-NLS-1$
+ }
+ listenToMarkerChanges(true);
+
+ } else {
+ // remember deleted annotations in order to remove their markers later on
+ fDeletedAnnotations.addAll(markerAnnotations);
+ }
+ }
+
+ if (fireModelChanged)
+ fireModelChanged();
+ }
+ }
+
+ /**
+ * Removes the annotation corresponding to the given marker. Does nothing
+ * if there is no annotation for this marker.
+ *
+ * @param marker the marker
+ */
+ protected final void removeMarkerAnnotation(IMarker marker) {
+ MarkerAnnotation a= getMarkerAnnotation(marker);
+ if (a != null) {
+ removeAnnotation(a, false);
+ }
+ }
+
+ /**
+ * Re-populates this model with annotations for all markers retrieved
+ * from the maker source via <code>retrieveMarkers</code>.
+ *
+ * @exception CoreException if there is a problem getting the markers
+ */
+ private void catchupWithMarkers() throws CoreException {
+
+ for (Iterator e=getAnnotationIterator(false); e.hasNext();) {
+ Annotation a= (Annotation) e.next();
+ if (a instanceof MarkerAnnotation)
+ removeAnnotation(a, false);
+ }
+
+ IMarker[] markers= retrieveMarkers();
+ if (markers != null) {
+ for (int i= 0; i < markers.length; i++)
+ addMarkerAnnotation(markers[i]);
+ }
+ }
+
+ /**
+ * Returns this model's annotation for the given marker.
+ *
+ * @param marker the marker
+ * @return the annotation, or <code>null</code> if none
+ */
+ public final MarkerAnnotation getMarkerAnnotation(IMarker marker) {
+ Iterator e= getAnnotationIterator(false);
+ while (e.hasNext()) {
+ Object o= e.next();
+ if (o instanceof MarkerAnnotation) {
+ MarkerAnnotation a= (MarkerAnnotation) o;
+ if (marker.equals(a.getMarker())) {
+ return a;
+ }
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Creates a marker updater as specified in the given configuration element.
+ *
+ * @param element the configuration element
+ * @return the created marker updater or <code>null</code> if none could be created
+ */
+ private IMarkerUpdater createMarkerUpdater(IConfigurationElement element) {
+ try {
+ return (IMarkerUpdater) element.createExecutableExtension("class"); //$NON-NLS-1$
+ } catch (CoreException x) {
+ handleCoreException(x, TextEditorMessages.getString("AbstractMarkerAnnotationModel.createMarkerUpdater")); //$NON-NLS-1$
+ }
+
+ return null;
+ }
+
+ /**
+ * Checks whether a marker updater is registered for the type of the
+ * given marker but not yet instantiated. If so, the method instantiates
+ * the marker updater and registers it with this model.
+ *
+ * @param marker the marker for which to look for an updater
+ * @since 2.0
+ */
+ private void checkMarkerUpdaters(IMarker marker) {
+ List toBeDeleted= new ArrayList();
+ for (int i= 0; i < fMarkerUpdaterSpecifications.size(); i++) {
+ IConfigurationElement spec= (IConfigurationElement) fMarkerUpdaterSpecifications.get(i);
+ String markerType= spec.getAttribute("markerType"); //$NON-NLS-1$
+ if (markerType == null || MarkerUtilities.isMarkerType(marker, markerType)) {
+ toBeDeleted.add(spec);
+ IMarkerUpdater updater= createMarkerUpdater(spec);
+ if (updater != null)
+ addMarkerUpdater(updater);
+ }
+ }
+
+ for (int i= 0; i < toBeDeleted.size(); i++)
+ fMarkerUpdaterSpecifications.remove(toBeDeleted.get(i));
+ }
+
+ /**
+ * Updates the given marker according to the given position in the given
+ * document. If the given position is <code>null</code>, the marker is
+ * assumed to carry the correct positional information. If it is detected
+ * that the marker is invalid and should thus be deleted, this method
+ * returns <code>false</code>.
+ *
+ * @param marker the marker to be updated
+ * @param document the document into which the given position points
+ * @param position the current position of the marker inside the given document
+ * @exception CoreException if there is a problem updating the marker
+ * @since 2.0
+ */
+ public boolean updateMarker(IMarker marker, IDocument document, Position position) throws CoreException {
+
+ if (fMarkerUpdaterSpecifications == null)
+ installMarkerUpdaters();
+
+ if (!fMarkerUpdaterSpecifications.isEmpty())
+ checkMarkerUpdaters(marker);
+
+ boolean isOK= true;
+
+ for (int i= 0; i < fInstantiatedMarkerUpdaters.size(); i++) {
+ IMarkerUpdater updater= (IMarkerUpdater) fInstantiatedMarkerUpdaters.get(i);
+ String markerType= updater.getMarkerType();
+ if (markerType == null || MarkerUtilities.isMarkerType(marker, markerType)) {
+
+ if (position == null) {
+ /* compatibility code */
+ position= createPositionFromMarker(marker);
+ }
+
+ isOK= (isOK && updater.updateMarker(marker, document, position));
+ }
+ }
+
+ return isOK;
+ }
+
+ /**
+ * Updates the markers managed by this annotation model by calling
+ * all registered marker updaters (<code>IMarkerUpdater</code>).
+ *
+ * @param document the document to which this model is currently connected
+ * @exception CoreException if there is a problem updating the markers
+ */
+ public void updateMarkers(IDocument document) throws CoreException {
+
+ Assert.isTrue(fDocument == document);
+
+ if (fAnnotations.size() == 0 && fDeletedAnnotations.size() == 0)
+ return;
+
+ if (fMarkerUpdaterSpecifications == null)
+ installMarkerUpdaters();
+
+ listenToMarkerChanges(false);
+
+ // update all markers with the positions known by the annotation model
+ for (Iterator e= getAnnotationIterator(false); e.hasNext();) {
+ Object o= e.next();
+ if (o instanceof MarkerAnnotation) {
+ MarkerAnnotation a= (MarkerAnnotation) o;
+ IMarker marker= a.getMarker();
+ Position position= (Position) fAnnotations.get(a);
+ if ( !updateMarker(marker, document, position)) {
+ if ( !fDeletedAnnotations.contains(a))
+ fDeletedAnnotations.add(a);
+ }
+ }
+ }
+
+ if (!fDeletedAnnotations.isEmpty()) {
+ removeAnnotations(fDeletedAnnotations, true, true);
+ fDeletedAnnotations.clear();
+ }
+
+ listenToMarkerChanges(true);
+ }
+
+ /**
+ * Resets all the markers to their original state.
+ */
+ public void resetMarkers() {
+
+ // reinitializes the positions from the markers
+ for (Iterator e= getAnnotationIterator(false); e.hasNext();) {
+ Object o= e.next();
+ if (o instanceof MarkerAnnotation) {
+ MarkerAnnotation a= (MarkerAnnotation) o;
+ Position p= createPositionFromMarker(a.getMarker());
+ if (p != null) {
+ removeAnnotation(a, false);
+ try {
+ addAnnotation(a, p, false);
+ } catch (BadLocationException e1) {
+ // ignore invalid position
+ }
+ }
+ }
+ }
+
+ // add the markers of deleted positions back to the annotation model
+ for (Iterator e= fDeletedAnnotations.iterator(); e.hasNext();) {
+ Object o= e.next();
+ if (o instanceof MarkerAnnotation) {
+ MarkerAnnotation a= (MarkerAnnotation) o;
+ Position p= createPositionFromMarker(a.getMarker());
+ if (p != null)
+ try {
+ addAnnotation(a, p, false);
+ } catch (BadLocationException e1) {
+ // ignore invalid position
+ }
+ }
+ }
+ fDeletedAnnotations.clear();
+
+ // fire annotation model changed
+ fireModelChanged();
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
new file mode 100644
index 000000000..01a1deb80
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
@@ -0,0 +1,324 @@
+/*******************************************************************************
+ * 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.Map;
+import java.util.ResourceBundle;
+
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.window.Window;
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+
+
+
+/**
+ * Action for creating a marker of a specified type for the editor's
+ * input element based on the editor's selection. If required, the
+ * action asks the user to provide a marker label. The action is initially
+ * associated with a text editor via the constructor, but that can be
+ * subsequently changed using <code>setEditor</code>.
+ * <p>
+ * The following keys, prepended by the given option prefix,
+ * are used for retrieving resources from the given bundle:
+ * <ul>
+ * <li><code>"dialog.title"</code> - the input dialog's title</li>
+ * <li><code>"dialog.message"</code> - the input dialog's message</li>
+ * <li><code>"error.dialog.title"</code> - the error dialog's title</li>
+ * <li><code>"error.dialog.message"</code> - the error dialog's message</li>
+ * </ul>
+ * This class may be instantiated but is not intended for subclassing.
+ * </p>
+ */
+public class AddMarkerAction extends TextEditorAction {
+
+
+ /** The maximum length of an proposed label. */
+ private static final int MAX_LABEL_LENGTH= 10;
+ /** The type for newly created markers */
+ private String fMarkerType;
+ /** Should the user be asked for a label? */
+ private boolean fAskForLabel;
+ /** The action's resource bundle */
+ private ResourceBundle fBundle;
+ /** The prefix used for resource bundle lookup */
+ private String fPrefix;
+
+
+ /**
+ * Creates a new action for the given text editor. The action configures its
+ * visual representation from the given resource bundle.
+ *
+ * @param bundle the resource bundle
+ * @param prefix a prefix to be prepended to the various resource keys
+ * (described in <code>ResourceAction</code> constructor), or
+ * <code>null</code> if none
+ * @param textEditor the text editor
+ * @param markerType the type of marker to add
+ * @param askForLabel <code>true</code> if the user should be asked for
+ * a label for the new marker
+ * @see ResourceAction#ResourceAction
+ */
+ public AddMarkerAction(ResourceBundle bundle, String prefix, ITextEditor textEditor, String markerType, boolean askForLabel) {
+ super(bundle, prefix, textEditor);
+ fBundle= bundle;
+ fPrefix= prefix;
+ fMarkerType= markerType;
+ fAskForLabel= askForLabel;
+ }
+
+ /**
+ * Returns this action's resource bundle.
+ *
+ * @return this action's resource bundle
+ */
+ protected ResourceBundle getResourceBundle() {
+ return fBundle;
+ }
+
+ /**
+ * Returns this action's resource key prefix.
+ *
+ * @return this action's resource key prefix
+ */
+ protected String getResourceKeyPrefix() {
+ return fPrefix;
+ }
+
+ /*
+ * @see IAction#run()
+ */
+ public void run() {
+ IResource resource= getResource();
+ if (resource == null)
+ return;
+ Map attributes= getInitialAttributes();
+ if (fAskForLabel) {
+ if (!askForLabel(attributes))
+ return;
+ }
+
+ try {
+ MarkerUtilities.createMarker(resource, attributes, fMarkerType);
+ } catch (CoreException x) {
+
+ Platform.getPlugin(PlatformUI.PLUGIN_ID).getLog().log(x.getStatus());
+
+ Shell shell= getTextEditor().getSite().getShell();
+ String title= getString(fBundle, fPrefix + "error.dialog.title", fPrefix + "error.dialog.title"); //$NON-NLS-2$ //$NON-NLS-1$
+ String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$
+
+ ErrorDialog.openError(shell, title, msg, x.getStatus());
+ }
+ }
+
+ /*
+ * @see TextEditorAction#update()
+ */
+ public void update() {
+ setEnabled(getResource() != null);
+ }
+
+ /**
+ * Asks the user for a marker label. Returns <code>true</code> if a label
+ * is entered, <code>false</code> if the user cancels the input dialog.
+ * The value for the attribute <code>message</code> is modified in the given
+ * attribute map.
+ *
+ * @param attributes the attributes map
+ * @return <code>true</code> if a label has been entered
+ */
+ protected boolean askForLabel(Map attributes) {
+
+ Object o= attributes.get("message"); //$NON-NLS-1$
+ String proposal= (o instanceof String) ? (String) o : ""; //$NON-NLS-1$
+ if (proposal == null)
+ proposal= ""; //$NON-NLS-1$
+
+ String title= getString(fBundle, fPrefix + "dialog.title", fPrefix + "dialog.title"); //$NON-NLS-2$ //$NON-NLS-1$
+ String message= getString(fBundle, fPrefix + "dialog.message", fPrefix + "dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$
+ IInputValidator inputValidator = new IInputValidator() {
+ public String isValid(String newText) {
+ return (newText == null || newText.trim().length() == 0) ? " " : null; //$NON-NLS-1$
+ }
+ };
+ InputDialog dialog= new InputDialog(getTextEditor().getSite().getShell(), title, message, proposal, inputValidator);
+
+ String label= null;
+ if (dialog.open() != Window.CANCEL)
+ label= dialog.getValue();
+
+ if (label == null)
+ return false;
+
+ label= label.trim();
+ if (label.length() == 0)
+ return false;
+
+ attributes.put("message", label); //$NON-NLS-1$
+ return true;
+ }
+
+ /**
+ * Returns the attributes the new marker will be initialized with.
+ * <p>
+ * Subclasses may extend or replace this method.</p>
+ *
+ * @return the attributes the new marker will be initialized with
+ */
+ protected Map getInitialAttributes() {
+
+ Map attributes= new HashMap(11);
+
+ ITextSelection selection= (ITextSelection) getTextEditor().getSelectionProvider().getSelection();
+ if (!selection.isEmpty()) {
+
+ int start= selection.getOffset();
+ int length= selection.getLength();
+
+ if (length < 0) {
+ length= -length;
+ start -= length;
+ }
+
+ MarkerUtilities.setCharStart(attributes, start);
+ MarkerUtilities.setCharEnd(attributes, start + length);
+
+ // marker line numbers are 1-based
+ int line= selection.getStartLine();
+ MarkerUtilities.setLineNumber(attributes, line == -1 ? -1 : line + 1);
+
+ IDocument document= getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
+ MarkerUtilities.setMessage(attributes, getLabelProposal(document, start, length));
+
+ }
+
+ return attributes;
+ }
+
+ /**
+ * Returns the initial label for the marker.
+ *
+ * @param document the document from which to extract a label proposal
+ * @param offset the document offset of the range from which to extract the label proposal
+ * @param length the length of the range from which to extract the label proposal
+ * @return the label proposal
+ */
+ protected String getLabelProposal(IDocument document, int offset, int length) {
+
+
+ try {
+
+
+ if (length > 0) {
+
+ // find first white char but skip leading white chars
+ int i= 0;
+ boolean skip= true;
+ while (i < length) {
+ boolean isWhitespace= Character.isWhitespace(document.getChar(offset + i));
+ if (!skip && isWhitespace)
+ break;
+ if (skip && !isWhitespace)
+ skip= false;
+ i++;
+ }
+
+ String label= document.get(offset, i);
+ return label.trim();
+ }
+
+
+ char ch;
+
+ // Get the first white char before the selection.
+ int left= offset;
+
+ int line= document.getLineOfOffset(offset);
+ int limit= document.getLineOffset(line);
+
+ while (left > limit) {
+ ch= document.getChar(left);
+ if (Character.isWhitespace(ch))
+ break;
+ --left;
+ }
+
+ limit += document.getLineLength(line);
+
+ // Now get the first letter.
+ while (left <= limit) {
+ ch= document.getChar(left);
+ if (!Character.isWhitespace(ch))
+ break;
+ ++left;
+ }
+
+ if (left > limit)
+ return null;
+
+ limit= Math.min(limit, left + MAX_LABEL_LENGTH);
+
+ // Get the next white char.
+ int right= (offset + length > limit ? limit : offset + length);
+ while (right < limit) {
+ ch= document.getChar(right);
+ if (Character.isWhitespace(ch))
+ break;
+ ++right;
+ }
+
+ // Trim the string and return it.
+ if (left != right) {
+ String label= document.get(left, right - left);
+ return label.trim();
+ }
+
+ } catch (BadLocationException x) {
+ // don't proposal label then
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the resource on which to create the marker,
+ * or <code>null</code> if there is no applicable resource. This
+ * queries the editor's input using <code>getAdapter(IResource.class)</code>.
+ * Subclasses may override this method.
+ *
+ * @return the resource to which to attach the newly created marker
+ */
+ protected IResource getResource() {
+ ITextEditor editor= getTextEditor();
+ if (editor != null) {
+ IEditorInput input= editor.getEditorInput();
+ return (IResource) ((IAdaptable) input).getAdapter(IResource.class);
+ }
+ return null;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java
new file mode 100644
index 000000000..4440eae64
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java
@@ -0,0 +1,98 @@
+/*******************************************************************************
+ * 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.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+
+import org.eclipse.core.resources.IMarker;
+
+
+/**
+ * Updates a marker's positional attributes which are
+ * start position, end position, and line number.
+ */
+public final class BasicMarkerUpdater implements IMarkerUpdater {
+
+ private final static String[] ATTRIBUTES= {
+ IMarker.CHAR_START,
+ IMarker.CHAR_END,
+ IMarker.LINE_NUMBER
+ };
+
+ /**
+ * Creates a new basic marker updater.
+ */
+ public BasicMarkerUpdater() {
+ super();
+ }
+
+ /*
+ * @see IMarkerUpdater#getAttribute()
+ */
+ public String[] getAttribute() {
+ return ATTRIBUTES;
+ }
+
+ /*
+ * @see IMarkerUpdater#getMarkerType()
+ */
+ public String getMarkerType() {
+ return null;
+ }
+
+ /*
+ * @see IMarkerUpdater#updateMarker(IMarker, IDocument, Position)
+ */
+ public boolean updateMarker(IMarker marker, IDocument document, Position position) {
+
+ if (position == null)
+ return true;
+
+ if (position.isDeleted())
+ return false;
+
+ boolean offsetsInitialized= false;
+ boolean offsetsChanged= false;
+ int markerStart= MarkerUtilities.getCharStart(marker);
+ int markerEnd= MarkerUtilities.getCharEnd(marker);
+
+ if (markerStart != -1 && markerEnd != -1) {
+
+ offsetsInitialized= true;
+
+ int offset= position.getOffset();
+ if (markerStart != offset) {
+ MarkerUtilities.setCharStart(marker, offset);
+ offsetsChanged= true;
+ }
+
+ offset += position.getLength();
+ if (markerEnd != offset) {
+ MarkerUtilities.setCharEnd(marker, offset);
+ offsetsChanged= true;
+ }
+ }
+
+ if (!offsetsInitialized || (offsetsChanged && MarkerUtilities.getLineNumber(marker) != -1)) {
+ try {
+ // marker line numbers are 1-based
+ MarkerUtilities.setLineNumber(marker, document.getLineOfOffset(position.getOffset()) + 1);
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return true;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BookmarkRulerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BookmarkRulerAction.java
new file mode 100644
index 000000000..1ff5846f9
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BookmarkRulerAction.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.IMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+
+/**
+ * Adapter for the managing bookmark action.
+ * @since 2.0
+ */
+public class BookmarkRulerAction extends AbstractRulerActionDelegate {
+
+ /**
+ * @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
+ */
+ protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
+ return new MarkerRulerAction(TextEditorMessages.getResourceBundle(), "Editor.ManageBookmarks.", editor, rulerInfo, IMarker.BOOKMARK, true); //$NON-NLS-1$
+ }
+}
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
new file mode 100644
index 000000000..128b75c35
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultAnnotation.java
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * 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.lang.reflect.InvocationTargetException;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+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.swt.widgets.Display;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.source.Annotation;
+
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+/**
+ * Default annotation.
+ * This class may be instantiated or be subclassed.
+ * <p>
+ * XXX: This is work in progress and can change anytime until API for 3.0 is frozen.
+ * </p>
+ * @since 3.0
+ */
+public class DefaultAnnotation extends Annotation implements IAnnotationExtension {
+
+ /**
+ * The layer in which task annotations are located.
+ */
+ public final static int TASK_LAYER= 1;
+
+ /**
+ * The layer in which bookmarks annotatons are located.
+ */
+ public final static int BOOKMARK_LAYER= 2;
+
+ /**
+ * The layer in which info annotations are located.
+ */
+ public final static int INFO_LAYER= 3;
+
+ /**
+ * The layer in which warning annotations representing are located.
+ */
+ public final static int WARNING_LAYER= 4;
+
+ /**
+ * The layer in which error annotations representing are located.
+ */
+ public final static int ERROR_LAYER= 5;
+
+ /** Internal image registry */
+ private static Map fgImageRegistry;
+ /** Internal type to descriptor map */
+ private static Map fgType2Descriptor= new HashMap();
+ /** Indicates that no descriptor was found */
+ private static final Object NO_DESCRIPTOR= new Object();
+
+ protected Image fImage;
+ protected String fImageName;
+
+ private int fSeverity;
+ private boolean fIsTemporary;
+ private String fMessage;
+ private String fAnnotationType;
+
+ private boolean fIsInitialized= false;
+
+ /**
+ * 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
+ */
+ protected static Image getImage(Display display, ImageDescriptor descriptor) {
+ Map map= getImageRegistry(display);
+ Image image= (Image) map.get(descriptor);
+ if (image == null) {
+ image= descriptor.createImage();
+ map.put(descriptor, image);
+ }
+ return image;
+ }
+
+ /**
+ * Returns an image registry for the given display. If no such registry exists
+ * the resgitry is created.
+ *
+ * @param display the display
+ * @return the image registry for the given display
+ */
+ protected static Map getImageRegistry(Display display) {
+ if (fgImageRegistry == null) {
+ fgImageRegistry= new HashMap();
+ display.disposeExec(new Runnable() {
+ public void run() {
+ if (fgImageRegistry != null) {
+ Map map= fgImageRegistry;
+ fgImageRegistry= null;
+ Iterator e= map.values().iterator();
+ while (e.hasNext()) {
+ Image image= (Image) e.next();
+ if (!image.isDisposed())
+ image.dispose();
+ }
+ }
+ }
+ });
+ }
+ return fgImageRegistry;
+ }
+
+ /**
+ * Returns whether the given annotationType is of the given type.
+ * <p>
+ * XXX: See bug 41478 why we don't match sub-types
+ * </p>
+ *
+ * @param annotationType the annotationType to be checked
+ * @param type the reference type
+ * @return <code>true</code>if annotationType is an instance of the reference type
+ */
+ private static boolean isAnnotationType(String annotationType, String type) {
+ return annotationType != null && annotationType.equals(type);
+ }
+
+ /**
+ * Creates a new editor annotation.
+ *
+ * @param annotationType the type of this annotation
+ * @param severity the severity of this annotation
+ * @param isTemporary <code>true</code> if this is a temporary annotation
+ * @param message the message of this annotation
+ */
+ public DefaultAnnotation(String annotationType, int severity, boolean isTemporary, String message) {
+ Assert.isTrue(severity == IMarker.SEVERITY_INFO || severity == IMarker.SEVERITY_WARNING || severity == IMarker.SEVERITY_ERROR);
+ fSeverity= severity;
+ fIsTemporary= isTemporary;
+ fMessage= message;
+ fAnnotationType= annotationType;
+ }
+
+ /**
+ * Initializes the annotation's icon representation and its drawing layer
+ * based upon the properties of the underlying marker.
+ */
+ protected void initialize() {
+
+ String name= getUnknownImageName(fAnnotationType);
+ int layer= 1;
+
+ if (isAnnotationType(fAnnotationType, IMarker.TASK)) {
+ name= IDE.SharedImages.IMG_OBJS_TASK_TSK;
+ layer= TASK_LAYER;
+ } else if (isAnnotationType(fAnnotationType, IMarker.BOOKMARK)) {
+ name= IDE.SharedImages.IMG_OBJS_BKMRK_TSK;
+ layer= BOOKMARK_LAYER;
+ } else if (isAnnotationType(fAnnotationType, IMarker.PROBLEM)) {
+ switch (fSeverity) {
+ case IMarker.SEVERITY_INFO:
+ name= ISharedImages.IMG_OBJS_INFO_TSK;
+ layer= INFO_LAYER;
+ break;
+ case IMarker.SEVERITY_WARNING:
+ name= ISharedImages.IMG_OBJS_WARN_TSK;
+ layer= WARNING_LAYER;
+ break;
+ case IMarker.SEVERITY_ERROR:
+ name= ISharedImages.IMG_OBJS_ERROR_TSK;
+ layer= ERROR_LAYER;
+ break;
+ }
+ }
+
+ fImage= null;
+ fImageName= name;
+ setLayer(layer);
+ }
+
+ /**
+ * 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.
+ *
+ * @return the name of an image for markers of unknown type.
+ */
+ protected String getUnknownImageName(String annotationType) {
+ return null;
+ }
+
+ /*
+ * @see Annotation#paint(GC, Canvas, Rectangle)
+ */
+ public void paint(GC gc, Canvas canvas, Rectangle r) {
+ Image image= getImage(canvas.getDisplay());
+ if (image != null)
+ drawImage(image, gc, canvas, r, SWT.CENTER, SWT.TOP);
+ }
+
+ /**
+ * Sets the marker image to the given image.
+ *
+ * @param image the new marker image
+ */
+ protected void setImage(Image image) {
+ fImage= image;
+ }
+
+ /**
+ * Returns the image of the given name. Subclasses may extend this method.
+ * If so, subclasses must assume responsibility for disposing the images
+ * they create.
+ *
+ * @param name the name of the requested image
+ * @return the image or <code>null</code> if there is no such image
+ */
+ protected Image getImage(String name) {
+ if (name != null)
+ return PlatformUI.getWorkbench().getSharedImages().getImage(name);
+ return null;
+ }
+
+ /*
+ * @see IJavaAnnotation#getImage(Display)
+ */
+ protected Image getImage(final Display display) {
+
+ if (!fIsInitialized) {
+ fIsInitialized= true;
+ initialize();
+ }
+
+ if (fImage != null)
+ return fImage;
+
+ final String key= fAnnotationType + fSeverity;
+
+ Object descriptor= fgType2Descriptor.get(key);
+ if (descriptor == NO_DESCRIPTOR)
+ fImage= getImage(fImageName);
+ else if (descriptor != null)
+ fImage= getImage(display, (ImageDescriptor)descriptor);
+
+ if (fImage != null)
+ return fImage;
+
+ // XXX: hack since I cannot get the image for a marker type
+ WorkspaceModifyOperation r= new WorkspaceModifyOperation() {
+ /*
+ * @see WorkspaceModifyOperation
+ */
+ public void execute(IProgressMonitor monitor) throws CoreException,InvocationTargetException, InterruptedException {
+ IMarker tempMarker= ResourcesPlugin.getWorkspace().getRoot().createMarker(fAnnotationType);
+ tempMarker.setAttribute(IMarker.SEVERITY, fSeverity);
+ if (tempMarker.exists()) {
+ IWorkbenchAdapter adapter= (IWorkbenchAdapter) tempMarker.getAdapter(IWorkbenchAdapter.class);
+ if (adapter != null) {
+ Object imageDescriptor= adapter.getImageDescriptor(tempMarker);
+ if (imageDescriptor != null) {
+ fImage= getImage(display, (ImageDescriptor)imageDescriptor);
+ fgType2Descriptor.put(key, imageDescriptor);
+ } else {
+ fgType2Descriptor.put(key, NO_DESCRIPTOR);
+ }
+ }
+ tempMarker.delete();
+ }
+ }
+ };
+ try {
+ r.run(null);
+ } catch (InvocationTargetException ex) {
+ fgType2Descriptor.put(key, NO_DESCRIPTOR);
+ } catch (InterruptedException ex) {
+ fgType2Descriptor.put(key, NO_DESCRIPTOR);
+ }
+
+ if (fImage == null)
+ fImage= getImage(fImageName);
+
+ return fImage;
+ }
+
+ /*
+ * @see IAnnotationExtension#getMessage()
+ */
+ public String getMessage() {
+ return fMessage;
+ }
+
+ public String getMarkerType() {
+ return fAnnotationType;
+ }
+
+ /*
+ * @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
new file mode 100644
index 000000000..1e5318afe
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
@@ -0,0 +1,144 @@
+/*******************************************************************************
+ * 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.Iterator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationAccess;
+import org.eclipse.jface.text.source.IAnnotationAccessExtension;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
+
+/**
+ * @since 2.1
+ */
+public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnotationAccessExtension {
+
+ /** Constant for the unknown marker type */
+ public final static String UNKNOWN= EditorsPlugin.getPluginId() + ".unknown"; //$NON-NLS-1$
+
+ /** The marker annotation preferences */
+ protected MarkerAnnotationPreferences fMarkerAnnotationPreferences;
+
+ /**
+ * Returns a new default marker annotation access with the given preferences.
+ *
+ * @param markerAnnotationPreferences
+ */
+ 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.
+ *
+ * @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;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IAnnotationAccess#getType(org.eclipse.jface.text.source.Annotation)
+ */
+ public Object getType(Annotation annotation) {
+ if (annotation instanceof MarkerAnnotation) {
+ MarkerAnnotation markerAnnotation= (MarkerAnnotation) annotation;
+ IMarker marker= markerAnnotation.getMarker();
+ if (marker != null && marker.exists()) {
+ AnnotationPreference preference= getAnnotationPreference(marker);
+ if (preference != null)
+ return preference.getAnnotationType();
+ }
+ } else if (annotation instanceof IAnnotationExtension) {
+ IAnnotationExtension annotationExtension= (IAnnotationExtension)annotation;
+ AnnotationPreference preference= getAnnotationPreference(annotationExtension.getMarkerType(), annotationExtension.getSeverity());
+ if (preference != null)
+ return preference.getAnnotationType();
+ }
+ return UNKNOWN;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IAnnotationAccess#isMultiLine(org.eclipse.jface.text.source.Annotation)
+ */
+ public boolean isMultiLine(Annotation annotation) {
+ return true;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IAnnotationAccess#isTemporary(org.eclipse.jface.text.source.Annotation)
+ */
+ public boolean isTemporary(Annotation annotation) {
+
+ if (annotation instanceof IAnnotationExtension)
+ return ((IAnnotationExtension)annotation).isTemporary();
+
+ return false;
+ }
+
+ /*
+ * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#getLabel(org.eclipse.jface.text.source.Annotation)
+ */
+ public String getTypeLabel(Annotation annotation) {
+ AnnotationPreference preference= null;
+ if (annotation instanceof MarkerAnnotation) {
+ MarkerAnnotation markerAnnotation= (MarkerAnnotation) annotation;
+ IMarker marker= markerAnnotation.getMarker();
+ if (marker != null && marker.exists()) {
+ preference= getAnnotationPreference(marker);
+ }
+ } else if (annotation instanceof IAnnotationExtension) {
+ IAnnotationExtension annotationExtension= (IAnnotationExtension)annotation;
+ preference= getAnnotationPreference(annotationExtension.getMarkerType(), annotationExtension.getSeverity());
+ }
+ if (preference != null)
+ return preference.getPreferenceLabel();
+
+ return null;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
new file mode 100644
index 000000000..2ff99547e
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
@@ -0,0 +1,301 @@
+/*******************************************************************************
+ * 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.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.StringTokenizer;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+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.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
+
+/**
+ * This registry manages shareable document provider. Document
+ * providers are specified in <code>plugin.xml</code> either
+ * per name extension or per editor input type. A name extension
+ * rule always overrules an editor input type rule. Editor input
+ * type rules follow the same rules <code>IAdapterManager</code>
+ * used to find object adapters.
+ *
+ * @see org.eclipse.core.runtime.IAdapterManager
+ */
+public class DocumentProviderRegistry {
+
+ /** The registry singleton. */
+ private static DocumentProviderRegistry fgRegistry;
+
+ /**
+ * Returns the standard document provider registry.
+ */
+ public static DocumentProviderRegistry getDefault() {
+ if (fgRegistry == null)
+ fgRegistry= new DocumentProviderRegistry();
+ return fgRegistry;
+ }
+
+
+ /** The mapping between name extensions and configuration elements. */
+ private Map fExtensionMapping= new HashMap();
+ /** The mapping between editor input type names and configuration elements. */
+ private Map fInputTypeMapping= new HashMap();
+ /** The mapping between configuration elements and instantiated document providers. */
+ private Map fInstances= new HashMap();
+
+
+ /**
+ * Creates a new document provider registry and intializes it with the information
+ * found in the plugin registry.
+ */
+ private DocumentProviderRegistry() {
+ initialize();
+ }
+
+ /**
+ * Reads the comma-separated value of the given configuration element
+ * for the given attribute name and remembers the configuration element
+ * in the given map under the individual tokens of the attribute value.
+ */
+ private void read(Map map, IConfigurationElement element, String attributeName) {
+ String value= element.getAttribute(attributeName);
+ if (value != null) {
+ StringTokenizer tokenizer= new StringTokenizer(value, ","); //$NON-NLS-1$
+ while (tokenizer.hasMoreTokens()) {
+ String token= tokenizer.nextToken().trim();
+
+ Set s= (Set) map.get(token);
+ if (s == null) {
+ s= new HashSet();
+ map.put(token, s);
+ }
+ s.add(element);
+ }
+ }
+ }
+
+ /**
+ * Initializes the document provider registry. It retrieves all implementers of the <code>documentProviders</code>
+ * extension point and remembers those implementers based on the name extensions and the editor input
+ * types they are for.
+ */
+ private void initialize() {
+
+ IExtensionPoint extensionPoint;
+ extensionPoint= Platform.getPluginRegistry().getExtensionPoint(EditorsPlugin.getPluginId(), "documentProviders"); //$NON-NLS-1$
+
+ if (extensionPoint == null) {
+ String msg= MessageFormat.format(TextEditorMessages.getString("DocumentProviderRegistry.error.extension_point_not_found"), new Object[] { PlatformUI.PLUGIN_ID }); //$NON-NLS-1$
+ ILog log= Platform.getPlugin(PlatformUI.PLUGIN_ID).getLog();
+ log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, msg, null));
+ return;
+ }
+
+ IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
+ for (int i= 0; i < elements.length; i++) {
+ read(fExtensionMapping, elements[i], "extensions"); //$NON-NLS-1$
+ read(fInputTypeMapping, elements[i], "inputTypes"); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Returns the document provider for the given configuration element.
+ * If there is no instantiated document provider remembered for this
+ * element, a new document provider is created and put into the cache.
+ */
+ private IDocumentProvider getDocumentProvider(IConfigurationElement entry) {
+ IDocumentProvider provider= (IDocumentProvider) fInstances.get(entry);
+ if (provider == null) {
+ try {
+ provider= (IDocumentProvider) entry.createExecutableExtension("class"); //$NON-NLS-1$
+ fInstances.put(entry, provider);
+ } catch (CoreException x) {
+ }
+ }
+ return provider;
+ }
+
+ /**
+ * Returns the first enumerated element of the given set.
+ */
+ private IConfigurationElement selectConfigurationElement(Set set) {
+ if (set != null && !set.isEmpty()) {
+ Iterator e= set.iterator();
+ return (IConfigurationElement) e.next();
+ }
+ return null;
+ }
+
+ /**
+ * Returns a shareable document provider for the given name extension.
+ *
+ * @param extension the name extension to be used for lookup
+ * @return the shareable document provider or <code>null</code>
+ */
+ public IDocumentProvider getDocumentProvider(String extension) {
+
+ Set set= (Set) fExtensionMapping.get(extension);
+ if (set != null) {
+ IConfigurationElement entry= selectConfigurationElement(set);
+ return getDocumentProvider(entry);
+ }
+ return null;
+ }
+
+ /**
+ * Computes the class hierarchy of the given type. The type is
+ * part of the computed hierarchy.
+ *
+ * @return a list with elements of type <code>Class</code>
+ */
+ private List computeClassList(Class type) {
+
+ List result= new ArrayList();
+
+ Class c= type;
+ while (c != null) {
+ result.add(c);
+ c= c.getSuperclass();
+ }
+
+ return result;
+ }
+
+ /**
+ * Computes the list of all interfaces for the given list of
+ * classes. The interface lists of the given classes are
+ * concatenated.
+ *
+ * @return a list with elements of type <code>Class</code>
+ */
+ private List computeInterfaceList(List classes) {
+
+ List result= new ArrayList(4);
+ Hashtable visited= new Hashtable(4);
+
+ Iterator e= classes.iterator();
+ while (e.hasNext()) {
+ Class c= (Class) e.next();
+ computeInterfaceList(c.getInterfaces(), result, visited);
+ }
+
+ return result;
+ }
+
+ /**
+ * Computes the list of all interfaces of the given list of interfaces,
+ * taking a depth-first approach.
+ */
+ private void computeInterfaceList(Class[] interfaces, List result, Hashtable visited) {
+
+ List toBeVisited= new ArrayList(interfaces.length);
+
+ for (int i= 0; i < interfaces.length; i++) {
+ Class iface= interfaces[i];
+ if (visited.get(iface) == null) {
+ visited.put(iface, iface);
+ result.add(iface);
+ toBeVisited.add(iface);
+ }
+ }
+
+ Iterator e= toBeVisited.iterator();
+ while(e.hasNext()) {
+ Class iface= (Class) e.next();
+ computeInterfaceList(iface.getInterfaces(), result, visited);
+ }
+ }
+
+ /**
+ * Returns the configuration elements for the first class in the list
+ * of given classes for which configuration elements have been remembered.
+ *
+ * returns an input type mapping or <code>null</code>
+ */
+ private Object getFirstInputTypeMapping(List classes) {
+ Iterator e= classes.iterator();
+ while (e.hasNext()) {
+ Class c= (Class) e.next();
+ Object mapping= fInputTypeMapping.get(c.getName());
+ if (mapping != null)
+ return mapping;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the appropriate configuration element for the given type. If
+ * there is no configuration element for the type's name, first the list of
+ * super classes is searched, and if not successful the list of all interfaces.
+ *
+ * returns an input type mapping or <code>null</code>
+ */
+ private Object findInputTypeMapping(Class type) {
+
+ if (type == null)
+ return null;
+
+ Object mapping= fInputTypeMapping.get(type.getName());
+ if (mapping != null)
+ return mapping;
+
+ List classList= computeClassList(type);
+ mapping= getFirstInputTypeMapping(classList);
+ if (mapping != null)
+ return mapping;
+
+ return getFirstInputTypeMapping(computeInterfaceList(classList));
+ }
+
+ /**
+ * Returns the shareable document for the type of the given editor input.
+ *
+ * @param editorInput the input for whose type the provider is looked up
+ * @return the shareable document provider
+ */
+ public IDocumentProvider getDocumentProvider(IEditorInput editorInput) {
+
+ IDocumentProvider provider= null;
+
+ IFile file= (IFile) editorInput.getAdapter(IFile.class);
+ if (file != null)
+ provider= getDocumentProvider(file.getFileExtension());
+
+ if (provider == null) {
+ Set set= (Set) findInputTypeMapping(editorInput.getClass());
+ if (set != null) {
+ IConfigurationElement entry= selectConfigurationElement(set);
+ provider= getDocumentProvider(entry);
+ }
+ }
+
+ return provider;
+ }
+}
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
new file mode 100644
index 000000000..3d55b2bdb
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditor.java
@@ -0,0 +1,1010 @@
+/*******************************************************************************
+ * 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.Iterator;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.runtime.IStatus;
+
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.util.PropertyChangeEvent;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.AnnotationRulerColumn;
+import org.eclipse.jface.text.source.ChangeRulerColumn;
+import org.eclipse.jface.text.source.CompositeRuler;
+import org.eclipse.jface.text.source.IAnnotationAccess;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IAnnotationModelExtension;
+import org.eclipse.jface.text.source.IChangeRulerColumn;
+import org.eclipse.jface.text.source.IOverviewRuler;
+import org.eclipse.jface.text.source.ISharedTextColors;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.ISourceViewerExtension;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.IVerticalRulerColumn;
+import org.eclipse.jface.text.source.LineChangeHover;
+import org.eclipse.jface.text.source.LineNumberChangeRulerColumn;
+import org.eclipse.jface.text.source.LineNumberRulerColumn;
+import org.eclipse.jface.text.source.OverviewRuler;
+import org.eclipse.jface.text.source.SourceViewer;
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.editors.text.ITextEditorHelpContextIds;
+import org.eclipse.ui.ide.IDEActionFactory;
+import org.eclipse.ui.ide.IGotoMarker;
+import org.eclipse.ui.texteditor.quickdiff.QuickDiff;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+import org.eclipse.ui.internal.texteditor.quickdiff.DocumentLineDiffer;
+
+/**
+ * An intermediate editor comprising functionality not present in the leaner <code>AbstractTextEditor</code>,
+ * but used in many heavy weight (and especially source editing) editors, such as line numbers,
+ * change ruler, overview ruler, print margins, current line highlighting, etc.
+ *
+ * <p>Note that this is work in progress and API is still subject to change for <code>3.0</code>.</p>
+ *
+ * @since 3.0
+ */
+public abstract class ExtendedTextEditor extends StatusTextEditor {
+ /**
+ * Preference key for showing the line number ruler.
+ */
+ private final static String LINE_NUMBER_RULER= ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER;
+ /**
+ * Preference key for the foreground color of the line numbers.
+ */
+ private final static String LINE_NUMBER_COLOR= ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR;
+ /**
+ * Preference key for showing the overview ruler.
+ */
+ private final static String OVERVIEW_RULER= ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER;
+ /**
+ * Preference key for highlighting current line.
+ */
+ private final static String CURRENT_LINE= ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE;
+ /**
+ * Preference key for highlight color of current line.
+ */
+ private final static String CURRENT_LINE_COLOR= ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
+ /**
+ * Preference key for showing print marging ruler.
+ */
+ private final static String PRINT_MARGIN= ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN;
+ /**
+ * Preference key for print margin ruler color.
+ */
+ private final static String PRINT_MARGIN_COLOR= ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
+ /**
+ * Preference key for print margin ruler column.
+ */
+ private final static String PRINT_MARGIN_COLUMN= ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
+
+ /**
+ * Adapter class for <code>IGotoMarker</code>.
+ */
+ private class GotoMarkerAdapter implements IGotoMarker {
+ public void gotoMarker(IMarker marker) {
+ ExtendedTextEditor.this.gotoMarker(marker);
+ }
+ }
+
+ /**
+ * The annotation preferences.
+ */
+ private MarkerAnnotationPreferences fAnnotationPreferences;
+ /**
+ * The overview ruler of this editor.
+ *
+ * <p>This field should not be referenced by subclasses. It is <code>protected</code> for API
+ * compatibility reasons and will be made <code>private</code> soon. Use
+ * {@link #getOverviewRuler()} instead.</p>
+ */
+ protected IOverviewRuler fOverviewRuler;
+ /**
+ * Helper for accessing annotation from the perspective of this editor.
+ *
+ * <p>This field should not be referenced by subclasses. It is <code>protected</code> for API
+ * compatibility reasons and will be made <code>private</code> soon. Use
+ * {@link #getAnnotationAccess()} instead.</p>
+ */
+ protected IAnnotationAccess fAnnotationAccess;
+ /**
+ * Helper for managing the decoration support of this editor's viewer.
+ *
+ * <p>This field should not be referenced by subclasses. It is <code>protected</code> for API
+ * compatibility reasons and will be made <code>private</code> soon. Use
+ * {@link #getSourceViewerDecorationSupport(ISourceViewer)} instead.</p>
+ */
+ protected SourceViewerDecorationSupport fSourceViewerDecorationSupport;
+ /**
+ * The line number column.
+ *
+ * <p>This field should not be referenced by subclasses. It is <code>protected</code> for API
+ * compatibility reasons and will be made <code>private</code> soon. Use
+ * {@link AbstractTextEditor#getVerticalRuler()} to access the vertical bar instead.</p>
+ */
+ protected LineNumberRulerColumn fLineNumberRulerColumn;
+ /**
+ * The change ruler column.
+ */
+ private IChangeRulerColumn fChangeRulerColumn;
+ /**
+ * Whether quick diff information is displayed, either on a change ruler or the line number ruler.
+ */
+ private boolean fIsChangeInformationShown;
+ /**
+ * The annotation ruler column used in the vertical ruler.
+ * @since 3.0
+ */
+ private AnnotationRulerColumn fAnnotationRulerColumn;
+ /**
+ * The editor's implicit document provider.
+ * @since 3.0
+ */
+ private IDocumentProvider fImplicitDocumentProvider;
+ /**
+ * The editor's goto marker adapter.
+ * @since 3.0
+ */
+ private Object fGotoMarkerAdapter= new GotoMarkerAdapter();
+
+
+ /**
+ * Creates a new text editor.
+ */
+ public ExtendedTextEditor() {
+ super();
+ fAnnotationPreferences= new MarkerAnnotationPreferences();
+ setRangeIndicator(new DefaultRangeIndicator());
+ initializeKeyBindingScopes();
+ initializeEditor();
+ }
+
+ /**
+ * Initializes this editor.
+ */
+ protected void initializeEditor() {
+ setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
+ }
+
+ /**
+ * Initializes the key binding scopes of this editor.
+ */
+ protected void initializeKeyBindingScopes() {
+ setKeyBindingScopes(new String[] { "org.eclipse.ui.textEditorScope" }); //$NON-NLS-1$
+ }
+
+ /*
+ * @see IWorkbenchPart#dispose()
+ */
+ public void dispose() {
+ if (fSourceViewerDecorationSupport != null) {
+ fSourceViewerDecorationSupport.dispose();
+ fSourceViewerDecorationSupport= null;
+ }
+
+ fAnnotationAccess= null;
+ fAnnotationPreferences= null;
+ fAnnotationRulerColumn= null;
+
+ super.dispose();
+ }
+
+ /*
+ * @see AbstractTextEditor#editorContextMenuAboutToShow(IMenuManager)
+ */
+ protected void editorContextMenuAboutToShow(IMenuManager menu) {
+ super.editorContextMenuAboutToShow(menu);
+ addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_RIGHT);
+ addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_LEFT);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#createSourceViewer(Composite, IVerticalRuler, int)
+ */
+ protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
+
+ fAnnotationAccess= createAnnotationAccess();
+ fOverviewRuler= createOverviewRuler(getSharedColors());
+
+ ISourceViewer viewer= new SourceViewer(parent, ruler, getOverviewRuler(), isOverviewRulerVisible(), styles);
+ // ensure decoration support has been created and configured.
+ getSourceViewerDecorationSupport(viewer);
+
+ return viewer;
+ }
+
+ protected ISharedTextColors getSharedColors() {
+ ISharedTextColors sharedColors= EditorsPlugin.getDefault().getSharedTextColors();
+ return sharedColors;
+ }
+
+ protected IOverviewRuler createOverviewRuler(ISharedTextColors sharedColors) {
+ IOverviewRuler ruler= new OverviewRuler(getAnnotationAccess(), VERTICAL_RULER_WIDTH, sharedColors);
+ Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ while (e.hasNext()) {
+ AnnotationPreference preference= (AnnotationPreference) e.next();
+ if (preference.contributesToHeader())
+ ruler.addHeaderAnnotationType(preference.getAnnotationType());
+ }
+ return ruler;
+ }
+
+ /**
+ * Creates the annotation access for this editor.
+ *
+ * @return the created annotation access
+ */
+ protected IAnnotationAccess createAnnotationAccess() {
+ return new DefaultMarkerAnnotationAccess(fAnnotationPreferences);
+ }
+
+ /**
+ * Configures the decoration support for this editor's the source viewer. Subclasses may override this
+ * method, but should call their superclass' implementation at some point.
+ */
+ protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
+
+ Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ while (e.hasNext())
+ support.setAnnotationPreference((AnnotationPreference) e.next());
+
+ support.setCursorLinePainterPreferenceKeys(CURRENT_LINE, CURRENT_LINE_COLOR);
+ support.setMarginPainterPreferenceKeys(PRINT_MARGIN, PRINT_MARGIN_COLOR, PRINT_MARGIN_COLUMN);
+ support.setSymbolicFontName(getFontPropertyPreferenceKey());
+ }
+
+ /*
+ * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
+ */
+ public void createPartControl(Composite parent) {
+ super.createPartControl(parent);
+ if (fSourceViewerDecorationSupport != null)
+ fSourceViewerDecorationSupport.install(getPreferenceStore());
+
+ if (isPrefQuickDiffAlwaysOn())
+ showChangeInformation(true);
+ }
+
+ /**
+ * Tells whether the overview ruler is visible.
+ */
+ protected boolean isOverviewRulerVisible() {
+ IPreferenceStore store= getPreferenceStore();
+ return store != null ? store.getBoolean(OVERVIEW_RULER) : false;
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.ITextEditorExtension3#showChangeInformation(boolean)
+ */
+ public void showChangeInformation(boolean show) {
+ if (show == fIsChangeInformationShown)
+ return;
+
+ if (fIsChangeInformationShown) {
+ uninstallChangeRulerModel();
+ showChangeRuler(false); // hide change ruler if its displayed - if the line number ruler is showing, only the colors get removed by deinstalling the model
+ } else {
+ ensureChangeInfoCanBeDisplayed();
+ installChangeRulerModel();
+ }
+
+ fIsChangeInformationShown= show;
+ }
+
+ /**
+ * Installs the differ annotation model with the current quick diff display.
+ */
+ private void installChangeRulerModel() {
+ IChangeRulerColumn column= getChangeColumn();
+ if (column != null)
+ column.setModel(getOrCreateDiffer());
+ IOverviewRuler ruler= getOverviewRuler();
+ if (ruler != null) {
+ ruler.addAnnotationType("org.eclipse.ui.workbench.texteditor.quickdiffChange"); //$NON-NLS-1$
+ ruler.addAnnotationType("org.eclipse.ui.workbench.texteditor.quickdiffAddition"); //$NON-NLS-1$
+ ruler.addAnnotationType("org.eclipse.ui.workbench.texteditor.quickdiffDeletion"); //$NON-NLS-1$
+ ruler.update();
+ }
+ }
+
+ /**
+ * Uninstalls the differ annotation model from the current quick diff display.
+ */
+ private void uninstallChangeRulerModel() {
+ IChangeRulerColumn column= getChangeColumn();
+ if (column != null)
+ column.setModel(null);
+ IOverviewRuler ruler= getOverviewRuler();
+ if (ruler != null) {
+ ruler.removeAnnotationType("org.eclipse.ui.workbench.texteditor.quickdiffChange"); //$NON-NLS-1$
+ ruler.removeAnnotationType("org.eclipse.ui.workbench.texteditor.quickdiffAddition"); //$NON-NLS-1$
+ ruler.removeAnnotationType("org.eclipse.ui.workbench.texteditor.quickdiffDeletion"); //$NON-NLS-1$
+ ruler.update();
+ }
+ IAnnotationModel model= getOrCreateDiffer();
+ if (model instanceof DocumentLineDiffer)
+ ((DocumentLineDiffer)model).suspend();
+ }
+
+ /**
+ * Ensures that either the line number display is a <code>LineNumberChangeRuler</code> or
+ * a separate change ruler gets displayed.
+ */
+ private void ensureChangeInfoCanBeDisplayed() {
+ if (isLineNumberRulerVisible()) {
+ if (!(fLineNumberRulerColumn instanceof IChangeRulerColumn)) {
+ hideLineNumberRuler();
+ // HACK: set state already so a change ruler is created. Not needed once always a change line number bar gets installed
+ fIsChangeInformationShown= true;
+ showLineNumberRuler();
+ }
+ } else
+ showChangeRuler(true);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.ITextEditorExtension3#isChangeInformationShowing()
+ */
+ public boolean isChangeInformationShowing() {
+ return fIsChangeInformationShown;
+ }
+
+ /**
+ * Extracts the line differ from the displayed document's annotation model. If none can be found,
+ * a new differ is created and attached to the annotation model.
+ *
+ * @return the linediffer, or <code>null</code> if none could be found or created.
+ */
+ private IAnnotationModel getOrCreateDiffer() {
+ // get annotation model extension
+ ISourceViewer viewer= getSourceViewer();
+ if (viewer == null)
+ return null;
+
+ IAnnotationModel m= viewer.getAnnotationModel();
+ IAnnotationModelExtension model;
+ if (m instanceof IAnnotationModelExtension)
+ model= (IAnnotationModelExtension) m;
+ else
+ return null;
+
+ // get diff model if it exists already
+ IAnnotationModel differ= model.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
+
+ // create diff model if it doesn't
+ if (differ == null) {
+ String defaultId= getPreferenceStore().getString(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER);
+ differ= new QuickDiff().createQuickDiffAnnotationModel(this, defaultId);
+ if (differ != null)
+ model.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, differ);
+ } else if (differ instanceof DocumentLineDiffer && !fIsChangeInformationShown)
+ ((DocumentLineDiffer)differ).resume();
+
+ return differ;
+ }
+
+ /**
+ * Returns the <code>IChangeRulerColumn</code> of this editor, or <code>null</code> if there is none. Either
+ * the line number bar or a separate change ruler column can be returned.
+ *
+ * @return an instance of <code>IChangeRulerColumn</code> or <code>null</code>.
+ */
+ private IChangeRulerColumn getChangeColumn() {
+ if (fChangeRulerColumn != null)
+ return fChangeRulerColumn;
+ else if (fLineNumberRulerColumn instanceof IChangeRulerColumn)
+ return (IChangeRulerColumn) fLineNumberRulerColumn;
+ else
+ return null;
+ }
+
+ /**
+ * Sets the display state of the separate change ruler column (not the quick diff display on
+ * the line number ruler column) to <code>show</code>.
+ *
+ * @param show <code>true</code> if the change ruler column should be shown, <code>false</code> if it should be hidden
+ */
+ private void showChangeRuler(boolean show) {
+ IVerticalRuler v= getVerticalRuler();
+ if (v instanceof CompositeRuler) {
+ CompositeRuler c= (CompositeRuler) v;
+ if (show && fChangeRulerColumn == null)
+ c.addDecorator(1, createChangeRulerColumn());
+ else if (!show && fChangeRulerColumn != null) {
+ c.removeDecorator(fChangeRulerColumn);
+ fChangeRulerColumn= null;
+ }
+ }
+ }
+
+ /**
+ * Shows the line number ruler column.
+ */
+ private void showLineNumberRuler() {
+ showChangeRuler(false);
+ if (fLineNumberRulerColumn == null) {
+ IVerticalRuler v= getVerticalRuler();
+ if (v instanceof CompositeRuler) {
+ CompositeRuler c= (CompositeRuler) v;
+ c.addDecorator(1, createLineNumberRulerColumn());
+ }
+ }
+ }
+
+ /**
+ * Hides the line number ruler column.
+ */
+ private void hideLineNumberRuler() {
+ if (fLineNumberRulerColumn != null) {
+ IVerticalRuler v= getVerticalRuler();
+ if (v instanceof CompositeRuler) {
+ CompositeRuler c= (CompositeRuler) v;
+ c.removeDecorator(fLineNumberRulerColumn);
+ }
+ fLineNumberRulerColumn = null;
+ }
+ if (fIsChangeInformationShown)
+ showChangeRuler(true);
+ }
+
+ /**
+ * Returns whether the line number ruler column should be
+ * visible according to the preference store settings. Subclasses may override this
+ * method to provide a custom preference setting.
+ *
+ * @return <code>true</code> if the line numbers should be visible
+ */
+ protected boolean isLineNumberRulerVisible() {
+ IPreferenceStore store= getPreferenceStore();
+ return store != null ? store.getBoolean(LINE_NUMBER_RULER) : false;
+ }
+
+ /**
+ * Returns whether quick diff info should be visible upon opening an editor
+ * according to the preference store settings.
+ *
+ * @return <code>true</code> if the line numbers should be visible
+ */
+ protected boolean isPrefQuickDiffAlwaysOn() {
+ IPreferenceStore store= getPreferenceStore();
+ return store.getBoolean(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON);
+ }
+
+ /**
+ * Initializes the given line number ruler column from the preference store.
+ *
+ * @param rulerColumn the ruler column to be initialized
+ */
+ protected void initializeLineNumberRulerColumn(LineNumberRulerColumn rulerColumn) {
+ ISharedTextColors sharedColors= getSharedColors();
+ IPreferenceStore store= getPreferenceStore();
+ if (store != null) {
+
+ RGB rgb= null;
+ // foreground color
+ if (store.contains(LINE_NUMBER_COLOR)) {
+ if (store.isDefault(LINE_NUMBER_COLOR))
+ rgb= PreferenceConverter.getDefaultColor(store, LINE_NUMBER_COLOR);
+ else
+ rgb= PreferenceConverter.getColor(store, LINE_NUMBER_COLOR);
+ }
+ if (rgb == null)
+ rgb= new RGB(0, 0, 0);
+ rulerColumn.setForeground(sharedColors.getColor(rgb));
+
+
+ rgb= null;
+ // background color: same as editor, or system default
+ if (!store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
+ if (store.contains(PREFERENCE_COLOR_BACKGROUND)) {
+ if (store.isDefault(PREFERENCE_COLOR_BACKGROUND))
+ rgb= PreferenceConverter.getDefaultColor(store, PREFERENCE_COLOR_BACKGROUND);
+ else
+ rgb= PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND);
+ }
+ }
+ rulerColumn.setBackground(sharedColors.getColor(rgb));
+
+ rulerColumn.redraw();
+ }
+ }
+
+ /**
+ * Initializes the given change ruler column from the preference store.
+ *
+ * @param changeColumn the ruler column to be initialized
+ */
+ private void initializeChangeRulerColumn(IChangeRulerColumn changeColumn) {
+ ISharedTextColors sharedColors= getSharedColors();
+ IPreferenceStore store= getPreferenceStore();
+
+ if (store != null) {
+ ISourceViewer v= getSourceViewer();
+ if (v != null && v.getAnnotationModel() != null) {
+ changeColumn.setModel(v.getAnnotationModel());
+ }
+
+ Iterator iter= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ while (iter.hasNext()) {
+ AnnotationPreference pref= (AnnotationPreference) iter.next();
+
+ if ("org.eclipse.quickdiff.changeindication".equals(pref.getMarkerType())) { //$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$
+ RGB rgb= getColorPreference(store, pref);
+ changeColumn.setAddedColor(sharedColors.getColor(rgb));
+ } else if ("org.eclipse.quickdiff.deletionindication".equals(pref.getMarkerType())) { //$NON-NLS-1$
+ RGB rgb= getColorPreference(store, pref);
+ changeColumn.setDeletedColor(sharedColors.getColor(rgb));
+ }
+ }
+
+ RGB rgb= null;
+ // background color: same as editor, or system default
+ if (!store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)) {
+ if (store.contains(PREFERENCE_COLOR_BACKGROUND)) {
+ if (store.isDefault(PREFERENCE_COLOR_BACKGROUND))
+ rgb= PreferenceConverter.getDefaultColor(store, PREFERENCE_COLOR_BACKGROUND);
+ else
+ rgb= PreferenceConverter.getColor(store, PREFERENCE_COLOR_BACKGROUND);
+ }
+ }
+ changeColumn.setBackground(sharedColors.getColor(rgb));
+
+ if (changeColumn instanceof LineNumberChangeRulerColumn) {
+ LineNumberChangeRulerColumn lncrc= (LineNumberChangeRulerColumn) changeColumn;
+ lncrc.setDisplayMode(store.getBoolean(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE));
+ }
+ }
+
+ changeColumn.redraw();
+ }
+
+ /**
+ * Extracts the color preference for <code>pref</code> from <code>store</code>. If <code>store</code>
+ * indicates that the default value is to be used, or the value stored in the preferences store is <code>null</code>,
+ * the value is taken from the <code>AnnotationPreference</code>'s default color value.
+ *
+ * <p>The return value is never <code>null</code></p>
+ *
+ * @param store
+ * @param pref
+ * @return
+ */
+ private RGB getColorPreference(IPreferenceStore store, AnnotationPreference pref) {
+ RGB rgb= null;
+ if (store.contains(pref.getColorPreferenceKey())) {
+ if (store.isDefault(pref.getColorPreferenceKey()))
+ rgb= pref.getColorPreferenceValue();
+ else
+ rgb= PreferenceConverter.getColor(store, pref.getColorPreferenceKey());
+ }
+ if (rgb == null)
+ rgb= pref.getColorPreferenceValue();
+ return rgb;
+ }
+
+ /**
+ * Creates a new line number ruler column that is appropriately initialized.
+ */
+ protected IVerticalRulerColumn createLineNumberRulerColumn() {
+ if (isPrefQuickDiffAlwaysOn() || isChangeInformationShowing()) {
+ LineNumberChangeRulerColumn column= new LineNumberChangeRulerColumn(getSharedColors());
+ column.setHover(createChangeHover());
+ initializeChangeRulerColumn(column);
+ fLineNumberRulerColumn= column;
+ } else {
+ fLineNumberRulerColumn= new LineNumberRulerColumn();
+ }
+ initializeLineNumberRulerColumn(fLineNumberRulerColumn);
+ return fLineNumberRulerColumn;
+ }
+
+ /**
+ * Creates and returns a <code>LineChangeHover</code> to be used on this editor's change
+ * ruler column. This default implementation returns a plain <code>LineChangeHover</code>.
+ * Subclasses may override.
+ *
+ * @return the change hover to be used by this editors quick diff display
+ */
+ protected LineChangeHover createChangeHover() {
+ return new LineChangeHover();
+ }
+
+ /**
+ * Creates a new change ruler column for quick diff display independent of the
+ * line number ruler column
+ *
+ * @return a new change ruler column
+ */
+ protected IChangeRulerColumn createChangeRulerColumn() {
+ IChangeRulerColumn column= new ChangeRulerColumn();
+ column.setHover(createChangeHover());
+ fChangeRulerColumn= column;
+ initializeChangeRulerColumn(fChangeRulerColumn);
+ return fChangeRulerColumn;
+ }
+
+ /**
+ * Returns {@link #createCompositeRuler()}. Subclasses should not override this method, but
+ * rather <code>createCompositeRuler</code> if they want to contribute their own vertical ruler
+ * implementation. If not an instance of {@link CompositeRuler} is returned, the built-in ruler
+ * columns (line numbers, annotations) will not work.
+ *
+ * <p>May become <code>final</code> in the future.</p>
+ *
+ * @see AbstractTextEditor#createVerticalRuler()
+ */
+ protected IVerticalRuler createVerticalRuler() {
+ CompositeRuler ruler= createCompositeRuler();
+ if (ruler != null) {
+ for (Iterator iter= ruler.getDecoratorIterator(); iter.hasNext();) {
+ IVerticalRulerColumn column= (IVerticalRulerColumn)iter.next();
+ if (column instanceof AnnotationRulerColumn) {
+ fAnnotationRulerColumn= (AnnotationRulerColumn)column;
+ for (Iterator iter2= fAnnotationPreferences.getAnnotationPreferences().iterator(); iter2.hasNext();) {
+ AnnotationPreference preference= (AnnotationPreference)iter2.next();
+ String key= preference.getVerticalRulerPreferenceKey();
+ boolean showAnnotation= true;
+ if (key != null)
+ showAnnotation= getPreferenceStore().getBoolean(key);
+ if (showAnnotation)
+ fAnnotationRulerColumn.addAnnotationType(preference.getAnnotationType());
+ }
+ fAnnotationRulerColumn.addAnnotationType(DefaultMarkerAnnotationAccess.UNKNOWN);
+ break;
+ }
+ }
+ }
+ return ruler;
+ }
+
+ /**
+ * Creates a composite ruler to be used as the vertical ruler by this editor.
+ * Subclasses may re-implement this method.
+ *
+ * @return the vertical ruler
+ */
+ protected CompositeRuler createCompositeRuler() {
+ CompositeRuler ruler= new CompositeRuler();
+ ruler.addDecorator(0, new AnnotationRulerColumn(VERTICAL_RULER_WIDTH, getAnnotationAccess()));
+
+ if (isLineNumberRulerVisible())
+ ruler.addDecorator(1, createLineNumberRulerColumn());
+ else if (isPrefQuickDiffAlwaysOn())
+ ruler.addDecorator(1, createChangeRulerColumn());
+
+ return ruler;
+ }
+
+ /*
+ * @see AbstractTextEditor#handlePreferenceStoreChanged(PropertyChangeEvent)
+ */
+ protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
+
+ try {
+
+ ISourceViewer sourceViewer= getSourceViewer();
+ if (sourceViewer == null)
+ return;
+
+ String property= event.getProperty();
+
+ if (fSourceViewerDecorationSupport != null && fOverviewRuler != null && OVERVIEW_RULER.equals(property)) {
+ if (isOverviewRulerVisible())
+ showOverviewRuler();
+ else
+ hideOverviewRuler();
+ return;
+ }
+
+ if (LINE_NUMBER_RULER.equals(property)) {
+ if (isLineNumberRulerVisible())
+ showLineNumberRuler();
+ else
+ hideLineNumberRuler();
+ return;
+ }
+
+ if (fLineNumberRulerColumn != null
+ && (LINE_NUMBER_COLOR.equals(property)
+ || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
+ || PREFERENCE_COLOR_BACKGROUND.equals(property))) {
+
+ initializeLineNumberRulerColumn(fLineNumberRulerColumn);
+ }
+
+ if (fChangeRulerColumn != null
+ && (LINE_NUMBER_COLOR.equals(property)
+ || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property)
+ || PREFERENCE_COLOR_BACKGROUND.equals(property))) {
+
+ initializeChangeRulerColumn(fChangeRulerColumn);
+ }
+
+ if (fLineNumberRulerColumn instanceof LineNumberChangeRulerColumn
+ && ExtendedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE.equals(property)) {
+ initializeChangeRulerColumn(getChangeColumn());
+ }
+
+ AnnotationPreference pref= getAnnotationPreference(property);
+ 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);
+ }
+ }
+ }
+
+ AnnotationPreference annotationPreference= getVerticalRulerAnnotationPreference(property);
+ if (annotationPreference != null && event.getNewValue() instanceof Boolean) {
+ Object type= annotationPreference.getAnnotationType();
+ if (((Boolean)event.getNewValue()).booleanValue())
+ fAnnotationRulerColumn.addAnnotationType(type);
+ else
+ fAnnotationRulerColumn.removeAnnotationType(type);
+ getVerticalRuler().update();
+ }
+
+ } finally {
+ super.handlePreferenceStoreChanged(event);
+ }
+ }
+
+ /**
+ * Returns the <code>AnnotationPreference</code> corresponding to <code>colorKey</code>.
+ *
+ * @param colorKey the color key.
+ * @return the corresponding <code>AnnotationPreference</code>
+ */
+ private AnnotationPreference getAnnotationPreference(String colorKey) {
+ for (Iterator iter= fAnnotationPreferences.getAnnotationPreferences().iterator(); iter.hasNext();) {
+ AnnotationPreference pref= (AnnotationPreference) iter.next();
+ if (colorKey.equals(pref.getColorPreferenceKey()))
+ return pref;
+ }
+ return null;
+ }
+
+ /**
+ * Returns the annotation preference for which the given
+ * preference matches a vertical ruler preference key.
+ *
+ * @param preferenceKey the preference key string
+ * @return the annotation preference or <code>null</code> if none
+ * @since 3.0
+ */
+ private AnnotationPreference getVerticalRulerAnnotationPreference(String preferenceKey) {
+ if (preferenceKey == null)
+ return null;
+
+ Iterator e= fAnnotationPreferences.getAnnotationPreferences().iterator();
+ while (e.hasNext()) {
+ AnnotationPreference info= (AnnotationPreference) e.next();
+ if (info != null && preferenceKey.equals(info.getVerticalRulerPreferenceKey()))
+ return info;
+ }
+ return null;
+ }
+
+ /**
+ * Shows the overview ruler.
+ */
+ protected void showOverviewRuler() {
+ if (fOverviewRuler != null) {
+ if (getSourceViewer() instanceof ISourceViewerExtension) {
+ ((ISourceViewerExtension) getSourceViewer()).showAnnotationsOverview(true);
+ fSourceViewerDecorationSupport.updateOverviewDecorations();
+ }
+ }
+ }
+
+ /**
+ * Hides the overview ruler.
+ */
+ protected void hideOverviewRuler() {
+ if (getSourceViewer() instanceof ISourceViewerExtension) {
+ fSourceViewerDecorationSupport.hideAnnotationOverview();
+ ((ISourceViewerExtension) getSourceViewer()).showAnnotationsOverview(false);
+ }
+ }
+
+ /**
+ * Returns the annotation access.
+ *
+ * @return the annotation access
+ */
+ protected IAnnotationAccess getAnnotationAccess() {
+ if (fAnnotationAccess == null)
+ fAnnotationAccess= createAnnotationAccess();
+ return fAnnotationAccess;
+ }
+
+ /**
+ * Returns the overview ruler.
+ *
+ * @return the overview ruler
+ */
+ protected IOverviewRuler getOverviewRuler() {
+ if (fOverviewRuler == null)
+ fOverviewRuler= createOverviewRuler(getSharedColors());
+ return fOverviewRuler;
+ }
+
+ /**
+ * Returns the source viewer decoration support.
+ *
+ * @return the source viewer decoration support
+ */
+ protected SourceViewerDecorationSupport getSourceViewerDecorationSupport(ISourceViewer viewer) {
+ if (fSourceViewerDecorationSupport == null) {
+ fSourceViewerDecorationSupport= new SourceViewerDecorationSupport(viewer, getOverviewRuler(), getAnnotationAccess(), getSharedColors());
+ configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
+ }
+ return fSourceViewerDecorationSupport;
+ }
+
+ /**
+ * Returns the annotation preferences.
+ *
+ * @return the annotation preferences
+ */
+ protected MarkerAnnotationPreferences getAnnotationPreferences() {
+ return fAnnotationPreferences;
+ }
+
+
+ /**
+ * If the editor can be saved all marker ranges have been changed according to
+ * the text manipulations. However, those changes are not yet propagated to the
+ * marker manager. Thus, when opening a marker, the marker's position in the editor
+ * must be determined as it might differ from the position stated in the marker.
+ *
+ * @param marker the marker to go to
+ * @deprecated visibility will be reduced, use <code>getAdapter(IGotoMarker.class) for accessing this method</code>
+ */
+ public void gotoMarker(IMarker marker) {
+
+ if (getSourceViewer() == null)
+ return;
+
+ int start= MarkerUtilities.getCharStart(marker);
+ int end= MarkerUtilities.getCharEnd(marker);
+
+ if (start < 0 || end < 0) {
+
+ // there is only a line number
+ int line= MarkerUtilities.getLineNumber(marker);
+ if (line > -1) {
+
+ // marker line numbers are 1-based
+ -- line;
+
+ try {
+
+ IDocument document= getDocumentProvider().getDocument(getEditorInput());
+ selectAndReveal(document.getLineOffset(line), document.getLineLength(line));
+
+ } catch (BadLocationException x) {
+ // marker refers to invalid text position -> do nothing
+ }
+ }
+
+ } else {
+
+ // look up the current range of the marker when the document has been edited
+ IAnnotationModel model= getDocumentProvider().getAnnotationModel(getEditorInput());
+ if (model instanceof AbstractMarkerAnnotationModel) {
+
+ AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
+ Position pos= markerModel.getMarkerPosition(marker);
+ if (pos != null && !pos.isDeleted()) {
+ // use position instead of marker values
+ start= pos.getOffset();
+ end= pos.getOffset() + pos.getLength();
+ }
+
+ if (pos != null && pos.isDeleted()) {
+ // do nothing if position has been deleted
+ return;
+ }
+ }
+
+ IDocument document= getDocumentProvider().getDocument(getEditorInput());
+ int length= document.getLength();
+ if (end - 1 < length && start < length)
+ selectAndReveal(start, end - start);
+ }
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.StatusTextEditor#isErrorStatus(org.eclipse.core.runtime.IStatus)
+ * @since 3.0
+ */
+ protected boolean isErrorStatus(IStatus status) {
+ // see bug 42230
+ return status != null && !status.isOK() && status.getCode() != IResourceStatus.READ_ONLY_LOCAL;
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions()
+ */
+ protected void createActions() {
+ super.createActions();
+
+ ResourceAction action= new AddMarkerAction(TextEditorMessages.getResourceBundle(), "Editor.AddBookmark.", this, IMarker.BOOKMARK, true); //$NON-NLS-1$
+ action.setHelpContextId(ITextEditorHelpContextIds.BOOKMARK_ACTION);
+ action.setActionDefinitionId(ITextEditorActionDefinitionIds.ADD_BOOKMARK);
+ setAction(IDEActionFactory.BOOKMARK.getId(), action);
+
+ action= new AddTaskAction(TextEditorMessages.getResourceBundle(), "Editor.AddTask.", this); //$NON-NLS-1$
+ action.setHelpContextId(ITextEditorHelpContextIds.ADD_TASK_ACTION);
+ action.setActionDefinitionId(ITextEditorActionDefinitionIds.ADD_TASK);
+ setAction(IDEActionFactory.ADD_TASK.getId(), action);
+ }
+
+ /*
+ * @see IAdaptable#getAdapter(java.lang.Class)
+ * @since 3.0
+ */
+ public Object getAdapter(Class adapter) {
+ if (IGotoMarker.class.equals(adapter))
+ return fGotoMarkerAdapter;
+ return super.getAdapter(adapter);
+ }
+
+ /*
+ * If there is no explicit document provider set, the implicit one is
+ * re-initialized based on the given editor input.
+ *
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#setDocumentProvider(org.eclipse.ui.IEditorInput)
+ * @since 3.0
+ */
+ protected void setDocumentProvider(IEditorInput input) {
+ fImplicitDocumentProvider= DocumentProviderRegistry.getDefault().getDocumentProvider(input);
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.ITextEditor#getDocumentProvider()
+ * @since 3.0
+ */
+ public IDocumentProvider getDocumentProvider() {
+ IDocumentProvider provider= super.getDocumentProvider();
+ if (provider == null)
+ return fImplicitDocumentProvider;
+ return provider;
+ }
+
+ /*
+ * @see org.eclipse.ui.texteditor.AbstractTextEditor#disposeDocumentProvider()
+ * @since 3.0
+ */
+ protected void disposeDocumentProvider() {
+ super.disposeDocumentProvider();
+ fImplicitDocumentProvider= null;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java
new file mode 100644
index 000000000..a49e4ae2a
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ExtendedTextEditorPreferenceConstants.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * 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.graphics.RGB;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+
+
+
+/**
+ * Preference constants used in the extended text editor preference store.
+ * @since 3.0
+ */
+public class ExtendedTextEditorPreferenceConstants {
+
+ /**
+ * Prevent initialization.
+ */
+ private ExtendedTextEditorPreferenceConstants() {
+ }
+
+ /**
+ * A named preference that controls whether the current line highlighting is turned on or off
+ * (value <code>"currentLine"</code>).
+ * <p>
+ * The preference value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_CURRENT_LINE= "currentLine"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to highlight the current line
+ * (value <code>"currentLineColor"</code>).
+ * <p>
+ * The preference value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>.
+ * </p>
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the print margin is turned on or off
+ * (value <code>"printMargin"</code>).
+ * <p>
+ * The preference value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_PRINT_MARGIN= "printMargin"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render the print margin
+ * (value <code>"printMarginColor"</code>).
+ * <p>
+ * The preference value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>.
+ * </p>
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ */
+ public final static String EDITOR_PRINT_MARGIN_COLOR= "printMarginColor"; //$NON-NLS-1$
+
+ /**
+ * Print margin column
+ * (value <code>"printMarginColumn"</code>).
+ * <p>
+ * The preference value is of type <code>int</code>.
+ * </p>
+ */
+ public final static String EDITOR_PRINT_MARGIN_COLUMN= "printMarginColumn"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the editor shows unknown
+ * indicators in text (squiggly lines).
+ * (value <code>"othersIndication"</code>).
+ * <p>
+ * The preference value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ * @deprecated as of 3.0 there are no UNKNOWN annotations any more
+ */
+ public final static String EDITOR_UNKNOWN_INDICATION= "othersIndication"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render unknown indicators
+ * (value <code>"othersIndicationColor"</code>).
+ * <p>
+ * The preference value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>.
+ * </p>
+ * @see #EDITOR_UNKNOWN_INDICATION
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @since 2.1
+ * @deprecated as of 3.0 there are no UNKNOWN annotations any more
+ */
+ public final static String EDITOR_UNKNOWN_INDICATION_COLOR= "othersIndicationColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether the overview ruler shows unknown indicators
+ * (value <code>"othersIndicationInOverviewRuler"</code>).
+ * <p>
+ * The preference value is of type <code>Boolean</code>.
+ * </p>
+ * @since 2.1
+ * @deprecated as of 3.0 there are no UNKNOWN annotations any more
+ */
+ public final static String EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER= "othersIndicationInOverviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the overview ruler is shown in the UI
+ * (value <code>"overviewRuler"</code>).
+ * <p>
+ * The preference value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_OVERVIEW_RULER= "overviewRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls if the line number ruler is shown in the UI
+ * (value <code>"lineNumberRuler"</code>).
+ * <p>
+ * The preference value is of type <code>Boolean</code>.
+ * </p>
+ */
+ public final static String EDITOR_LINE_NUMBER_RULER= "lineNumberRuler"; //$NON-NLS-1$
+
+ /**
+ * A named preference that holds the color used to render line numbers inside the line number ruler
+ * (value <code>"lineNumberColor"</code>).
+ * <p>
+ * The preference value is of type <code>String</code>. A RGB color value encoded as a string
+ * using class <code>PreferenceConverter</code>.
+ * </p>
+ * @see org.eclipse.jface.resource.StringConverter
+ * @see org.eclipse.jface.preference.PreferenceConverter
+ * @see #EDITOR_LINE_NUMBER_RULER
+ */
+ public final static String EDITOR_LINE_NUMBER_RULER_COLOR= "lineNumberColor"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls whether quick diff colors are shown on the line number bar.
+ * <p>
+ * Value is of type <code>boolean</code>.
+ * @since 3.0
+ */
+ public static final String QUICK_DIFF_ALWAYS_ON= "quickdiff.quickDiff"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the default quick diff reference provider.
+ * <p>
+ * Value is of type <code>String</code>.
+ * @since 3.0
+ */
+ public static final String QUICK_DIFF_DEFAULT_PROVIDER= "quickdiff.defaultProvider"; //$NON-NLS-1$
+
+ /**
+ * A named preference that controls the default quick diff reference provider.
+ * <p>
+ * Value is of type <code>String</code>.
+ * @since 3.0
+ */
+ public static final String QUICK_DIFF_CHARACTER_MODE= "quickdiff.characterMode"; //$NON-NLS-1$
+
+ /**
+ * Initializes the given preference store with the default values.
+ *
+ * @param store the preference store to be initialized
+ */
+ public static void initializeDefaultValues(IPreferenceStore store) {
+
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
+ PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(225, 235, 224));
+
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, false);
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
+ PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180 , 185));
+
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, false);
+ PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(0, 0, 0));
+ store.setDefault(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, true);
+ store.setDefault(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, false);
+ store.setDefault(ExtendedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER, "org.eclipse.ui.internal.texteditor.quickdiff.LastSaveReferenceProvider"); //$NON-NLS-1$
+
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
+
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION, false);
+ store.setDefault(ExtendedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER, false);
+ PreferenceConverter.setDefault(store, ExtendedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, new RGB(0, 0, 0));
+
+ MarkerAnnotationPreferences.initializeDefaultValues(store);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java
new file mode 100644
index 000000000..04ce65f85
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java
@@ -0,0 +1,59 @@
+/*******************************************************************************
+ * 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.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+
+import org.eclipse.core.resources.IMarker;
+
+
+/**
+ * A marker updater is responsible for saving changes to markers.
+ * Marker updaters either update markers of a specific types or
+ * any type. Also they either assume update responsibility for a
+ * specific set of marker attributes or any marker attribute.
+ * Marker updater must be registered with an <code>AbstractMarkerAnnotationModel</code>.
+ */
+public interface IMarkerUpdater {
+
+ /**
+ * Returns the marker type for which this updater is responsible. If
+ * the result is <code>null</code>, the updater assumes responsibility
+ * for any marker type.
+ *
+ * @return the marker type or <code>null</code> for any marker type
+ */
+ String getMarkerType();
+
+ /**
+ * Returns the attributes for which this updater is responsible. If the
+ * result is <code>null</code>, the updater assumes responsibility for
+ * any attributes.
+ *
+ * @return the attributes or <code>null</code> for any attribute
+ */
+ String[] getAttribute();
+
+ /**
+ * Updates the given marker according to the position of the given document.
+ * If the given position is <code>null</code>, the marker is assumed to
+ * carry the correct positional information.
+ *
+ * @param marker the marker to be updated
+ * @param document the document into which the given position points
+ * @param position the current position of the marker inside the given document
+ * @return <code>false</code> if the updater recognizes that the marker should be deleted
+ */
+ boolean updateMarker(IMarker marker, IDocument document, Position position);
+}
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
new file mode 100644
index 000000000..00fc3cb15
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
@@ -0,0 +1,300 @@
+/*******************************************************************************
+ * 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.core.resources.IMarker;
+import org.eclipse.core.runtime.CoreException;
+
+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.swt.widgets.Display;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+
+import org.eclipse.jface.text.Assert;
+import org.eclipse.jface.text.source.Annotation;
+
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.model.IWorkbenchAdapter;
+
+
+/**
+ * Annotation representing a marker on a resource in the workspace.
+ * This class may be instantiated or be subclassed.
+ *
+ * @see org.eclipse.core.resources.IMarker
+ */
+public class MarkerAnnotation extends Annotation implements IAnnotationExtension {
+
+ /**
+ * The layer in which markers representing problem are located.
+ * @since 2.0
+ * XXX to be deprecated as of 3.0 use {@link DefaultAnnotation#ERROR_LAYER}
+ */
+ public final static int PROBLEM_LAYER= 5;
+
+ /** Internal image registry */
+ private static Map fgImageRegistry;
+
+ /**
+ * 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
+ */
+ protected static Image getImage(Display display, ImageDescriptor descriptor) {
+ Map map= getImageRegistry(display);
+ Image image= (Image) map.get(descriptor);
+ if (image == null) {
+ image= descriptor.createImage();
+ map.put(descriptor, image);
+ }
+ return image;
+ }
+
+ /**
+ * Returns an image registry for the given display. If no such registry exists
+ * the resgitry is created.
+ * @param display the display
+ * @return the image registry for the given display
+ */
+ protected static Map getImageRegistry(Display display) {
+ if (fgImageRegistry == null) {
+ fgImageRegistry= new HashMap();
+ display.disposeExec(new Runnable() {
+ public void run() {
+ if (fgImageRegistry != null) {
+ Map map= fgImageRegistry;
+ fgImageRegistry= null;
+ Iterator e= map.values().iterator();
+ while (e.hasNext()) {
+ Image image= (Image) e.next();
+ if (!image.isDisposed())
+ image.dispose();
+ }
+ }
+ }
+ });
+ }
+ return fgImageRegistry;
+ }
+
+
+ /** The marker this annotation represents */
+ private IMarker fMarker;
+ /** The image, i.e., visual presentation of this annotation */
+ private Image fImage;
+ /** The image name */
+ private String fImageName;
+
+ /**
+ * Creates a new annotation for the given marker.
+ *
+ * @param marker the marker
+ */
+ public MarkerAnnotation(IMarker marker) {
+ Assert.isNotNull(marker);
+ fMarker= marker;
+ initialize();
+ }
+
+ /**
+ * Sets the marker image to the given image.
+ *
+ * @param image the new marker image
+ */
+ protected void setImage(Image image) {
+ fImage= image;
+ }
+
+ /**
+ * The <code>MarkerAnnotation</code> implementation of this
+ * <code>Object</code> method returns <code>true</code> iff the other
+ * object is also a <code>MarkerAnnotation</code> and the marker handles are
+ * equal.
+ */
+ public boolean equals(Object o) {
+ if (o != null && o.getClass() == getClass())
+ return fMarker.equals(((MarkerAnnotation) o).fMarker);
+ return false;
+ }
+
+ /*
+ * @see Object#hashCode()
+ */
+ public int hashCode() {
+ return fMarker.hashCode();
+ }
+
+ /**
+ * Returns this annotation's underlying marker.
+ *
+ * @return the marker
+ */
+ public IMarker getMarker() {
+ return fMarker;
+ }
+
+ /**
+ * Initializes the annotation's icon representation and its drawing layer
+ * based upon the properties of the underlying marker.
+ */
+ protected void initialize() {
+
+ String name= getUnknownImageName(fMarker);
+ int layer= 1;
+
+ if (MarkerUtilities.isMarkerType(fMarker, IMarker.TASK)) {
+ name= IDE.SharedImages.IMG_OBJS_TASK_TSK;
+ layer= DefaultAnnotation.TASK_LAYER;
+ } else if (MarkerUtilities.isMarkerType(fMarker, IMarker.BOOKMARK)) {
+ 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)) {
+ case IMarker.SEVERITY_INFO:
+ name= ISharedImages.IMG_OBJS_INFO_TSK;
+ layer= 3;
+ break;
+ case IMarker.SEVERITY_WARNING:
+ name= ISharedImages.IMG_OBJS_WARN_TSK;
+ layer= DefaultAnnotation.WARNING_LAYER;
+ break;
+ case IMarker.SEVERITY_ERROR:
+ name= ISharedImages.IMG_OBJS_ERROR_TSK;
+ layer= DefaultAnnotation.ERROR_LAYER;
+ break;
+ }
+ }
+
+ fImage= null;
+ fImageName= name;
+ setLayer(layer);
+ }
+
+ /*
+ * @see Annotation#paint(GC, Canvas, Rectangle)
+ */
+ public void paint(GC gc, Canvas canvas, Rectangle r) {
+ Image image= getImage(canvas.getDisplay());
+ if (image != null)
+ drawImage(image, gc, canvas, r, SWT.CENTER, SWT.TOP);
+ }
+
+ /**
+ * Informs this annotation about changes applied to its underlying marker
+ * and adapts to those changes.
+ */
+ public void update() {
+ initialize();
+ }
+
+ /**
+ * 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 unkown type
+ * @return the name of an image for markers of unknown type.
+ */
+ protected String getUnknownImageName(IMarker marker) {
+ return null;
+ }
+
+ /**
+ * Returns the image of the given name. Subclasses may extend this method.
+ * If so, subclasses must assume responsibility for disposing the images
+ * they create.
+ *
+ * @param name the name of the requested image
+ * @return the image or <code>null</code> if there is no such image
+ */
+ protected Image getImage(String name) {
+ if (name != null)
+ return PlatformUI.getWorkbench().getSharedImages().getImage(name);
+ return null;
+ }
+
+
+ /**
+ * 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
+ */
+ protected Image getImage(Display display) {
+ if (fImage == null) {
+
+ if (fMarker.exists()) {
+ IWorkbenchAdapter adapter= (IWorkbenchAdapter) fMarker.getAdapter(IWorkbenchAdapter.class);
+ if (adapter != null) {
+ ImageDescriptor descriptor= adapter.getImageDescriptor(fMarker);
+ if (descriptor != null)
+ fImage= getImage(display, descriptor);
+ }
+ }
+
+ if (fImage == null)
+ fImage= getImage(fImageName);
+
+ }
+ return fImage;
+ }
+
+ /*
+ * @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
+ */
+ public String getMessage() {
+ return fMarker.getAttribute(IMarker.MESSAGE, null);
+ }
+}
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
new file mode 100644
index 000000000..97954faed
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * 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.text.Collator;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.runtime.IConfigurationElement;
+import org.eclipse.core.runtime.IExtensionPoint;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.swt.graphics.RGB;
+
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.resource.StringConverter;
+
+import org.eclipse.ui.internal.editors.text.EditorsPlugin;
+
+
+/**
+ * Objects of this class provide access to all extensions declared for the <code>markerAnnotationSpecification</code> extension point.
+ * The extensions are represented as instances of <code>AnnotationPreference</code>.
+ *
+ * @since 2.1
+ */
+public class MarkerAnnotationPreferences {
+
+ /** The list of extensions */
+ private List fPreferences;
+
+ /**
+ * Creates a new marker annotation preferences accessor.
+ */
+ public MarkerAnnotationPreferences() {
+ }
+
+ /**
+ * Returns all extensions provided for the <code>markerAnnotationSpecification</code> extension point.
+ *
+ * @return all extensions provided for the <code>markerAnnotationSpecification</code> extension point
+ */
+ public List getAnnotationPreferences() {
+ if (fPreferences == null)
+ initialize();
+
+ return fPreferences;
+ }
+
+ /**
+ * 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
+ fPreferences= new ArrayList(2);
+
+ // populate list
+ IExtensionPoint extensionPoint= Platform.getPluginRegistry().getExtensionPoint(EditorsPlugin.getPluginId(), "markerAnnotationSpecification"); //$NON-NLS-1$
+ if (extensionPoint != null) {
+ IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
+ for (int i= 0; i < elements.length; i++) {
+ AnnotationPreference spec= createSpec(elements[i]);
+ if (spec != null)
+ fPreferences.add(createSpec(elements[i]));
+ }
+ }
+
+ final Collator collator= Collator.getInstance();
+ Collections.sort(fPreferences, new Comparator() {
+ /*
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ */
+ public int compare(Object o1, Object o2) {
+ if (o1 == o2)
+ return 0;
+
+ AnnotationPreference ap1= (AnnotationPreference)o1;
+ AnnotationPreference ap2= (AnnotationPreference)o2;
+
+ String label1= ap1.getPreferenceLabel();
+ String label2= ap2.getPreferenceLabel();
+
+ if (label1 == null && label2 == null)
+ return 0;
+
+ if (label1 == null)
+ return -1;
+
+ if (label2 == null)
+ return 1;
+
+ return collator.compare(label1, label2);
+ }
+ });
+ }
+
+ /**
+ * Creates a <code>AnnotationPreference</code> the given configuration element.
+ *
+ * @param element the configuration element
+ * @return the created annotation preference
+ */
+ private AnnotationPreference createSpec(IConfigurationElement element) {
+
+ String s;
+ int i;
+ boolean b;
+
+ AnnotationPreference info= new AnnotationPreference();
+
+ s= element.getAttribute("annotationType"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ info.setAnnotationType(s);
+
+ s= element.getAttribute("label"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ info.setPreferenceLabel(s);
+
+ s= element.getAttribute("markerType"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ info.setMarkerType(s);
+
+ i= IMarker.SEVERITY_INFO;
+ s= element.getAttribute("markerSeverity"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ i= StringConverter.asInt(s, IMarker.SEVERITY_INFO);
+ info.setSeverity(i);
+
+ s= element.getAttribute("textPreferenceKey"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ info.setTextPreferenceKey(s);
+
+ b= false;
+ s= element.getAttribute("textPreferenceValue"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, false);
+ info.setTextPreferenceValue(b);
+
+ s= element.getAttribute("highlightPreferenceKey"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0)
+ s= null;
+ info.setHighlightPreferenceKey(s);
+
+ b= false;
+ s= element.getAttribute("highlightPreferenceValue"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, false);
+ info.setHighlightPreferenceValue(b);
+
+ s= element.getAttribute("overviewRulerPreferenceKey"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ info.setOverviewRulerPreferenceKey(s);
+
+ b= false;
+ s= element.getAttribute("overviewRulerPreferenceValue"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, false);
+ info.setOverviewRulerPreferenceValue(b);
+
+ s= element.getAttribute("verticalRulerPreferenceKey"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0)
+ s= null;
+ info.setVerticalRulerPreferenceKey(s);
+
+ b= false;
+ s= element.getAttribute("verticalRulerPreferenceValue"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, true);
+ info.setVerticalRulerPreferenceValue(b);
+
+ s= element.getAttribute("colorPreferenceKey"); //$NON-NLS-1$
+ if (s == null || s.trim().length() == 0) return null;
+ 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);
+
+ i= 0;
+ s= element.getAttribute("presentationLayer"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ i= StringConverter.asInt(s, 0);
+ info.setPresentationLayer(i);
+
+ b= false;
+ s= element.getAttribute("contributesToHeader"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, false);
+ info.setContributesToHeader(b);
+
+ s= element.getAttribute("showInNextPrevDropdownToolbarActionKey"); //$NON-NLS-1$
+ if (s != null && s.trim().length() == 0)
+ s= null;
+ info.setShowInNextPrevDropdownToolbarActionKey(s);
+
+ b= false;
+ s= element.getAttribute("showInNextPrevDropdownToolbarAction"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, false);
+ info.setShowInNextPrevDropdownToolbarAction(b);
+
+ s= element.getAttribute("isGoToNextNavigationTargetKey"); //$NON-NLS-1$
+ if (s != null && s.trim().length() == 0)
+ s= null;
+ info.setIsGoToNextNavigationTargetKey(s);
+
+ b= false;
+ s= element.getAttribute("isGoToNextNavigationTarget"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, false);
+ info.setIsGoToNextNavigationTarget(b);
+
+ s= element.getAttribute("isGoToPreviousNavigationTargetKey"); //$NON-NLS-1$
+ if (s != null && s.trim().length() == 0)
+ s= null;
+ info.setIsGoToPreviousNavigationTargetKey(s);
+
+ b= false;
+ s= element.getAttribute("isGoToPreviousNavigationTarget"); //$NON-NLS-1$
+ if (s != null && s.trim().length() > 0)
+ b= StringConverter.asBoolean(s, false);
+ info.setIsGoToPreviousNavigationTarget(b);
+
+ return info;
+ }
+
+ /**
+ * 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());
+ }
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
new file mode 100644
index 000000000..a7013a3ed
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
@@ -0,0 +1,428 @@
+/*******************************************************************************
+ * 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
+ * Sebastian Davids <sdavids@gmx.de> bug 38745
+ *******************************************************************************/
+
+package org.eclipse.ui.texteditor;
+
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.ResourceBundle;
+
+import org.eclipse.swt.widgets.Shell;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.ILog;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.core.runtime.Status;
+
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.IInputValidator;
+import org.eclipse.jface.dialogs.InputDialog;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+import org.eclipse.jface.window.Window;
+
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.PlatformUI;
+
+
+
+/**
+ * A ruler action which can add and remove markers which have a visual
+ * representation in the ruler.
+ * <p>
+ * This class may be instantiated but is not intended for subclassing.
+ * </p>
+ */
+public class MarkerRulerAction extends ResourceAction implements IUpdate {
+
+ /** The vertical ruler info of the editor */
+ private IVerticalRulerInfo fRuler;
+ /** The associated editor */
+ private ITextEditor fTextEditor;
+ /** The of the marker to be created/removed */
+ private String fMarkerType;
+ /** The cached list of markers covering a particular vertical ruler position */
+ private List fMarkers;
+ /** The flag indicating whether user interaction is required. */
+ private boolean fAskForLabel;
+ /** The action's resource bundle */
+ private ResourceBundle fBundle;
+ /** The prefix used for resource bundle look ups */
+ private String fPrefix;
+ /** The cached action label when adding a marker */
+ private String fAddLabel;
+ /** The cached action label when removing a marker */
+ private String fRemoveLabel;
+
+
+ /**
+ * Creates a new action for the given ruler and editor. The action configures
+ * its visual representation from the given resource bundle.
+ *
+ * @param bundle the resource bundle
+ * @param prefix a prefix to be prepended to the various resource keys
+ * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none
+ * @param editor the editor
+ * @param ruler the ruler
+ * @param markerType the type of marker
+ * @param askForLabel <code>true</code> if the user should be asked for a label when a new marker is created
+ * @see ResourceAction#ResourceAction
+ * @since 2.0
+ */
+ public MarkerRulerAction(ResourceBundle bundle, String prefix, ITextEditor editor, IVerticalRulerInfo ruler, String markerType, boolean askForLabel) {
+ super(bundle, prefix);
+ fRuler= ruler;
+ fTextEditor= editor;
+ fMarkerType= markerType;
+ fAskForLabel= askForLabel;
+
+ fBundle= bundle;
+ fPrefix= prefix;
+
+ fAddLabel= getString(bundle, prefix + "add.label", prefix + "add.label"); //$NON-NLS-2$ //$NON-NLS-1$
+ fRemoveLabel= getString(bundle, prefix + "remove.label", prefix + "remove.label"); //$NON-NLS-2$ //$NON-NLS-1$
+ }
+
+ /**
+ * @deprecated use <code>MarkerRulerAction(ResourceBundle, String, ITextEditor, IVerticalRulerInfo, String, boolean)</code> instead
+ */
+ public MarkerRulerAction(ResourceBundle bundle, String prefix, IVerticalRuler ruler, ITextEditor editor, String markerType, boolean askForLabel) {
+ this(bundle, prefix, editor, ruler, markerType, askForLabel);
+ }
+
+
+ /**
+ * Returns this action's text editor.
+ *
+ * @return this action's text editor
+ */
+ protected ITextEditor getTextEditor() {
+ return fTextEditor;
+ }
+
+ /**
+ * Returns this action's vertical ruler.
+ *
+ * @return this action's vertical ruler
+ * @deprecated use <code>getVerticalRulerInfo</code> instead
+ */
+ protected IVerticalRuler getVerticalRuler() {
+ if (fRuler instanceof IVerticalRuler)
+ return (IVerticalRuler) fRuler;
+ return null;
+ }
+
+ /**
+ * Returns this action's vertical ruler info.
+ *
+ * @return this action's vertical ruler info
+ * @since 2.0
+ */
+ protected IVerticalRulerInfo getVerticalRulerInfo() {
+ return fRuler;
+ }
+
+ /**
+ * Returns this action's resource bundle.
+ *
+ * @return this action's resource bundle
+ */
+ protected ResourceBundle getResourceBundle() {
+ return fBundle;
+ }
+
+ /**
+ * Returns this action's resource key prefix.
+ *
+ * @return this action's resource key prefix
+ */
+ protected String getResourceKeyPrefix() {
+ return fPrefix;
+ }
+
+ /*
+ * @see IUpdate#update()
+ */
+ public void update() {
+ //bug 38745
+ int line= getVerticalRuler().getLineOfLastMouseButtonActivity() + 1;
+ IDocument document= getDocument();
+ if (document != null) {
+ if (line > getDocument().getNumberOfLines()) {
+ setEnabled(false);
+ setText(fAddLabel);
+ } else {
+ setEnabled(true);
+ fMarkers= getMarkers();
+ setText(fMarkers.isEmpty() ? fAddLabel : fRemoveLabel);
+ }
+ }
+ }
+
+ /*
+ * @see Action#run()
+ */
+ public void run() {
+ if (fMarkers.isEmpty())
+ addMarker();
+ else
+ removeMarkers(fMarkers);
+ }
+
+ /**
+ * Returns the resource for which to create the marker,
+ * or <code>null</code> if there is no applicable resource.
+ *
+ * @return the resource for which to create the marker or <code>null</code>
+ */
+ protected IResource getResource() {
+ IEditorInput input= fTextEditor.getEditorInput();
+
+ IResource resource= (IResource) input.getAdapter(IFile.class);
+
+ if (resource == null)
+ resource= (IResource) input.getAdapter(IResource.class);
+
+ return resource;
+ }
+
+ /**
+ * Returns the <code>AbstractMarkerAnnotationModel</code> of the editor's input.
+ *
+ * @return the marker annotation model
+ */
+ protected AbstractMarkerAnnotationModel getAnnotationModel() {
+ IDocumentProvider provider= fTextEditor.getDocumentProvider();
+ IAnnotationModel model= provider.getAnnotationModel(fTextEditor.getEditorInput());
+ if (model instanceof AbstractMarkerAnnotationModel)
+ return (AbstractMarkerAnnotationModel) model;
+ return null;
+ }
+
+ /**
+ * Returns the <code>IDocument</code> of the editor's input.
+ *
+ * @return the document of the editor's input
+ */
+ protected IDocument getDocument() {
+ IDocumentProvider provider= fTextEditor.getDocumentProvider();
+ return provider.getDocument(fTextEditor.getEditorInput());
+ }
+
+ /**
+ * Checks whether a position includes the ruler's line of activity.
+ *
+ * @param position the position to be checked
+ * @param document the document the position refers to
+ * @return <code>true</code> if the line is included by the given position
+ */
+ protected boolean includesRulerLine(Position position, IDocument document) {
+
+ if (position != null) {
+ try {
+ int markerLine= document.getLineOfOffset(position.getOffset());
+ int line= fRuler.getLineOfLastMouseButtonActivity();
+ if (line == markerLine)
+ return true;
+ // commented because of "1GEUOZ9: ITPJUI:ALL - Confusing UI for multiline Bookmarks and Tasks"
+ // return (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()));
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * Handles core exceptions. This implementation logs the exceptions
+ * with the workbech plugin and shows an error dialog.
+ *
+ * @param exception the exception to be handled
+ * @param message the message to be logged with the given exception
+ */
+ protected void handleCoreException(CoreException exception, String message) {
+ ILog log= Platform.getPlugin(PlatformUI.PLUGIN_ID).getLog();
+
+ if (message != null)
+ log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, exception));
+ else
+ log.log(exception.getStatus());
+
+
+ Shell shell= getTextEditor().getSite().getShell();
+ String title= getString(fBundle, fPrefix + "error.dialog.title", fPrefix + "error.dialog.title"); //$NON-NLS-2$ //$NON-NLS-1$
+ String msg= getString(fBundle, fPrefix + "error.dialog.message", fPrefix + "error.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$
+
+ ErrorDialog.openError(shell, title, msg, exception.getStatus());
+ }
+
+ /**
+ * Returns all markers which include the ruler's line of activity.
+ *
+ * @return all a list of markers which include the ruler's line of activity
+ */
+ protected List getMarkers() {
+
+ List markers= new ArrayList();
+
+ IResource resource= getResource();
+ IDocument document= getDocument();
+ AbstractMarkerAnnotationModel model= getAnnotationModel();
+
+ if (resource != null && model != null && resource.exists()) {
+ try {
+ IMarker[] allMarkers= resource.findMarkers(fMarkerType, true, IResource.DEPTH_ZERO);
+ if (allMarkers != null) {
+ for (int i= 0; i < allMarkers.length; i++) {
+ if (includesRulerLine(model.getMarkerPosition(allMarkers[i]), document)) {
+ markers.add(allMarkers[i]);
+ }
+ }
+ }
+ } catch (CoreException x) {
+ handleCoreException(x, TextEditorMessages.getString("MarkerRulerAction.getMarker")); //$NON-NLS-1$
+ }
+ }
+
+ return markers;
+ }
+
+ /**
+ * Creates a new marker according to the specification of this action and
+ * adds it to the marker resource.
+ */
+ protected void addMarker() {
+ IResource resource= getResource();
+ if (resource == null)
+ return;
+ Map attributes= getInitialAttributes();
+ if (fAskForLabel) {
+ if (!askForLabel(attributes))
+ return;
+ }
+
+ try {
+ MarkerUtilities.createMarker(resource, attributes, fMarkerType);
+ } catch (CoreException x) {
+ handleCoreException(x, TextEditorMessages.getString("MarkerRulerAction.addMarker")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Removes the given markers.
+ *
+ * @param markers the markers to be deleted
+ */
+ protected void removeMarkers(final List markers) {
+ try {
+ getResource().getWorkspace().run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ for (int i= 0; i < markers.size(); ++i) {
+ IMarker marker= (IMarker) markers.get(i);
+ marker.delete();
+ }
+ }
+ }, null);
+ } catch (CoreException x) {
+ handleCoreException(x, TextEditorMessages.getString("MarkerRulerAction.removeMarkers")); //$NON-NLS-1$
+ }
+ }
+
+ /**
+ * Asks the user for a marker label. Returns <code>true</code> if a label
+ * is entered, <code>false</code> if the user cancels the input dialog.
+ * Sets the value of the attribute <code>message</code> in the given
+ * map of attributes.
+ *
+ * @param attributes the map of attributes
+ * @return <code>true</code> if the map of attributes has successfully been initialized
+ */
+ protected boolean askForLabel(Map attributes) {
+
+ Object o= attributes.get("message"); //$NON-NLS-1$
+ String proposal= (o instanceof String) ? (String) o : ""; //$NON-NLS-1$
+ if (proposal == null)
+ proposal= ""; //$NON-NLS-1$
+
+ String title= getString(fBundle, fPrefix + "add.dialog.title", fPrefix + "add.dialog.title"); //$NON-NLS-2$ //$NON-NLS-1$
+ String message= getString(fBundle, fPrefix + "add.dialog.message", fPrefix + "add.dialog.message"); //$NON-NLS-2$ //$NON-NLS-1$
+ IInputValidator inputValidator = new IInputValidator() {
+ public String isValid(String newText) {
+ return (newText == null || newText.trim().length() == 0) ? " " : null; //$NON-NLS-1$
+ }
+ };
+ InputDialog dialog= new InputDialog(fTextEditor.getSite().getShell(), title, message, proposal, inputValidator);
+
+ String label= null;
+ if (dialog.open() != Window.CANCEL)
+ label= dialog.getValue();
+
+ if (label == null)
+ return false;
+
+ label= label.trim();
+ if (label.length() == 0)
+ return false;
+
+ MarkerUtilities.setMessage(attributes, label);
+ return true;
+ }
+
+ /**
+ * Returns the attributes with which a newly created marker will be
+ * initialized.
+ *
+ * @return the initial marker attributes
+ */
+ protected Map getInitialAttributes() {
+
+ Map attributes= new HashMap(11);
+
+ IDocumentProvider provider= fTextEditor.getDocumentProvider();
+ IDocument document= provider.getDocument(fTextEditor.getEditorInput());
+ int line= fRuler.getLineOfLastMouseButtonActivity();
+ int start= -1;
+ int end= -1;
+
+ try {
+
+ IRegion lineInformation= document.getLineInformation(line);
+ start= lineInformation.getOffset();
+ int length= lineInformation.getLength();
+
+ end= start + length;
+
+ } catch (BadLocationException x) {
+ }
+
+ // marker line numbers are 1-based
+ MarkerUtilities.setLineNumber(attributes, line + 1);
+ MarkerUtilities.setCharStart(attributes, start);
+ MarkerUtilities.setCharEnd(attributes, end);
+
+ return attributes;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerInfoAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerInfoAction.java
new file mode 100644
index 000000000..2e80bc1e3
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerInfoAction.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * 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.ResourceBundle;
+import org.eclipse.jface.text.source.IVerticalRulerInfo;
+
+
+/**
+ * @deprecated use <code>MarkerRulerAction</code> instead
+ * @since 2.0
+ */
+public class MarkerRulerInfoAction extends MarkerRulerAction {
+
+ /**
+ * @deprecated use super class instead
+ */
+ public MarkerRulerInfoAction(ResourceBundle bundle, String prefix, IVerticalRulerInfo ruler, ITextEditor editor, String markerType, boolean askForLabel) {
+ super(bundle, prefix, editor, ruler, markerType, askForLabel);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUpdater.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUpdater.java
new file mode 100644
index 000000000..af2a4bf87
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUpdater.java
@@ -0,0 +1,65 @@
+/*******************************************************************************
+ * 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.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+
+import org.eclipse.core.resources.IMarker;
+
+/**
+ * Updates a marker's positional attributes which are start position, end position,
+ * and line number.
+ */
+class MarkerUpdater implements IMarkerUpdater {
+
+ private final static String[] ATTRIBUTES= {IMarker.CHAR_START, IMarker.CHAR_END, IMarker.LINE_NUMBER};
+
+ /*
+ * @see IMarkerUpdater#getAttribute()
+ */
+ public String[] getAttribute() {
+ return ATTRIBUTES;
+ }
+
+ /*
+ * @see IMarkerUpdater#getMarkerType()
+ */
+ public String getMarkerType() {
+ return null;
+ }
+
+ /*
+ * @see IMarkerUpdater#updateMarker(IMarker, IDocument, Position)
+ */
+ public boolean updateMarker(IMarker marker, IDocument document, Position position) {
+
+ if (position.isDeleted())
+ return false;
+
+ if (MarkerUtilities.getCharStart(marker) != -1 && MarkerUtilities.getCharEnd(marker) != -1) {
+ MarkerUtilities.setCharStart(marker, position.getOffset());
+ MarkerUtilities.setCharEnd(marker, position.getOffset() + position.getLength());
+ }
+ if (MarkerUtilities.getLineNumber(marker) != -1) {
+ try {
+ // marker line numbers are 1-based
+ MarkerUtilities.setLineNumber(marker, document.getLineOfOffset(position.getOffset()) + 1);
+ } catch (BadLocationException x) {
+ }
+ }
+
+ return true;
+ }
+
+}
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
new file mode 100644
index 000000000..f7f3774ad
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java
@@ -0,0 +1,256 @@
+/*******************************************************************************
+ * 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.Map;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.Platform;
+
+import org.eclipse.ui.PlatformUI;
+
+
+
+/**
+ * Utility class for accessing marker attributes. The static methods provided
+ * on this class provide internal exception handling (unexpected
+ * <code>CoreException</code>s are logged to workbench).
+ * <p>
+ * This class provides static methods only; it is not intended to be
+ * instantiated or subclassed by clients.
+ * </p>
+ */
+public final class MarkerUtilities {
+
+ /**
+ * Don't allow instantiation.
+ */
+ private MarkerUtilities() {
+ }
+
+ /**
+ * Returns the ending character offset of the given marker.
+ *
+ * @param marker the marker
+ * @return the ending character offset, or <code>-1</code> if not set
+ * @see IMarker#CHAR_END
+ * @see IMarker#getAttribute(java.lang.String, int)
+ */
+ public static int getCharEnd(IMarker marker) {
+ return getIntAttribute(marker, IMarker.CHAR_END, -1);
+ }
+
+ /**
+ * Returns the starting character offset of the given marker.
+ *
+ * @param marker the marker
+ * @return the starting character offset, or <code>-1</code> if not set
+ * @see IMarker#CHAR_START
+ * @see IMarker#getAttribute(java.lang.String,int)
+ */
+ public static int getCharStart(IMarker marker) {
+ return getIntAttribute(marker, IMarker.CHAR_START, -1);
+ }
+
+ /**
+ * Returns the specified attribute of the given marker as an integer.
+ * Returns the given default if the attribute value is not an integer.
+ */
+ private static int getIntAttribute(IMarker marker, String attributeName, int defaultValue) {
+ if (marker.exists())
+ return marker.getAttribute(attributeName, defaultValue);
+ return defaultValue;
+ }
+
+ /**
+ * Returns the line number of the given marker.
+ *
+ * @param marker the marker
+ * @return the line number, or <code>-1</code> if not set
+ * @see IMarker#LINE_NUMBER
+ * @see IMarker#getAttribute(java.lang.String,int)
+ */
+ public static int getLineNumber(IMarker marker) {
+ return getIntAttribute(marker, IMarker.LINE_NUMBER, -1);
+ }
+
+ /**
+ * Returns the priority of the given marker.
+ *
+ * @param marker the marker
+ * @return the priority, or <code>IMarker.PRIORITY_NORMAL</code> if not set
+ * @see IMarker#PRIORITY
+ * @see IMarker#PRIORITY_NORMAL
+ * @see IMarker#getAttribute(java.lang.String,int)
+ */
+ public static int getPriority(IMarker marker) {
+ return getIntAttribute(marker, IMarker.PRIORITY, IMarker.PRIORITY_NORMAL);
+ }
+
+ /**
+ * Handles a core exception which occurs when accessing marker attributes.
+ */
+ private static void handleCoreException(CoreException e) {
+ Platform.getPlugin(PlatformUI.PLUGIN_ID).getLog().log(e.getStatus());
+ }
+
+ /**
+ * Returns whether the given marker is of the given type (either directly or indirectly).
+ *
+ * @param marker the marker to be checked
+ * @param type the reference type
+ * @return <code>true</code>if maker is an instance of the reference type
+ */
+ public static boolean isMarkerType(IMarker marker, String type) {
+ if (marker != null) {
+ try {
+ return marker.exists() && marker.isSubtypeOf(type);
+ } catch (CoreException e) {
+ handleCoreException(e);
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Sets the ending character offset of the given marker.
+ *
+ * @param marker the marker
+ * @param charEnd the ending character offset
+ * @see IMarker#CHAR_END
+ * @see IMarker#setAttribute(java.lang.String,int)
+ */
+ public static void setCharEnd(IMarker marker, int charEnd) {
+ setIntAttribute(marker, IMarker.CHAR_END, charEnd);
+ }
+
+ /**
+ * Sets the ending character offset in the given map using the standard
+ * marker attribute name as the key.
+ *
+ * @param map the map (key type: <code>String</code>, value type:
+ * <code>Object</code>)
+ * @param charEnd the ending character offset
+ * @see IMarker#CHAR_END
+ */
+ public static void setCharEnd(Map map, int charEnd) {
+ map.put(IMarker.CHAR_END, new Integer(charEnd));
+ }
+
+ /**
+ * Sets the starting character offset of the given marker.
+ *
+ * @param marker the marker
+ * @param charStart the starting character offset
+ * @see IMarker#CHAR_START
+ * @see IMarker#setAttribute(java.lang.String,int)
+ */
+ public static void setCharStart(IMarker marker, int charStart) {
+ setIntAttribute(marker, IMarker.CHAR_START, charStart);
+ }
+
+ /**
+ * Sets the starting character offset in the given map using the standard
+ * marker attribute name as the key.
+ *
+ * @param map the map (key type: <code>String</code>, value type:
+ * <code>Object</code>)
+ * @param charStart the starting character offset
+ * @see IMarker#CHAR_START
+ */
+ public static void setCharStart(Map map, int charStart) {
+ map.put(IMarker.CHAR_START, new Integer(charStart));
+ }
+
+ /**
+ * Sets the specified attribute of the given marker as an integer.
+ *
+ * @param marker the marker
+ * @param attributeName the attribute name
+ * @param value the int value
+ */
+ private static void setIntAttribute(IMarker marker, String attributeName, int value) {
+ try {
+ if (marker.exists())
+ marker.setAttribute(attributeName, value);
+ } catch (CoreException e) {
+ handleCoreException(e);
+ }
+ }
+
+ /**
+ * Sets the line number of the given marker.
+ *
+ * @param marker the marker
+ * @param lineNum the line number
+ * @see IMarker#LINE_NUMBER
+ * @see IMarker#setAttribute(java.lang.String,int)
+ */
+ public static void setLineNumber(IMarker marker, int lineNum) {
+ setIntAttribute(marker, IMarker.LINE_NUMBER, lineNum);
+ }
+
+ /**
+ * Sets the line number in the given map using the standard marker attribute
+ * name as the key.
+ *
+ * @param map the map (key type: <code>String</code>, value type:
+ * <code>Object</code>)
+ * @param lineNum the line number
+ * @see IMarker#LINE_NUMBER
+ */
+ public static void setLineNumber(Map map, int lineNum) {
+ map.put(IMarker.LINE_NUMBER, new Integer(lineNum));
+ }
+
+ /**
+ * Sets the message in the given map using the standard marker attribute name
+ * as the key.
+ *
+ * @param map the map (key type: <code>String</code>, value type:
+ * <code>Object</code>)
+ * @param message the message
+ * @see IMarker#MESSAGE
+ */
+ public static void setMessage(Map map, String message) {
+ map.put(IMarker.MESSAGE, message);
+ }
+
+ /**
+ * Creates a marker on the given resource with the given type and attributes.
+ * <p>
+ * This method modifies the workspace (progress is not reported to the user).</p>
+ *
+ * @param resource the resource
+ * @param attributes the attribute map (key type: <code>String</code>,
+ * value type: <code>Object</code>)
+ * @param markerType the type of marker
+ * @exception CoreException if this method fails
+ * @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);
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
new file mode 100644
index 000000000..e77c088a6
--- /dev/null
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java
@@ -0,0 +1,152 @@
+/*******************************************************************************
+ * 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.IMarker;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+
+import org.eclipse.jface.text.Assert;
+
+
+
+/**
+ * A marker annotation model whose underlying source of markers is
+ * a resource in the workspace.
+ * <p>
+ * This class may be instantiated; it is not intended to be subclassed.</p>
+ */
+public class ResourceMarkerAnnotationModel extends AbstractMarkerAnnotationModel {
+
+
+ /**
+ * Internal resource change listener.
+ *
+ * @see IResourceChangeListener
+ */
+ class ResourceChangeListener implements IResourceChangeListener {
+ /*
+ * @see IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
+ */
+ public void resourceChanged(IResourceChangeEvent e) {
+ IResourceDelta delta= e.getDelta();
+ if (delta != null && fResource != null) {
+ IResourceDelta child= delta.findMember(fResource.getFullPath());
+ if (child != null)
+ update(child.getMarkerDeltas());
+ }
+ }
+ }
+
+ /** The workspace. */
+ private IWorkspace fWorkspace;
+ /** The resource. */
+ private IResource fResource;
+ /** The resource change listener. */
+ private IResourceChangeListener fResourceChangeListener= new ResourceChangeListener();
+
+
+ /**
+ * Creates a marker annotation model with the given resource as the source
+ * of the markers.
+ *
+ * @param resource the resource
+ */
+ public ResourceMarkerAnnotationModel(IResource resource) {
+ Assert.isNotNull(resource);
+ fResource= resource;
+ fWorkspace= resource.getWorkspace();
+ }
+
+ /*
+ * @see AbstractMarkerAnnotationModel#isAcceptable(IMarker)
+ */
+ protected boolean isAcceptable(IMarker marker) {
+ return marker != null && fResource.equals(marker.getResource());
+ }
+
+ /**
+ * Updates this model to the given marker deltas.
+ *
+ * @param markerDeltas the array of marker deltas
+ */
+ protected void update(IMarkerDelta[] markerDeltas) {
+
+ if (markerDeltas.length == 0)
+ return;
+
+ for (int i= 0; i < markerDeltas.length; i++) {
+ IMarkerDelta delta= markerDeltas[i];
+ switch (delta.getKind()) {
+ case IResourceDelta.ADDED :
+ addMarkerAnnotation(delta.getMarker());
+ break;
+ case IResourceDelta.REMOVED :
+ removeMarkerAnnotation(delta.getMarker());
+ break;
+ case IResourceDelta.CHANGED :
+ modifyMarkerAnnotation(delta.getMarker());
+ break;
+ }
+ }
+
+ fireModelChanged();
+ }
+
+ /*
+ * @see AbstractMarkerAnnotationModel#listenToMarkerChanges(boolean)
+ */
+ protected void listenToMarkerChanges(boolean listen) {
+ if (listen)
+ fWorkspace.addResourceChangeListener(fResourceChangeListener);
+ else
+ fWorkspace.removeResourceChangeListener(fResourceChangeListener);
+ }
+
+ /*
+ * @see AbstractMarkerAnnotationModel#deleteMarkers(IMarker[])
+ */
+ protected void deleteMarkers(final IMarker[] markers) throws CoreException {
+ fWorkspace.run(new IWorkspaceRunnable() {
+ public void run(IProgressMonitor monitor) throws CoreException {
+ for (int i= 0; i < markers.length; ++i) {
+ markers[i].delete();
+ }
+ }
+ }, null);
+ }
+
+ /*
+ * @see AbstractMarkerAnnotationModel#retrieveMarkers()
+ */
+ protected IMarker[] retrieveMarkers() throws CoreException {
+ return fResource.findMarkers(IMarker.MARKER, true, IResource.DEPTH_ZERO);
+ }
+
+ /**
+ * Returns the resource serving as the source of markers for this annotation model.
+ *
+ * @return the resource serving as the source of markers for this annotation model
+ * @since 2.0
+ */
+ protected IResource getResource() {
+ return fResource;
+ }
+}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties
index f41bc037f..9150ab089 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties
@@ -28,6 +28,25 @@ Editor.ManageTasks.add.dialog.message=Enter Task description
Editor.ManageTasks.error.dialog.title=Managing Tasks
Editor.ManageTasks.error.dialog.message=Problems managing tasks
+Editor.AddBookmark.label=Boo&kmark...
+Editor.AddBookmark.tooltip=Add Bookmark
+Editor.AddBookmark.image=
+Editor.AddBookmark.description=Add Bookmark
+Editor.AddBookmark.dialog.title=Add Bookmark
+Editor.AddBookmark.dialog.message=Enter Bookmark name:
+Editor.AddBookmark.error.dialog.title=Add Bookmark
+Editor.AddBookmark.error.dialog.message=Problems adding new bookmark
+
+Editor.ManageBookmarks.tooltip=Adds and Removes Bookmarks
+Editor.ManageBookmarks.image=
+Editor.ManageBookmarks.description=Adds and removes Bookmarks
+Editor.ManageBookmarks.add.label=Add Boo&kmark...
+Editor.ManageBookmarks.remove.label=Remove Boo&kmark
+Editor.ManageBookmarks.add.dialog.title=Add Bookmark
+Editor.ManageBookmarks.add.dialog.message=Enter Bookmark name:
+Editor.ManageBookmarks.error.dialog.title=Managing Bookmarks
+Editor.ManageBookmarks.error.dialog.message=Problems managing bookmarks
+
Editor.SelectMarker.tooltip=Selects the marker's range
Editor.SelectMarker.image=
Editor.SelectMarker.description=Selects the Marker's Range
@@ -41,3 +60,12 @@ MarkerRulerAction.removeMarkers=MarkerRulerAction.removeMarkers
SelectMarkerRulerAction.getMarker=SelectMarkerRulerAction.getMarker
SelectMarkerRulerInfoAction.getMarker=SelectMarkerRulerInfoAction.getMarker
+
+## Others ##
+
+AbstractMarkerAnnotationModel.connected=AbstractMarkerAnnotationModel.connected
+AbstractMarkerAnnotationModel.createMarkerUpdater=AbstractMarkerAnnotationModel.createMarkerUpdater
+AbstractMarkerAnnotationModel.removeAnnotations=AbstractMarkerAnnotationModel.removeAnnotations
+ResourceMarkerAnnotationModel.resourceChanged=ResourceMarkerAnnotationModel.resourceChanged
+
+DocumentProviderRegistry.error.extension_point_not_found=Extension point: {0}.documentProviders not found

Back to the top