Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ui.editors/src/org/eclipse/ui')
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java226
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java141
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java463
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java1053
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ForwardingDocumentProvider.java365
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsConstants.java77
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsDefinitionIds.java76
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsHelpContextIds.java79
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingSupport.java41
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IFoldingCommandIds.java49
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ILocationProvider.java35
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IStorageDocumentProvider.java46
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java49
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java437
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java321
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java126
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.java71
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.properties129
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferenceConstants.java260
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferencePage.java119
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java1119
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java78
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/package.html12
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java195
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.java42
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.properties14
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java230
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/package.html113
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java436
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.java44
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.properties14
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AbstractConfigurationBlockPreferencePage.java125
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java433
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsPreferencePage.java54
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ColorEditor.java159
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java171
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java62
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IEditorsStatusConstants.java28
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IPreferenceConfigurationBlock.java64
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/JavaFileEditorInput.java112
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java192
-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/OpenExternalFileAction.java162
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java547
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PixelConverter.java62
-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/QuickDiffConfigurationBlock.java406
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffPreferencePage.java54
-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/internal/editors/text/StatusInfo.java194
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java66
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java52
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties67
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java550
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UISynchronizationContext.java42
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/WorkspaceOperationRunner.java75
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationType.java70
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java109
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java251
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java367
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/TextChangeHover.java63
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java1078
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java306
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java645
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java327
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java61
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java116
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java208
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java96
-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/ChainedPreferenceStore.java555
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java364
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java322
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java58
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java38
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java311
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java495
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java458
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerInfoAction.java29
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUpdater.java64
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerUtilities.java410
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModel.java147
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ResourceMarkerAnnotationModelFactory.java35
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerAction.java320
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectMarkerRulerInfoAction.java30
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SelectRulerAction.java30
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/SimpleMarkerAnnotation.java108
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TaskRulerAction.java77
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.java51
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/TextEditorMessages.properties71
-rw-r--r--org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/package.html10
91 files changed, 0 insertions, 17983 deletions
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
deleted file mode 100644
index 65fbeb337..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.io.CharConversionException;
-import java.io.UnsupportedEncodingException;
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Preferences;
-
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.StatusTextEditor;
-
-
-/**
- * The standard implementation of <code>IEncodingSupport</code>.
- * @since 2.0
- */
-public class DefaultEncodingSupport implements IEncodingSupport {
-
- /** Internal property change listener. */
- private Preferences.IPropertyChangeListener fPropertyChangeListener;
- /** The editor this support is associated with. */
- private StatusTextEditor fTextEditor;
- /** The action group of this support. */
- private EncodingActionGroup fEncodingActionGroup;
-
- /**
- * Creates a new encoding support.
- */
- public DefaultEncodingSupport() {
- super();
- }
-
- /**
- * Associates this encoding support to the given text editor and initializes this encoding.
- *
- * @param textEditor the editor
- */
- public void initialize(StatusTextEditor textEditor) {
-
- fTextEditor= textEditor;
-
- fPropertyChangeListener= new Preferences.IPropertyChangeListener() {
- public void propertyChange(Preferences.PropertyChangeEvent e) {
- if (ResourcesPlugin.PREF_ENCODING.equals(e.getProperty()))
- setEncoding(null, false); // null means: use default
- }
- };
-
- Preferences p= ResourcesPlugin.getPlugin().getPluginPreferences();
- p.addPropertyChangeListener(fPropertyChangeListener);
-
- fEncodingActionGroup= new EncodingActionGroup(fTextEditor);
- fEncodingActionGroup.update();
- }
-
- /**
- * Disposes this encoding support.
- */
- public void dispose() {
- Preferences p= ResourcesPlugin.getPlugin().getPluginPreferences();
- p.removePropertyChangeListener(fPropertyChangeListener);
-
- fEncodingActionGroup.dispose();
- fEncodingActionGroup= null;
-
- fTextEditor= null;
- }
-
- /**
- * Resets this encoding support. Should be called if, e.g., the input element of the
- * associated editor changed.
- */
- public void reset() {
- fEncodingActionGroup.update();
- }
-
- /**
- * Sets the encoding of the editor's input to the given value. If <code>overwrite</code> is
- * <code>true</code> the value is set even if the encoding is already set.
- *
- * @param encoding the new encoding
- * @param overwrite <code>true</code> if current encoding should be overwritten
- */
- protected void setEncoding(String encoding, boolean overwrite) {
- IDocumentProvider p= fTextEditor.getDocumentProvider();
- if (p instanceof IStorageDocumentProvider) {
- final IEditorInput input= fTextEditor.getEditorInput();
- IStorageDocumentProvider provider= (IStorageDocumentProvider)p;
- String current= provider.getEncoding(input);
- if (!fTextEditor.isDirty()) {
- String internal= encoding == null ? "" : encoding; //$NON-NLS-1$
- boolean apply= (overwrite || current == null) && !internal.equals(current);
- if (apply) {
- provider.setEncoding(input, encoding);
- Runnable encodingSetter=
- new Runnable() {
- public void run() {
- fTextEditor.doRevertToSaved();
- fTextEditor.updatePartControl(input);
- }
- };
- Display display= fTextEditor.getSite().getShell().getDisplay();
- if (display != null && !display.isDisposed())
- BusyIndicator.showWhile(display, encodingSetter);
- else
- encodingSetter.run();
- }
- }
- fEncodingActionGroup.update();
- }
- }
-
- /*
- * @see IEncodingSupport#setEncoding(String)
- */
- public void setEncoding(String encoding) {
- setEncoding(encoding, true);
- }
-
- /*
- * @see IEncodingSupport#getEncoding()
- */
- public String getEncoding() {
- IDocumentProvider p= fTextEditor.getDocumentProvider();
- if (p instanceof IStorageDocumentProvider) {
- IStorageDocumentProvider provider= (IStorageDocumentProvider) p;
- return provider.getEncoding(fTextEditor.getEditorInput());
- }
- return null;
- }
-
- /*
- * @see IEncodingSupport#getDefaultEncoding()
- */
- public String getDefaultEncoding() {
- IDocumentProvider p= fTextEditor.getDocumentProvider();
- if (p instanceof IStorageDocumentProvider) {
- IStorageDocumentProvider provider= (IStorageDocumentProvider) p;
- return provider.getDefaultEncoding();
- }
- return null;
- }
-
- /**
- * Returns a status header for the given status.
- *
- * @param status the status
- * @return a status header for the given status.
- */
- public String getStatusHeader(IStatus status) {
- Throwable t= status.getException();
-
- if (t instanceof CharConversionException)
- return TextEditorMessages.getString("Editor.error.unreadable_encoding.header"); //$NON-NLS-1$
-
- if (t instanceof UnsupportedEncodingException)
- return TextEditorMessages.getString("Editor.error.unsupported_encoding.header"); //$NON-NLS-1$
-
- return null;
- }
-
- /**
- * Returns a banner for the given status.
- *
- * @param status the status
- * @return a banner for the given status.
- */
- public String getStatusBanner(IStatus status) {
- Throwable t= status.getException();
-
- if (t instanceof CharConversionException)
- return TextEditorMessages.getString("Editor.error.unreadable_encoding.banner"); //$NON-NLS-1$
-
- if (t instanceof UnsupportedEncodingException)
- return TextEditorMessages.getString("Editor.error.unsupported_encoding.banner"); //$NON-NLS-1$
-
- return null;
-
- }
-
- /**
- * Returns a status message if any.
- *
- * @param status the status
- * @return a status message indicating encoding problems or <code>null</code> otherwise
- */
- public String getStatusMessage(IStatus status) {
- Throwable t= status.getException();
- if (t instanceof CharConversionException || t instanceof UnsupportedEncodingException) {
-
- String encoding= getEncoding();
- if (encoding == null)
- encoding= getDefaultEncoding();
-
- if (t instanceof CharConversionException) {
- if (encoding != null)
- return MessageFormat.format(TextEditorMessages.getString("Editor.error.unreadable_encoding.message_arg"), new Object[] { encoding }); //$NON-NLS-1$
- return TextEditorMessages.getString("Editor.error.unreadable_encoding.message"); //$NON-NLS-1$
- }
-
- if (t instanceof UnsupportedEncodingException) {
- if (encoding != null)
- return TextEditorMessages.getFormattedString("Editor.error.unsupported_encoding.message_arg", encoding); //$NON-NLS-1$
- return TextEditorMessages.getString("Editor.error.unsupported_encoding.message"); //$NON-NLS-1$
- }
- }
-
- return null;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java
deleted file mode 100644
index ceb5384f4..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EditorsUI.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.core.runtime.Preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
-import org.eclipse.ui.texteditor.AnnotationTypeLookup;
-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
-
-/**
- * The central class for access to this plug-in.
- * This class cannot be instantiated; all functionality is provided by
- * static methods.
- *
- * @since 3.0
- */
-public final class EditorsUI {
-
- /**
- * TextEditor Plug-in ID (value <code>"org.eclipse.ui.editors"</code>).
- */
- public static final String PLUGIN_ID= "org.eclipse.ui.editors"; //$NON-NLS-1$
-
- /**
- * The ID of the default text editor.
- */
- public static final String DEFAULT_TEXT_EDITOR_ID = "org.eclipse.ui.DefaultTextEditor"; //$NON-NLS-1$
-
-
- /**
- * Returns the annotation type lookup of this plug-in.
- *
- * @return the annotation type lookup
- */
- public static AnnotationTypeLookup getAnnotationTypeLookup() {
- return EditorsPlugin.getDefault().getAnnotationTypeLookup();
- }
-
- /**
- * Returns the annotation preference lookup of this plug-in.
- *
- * @return the annotation preference lookup
- */
- public static AnnotationPreferenceLookup getAnnotationPreferenceLookup() {
- return EditorsPlugin.getDefault().getAnnotationPreferenceLookup();
- }
-
- /**
- * Returns the preference store of this plug-in.
- *
- * @return this plug-in's preference store
- */
- public static IPreferenceStore getPreferenceStore() {
- return EditorsPlugin.getDefault().getPreferenceStore();
- }
-
- /**
- * Removes all preference which are handled by this plug-in's
- * general preference pages from the given store and prevents
- * setting the default values in the future.
- * <p>
- * To access the
- * general preference from another plug-in use a
- * {@link org.eclipse.ui.texteditor.ChainedPreferenceStore}:
- * <pre>
- * List stores= new ArrayList(3);
- * stores.add(YourPlugin.getDefault().getPreferenceStore());
- * stores.add(EditorsUI.getPreferenceStore());
- * combinedStore= new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
- *
- * </pre>
- * </p>
- * <p>
- * Note: In order to work this method must be called before
- * the store's default values are set.
- * </p>
- *
- * @param store the preference store to mark
- */
- public static void useAnnotationsPreferencePage(IPreferenceStore store) {
- MarkerAnnotationPreferences.useAnnotationsPreferencePage(store);
- }
-
- /**
- * Removes all preference which are handled by this plug-in's
- * Quick Diff preference page from the given store and prevents
- * setting the default values in the future.
- * <p>
- * To access the
- * general preference from another plug-in use a
- * {@link org.eclipse.ui.texteditor.ChainedPreferenceStore}:
- * <pre>
- * List stores= new ArrayList(3);
- * stores.add(YourPlugin.getDefault().getPreferenceStore());
- * stores.add(EditorsUI.getPreferenceStore());
- * combinedStore= new ChainedPreferenceStore((IPreferenceStore[]) stores.toArray(new IPreferenceStore[stores.size()]));
- *
- * </pre>
- * </p>
- * <p>
- * Note: In order to work this method must be called before
- * the store's default values are set.
- * </p>
- *
- * @param store the preference store to mark
- */
- public static void useQuickDiffPreferencePage(IPreferenceStore store) {
- MarkerAnnotationPreferences.useQuickDiffPreferencePage(store);
-
- store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON);
- store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE);
- store.setToDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER);
- }
-
- private EditorsUI() {
- // block instantiation
- }
-
- /**
- * Returns the preferences of this plug-in.
- *
- * @return the plug-in preferences
- * @see org.eclipse.core.runtime.Plugin#getPluginPreferences()
- */
- public static Preferences getPluginPreferences() {
- return EditorsPlugin.getDefault().getPluginPreferences();
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
deleted file mode 100644
index bb774194d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/EncodingActionGroup.java
+++ /dev/null
@@ -1,463 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.content.IContentDescription;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.jface.dialogs.InputDialog;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.actions.ActionGroup;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.ResourceAction;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-
-/**
- * Action group for encoding actions.
- * @since 2.0
- */
-public class EncodingActionGroup extends ActionGroup {
-
- private static final String FILE_CONTENT_ENCODING_FORMAT= TextEditorMessages.getString("ResourceInfo.fileContentEncodingFormat"); //$NON-NLS-1$
- private static final String FILE_CONTAINER_ENCODING_FORMAT= TextEditorMessages.getString("ResourceInfo.fileContainerEncodingFormat"); //$NON-NLS-1$
-
-
- /**
- * Action for setting the encoding of the editor to the value this action has
- * been initialized with.
- */
- static class PredefinedEncodingAction extends TextEditorAction {
-
- /** The target encoding of this action. */
- private String fEncoding;
- /** The action label. */
- private String fLabel;
- /** Indicates whether the target encoding is the default encoding. */
- private boolean fIsDefault;
-
- /**
- * Creates a new action for the given specification.
- *
- * @param bundle the resource bundle
- * @param prefix the prefix for lookups from the resource bundle
- * @param encoding the target encoding
- * @param editor the target editor
- */
- public PredefinedEncodingAction(ResourceBundle bundle, String prefix, String encoding, ITextEditor editor) {
- super(bundle, prefix, editor);
- fEncoding= encoding;
- if (prefix == null)
- setText(encoding);
- fLabel= getText();
- }
-
- /**
- * Creates a new action for the given specification.
- *
- * @param bundle the resource bundle
- * @param encoding the target encoding
- * @param editor the target editor
- */
- public PredefinedEncodingAction(ResourceBundle bundle, String encoding, ITextEditor editor) {
- super(bundle, null, editor);
- fEncoding= encoding;
- setText(encoding);
- fLabel= getText();
- }
-
- /**
- * Returns the encoding support of the action's editor.
- *
- * @return the encoding support of the action's editor or <code>null</code> if none
- */
- private IEncodingSupport getEncodingSupport() {
- ITextEditor editor= getTextEditor();
- if (editor != null)
- return (IEncodingSupport) editor.getAdapter(IEncodingSupport.class);
- return null;
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- IEncodingSupport s= getEncodingSupport();
- if (s != null)
- s.setEncoding(fIsDefault ? null : fEncoding);
- }
-
- /**
- * Returns the encoding currently used in the given editor.
- *
- * @param editor the editor
- * @return the encoding currently used in the given editor or <code>null</code> if no encoding support is installed
- */
- private String getEncoding(ITextEditor editor) {
-
- IEditorInput input= (editor.getEditorInput());
- if (input instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)input).getFile();
- try {
- String explicitEncoding;
- explicitEncoding= file.getCharset(false);
- if (explicitEncoding == null)
- return null;
- } catch (CoreException e) {
- // continue - assume file is not using default encoding
- }
- }
-
- IEncodingSupport s= getEncodingSupport();
- if (s != null)
- return s.getEncoding();
-
- return null;
- }
-
- /*
- * @see IUpdate#update()
- */
- public void update() {
-
- if (fEncoding == null) {
- setEnabled(false);
- return;
- }
-
- ITextEditor editor= getTextEditor();
- if (editor == null) {
- setEnabled(false);
- return;
- }
-
- // update label
- fIsDefault= IEncodingActionsConstants.DEFAULT.equals(fEncoding);
- if (fIsDefault)
- setText(getDefaultEncodingText(editor, fLabel));
- else
- setText(fLabel);
-
- // update enable state
- if (editor.isDirty())
- setEnabled(false);
- else
- setEnabled(true);
-
- // update checked state
- String current= getEncoding(editor);
- if (fIsDefault)
- setChecked(current == null);
- else
- setChecked(fEncoding.equals(current));
- }
-
- }
-
- /*
- * @since 3.0
- */
- private static String getDefaultEncodingText(ITextEditor editor, String defaultText) {
- IEditorInput input= (editor.getEditorInput());
- if (!(input instanceof IFileEditorInput))
- return defaultText;
-
- IFile file= ((IFileEditorInput)input).getFile();
-
- String format= format= FILE_CONTENT_ENCODING_FORMAT;
- String encoding;
- try {
- encoding= getEncodingFromContent(file);
- if (encoding == null) {
- format= FILE_CONTAINER_ENCODING_FORMAT;
- encoding= file.getParent().getDefaultCharset();
- }
- } catch (CoreException ex) {
- return defaultText;
- }
-
- return MessageFormat.format(format, new String[] { encoding });
- }
-
- /*
- * @since 3.0
- */
- private static String getEncodingFromContent(IFile file) throws CoreException {
- IContentDescription description = file.getContentDescription();
- if (description != null) {
- byte[] bom= (byte[])description.getProperty(IContentDescription.BYTE_ORDER_MARK);
- if (bom == null)
- return (String)description.getProperty(IContentDescription.CHARSET);
- if (bom == IContentDescription.BOM_UTF_8)
- return TextEditorMessages.getString("WorkbenchPreference.encoding.BOM_UTF_8"); //$NON-NLS-1$
- if (bom == IContentDescription.BOM_UTF_16BE)
- return TextEditorMessages.getString("WorkbenchPreference.encoding.BOM_UTF_16BE"); //$NON-NLS-1$
- if (bom == IContentDescription.BOM_UTF_16LE)
- return TextEditorMessages.getString("WorkbenchPreference.encoding.BOM_UTF_16LE"); //$NON-NLS-1$
- }
-
- return null;
- }
-
- /**
- * Sets the encoding of an editor to the value that has interactively been defined.
- */
- static class CustomEncodingAction extends TextEditorAction {
-
-
- /*
- * @see org.eclipse.ui.texteditor.TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor)
- */
- protected CustomEncodingAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /*
- * @see IUpdate#update()
- */
- public void update() {
- ITextEditor editor= getTextEditor();
- setEnabled(editor != null && !editor.isDirty());
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
-
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- IEncodingSupport encodingSupport= (IEncodingSupport) editor.getAdapter(IEncodingSupport.class);
- if (encodingSupport == null)
- return;
-
- String title= TextEditorMessages.getString("Editor.ConvertEncoding.Custom.dialog.title"); //$NON-NLS-1$
- String message= TextEditorMessages.getString("Editor.ConvertEncoding.Custom.dialog.message"); //$NON-NLS-1$
- IInputValidator inputValidator = new IInputValidator() {
- public String isValid(String newText) {
- return (newText == null || newText.length() == 0) ? " " : null; //$NON-NLS-1$
- }
- };
-
- String initialValue= encodingSupport.getEncoding();
- if (initialValue == null)
- initialValue= encodingSupport.getDefaultEncoding();
- if (initialValue == null)
- initialValue= ""; //$NON-NLS-1$
-
- InputDialog d= new InputDialog(editor.getSite().getShell(), title, message, initialValue, inputValidator); //$NON-NLS-1$
- if (d.open() == Window.OK)
- encodingSupport.setEncoding(d.getValue());
- }
- }
-
-
- /** List of predefined encodings. */
- private static final String[][] ENCODINGS;
-
- /** The default encoding. */
- private static final String SYSTEM_ENCODING;
-
- /**
- * Initializer: computes the set of predefined encoding actions.
- */
- static {
-
- String[][] encodings= {
- { IEncodingActionsConstants.DEFAULT, IEncodingActionsHelpContextIds.DEFAULT, IEncodingActionsDefinitionIds.DEFAULT },
- { IEncodingActionsConstants.US_ASCII, IEncodingActionsHelpContextIds.US_ASCII, IEncodingActionsDefinitionIds.US_ASCII },
- { IEncodingActionsConstants.ISO_8859_1, IEncodingActionsHelpContextIds.ISO_8859_1, IEncodingActionsDefinitionIds.ISO_8859_1 },
- { IEncodingActionsConstants.UTF_8, IEncodingActionsHelpContextIds.UTF_8, IEncodingActionsDefinitionIds.UTF_8 },
- { IEncodingActionsConstants.UTF_16BE, IEncodingActionsHelpContextIds.UTF_16BE, IEncodingActionsDefinitionIds.UTF_16BE },
- { IEncodingActionsConstants.UTF_16LE, IEncodingActionsHelpContextIds.UTF_16LE, IEncodingActionsDefinitionIds.UTF_16LE },
- { IEncodingActionsConstants.UTF_16, IEncodingActionsHelpContextIds.UTF_16, IEncodingActionsDefinitionIds.UTF_16 }
- };
-
- String system= System.getProperty("file.encoding"); //$NON-NLS-1$
- if (system != null) {
-
- int i;
- for (i= 0; i < encodings.length; i++) {
- if (encodings[i][0].equals(system))
- break;
- }
-
- if (i != encodings.length) {
- // bring system encoding in second position - first is default encoding
- String[] s= encodings[i];
- encodings[i]= encodings[1];
- encodings[1]= s;
- // forget system encoding as it's already in the list
- system= null;
- }
- }
-
- SYSTEM_ENCODING= system;
- ENCODINGS= encodings;
- }
-
-
-
- /** List of encoding actions of this group. */
- private List fRetargetActions= new ArrayList();
-
- /**
- * Creates a new encoding action group for an action bar contributor.
- */
- public EncodingActionGroup() {
-
- ResourceBundle b= TextEditorMessages.getResourceBundle();
-
- fRetargetActions.add(new RetargetTextEditorAction(b, "Editor.ConvertEncoding." + ENCODINGS[0][0] + ".", ENCODINGS[0][0], IAction.AS_RADIO_BUTTON)); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (SYSTEM_ENCODING != null)
- fRetargetActions.add(new RetargetTextEditorAction(b, "Editor.ConvertEncoding.System.", IEncodingActionsConstants.SYSTEM, IAction.AS_RADIO_BUTTON)); //$NON-NLS-1$
-
- for (int i= 1; i < ENCODINGS.length; i++)
- fRetargetActions.add(new RetargetTextEditorAction(b, "Editor.ConvertEncoding." + ENCODINGS[i][0] + ".", ENCODINGS[i][0], IAction.AS_RADIO_BUTTON)); //$NON-NLS-1$ //$NON-NLS-2$
-
- fRetargetActions.add(new RetargetTextEditorAction(b, "Editor.ConvertEncoding.Custom.", IEncodingActionsConstants.CUSTOM, IAction.AS_PUSH_BUTTON)); //$NON-NLS-1$
- }
-
- /*
- * @see ActionGroup#fillActionBars(org.eclipse.ui.IActionBars)
- */
- public void fillActionBars(IActionBars actionBars) {
- IMenuManager menuManager= actionBars.getMenuManager();
- IMenuManager editMenu= menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null && fRetargetActions.size() > 0) {
- MenuManager subMenu= new MenuManager(TextEditorMessages.getString("Editor.ConvertEncoding.submenu.label")); //$NON-NLS-1$
- subMenu.addMenuListener(new IMenuListener() {
- public void menuAboutToShow(IMenuManager manager) {
- update();
- }
- });
-
- Iterator e= fRetargetActions.iterator();
- subMenu.add((IAction) e.next());
- subMenu.add(new Separator());
- while (e.hasNext())
- subMenu.add((IAction) e.next());
-
- editMenu.add(subMenu);
- }
- }
-
- /**
- * Retargets this action group to the given editor.
- *
- * @param editor the text editor to which the group should be retargeted
- */
- public void retarget(ITextEditor editor) {
- fTextEditor= editor;
- Iterator e= fRetargetActions.iterator();
- while (e.hasNext()) {
- RetargetTextEditorAction a= (RetargetTextEditorAction) e.next();
- a.setAction(editor == null ? null : editor.getAction(a.getId()));
- }
- }
-
-
- //------------------------------------------------------------------------------------------
-
-
- /** Text editor this group is associated with. */
- private ITextEditor fTextEditor;
-
- /**
- * Creates a new encoding action group for the given editor.
- *
- * @param editor the text editor
- */
- public EncodingActionGroup(ITextEditor editor) {
-
- fTextEditor= editor;
- ResourceBundle b= TextEditorMessages.getResourceBundle();
-
- ResourceAction a;
- if (SYSTEM_ENCODING != null) {
- a= new PredefinedEncodingAction(b, SYSTEM_ENCODING, editor);
- a.setHelpContextId(IEncodingActionsHelpContextIds.SYSTEM);
- a.setActionDefinitionId(IEncodingActionsDefinitionIds.SYSTEM);
- editor.setAction(IEncodingActionsConstants.SYSTEM, a);
- }
-
- for (int i= 0; i < ENCODINGS.length; i++) {
- a= new PredefinedEncodingAction(b, "Editor.ConvertEncoding." + ENCODINGS[i][0] + ".", ENCODINGS[i][0], editor); //$NON-NLS-1$ //$NON-NLS-2$
- a.setHelpContextId( ENCODINGS[i][1]);
- a.setActionDefinitionId( ENCODINGS[i][2]);
- editor.setAction(ENCODINGS[i][0], a);
- }
-
- a= new CustomEncodingAction(b, "Editor.ConvertEncoding." + IEncodingActionsConstants.CUSTOM + ".", editor); //$NON-NLS-1$ //$NON-NLS-2$
- a.setHelpContextId(IEncodingActionsHelpContextIds.CUSTOM);
- a.setActionDefinitionId(IEncodingActionsDefinitionIds.CUSTOM);
- editor.setAction(IEncodingActionsConstants.CUSTOM, a);
- }
-
- /**
- * Updates all actions of this action group.
- */
- public void update() {
- if (fTextEditor == null)
- return;
-
- IAction a= fTextEditor.getAction(IEncodingActionsConstants.SYSTEM);
- if (a instanceof IUpdate)
- ((IUpdate) a).update();
-
- for (int i= 0; i < ENCODINGS.length; i++) {
- a= fTextEditor.getAction(ENCODINGS[i][0]);
- if (a instanceof IUpdate)
- ((IUpdate) a).update();
- }
-
- a= fTextEditor.getAction(IEncodingActionsConstants.CUSTOM);
- if (a instanceof IUpdate)
- ((IUpdate) a).update();
- }
-
- /*
- * @see ActionGroup#dispose()
- */
- public void dispose() {
- if (fTextEditor != null) {
- fTextEditor.setAction(IEncodingActionsConstants.SYSTEM, null);
- for (int i= 0; i < ENCODINGS.length; i++)
- fTextEditor.setAction(ENCODINGS[i][0], null);
- fTextEditor.setAction(IEncodingActionsConstants.CUSTOM, null);
-
- fTextEditor= null;
- }
- }
-}
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
deleted file mode 100644
index 85679f1b3..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/FileDocumentProvider.java
+++ /dev/null
@@ -1,1053 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.internal.filebuffers.ContainerGenerator;
-import org.eclipse.core.resources.IFile;
-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.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceRuleFactory;
-import org.eclipse.core.resources.IResourceStatus;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-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;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner;
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
-import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
-
-
-/**
- * Shared document provider specialized for file resources (<code>IFile</code>).
- * <p>
- * This class may be instantiated or be subclassed.</p>
- */
-public class FileDocumentProvider extends StorageDocumentProvider {
-
- /**
- * Qualified name for the encoding key.
- *
- * @since 2.1
- */
- private static final QualifiedName ENCODING_KEY = new QualifiedName(EditorsUI.PLUGIN_ID, "encoding"); //$NON-NLS-1$
- /**
- * Constant denoting UTF-8 encoding.
- * @since 3.0
- */
- private static final String CHARSET_UTF_8= "UTF-8"; //$NON-NLS-1$
-
-
- /**
- * The runnable context for that provider.
- * @since 3.0
- */
- private WorkspaceOperationRunner fOperationRunner;
- /**
- * The scheduling rule factory.
- * @since 3.0
- */
- private IResourceRuleFactory fResourceRuleFactory;
-
- /**
- * Runnable encapsulating an element state change. This runnable ensures
- * that a element change failed message is sent out to the element state listeners
- * in case an exception occurred.
- *
- * @since 2.0
- */
- protected class SafeChange implements Runnable {
-
- /** The input that changes. */
- private IFileEditorInput fInput;
-
- /**
- * Creates a new safe runnable for the given input.
- *
- * @param input the input
- */
- public SafeChange(IFileEditorInput input) {
- fInput= input;
- }
-
- /**
- * Execute the change.
- * Subclass responsibility.
- *
- * @param input the input
- * @throws Exception an exception in case of error
- */
- protected void execute(IFileEditorInput input) throws Exception {
- }
-
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
-
- if (getElementInfo(fInput) == null) {
- fireElementStateChangeFailed(fInput);
- return;
- }
-
- try {
- execute(fInput);
- } catch (Exception e) {
- fireElementStateChangeFailed(fInput);
- }
- }
- }
-
-
- /**
- * Synchronizes the document with external resource changes.
- */
- protected class FileSynchronizer implements IResourceChangeListener, IResourceDeltaVisitor {
-
- /** The file editor input. */
- protected IFileEditorInput fFileEditorInput;
- /**
- * A flag indicating whether this synchronizer is installed or not.
- *
- * @since 2.1
- */
- protected boolean fIsInstalled= false;
-
- /**
- * Creates a new file synchronizer. Is not yet installed on a resource.
- *
- * @param fileEditorInput the editor input to be synchronized
- */
- public FileSynchronizer(IFileEditorInput fileEditorInput) {
- fFileEditorInput= fileEditorInput;
- }
-
- /**
- * Creates a new file synchronizer which is not yet installed on a resource.
- *
- * @param fileEditorInput the editor input to be synchronized
- * @deprecated use {@link FileSynchronizer#FileSynchronizer(IFileEditorInput)}
- */
- public FileSynchronizer(FileEditorInput fileEditorInput) {
- fFileEditorInput= fileEditorInput;
- }
-
- /**
- * Returns the file wrapped by the file editor input.
- *
- * @return the file wrapped by the editor input associated with that synchronizer
- */
- protected IFile getFile() {
- return fFileEditorInput.getFile();
- }
-
- /**
- * Installs the synchronizer on the input's file.
- */
- public void install() {
- getFile().getWorkspace().addResourceChangeListener(this);
- fIsInstalled= true;
- }
-
- /**
- * Uninstalls the synchronizer from the input's file.
- */
- public void uninstall() {
- getFile().getWorkspace().removeResourceChangeListener(this);
- fIsInstalled= false;
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent e) {
- IResourceDelta delta= e.getDelta();
- try {
- if (delta != null && fIsInstalled)
- delta.accept(this);
- } catch (CoreException x) {
- handleCoreException(x, "FileDocumentProvider.resourceChanged"); //$NON-NLS-1$
- }
- }
-
- /*
- * @see IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
-
- if (delta != null && getFile().equals(delta.getResource())) {
-
- Runnable runnable= null;
-
- switch (delta.getKind()) {
- case IResourceDelta.CHANGED:
- if ((IResourceDelta.CONTENT & delta.getFlags()) != 0) {
- FileInfo info= (FileInfo) getElementInfo(fFileEditorInput);
- if (info != null && !info.fCanBeSaved && computeModificationStamp(getFile()) != info.fModificationStamp) {
- runnable= new SafeChange(fFileEditorInput) {
- protected void execute(IFileEditorInput input) throws Exception {
- handleElementContentChanged(input);
- }
- };
- }
- }
- break;
- case IResourceDelta.REMOVED:
- if ((IResourceDelta.MOVED_TO & delta.getFlags()) != 0) {
- final IPath path= delta.getMovedToPath();
- runnable= new SafeChange(fFileEditorInput) {
- protected void execute(IFileEditorInput input) throws Exception {
- handleElementMoved(input, path);
- }
- };
- } else {
- FileInfo info= (FileInfo) getElementInfo(fFileEditorInput);
- if (info != null && !info.fCanBeSaved) {
- runnable= new SafeChange(fFileEditorInput) {
- protected void execute(IFileEditorInput input) throws Exception {
- handleElementDeleted(input);
- }
- };
- }
- }
- break;
- }
-
- if (runnable != null)
- update(runnable);
- }
-
- return true; // because we are sitting on files anyway
- }
-
- /**
- * Posts the update code "behind" the running operation.
- *
- * @param runnable the update code
- */
- protected void update(Runnable runnable) {
-
- if (runnable instanceof SafeChange)
- fireElementStateChanging(fFileEditorInput);
-
- IWorkbench workbench= PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- if (windows != null && windows.length > 0) {
- Display display= windows[0].getShell().getDisplay();
- display.asyncExec(runnable);
- } else {
- runnable.run();
- }
- }
- }
-
-
-
- /**
- * Bundle of all required information to allow files as underlying document resources.
- */
- protected class FileInfo extends StorageInfo {
-
- /** The file synchronizer. */
- public FileSynchronizer fFileSynchronizer;
- /** The time stamp at which this provider changed the file. */
- public long fModificationStamp= IResource.NULL_STAMP;
- /**
- * Tells whether the file on disk has a BOM.
- */
- private boolean fHasBOM;
-
- /**
- * Creates and returns a new file info.
- *
- * @param document the document
- * @param model the annotation model
- * @param fileSynchronizer the file synchronizer
- */
- public FileInfo(IDocument document, IAnnotationModel model, FileSynchronizer fileSynchronizer) {
- super(document, model);
- fFileSynchronizer= fileSynchronizer;
- }
- }
-
-
- /**
- * Creates and returns a new document provider.
- */
- public FileDocumentProvider() {
- super();
- fResourceRuleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
- }
-
- /**
- * Overrides <code>StorageDocumentProvider#setDocumentContent(IDocument, IEditorInput)</code>.
- *
- * @see StorageDocumentProvider#setDocumentContent(IDocument, IEditorInput)
- * @deprecated use file encoding based version
- * @since 2.0
- */
- protected boolean setDocumentContent(IDocument document, IEditorInput editorInput) throws CoreException {
- if (editorInput instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) editorInput).getFile();
- setDocumentContent(document, file.getContents(false));
- return true;
- }
- return super.setDocumentContent(document, editorInput);
- }
-
- /*
- * @see StorageDocumentProvider#setDocumentContent(IDocument, IEditorInput, String)
- * @since 2.0
- */
- protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException {
- if (editorInput instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput) editorInput).getFile();
- InputStream contentStream= file.getContents(false);
-
- FileInfo info= (FileInfo)getElementInfo(editorInput);
-
- /*
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- * </p>
- */
- if (info != null && info.fHasBOM && CHARSET_UTF_8.equals(encoding)) {
- try {
- contentStream.read(new byte[IContentDescription.BOM_UTF_8.length]);
- } catch (IOException e) {
- // ignore if we cannot remove BOM
- }
- }
-
- setDocumentContent(document, contentStream, encoding);
- return true;
- }
- return super.setDocumentContent(document, editorInput, encoding);
- }
-
- /*
- * @see AbstractDocumentProvider#createAnnotationModel(Object)
- */
- protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return new ResourceMarkerAnnotationModel(input.getFile());
- }
-
- return super.createAnnotationModel(element);
- }
-
- /**
- * Checks whether the given resource has been changed on the
- * local file system by comparing the actual time stamp with the
- * cached one. If the resource has been changed, a <code>CoreException</code>
- * is thrown.
- *
- * @param cachedModificationStamp the cached modification stamp
- * @param resource the resource to check
- * @throws org.eclipse.core.runtime.CoreException if resource has been changed on the file system
- */
- protected void checkSynchronizationState(long cachedModificationStamp, IResource resource) throws CoreException {
- if (cachedModificationStamp != computeModificationStamp(resource)) {
- Status status= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IResourceStatus.OUT_OF_SYNC_LOCAL, TextEditorMessages.getString("FileDocumentProvider.error.out_of_sync"), null); //$NON-NLS-1$
- throw new CoreException(status);
- }
- }
-
- /**
- * Computes the initial modification stamp for the given resource.
- *
- * @param resource the resource
- * @return the modification stamp
- */
- protected long computeModificationStamp(IResource resource) {
- long modificationStamp= resource.getModificationStamp();
-
- IPath path= resource.getLocation();
- if (path == null)
- return modificationStamp;
-
- modificationStamp= path.toFile().lastModified();
- return modificationStamp;
- }
-
- /*
- * @see IDocumentProvider#getModificationStamp(Object)
- */
- public long getModificationStamp(Object element) {
-
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return computeModificationStamp(input.getFile());
- }
-
- return super.getModificationStamp(element);
- }
-
- /*
- * @see IDocumentProvider#getSynchronizationStamp(Object)
- */
- public long getSynchronizationStamp(Object element) {
-
- if (element instanceof IFileEditorInput) {
- FileInfo info= (FileInfo) getElementInfo(element);
- if (info != null)
- return info.fModificationStamp;
- }
-
- return super.getSynchronizationStamp(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSynchronize(java.lang.Object)
- * @since 3.0
- */
- protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
- if (element instanceof IFileEditorInput) {
-
- IFileEditorInput input= (IFileEditorInput) element;
-
- FileInfo info= (FileInfo) getElementInfo(element);
- if (info != null) {
-
- if (info.fFileSynchronizer != null) {
- info.fFileSynchronizer.uninstall();
- refreshFile(input.getFile(), monitor);
- info.fFileSynchronizer.install();
- } else {
- refreshFile(input.getFile(), monitor);
- }
-
- handleElementContentChanged((IFileEditorInput) element);
- }
- return;
-
- }
- super.doSynchronize(element, monitor);
- }
-
- /*
- * @see IDocumentProvider#isDeleted(Object)
- */
- public boolean isDeleted(Object element) {
-
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
-
- IPath path= input.getFile().getLocation();
- if (path == null)
- return true;
-
- return !path.toFile().exists();
- }
-
- return super.isDeleted(element);
- }
-
- /*
- * @see AbstractDocumentProvider#doSaveDocument(IProgressMonitor, Object, IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- if (element instanceof IFileEditorInput) {
-
- IFileEditorInput input= (IFileEditorInput) element;
- String encoding= null;
- try {
- FileInfo info= (FileInfo) getElementInfo(element);
- IFile file= input.getFile();
- encoding= getCharsetForNewFile(file, document, info);
-
- byte[] bytes= document.get().getBytes(encoding);
-
- /*
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- */
- if (info != null && info.fHasBOM && CHARSET_UTF_8.equals(encoding)) {
- int bomLength= IContentDescription.BOM_UTF_8.length;
- byte[] bytesWithBOM= new byte[bytes.length + bomLength];
- System.arraycopy(IContentDescription.BOM_UTF_8, 0, bytesWithBOM, 0, bomLength);
- System.arraycopy(bytes, 0, bytesWithBOM, bomLength, bytes.length);
- bytes= bytesWithBOM;
- }
-
- InputStream stream= new ByteArrayInputStream(bytes);
-
- if (file.exists()) {
-
- if (info != null && !overwrite)
- checkSynchronizationState(info.fModificationStamp, file);
-
- // inform about the upcoming content change
- fireElementStateChanging(element);
- try {
- file.setContents(stream, overwrite, true, monitor);
- } catch (CoreException x) {
- // inform about failure
- fireElementStateChangeFailed(element);
- throw x;
- } catch (RuntimeException x) {
- // inform about failure
- fireElementStateChangeFailed(element);
- throw x;
- }
-
- // If here, the editor state will be flipped to "not dirty".
- // Thus, the state changing flag will be reset.
-
- if (info != null) {
-
- ResourceMarkerAnnotationModel model= (ResourceMarkerAnnotationModel) info.fModel;
- model.updateMarkers(info.fDocument);
-
- info.fModificationStamp= computeModificationStamp(file);
- }
-
- } else {
- try {
- monitor.beginTask(TextEditorMessages.getString("FileDocumentProvider.task.saving"), 2000); //$NON-NLS-1$
- ContainerGenerator generator = new ContainerGenerator(file.getWorkspace(), file.getParent().getFullPath());
- generator.generateContainer(new SubProgressMonitor(monitor, 1000));
- file.create(stream, false, new SubProgressMonitor(monitor, 1000));
- }
- finally {
- monitor.done();
- }
- }
-
- } catch (UnsupportedEncodingException x) {
- String message= TextEditorMessages.getFormattedString("Editor.error.unsupported_encoding.message_arg", encoding); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- }
-
- } else {
- super.doSaveDocument(monitor, element, document, overwrite);
- }
- }
-
- /*
- * @since 3.0
- */
- private String getCharsetForNewFile(IFile targetFile, IDocument document, FileInfo info) {
- // User-defined encoding has first priority
- String encoding;
- try {
- encoding= targetFile.getCharset(false);
- } catch (CoreException ex) {
- encoding= null;
- }
- if (encoding != null)
- return encoding;
-
- // Probe content
- Reader reader= new BufferedReader(new StringReader(document.get()));
- try {
- QualifiedName[] options= new QualifiedName[] { IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK };
- IContentDescription description= Platform.getContentTypeManager().getDescriptionFor(reader, targetFile.getName(), options);
- if (description != null) {
- encoding= description.getCharset();
- if (encoding != null)
- return encoding;
- }
- } catch (IOException ex) {
- // continue with next strategy
- } finally {
- try {
- reader.close();
- } catch (IOException ex) {
- TextEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, "TextFileDocumentProvider.getCharsetForNewFile(...): Could not close reader", ex)); //$NON-NLS-1$
- }
- }
-
- // Use file's encoding if the file has a BOM
- if (info != null && info.fHasBOM)
- return info.fEncoding;
-
- // Use parent chain
- try {
- return targetFile.getParent().getDefaultCharset();
- } catch (CoreException ex) {
- // Use global default
- return ResourcesPlugin.getEncoding();
- }
- }
-
- /*
- * @see AbstractDocumentProvider#createElementInfo(Object)
- */
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- if (element instanceof IFileEditorInput) {
-
- IFileEditorInput input= (IFileEditorInput) element;
-
- try {
- refreshFile(input.getFile());
- } catch (CoreException x) {
- handleCoreException(x,TextEditorMessages.getString("FileDocumentProvider.createElementInfo")); //$NON-NLS-1$
- }
-
- IDocument d= null;
- IStatus s= null;
-
- try {
- d= createDocument(element);
- } catch (CoreException x) {
- s= x.getStatus();
- d= createEmptyDocument();
- }
-
- IAnnotationModel m= createAnnotationModel(element);
- FileSynchronizer f= new FileSynchronizer(input);
- f.install();
-
- FileInfo info= new FileInfo(d, m, f);
- info.fModificationStamp= computeModificationStamp(input.getFile());
- info.fStatus= s;
- info.fEncoding= getPersistedEncoding(input);
- info.fHasBOM= hasBOM(input);
-
- return info;
- }
-
- return super.createElementInfo(element);
- }
-
- /*
- * @see AbstractDocumentProvider#disposeElementInfo(Object, ElementInfo)
- */
- protected void disposeElementInfo(Object element, ElementInfo info) {
- if (info instanceof FileInfo) {
- FileInfo fileInfo= (FileInfo) info;
- if (fileInfo.fFileSynchronizer != null)
- fileInfo.fFileSynchronizer.uninstall();
- }
-
- super.disposeElementInfo(element, info);
- }
-
- /**
- * Updates the element info to a change of the file content and sends out
- * appropriate notifications.
- *
- * @param fileEditorInput the input of an text editor
- */
- protected void handleElementContentChanged(IFileEditorInput fileEditorInput) {
- FileInfo info= (FileInfo) getElementInfo(fileEditorInput);
- if (info == null)
- return;
-
- IDocument document= createEmptyDocument();
- IStatus status= null;
-
- try {
-
- try {
- refreshFile(fileEditorInput.getFile());
- } catch (CoreException x) {
- handleCoreException(x, "FileDocumentProvider.handleElementContentChanged"); //$NON-NLS-1$
- }
-
- setDocumentContent(document, fileEditorInput, info.fEncoding);
-
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- String newContent= document.get();
-
- if ( !newContent.equals(info.fDocument.get())) {
-
- // set the new content and fire content related events
- fireElementContentAboutToBeReplaced(fileEditorInput);
-
- removeUnchangedElementListeners(fileEditorInput, info);
-
- info.fDocument.removeDocumentListener(info);
- info.fDocument.set(newContent);
- info.fCanBeSaved= false;
- info.fModificationStamp= computeModificationStamp(fileEditorInput.getFile());
- info.fStatus= status;
-
- addUnchangedElementListeners(fileEditorInput, info);
-
- fireElementContentReplaced(fileEditorInput);
-
- } else {
-
- removeUnchangedElementListeners(fileEditorInput, info);
-
- // fires only the dirty state related event
- info.fCanBeSaved= false;
- info.fModificationStamp= computeModificationStamp(fileEditorInput.getFile());
- info.fStatus= status;
-
- addUnchangedElementListeners(fileEditorInput, info);
-
- fireElementDirtyStateChanged(fileEditorInput, false);
- }
- }
-
- /**
- * Sends out the notification that the file serving as document input has been moved.
- *
- * @param fileEditorInput the input of an text editor
- * @param path the path of the new location of the file
- */
- protected void handleElementMoved(IFileEditorInput fileEditorInput, IPath path) {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IFile newFile= workspace.getRoot().getFile(path);
- fireElementMoved(fileEditorInput, newFile == null ? null : new FileEditorInput(newFile));
- }
-
- /**
- * Sends out the notification that the file serving as document input has been deleted.
- *
- * @param fileEditorInput the input of an text editor
- */
- protected void handleElementDeleted(IFileEditorInput fileEditorInput) {
- fireElementDeleted(fileEditorInput);
- }
-
- /*
- * @see AbstractDocumentProvider#getElementInfo(Object)
- * It's only here to circumvent visibility issues with certain compilers.
- */
- protected ElementInfo getElementInfo(Object element) {
- return super.getElementInfo(element);
- }
-
- /*
- * @see AbstractDocumentProvider#doValidateState(Object, Object)
- * @since 2.0
- */
- protected void doValidateState(Object element, Object computationContext) throws CoreException {
-
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- FileInfo info= (FileInfo) getElementInfo(input);
- if (info != null) {
- IFile file= input.getFile();
- if (file.isReadOnly()) { // do not use cached state here
- IWorkspace workspace= file.getWorkspace();
- workspace.validateEdit(new IFile[] { file }, computationContext);
- }
- }
- }
-
- super.doValidateState(element, computationContext);
- }
-
- /*
- * @see IDocumentProviderExtension#isModifiable(Object)
- * @since 2.0
- */
- public boolean isModifiable(Object element) {
- if (!isStateValidated(element)) {
- if (element instanceof IFileEditorInput)
- return true;
- }
- return super.isModifiable(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doResetDocument(java.lang.Object, org.eclipse.core.runtime.IProgressMonitor)
- * @since 3.0
- */
- protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- try {
- refreshFile(input.getFile(), monitor);
- } catch (CoreException x) {
- handleCoreException(x,TextEditorMessages.getString("FileDocumentProvider.resetDocument")); //$NON-NLS-1$
- }
- }
-
- super.doResetDocument(element, monitor);
-
- IAnnotationModel model= getAnnotationModel(element);
- if (model instanceof AbstractMarkerAnnotationModel) {
- AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) model;
- markerModel.resetMarkers();
- }
- }
-
- /**
- * Refreshes the given file resource.
- *
- * @param file
- * @throws CoreException if the refresh fails
- * @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 org.eclipse.core.runtime.CoreException if the refresh fails
- * @since 3.0
- */
- protected void refreshFile(IFile file, IProgressMonitor monitor) throws CoreException {
- try {
- file.refreshLocal(IResource.DEPTH_INFINITE, monitor);
- } catch (OperationCanceledException x) {
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3#isSynchronized(java.lang.Object)
- * @since 3.0
- */
- public boolean isSynchronized(Object element) {
- if (element instanceof IFileEditorInput) {
- if (getElementInfo(element) != null) {
- IFileEditorInput input= (IFileEditorInput) element;
- IResource resource= input.getFile();
- return resource.isSynchronized(IResource.DEPTH_ZERO);
- }
- return false;
- }
- return super.isSynchronized(element);
- }
-
- // --------------- Encoding support ---------------
-
- /**
- * Returns the persisted encoding for the given element.
- *
- * @param element the element for which to get the persisted encoding
- * @return the persisted encoding
- * @since 2.1
- */
- protected String getPersistedEncoding(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput editorInput= (IFileEditorInput)element;
- IFile file= editorInput.getFile();
- if (file != null) {
- String encoding= null;
- try {
- encoding= file.getPersistentProperty(ENCODING_KEY);
- } catch (CoreException x) {
- // we ignore exceptions here because we support the ENCODING_KEY property only for compatibility reasons
- }
- if (encoding != null) {
- // if we found an old encoding property, we try to migrate it to the new core.resources encoding support
- try {
- file.setCharset(encoding);
- // if successful delete old property
- file.setPersistentProperty(ENCODING_KEY, null);
- } catch (CoreException ex) {
- handleCoreException(ex, TextEditorMessages.getString("FileDocumentProvider.getPersistedEncoding")); //$NON-NLS-1$
- }
- } else {
- try {
- encoding= file.getCharset();
- } catch (CoreException e) {
- encoding= null;
- }
- }
- return encoding;
- }
- }
- return super.getPersistedEncoding(element);
- }
-
- /**
- * Persists the given encoding for the given element.
- *
- * @param element the element for which to store the persisted encoding
- * @param encoding the encoding
- * @throws org.eclipse.core.runtime.CoreException if persisting the encoding fails
- * @since 2.1
- */
- protected void persistEncoding(Object element, String encoding) throws CoreException {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput editorInput= (IFileEditorInput)element;
- IFile file= editorInput.getFile();
- if (file != null) {
- file.setCharset(encoding);
- StorageInfo info= (StorageInfo)getElementInfo(element);
- if (info != null) {
- if (encoding == null)
- info.fEncoding= file.getCharset();
- if (info instanceof FileInfo)
- ((FileInfo)info).fHasBOM= hasBOM(element);
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getOperationRunner(org.eclipse.core.runtime.IProgressMonitor)
- * @since 3.0
- */
- protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
- if (fOperationRunner == null)
- fOperationRunner = new WorkspaceOperationRunner();
- fOperationRunner.setProgressMonitor(monitor);
- return fOperationRunner;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getResetRule(java.lang.Object)
- * @since 3.0
- */
- protected ISchedulingRule getResetRule(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return fResourceRuleFactory.modifyRule(input.getFile());
- } else {
- return null;
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getSaveRule(java.lang.Object)
- * @since 3.0
- */
- protected ISchedulingRule getSaveRule(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return computeSchedulingRule(input.getFile());
- } else {
- return null;
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getSynchronizeRule(java.lang.Object)
- * @since 3.0
- */
- protected ISchedulingRule getSynchronizeRule(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return fResourceRuleFactory.refreshRule(input.getFile());
- } else {
- return null;
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getValidateStateRule(java.lang.Object)
- * @since 3.0
- */
- protected ISchedulingRule getValidateStateRule(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return fResourceRuleFactory.validateEditRule(new IResource[] { input.getFile() });
- } else {
- return null;
- }
- }
-
- /**
- * Returns whether the underlying file has a BOM.
- *
- * @param element the element, or <code>null</code>
- * @return <code>true</code> if the underlying file has BOM
- */
- private boolean hasBOM(Object element) {
- if (element instanceof IFileEditorInput) {
- IFile file= ((IFileEditorInput)element).getFile();
- if (file != null) {
- try {
- IContentDescription description= file.getContentDescription();
- return description != null && description.getProperty(IContentDescription.BYTE_ORDER_MARK) != null;
- } catch (CoreException ex) {
- return false;
- }
- }
- }
- return false;
- }
-
- /**
- * Reads the file's UTF-8 BOM if any and stores it.
- * <p>
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- * </p>
- * @param file the file
- * @param encoding the encoding
- * @param element the element, or <code>null</code>
- * @throws org.eclipse.core.runtime.CoreException if reading the BOM fails
- * @since 3.0
- * @deprecated as of 3.0 this method is no longer in use and does nothing
- */
- protected void readUTF8BOM(IFile file, String encoding, Object element) throws CoreException {
- }
-
- /**
- * Computes the scheduling rule needed to create or modify a resource. If
- * the resource exists, its modify rule is returned. If it does not, the
- * resource hierarchy is iterated towards the workspace root to find the
- * first parent of <code>toCreateOrModify</code> that exists. Then the
- * 'create' rule for the last non-existing resource is returned.
- *
- * @param toCreateOrModify the resource to create or modify
- * @return the minimal scheduling rule needed to modify or create a resource
- */
- private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
- if (toCreateOrModify.exists()) {
- return fResourceRuleFactory.modifyRule(toCreateOrModify);
- } else {
- IResource parent= toCreateOrModify;
- do {
- toCreateOrModify= parent;
- parent= toCreateOrModify.getParent();
- } while (parent != null && !parent.exists());
-
- return fResourceRuleFactory.createRule(toCreateOrModify);
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ForwardingDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ForwardingDocumentProvider.java
deleted file mode 100644
index aba57975f..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ForwardingDocumentProvider.java
+++ /dev/null
@@ -1,365 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.core.filebuffers.IDocumentSetupParticipant;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension2;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension3;
-import org.eclipse.ui.texteditor.IElementStateListener;
-
-
-/**
- * A forwarding document provider is a document provider that forwards all requests
- * to a known parent document provider. The only functional addition of the
- * forwarding document provider is that it ensures that all documents provided
- * to clients are appropriately set up.
- * <p>
- * This document provider should be used by editors that directly or indirectly
- * work with a {@link org.eclipse.ui.editors.text.TextFileDocumentProvider} and do not
- * accept that they may be provided with documents which do not contain the partitioning
- * they work on. This can happen either because of a plug-in configuration error
- * or when a user associates a file name or file extension with an existing text
- * editor and the file buffer infrastructure does not recognize that file name
- * or file extension to be of the same file type the editor works on. Thus, the
- * document provided for the files with that name or extension may not be set up
- * in the way the editor expects it. The <code>ForwardingDocumentProvider</code>
- * compensates for that situation.
- * </p>
- * <p>
- * Editors that directly work with a {@link org.eclipse.ui.editors.text.TextFileDocumentProvider} can
- * now use a <code>ForwardingDocumentProvider</code> instead and configure a
- * {@link org.eclipse.ui.editors.text.TextFileDocumentProvider} as its parent provider. Editors that
- * indirectly work with a {@link org.eclipse.ui.editors.text.TextFileDocumentProvider}, e.g. never
- * set a document provider explicitly, should explicitly set a
- * <code>ForwardingDocumentProvider</code> as document provider. In this case
- * the forwarding document provider may not be shared between editors.
- * </p>
- *
- * @since 3.0
- */
-public class ForwardingDocumentProvider implements IDocumentProvider, IDocumentProviderExtension, IDocumentProviderExtension2, IDocumentProviderExtension3, IStorageDocumentProvider {
-
- private IDocumentProvider fParentProvider;
- private String fPartitioning;
- private IDocumentSetupParticipant fDocumentSetupParticipant;
- private boolean fAllowSetParentProvider;
-
-
- /**
- * Creates a new forwarding document provider with a fixed parent document provider. Calling
- * {@link #setParentProvider(IDocumentProvider)} does not have any effect on this object.
- *
- * @param partitioning the partitioning
- * @param documentSetupParticipant the document setup participant
- * @param parentProvider the parent document provider
- */
- public ForwardingDocumentProvider(String partitioning, IDocumentSetupParticipant documentSetupParticipant, IDocumentProvider parentProvider) {
- fPartitioning= partitioning;
- fDocumentSetupParticipant= documentSetupParticipant;
- fParentProvider= parentProvider;
- fAllowSetParentProvider= false;
- }
-
- /**
- * Creates a new forwarding document provider with a dynamically changeable
- * parent provider. Forwarding document providers created with that method
- * are not allowed to be shared by multiple editors.
- *
- * @param partitioning the partitioning
- * @param documentSetupParticipant the document setup participant
- */
- public ForwardingDocumentProvider(String partitioning, IDocumentSetupParticipant documentSetupParticipant) {
- fPartitioning= partitioning;
- fDocumentSetupParticipant= documentSetupParticipant;
- fAllowSetParentProvider= true;
- }
-
- /**
- * Sets the parent document provider. This method has only an effect if the
- * forwarding document provider has accordingly be created.
- *
- * @param parentProvider the new parent document provider
- */
- public void setParentProvider(IDocumentProvider parentProvider) {
- if (fAllowSetParentProvider)
- fParentProvider= parentProvider;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#connect(java.lang.Object)
- */
- public void connect(Object element) throws CoreException {
- fParentProvider.connect(element);
- IDocument document= fParentProvider.getDocument(element);
- if (document instanceof IDocumentExtension3) {
- IDocumentExtension3 extension= (IDocumentExtension3) document;
- if (extension.getDocumentPartitioner(fPartitioning) == null)
- fDocumentSetupParticipant.setup(document);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#disconnect(java.lang.Object)
- */
- public void disconnect(Object element) {
- fParentProvider.disconnect(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getDocument(java.lang.Object)
- */
- public IDocument getDocument(Object element) {
- return fParentProvider.getDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#resetDocument(java.lang.Object)
- */
- public void resetDocument(Object element) throws CoreException {
- fParentProvider.resetDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#saveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- public void saveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- fParentProvider.saveDocument(monitor, element, document, overwrite);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getModificationStamp(java.lang.Object)
- */
- public long getModificationStamp(Object element) {
- return fParentProvider.getModificationStamp(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getSynchronizationStamp(java.lang.Object)
- */
- public long getSynchronizationStamp(Object element) {
- return fParentProvider.getSynchronizationStamp(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#isDeleted(java.lang.Object)
- */
- public boolean isDeleted(Object element) {
- return fParentProvider.isDeleted(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#mustSaveDocument(java.lang.Object)
- */
- public boolean mustSaveDocument(Object element) {
- return fParentProvider.mustSaveDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#canSaveDocument(java.lang.Object)
- */
- public boolean canSaveDocument(Object element) {
- return fParentProvider.canSaveDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object)
- */
- public IAnnotationModel getAnnotationModel(Object element) {
- return fParentProvider.getAnnotationModel(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#aboutToChange(java.lang.Object)
- */
- public void aboutToChange(Object element) {
- fParentProvider.aboutToChange(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#changed(java.lang.Object)
- */
- public void changed(Object element) {
- fParentProvider.changed(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#addElementStateListener(org.eclipse.ui.texteditor.IElementStateListener)
- */
- public void addElementStateListener(IElementStateListener listener) {
- fParentProvider.addElementStateListener(listener);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#removeElementStateListener(org.eclipse.ui.texteditor.IElementStateListener)
- */
- public void removeElementStateListener(IElementStateListener listener) {
- fParentProvider.removeElementStateListener(listener);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isReadOnly(java.lang.Object)
- */
- public boolean isReadOnly(Object element) {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- return extension.isReadOnly(element);
- }
- return false;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isModifiable(java.lang.Object)
- */
- public boolean isModifiable(Object element) {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- return extension.isModifiable(element);
- }
- return true;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#validateState(java.lang.Object, java.lang.Object)
- */
- public void validateState(Object element, Object computationContext) throws CoreException {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- extension.validateState(element, computationContext);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isStateValidated(java.lang.Object)
- */
- public boolean isStateValidated(Object element) {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- return extension.isStateValidated(element);
- }
- return true;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#updateStateCache(java.lang.Object)
- */
- public void updateStateCache(Object element) throws CoreException {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- extension.updateStateCache(element);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#setCanSaveDocument(java.lang.Object)
- */
- public void setCanSaveDocument(Object element) {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- extension.setCanSaveDocument(element);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#getStatus(java.lang.Object)
- */
- public IStatus getStatus(Object element) {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- return extension.getStatus(element);
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#synchronize(java.lang.Object)
- */
- public void synchronize(Object element) throws CoreException {
- if (fParentProvider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) fParentProvider;
- extension.synchronize(element);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor progressMonitor) {
- if (fParentProvider instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) fParentProvider;
- extension.setProgressMonitor(progressMonitor);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#getProgressMonitor()
- */
- public IProgressMonitor getProgressMonitor() {
- if (fParentProvider instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) fParentProvider;
- return extension.getProgressMonitor();
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3#isSynchronized(java.lang.Object)
- */
- public boolean isSynchronized(Object element) {
- if (fParentProvider instanceof IDocumentProviderExtension3) {
- IDocumentProviderExtension3 extension= (IDocumentProviderExtension3) fParentProvider;
- return extension.isSynchronized(element);
- }
- return true;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.IStorageDocumentProvider#getDefaultEncoding()
- */
- public String getDefaultEncoding() {
- if (fParentProvider instanceof IStorageDocumentProvider) {
- IStorageDocumentProvider provider= (IStorageDocumentProvider) fParentProvider;
- return provider.getDefaultEncoding();
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.IStorageDocumentProvider#getEncoding(java.lang.Object)
- */
- public String getEncoding(Object element) {
- if (fParentProvider instanceof IStorageDocumentProvider) {
- IStorageDocumentProvider provider= (IStorageDocumentProvider) fParentProvider;
- return provider.getEncoding(element);
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.editors.text.IStorageDocumentProvider#setEncoding(java.lang.Object, java.lang.String)
- */
- public void setEncoding(Object element, String encoding) {
- if (fParentProvider instanceof IStorageDocumentProvider) {
- IStorageDocumentProvider provider= (IStorageDocumentProvider) fParentProvider;
- provider.setEncoding(element, encoding);
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsConstants.java
deleted file mode 100644
index a0b687703..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsConstants.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-
-/**
- * Defines the names of the encoding actions.
- * <p>
- * This interface contains constants only; it is not intended to be implemented.</p>
- *
- * @since 2.0
- */
-public interface IEncodingActionsConstants {
-
- /**
- * Name of the action to change the encoding into default.
- * Value is <code>"default"</code>.
- * @since 3.0
- */
- static final String DEFAULT= "default"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into US ASCII.
- * Value is <code>"US-ASCII"</code>.
- */
- static final String US_ASCII= "US-ASCII"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into ISO-8859-1.
- * Value is <code>"ISO-8859-1"</code>.
- */
- static final String ISO_8859_1= "ISO-8859-1"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into UTF-8.
- * Value is <code>"UTF-8"</code>.
- */
- static final String UTF_8= "UTF-8"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into UTF-16BE.
- * Value is <code>"UTF-16BE"</code>.
- */
- static final String UTF_16BE= "UTF-16BE"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into UTF-16LE.
- * Value is <code>"UTF-16LE"</code>.
- */
- static final String UTF_16LE= "UTF-16LE"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into UTF-16.
- * Value is <code>"UTF-16"</code>.
- */
- static final String UTF_16= "UTF-16"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into the system encoding.
- * Value is <code>"System"</code>.
- */
- static final String SYSTEM= "System"; //$NON-NLS-1$
-
- /**
- * Name of the action to change the encoding into a custom encoding.
- * Value is <code>"Custom"</code>.
- */
- static final String CUSTOM= "Custom"; //$NON-NLS-1$
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsDefinitionIds.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsDefinitionIds.java
deleted file mode 100644
index a83d5bd63..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsDefinitionIds.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-
-/**
- * Defines the definition IDs for the encoding actions.
- * <p>
- * This interface contains constants only; it is not intended to be implemented.</p>
- *
- * @since 2.0
- */
-public interface IEncodingActionsDefinitionIds {
- /**
- * Action definition id of the action to change the encoding into default.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.default"</code>.
- * @since 3.0
- */
- public static final String DEFAULT= "org.eclipse.ui.edit.text.encoding.default"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into US ASCII.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.us-ascii"</code>.
- */
- public static final String US_ASCII= "org.eclipse.ui.edit.text.encoding.us-ascii"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into ISO-8859-1.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.iso-8859-1"</code>.
- */
- public static final String ISO_8859_1= "org.eclipse.ui.edit.text.encoding.iso-8859-1"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into UTF-8.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.utf-8"</code>.
- */
- public static final String UTF_8= "org.eclipse.ui.edit.text.encoding.utf-8"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into UTF-16BE.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.utf-16be"</code>.
- */
- public static final String UTF_16BE= "org.eclipse.ui.edit.text.encoding.utf-16be"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into UTF-16LE.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.utf-16le"</code>.
- */
- public static final String UTF_16LE= "org.eclipse.ui.edit.text.encoding.utf-16le"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into UTF-16.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.utf-16"</code>.
- */
- public static final String UTF_16= "org.eclipse.ui.edit.text.encoding.utf-16"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into the system encoding.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.system"</code>.
- */
- public static final String SYSTEM= "org.eclipse.ui.edit.text.encoding.system"; //$NON-NLS-1$
-
- /**
- * Action definition id of the action to change the encoding into a custom encoding.
- * Value is <code>"org.eclipse.ui.edit.text.encoding.custom"</code>.
- */
- public static final String CUSTOM= "org.eclipse.ui.edit.text.encoding.custom"; //$NON-NLS-1$
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsHelpContextIds.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsHelpContextIds.java
deleted file mode 100644
index 5eadf6f3f..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingActionsHelpContextIds.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-
-
-/**
- * Help context IDs for the encoding actions.
- * <p>
- * This interface contains constants only; it is not intended to be implemented.</p>
- *
- * @since 2.0
- */
-public interface IEncodingActionsHelpContextIds {
-
- /**
- * Help id of the action to change the encoding into default.
- * Default value: <code>"org.eclipse.ui.default_action_context"</code>
- * @since 3.0
- */
- public static final String DEFAULT= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.DEFAULT + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into US ASCII.
- * Default value: <code>"org.eclipse.ui.US-ASCII_action_context"</code>
- */
- public static final String US_ASCII= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.US_ASCII + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into ISO-8859-1.
- * Default value: <code>"org.eclipse.ui.ISO-8859-1_action_context"</code>
- */
- public static final String ISO_8859_1= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.ISO_8859_1 + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into UTF-8
- * Default value: <code>"org.eclipse.ui.UTF-8_action_context"</code>
- */
- public static final String UTF_8= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.UTF_8 + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into UTF-16BE.
- * Default value: <code>"org.eclipse.ui.UTF-16BE_action_context"</code>
- */
- public static final String UTF_16BE= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.UTF_16BE + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into UTF-16LE.
- * Default value: <code>"org.eclipse.ui.UTF-16LE_action_context"</code>
- */
- public static final String UTF_16LE= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.UTF_16LE + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into UTF-16.
- * Default value: <code>"org.eclipse.ui.UTF-16_action_context"</code>
- */
- public static final String UTF_16= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.UTF_16 + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into the system encoding.
- * Default value: <code>"org.eclipse.ui.System_action_context"</code>
- */
- public static final String SYSTEM= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.SYSTEM + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-
- /**
- * Help id of the action to change the encoding into a custom encoding.
- * Default value: <code>"org.eclipse.ui.Custom_action_context"</code>
- */
- public static final String CUSTOM= IAbstractTextEditorHelpContextIds.PREFIX + IEncodingActionsConstants.CUSTOM + IAbstractTextEditorHelpContextIds.ACTION_POSTFIX;
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingSupport.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingSupport.java
deleted file mode 100644
index 56e207be2..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IEncodingSupport.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-
-/**
- * Interface to be implemented by objects supporting character encodings.
- *
- * @since 2.0
- */
-public interface IEncodingSupport{
-
- /**
- * Sets the character encoding.
- *
- * @param encoding the character encoding
- */
- void setEncoding(String encoding);
-
- /**
- * Returns the character encoding.
- *
- * @return the character encoding
- */
- String getEncoding();
-
- /**
- * Returns the default character encoding.
- *
- * @return the default character encoding
- */
- String getDefaultEncoding();
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IFoldingCommandIds.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IFoldingCommandIds.java
deleted file mode 100644
index 51b72f8e5..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IFoldingCommandIds.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-
-/**
- * Command IDs for folding commands.
- *
- * @since 3.0
- */
-public interface IFoldingCommandIds {
-
- /**
- * Identifier of the "collapse folded region" command.
- * <p>
- * Value: {@value}.</p>
- */
- String FOLDING_COLLAPSE= "org.eclipse.ui.edit.text.folding.collapse"; //$NON-NLS-1$
-
- /**
- * Identifier of the "expand folded region" command.
- * <p>
- * Value: {@value}.</p>
- */
- String FOLDING_EXPAND= "org.eclipse.ui.edit.text.folding.expand"; //$NON-NLS-1$
-
- /**
- * Identifier of the "expand all folded regions" command.
- * <p>
- * Value: {@value}.</p>
- */
- String FOLDING_EXPAND_ALL= "org.eclipse.ui.edit.text.folding.expand_all"; //$NON-NLS-1$
-
- /**
- * Identifier of the "toggle folding" command.
- * <p>
- * Value: {@value}.</p>
- */
- String FOLDING_TOGGLE= "org.eclipse.ui.edit.text.folding.toggle"; //$NON-NLS-1$
-
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ILocationProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ILocationProvider.java
deleted file mode 100644
index c613d24a9..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ILocationProvider.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.core.runtime.IPath;
-
-
-/**
- * This class gets the location for a given
- * object.
- *
- * @since 3.0
- */
-public interface ILocationProvider {
-
- /**
- * Returns the location of the given object or <code>null</code>.
- * <p>
- * The provided location is either a full path of a workspace resource or
- * an absolute path in the local file system.
- * </p>
- *
- * @param element the object for which to get the location
- * @return the location of the given object or <code>null</code>
- */
- IPath getPath(Object element);
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IStorageDocumentProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IStorageDocumentProvider.java
deleted file mode 100644
index f513dae2b..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/IStorageDocumentProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-
-/**
- * Document provider for {@link org.eclipse.core.resources.IStorage} based domain elements.
- * Basically incorporates the concept of character encoding.
- *
- * @since 2.0
- */
-public interface IStorageDocumentProvider {
-
- /**
- * Returns the default character encoding used by this provider.
- *
- * @return the default character encoding used by this provider
- */
- String getDefaultEncoding();
-
- /**
- * Returns the character encoding for the given element, or
- * <code>null</code> if the element is not managed by this provider.
- *
- * @param element the element
- * @return the encoding for the given element
- */
- String getEncoding(Object element);
-
- /**
- * Sets the encoding for the given element. If <code>encoding</code>
- * is <code>null</code> the workbench's character encoding should be used.
- *
- * @param element the element
- * @param encoding the encoding to be used
- */
- void setEncoding(Object element, String encoding);
-}
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
deleted file mode 100644
index 5bb985d3e..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/ITextEditorHelpContextIds.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.ui.ide.IDEActionFactory;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-
-
-/**
- * Help context IDs for the text editor.
- * <p>
- * This interface contains constants only; it is not intended to be implemented.</p>
- */
-public interface ITextEditorHelpContextIds extends IAbstractTextEditorHelpContextIds {
-
- /**
- * Id for the text editor preference page.
- * Value: <code>"org.eclipse.ui.text_editor_preference_page_context"</code>.
- */
- public static final String TEXT_EDITOR_PREFERENCE_PAGE= PREFIX + "text_editor_preference_page_context"; //$NON-NLS-1$
-
- /**
- * Id for the text editor.
- * 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 Bookmark" action.
- * Value: <code>"org.eclipse.ui.bookmark_action_context"</code>
- * @since 3.0
- */
- public static final String BOOKMARK_ACTION= PREFIX + IDEActionFactory.BOOKMARK.getId() + ACTION_POSTFIX;
-
- /**
- * Help context id for the Add Task action.
- * Value: <code>"org.eclipse.ui.addTask_action_context"</code>
- * @since 3.0
- */
- public static final String ADD_TASK_ACTION= PREFIX + IDEActionFactory.ADD_TASK.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
deleted file mode 100644
index c14ec15d8..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/StorageDocumentProvider.java
+++ /dev/null
@@ -1,437 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import org.osgi.framework.Bundle;
-
-import org.eclipse.core.resources.IEncodedStorage;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.resources.ResourcesPlugin;
-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.operation.IRunnableContext;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.AbstractDocumentProvider;
-
-
-/**
- * Shared document provider specialized for {@link org.eclipse.core.resources.IStorage}s.
- */
-public class StorageDocumentProvider extends AbstractDocumentProvider implements IStorageDocumentProvider {
-
- /**
- * Default file size.
- *
- * @since 2.1
- */
- protected final static int DEFAULT_FILE_SIZE= 15 * 1024;
-
-
- /**
- * Bundle of all required information to allow {@link org.eclipse.core.resources.IStorage} as underlying document resources.
- * @since 2.0
- */
- protected class StorageInfo extends ElementInfo {
-
- /** The flag representing the cached state whether the storage is modifiable. */
- public boolean fIsModifiable= false;
- /** The flag representing the cached state whether the storage is read-only. */
- public boolean fIsReadOnly= true;
- /** The flag representing the need to update the cached flag. */
- public boolean fUpdateCache= true;
- /** The encoding used to create the document from the storage or <code>null</code> for workbench encoding. */
- public String fEncoding;
-
- /**
- * Creates a new storage info.
- *
- * @param document the document
- * @param model the annotation model
- */
- public StorageInfo(IDocument document, IAnnotationModel model) {
- super(document, model);
- fEncoding= null;
- }
- }
-
- /**
- * Creates a new document provider.
- *
- * @since 2.0
- */
- public StorageDocumentProvider() {
- super();
- }
-
- /**
- * Initializes the given document with the given stream.
- *
- * @param document the document to be initialized
- * @param contentStream the stream which delivers the document content
- * @throws CoreException if the given stream can not be read
- *
- * @deprecated use encoding based version instead
- */
- protected void setDocumentContent(IDocument document, InputStream contentStream) throws CoreException {
- setDocumentContent(document, contentStream, null);
- }
-
- /**
- * Initializes the given document with the given stream using the given encoding.
- *
- * @param document the document to be initialized
- * @param contentStream the stream which delivers the document content
- * @param encoding the character encoding for reading the given stream
- * @throws CoreException if the given stream can not be read
- * @since 2.0
- */
- protected void setDocumentContent(IDocument document, InputStream contentStream, String encoding) throws CoreException {
-
- Reader in= null;
-
- try {
-
- if (encoding == null)
- encoding= getDefaultEncoding();
-
- in= new BufferedReader(new InputStreamReader(contentStream, encoding), DEFAULT_FILE_SIZE);
- StringBuffer buffer= new StringBuffer(DEFAULT_FILE_SIZE);
- char[] readBuffer= new char[2048];
- int n= in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
-
- document.set(buffer.toString());
-
- } catch (IOException x) {
- String message= (x.getMessage() != null ? x.getMessage() : ""); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- }
- }
- }
- }
-
- /**
- * Initializes the given document from the given editor input using the default character encoding.
- *
- * @param document the document to be initialized
- * @param editorInput the input from which to derive the content of the document
- * @return <code>true</code> if the document content could be set, <code>false</code> otherwise
- * @throws CoreException if the given editor input cannot be accessed
- * @deprecated use the encoding based version instead
- * @since 2.0
- */
- protected boolean setDocumentContent(IDocument document, IEditorInput editorInput) throws CoreException {
- return setDocumentContent(document, editorInput, null);
- }
-
- /**
- * Initializes the given document from the given editor input using the given character encoding.
- *
- * @param document the document to be initialized
- * @param editorInput the input from which to derive the content of the document
- * @param encoding the character encoding used to read the editor input
- * @return <code>true</code> if the document content could be set, <code>false</code> otherwise
- * @throws CoreException if the given editor input cannot be accessed
- * @since 2.0
- */
- protected boolean setDocumentContent(IDocument document, IEditorInput editorInput, String encoding) throws CoreException {
- if (editorInput instanceof IStorageEditorInput) {
- IStorage storage= ((IStorageEditorInput) editorInput).getStorage();
- setDocumentContent(document, storage.getContents(), encoding);
- return true;
- }
- return false;
- }
-
- /*
- * @see AbstractDocumentProvider#createAnnotationModel(Object)
- */
- protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
- return null;
- }
-
- /**
- * Factory method for creating empty documents.
- * @return the newly created document
- * @since 2.1
- */
- protected IDocument createEmptyDocument() {
- return new Document();
- }
-
- /*
- * @see AbstractDocumentProvider#createDocument(Object)
- */
- protected IDocument createDocument(Object element) throws CoreException {
-
- if (element instanceof IEditorInput) {
- IDocument document= createEmptyDocument();
- if (setDocumentContent(document, (IEditorInput) element, getEncoding(element))) {
- setupDocument(element, document);
- return document;
- }
- }
-
- return null;
- }
-
- /**
- * Sets up the given document as it would be provided for the given element. The
- * content of the document is not changed. This default implementation is empty.
- * Subclasses may reimplement.
- *
- * @param element the blue-print element
- * @param document the document to set up
- * @since 3.0
- */
- protected void setupDocument(Object element, IDocument document) {
- }
-
- /*
- * @see AbstractDocumentProvider#createElementInfo(Object)
- * @since 2.0
- */
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- if (element instanceof IStorageEditorInput) {
-
- IDocument document= null;
- IStatus status= null;
-
- try {
- document= createDocument(element);
- } catch (CoreException x) {
- status= x.getStatus();
- document= createEmptyDocument();
- }
-
- ElementInfo info= new StorageInfo(document, createAnnotationModel(element));
- info.fStatus= status;
- ((StorageInfo)info).fEncoding= getPersistedEncoding(element);
-
- return info;
- }
-
- return super.createElementInfo(element);
- }
-
- /*
- * @see AbstractDocumentProvider#doSaveDocument(IProgressMonitor, Object, IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- }
-
- /**
- * Defines the standard procedure to handle <code>CoreExceptions</code>. Exceptions
- * are written to the plug-in log.
- *
- * @param exception the exception to be logged
- * @param message the message to be logged
- * @since 2.0
- */
- protected void handleCoreException(CoreException exception, String message) {
-
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log= Platform.getLog(bundle);
-
- if (message != null)
- log.log(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, exception));
- else
- log.log(exception.getStatus());
- }
-
- /**
- * Updates the internal cache for the given input.
- *
- * @param input the input whose cache will be updated
- * @throws CoreException if the storage cannot be retrieved from the input
- * @since 2.0
- */
- protected void updateCache(IStorageEditorInput input) throws CoreException {
- StorageInfo info= (StorageInfo) getElementInfo(input);
- if (info != null) {
- try {
- IStorage storage= input.getStorage();
- if (storage != null) {
- boolean readOnly= storage.isReadOnly();
- info.fIsReadOnly= readOnly;
- info.fIsModifiable= !readOnly;
- }
- } catch (CoreException x) {
- handleCoreException(x, TextEditorMessages.getString("StorageDocumentProvider.updateCache")); //$NON-NLS-1$
- }
- info.fUpdateCache= false;
- }
- }
-
- /*
- * @see IDocumentProviderExtension#isReadOnly(Object)
- * @since 2.0
- */
- public boolean isReadOnly(Object element) {
- if (element instanceof IStorageEditorInput) {
- StorageInfo info= (StorageInfo) getElementInfo(element);
- if (info != null) {
- if (info.fUpdateCache) {
- try {
- updateCache((IStorageEditorInput) element);
- } catch (CoreException x) {
- handleCoreException(x, TextEditorMessages.getString("StorageDocumentProvider.isReadOnly")); //$NON-NLS-1$
- }
- }
- return info.fIsReadOnly;
- }
- }
- return super.isReadOnly(element);
- }
-
- /*
- * @see IDocumentProviderExtension#isModifiable(Object)
- * @since 2.0
- */
- public boolean isModifiable(Object element) {
- if (element instanceof IStorageEditorInput) {
- StorageInfo info= (StorageInfo) getElementInfo(element);
- if (info != null) {
- if (info.fUpdateCache) {
- try {
- updateCache((IStorageEditorInput) element);
- } catch (CoreException x) {
- handleCoreException(x, TextEditorMessages.getString("StorageDocumentProvider.isModifiable")); //$NON-NLS-1$
- }
- }
- return info.fIsModifiable;
- }
- }
- return super.isModifiable(element);
- }
-
- /*
- * @see AbstractDocumentProvider#doUpdateStateCache(Object)
- * @since 2.0
- */
- protected void doUpdateStateCache(Object element) throws CoreException {
- if (element instanceof IStorageEditorInput) {
- StorageInfo info= (StorageInfo) getElementInfo(element);
- if (info != null)
- info.fUpdateCache= true;
- }
- super.doUpdateStateCache(element);
- }
-
- /*
- * @see IStorageDocumentProvider#getDefaultEncoding()
- * @since 2.0
- */
- public String getDefaultEncoding() {
- return ResourcesPlugin.getEncoding();
- }
-
- /*
- * @see IStorageDocumentProvider#getEncoding(Object)
- * @since 2.0
- */
- public String getEncoding(Object element) {
- if (element instanceof IStorageEditorInput) {
- StorageInfo info= (StorageInfo) getElementInfo(element);
- if (info != null)
- return info.fEncoding;
- else
- return getPersistedEncoding(element);
- }
- return null;
- }
-
- /*
- * @see IStorageDocumentProvider#setEncoding(Object, String)
- * @since 2.0
- */
- public void setEncoding(Object element, String encoding) {
- if (element instanceof IStorageEditorInput) {
- StorageInfo info= (StorageInfo) getElementInfo(element);
- if (info != null) {
- info.fEncoding= encoding;
- try {
- persistEncoding(element, encoding);
- } catch (CoreException ex) {
- // XXX: log
- }
- }
- }
- }
-
- /**
- * Returns the persisted encoding for the given element.
- *
- * @param element the element for which to get the persisted encoding
- * @return the persisted encoding
- * @since 2.1
- */
- protected String getPersistedEncoding(Object element) {
- if (element instanceof IStorageEditorInput) {
- IStorage storage;
- try {
- storage= ((IStorageEditorInput)element).getStorage();
- if (storage instanceof IEncodedStorage)
- return ((IEncodedStorage)storage).getCharset();
- } catch (CoreException e) {
- return null;
- }
- }
- return null;
- }
-
- /**
- * Persists the given encoding for the given element.
- *
- * @param element the element for which to store the persisted encoding
- * @param encoding the encoding
- * @throws CoreException if the operation fails
- * @since 2.1
- */
- 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)
- * @since 3.0
- */
- 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
deleted file mode 100644
index 921080ca8..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditor.java
+++ /dev/null
@@ -1,321 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.text.MessageFormat;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.dialogs.SaveAsDialog;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.ConvertLineDelimitersAction;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditor;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.ResourceAction;
-
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-
-
-/**
- * The standard text editor for file resources (<code>IFile</code>).
- * <p>
- * This editor has id <code>"org.eclipse.ui.DefaultTextEditor"</code>.
- * The editor's context menu has id <code>#TextEditorContext</code>.
- * The editor's ruler context menu has id <code>#TextRulerContext</code>.
- * </p>
- * <p>
- * The workbench will automatically instantiate this class when the default
- * editor is needed for a workbench window.
- * </p>
- */
-public class TextEditor extends AbstractDecoratedTextEditor {
-
- /**
- * The encoding support for the editor.
- * @since 2.0
- */
- protected DefaultEncodingSupport fEncodingSupport;
-
-
- /**
- * Creates a new text editor.
- */
- public TextEditor() {
- super();
- if (getSourceViewerConfiguration() == null) {
- // configuration not yet set by subclass
- setSourceViewerConfiguration(new TextSourceViewerConfiguration(getPreferenceStore()));
- }
-
- }
-
- /**
- * {@inheritDoc}
- *
- * This method configures the editor but does not define a
- * <code>SourceViewerConfiguration</code>. When only interested in
- * providing a custom source viewer configuration, subclasses may extend
- * this method.
- */
- protected void initializeEditor() {
- setEditorContextMenuId("#TextEditorContext"); //$NON-NLS-1$
- setRulerContextMenuId("#TextRulerContext"); //$NON-NLS-1$
- setHelpContextId(ITextEditorHelpContextIds.TEXT_EDITOR);
- setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
- configureInsertMode(SMART_INSERT, false);
- setInsertMode(INSERT);
- }
-
- /*
- * @see IWorkbenchPart#dispose()
- * @since 2.0
- */
- public void dispose() {
- if (fEncodingSupport != null) {
- fEncodingSupport.dispose();
- fEncodingSupport= null;
- }
-
- super.dispose();
- }
-
- /**
- * Installs the encoding support on the given text editor.
- * <p>
- * Subclasses may override to install their own encoding
- * support or to disable the default encoding support.
- * </p>
- * @since 2.1
- */
- protected void installEncodingSupport() {
- fEncodingSupport= new DefaultEncodingSupport();
- fEncodingSupport.initialize(this);
- }
-
- /**
- * The <code>TextEditor</code> implementation of this <code>AbstractTextEditor</code>
- * method asks the user for the workspace path of a file resource and saves the document there.
- *
- * @param progressMonitor the progress monitor to be used
- */
- protected void performSaveAs(IProgressMonitor progressMonitor) {
- Shell shell= getSite().getShell();
- IEditorInput input= getEditorInput();
-
- SaveAsDialog dialog= new SaveAsDialog(shell);
-
- IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null;
- if (original != null)
- dialog.setOriginalFile(original);
-
- dialog.create();
-
- IDocumentProvider provider= getDocumentProvider();
- if (provider == null) {
- // editor has programmatically been closed while the dialog was open
- return;
- }
-
- if (provider.isDeleted(input) && original != null) {
- String message= MessageFormat.format(TextEditorMessages.getString("Editor.warning.save.delete"), new Object[] { original.getName() }); //$NON-NLS-1$
- dialog.setErrorMessage(null);
- dialog.setMessage(message, IMessageProvider.WARNING);
- }
-
- if (dialog.open() == Window.CANCEL) {
- if (progressMonitor != null)
- progressMonitor.setCanceled(true);
- return;
- }
-
- IPath filePath= dialog.getResult();
- if (filePath == null) {
- if (progressMonitor != null)
- progressMonitor.setCanceled(true);
- return;
- }
-
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IFile file= workspace.getRoot().getFile(filePath);
- final IEditorInput newInput= new FileEditorInput(file);
-
- boolean success= false;
- try {
-
- provider.aboutToChange(newInput);
- provider.saveDocument(progressMonitor, newInput, provider.getDocument(input), true);
- success= true;
-
- } catch (CoreException x) {
- IStatus status= x.getStatus();
- if (status == null || status.getSeverity() != IStatus.CANCEL) {
- String title= TextEditorMessages.getString("Editor.error.save.title"); //$NON-NLS-1$
- String msg= MessageFormat.format(TextEditorMessages.getString("Editor.error.save.message"), new Object[] { x.getMessage() }); //$NON-NLS-1$
-
- 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 {
- provider.changed(newInput);
- if (success)
- setInput(newInput);
- }
-
- if (progressMonitor != null)
- progressMonitor.setCanceled(!success);
- }
-
- /*
- * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
- */
- public boolean isSaveAsAllowed() {
- return true;
- }
-
- /*
- * @see AbstractTextEditor#createActions()
- * @since 2.0
- */
- protected void createActions() {
- super.createActions();
-
- 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);
-
- action= new ConvertLineDelimitersAction(TextEditorMessages.getResourceBundle(), "Editor.ConvertToUNIX.", this, "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.CONVERT_LINE_DELIMITERS_TO_UNIX);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONVERT_LINE_DELIMITERS_TO_UNIX);
- setAction(ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX, action);
-
- action= new ConvertLineDelimitersAction(TextEditorMessages.getResourceBundle(), "Editor.ConvertToMac.", this, "\r"); //$NON-NLS-1$ //$NON-NLS-2$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.CONVERT_LINE_DELIMITERS_TO_MAC);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONVERT_LINE_DELIMITERS_TO_MAC);
- setAction(ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC, action);
-
- // http://dev.eclipse.org/bugs/show_bug.cgi?id=17709
- markAsStateDependentAction(ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS, true);
- markAsStateDependentAction(ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX, true);
- markAsStateDependentAction(ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC, true);
-
- installEncodingSupport();
- }
-
- /*
- * @see StatusTextEditor#getStatusHeader(IStatus)
- * @since 2.0
- */
- protected String getStatusHeader(IStatus status) {
- if (fEncodingSupport != null) {
- String message= fEncodingSupport.getStatusHeader(status);
- if (message != null)
- return message;
- }
- return super.getStatusHeader(status);
- }
-
- /*
- * @see StatusTextEditor#getStatusBanner(IStatus)
- * @since 2.0
- */
- protected String getStatusBanner(IStatus status) {
- if (fEncodingSupport != null) {
- String message= fEncodingSupport.getStatusBanner(status);
- if (message != null)
- return message;
- }
- return super.getStatusBanner(status);
- }
-
- /*
- * @see StatusTextEditor#getStatusMessage(IStatus)
- * @since 2.0
- */
- protected String getStatusMessage(IStatus status) {
- if (fEncodingSupport != null) {
- String message= fEncodingSupport.getStatusMessage(status);
- if (message != null)
- return message;
- }
- return super.getStatusMessage(status);
- }
-
- /*
- * @see AbstractTextEditor#doSetInput(IEditorInput)
- * @since 2.0
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
- super.doSetInput(input);
- if (fEncodingSupport != null)
- fEncodingSupport.reset();
- }
-
- /*
- * @see IAdaptable#getAdapter(java.lang.Class)
- * @since 2.0
- */
- public Object getAdapter(Class adapter) {
- if (IEncodingSupport.class.equals(adapter))
- return fEncodingSupport;
- return super.getAdapter(adapter);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#updatePropertyDependentActions()
- * @since 2.0
- */
- protected void updatePropertyDependentActions() {
- super.updatePropertyDependentActions();
- if (fEncodingSupport != null)
- fEncodingSupport.reset();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#editorContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager)
- * @since 3.0
- */
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
- super.editorContextMenuAboutToShow(menu);
- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_RIGHT);
- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, ITextEditorActionConstants.SHIFT_LEFT);
- }
-}
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
deleted file mode 100644
index a2119dc8a..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorActionContributor.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.jface.action.IMenuManager;
-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;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-
-
-/**
- * Manages the installation and de-installation of global actions for the default text editor.
- * <p>
- * If instantiated and used as-is, this contributor connects global actions and adds actions
- * for line delimiter conversion and encoding support.</p>
- *
- * @since 2.0
- */
-public class TextEditorActionContributor extends BasicTextEditorActionContributor {
-
- /** Convert to Windows action. */
- private RetargetTextEditorAction fConvertToWindows;
- /** Convert to UNIX action. */
- private RetargetTextEditorAction fConvertToUNIX;
- /** Convert to MAC action. */
- private RetargetTextEditorAction fConvertToMac;
- /** Encoding action group */
- private EncodingActionGroup fEncodingActionGroup;
-
-
- /**
- * Creates a new contributor.
- */
- public TextEditorActionContributor() {
- super();
-
- // line delimiter conversion
- fConvertToWindows= new RetargetTextEditorAction(TextEditorMessages.getResourceBundle(), "Editor.ConvertToWindows."); //$NON-NLS-1$
- fConvertToUNIX= new RetargetTextEditorAction(TextEditorMessages.getResourceBundle(), "Editor.ConvertToUNIX."); //$NON-NLS-1$
- fConvertToMac= new RetargetTextEditorAction(TextEditorMessages.getResourceBundle(), "Editor.ConvertToMac."); //$NON-NLS-1$
-
- // character encoding
- fEncodingActionGroup= new EncodingActionGroup();
- }
-
- /**
- * Internally sets the active editor to the actions provided by this contributor.
- * Cannot be overridden by subclasses.
- *
- * @param part the editor
- */
- private void doSetActiveEditor(IEditorPart part) {
-
- 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));
- fConvertToUNIX.setAction(getAction(textEditor, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX));
- fConvertToMac.setAction(getAction(textEditor, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC));
-
- // character encoding
- fEncodingActionGroup.retarget(textEditor);
- }
-
- /*
- * @see IEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
- */
- public void setActiveEditor(IEditorPart part) {
- super.setActiveEditor(part);
- doSetActiveEditor(part);
- }
-
- /*
- * @see EditorActionBarContributor#init(org.eclipse.ui.IActionBars)
- */
- public void init(IActionBars bars) {
- super.init(bars);
-
- // line delimiter conversion
- IMenuManager menuManager= bars.getMenuManager();
- IMenuManager editMenu= menuManager.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- MenuManager subMenu= new MenuManager(TextEditorMessages.getString("Editor.ConvertLineDelimiters.label")); //$NON-NLS-1$
-
- subMenu.add(fConvertToWindows);
- subMenu.add(fConvertToUNIX);
- subMenu.add(fConvertToMac);
-
- editMenu.add(subMenu);
- }
-
- // character encoding
- fEncodingActionGroup.fillActionBars(bars);
- }
-
- /*
- * @see IEditorActionBarContributor#dispose()
- */
- public void dispose() {
- doSetActiveEditor(null);
- super.dispose();
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.java
deleted file mode 100644
index cd4644891..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Helper class to get NLSed messages.
- */
-class TextEditorMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.ui.editors.text.TextEditorMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TextEditorMessages() {
- }
-
- /**
- * Gets a string from the resource bundle.
- *
- * @param key the string used to get the bundle value, must not be <code>null</code>
- * @return the string from the resource bundle
- */
- 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 given argument.
- *
- * @param key the string used to get the bundle value, must not be null
- * @param arg the argument used to format the string
- * @return the formatted string
- * @since 3.0
- */
- 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 });
- }
-
- /**
- * Returns a resource bundle.
- *
- * @return the resource bundle
- */
- public static ResourceBundle getResourceBundle() {
- return fgResourceBundle;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.properties
deleted file mode 100644
index f712fb987..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorMessages.properties
+++ /dev/null
@@ -1,129 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 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
-###############################################################################
-
-PreferencePage.description=Default Text Editor Settings
-PreferencePage.fontEditor=Text Font:
-
-FileDocumentProvider.createElementInfo=FileDocumentProvider.createElementInfo
-FileDocumentProvider.error.out_of_sync=Has been changed on the file system
-FileDocumentProvider.task.saving=Saving
-FileDocumentProvider.updateContent=FileDocumentProvider.updateContent
-FileDocumentProvider.resetDocument=FileDocumentProvider.resetDocument
-FileDocumentProvider.getPersistedEncoding=Cannot migrate encoding property
-
-StorageDocumentProvider.updateCache=StorageDocumentProvider.updateCache
-StorageDocumentProvider.isReadOnly=StorageDocumentProvider.isReadOnly
-StorageDocumentProvider.isModifiable=StorageDocumentProvider.isModifiable
-
-TextFileDocumentProvider.beginTask.saving= Saving
-
-Editor.error.save.message=Save could not be completed. {0}
-Editor.error.save.title=Problems During Save As...
-Editor.warning.save.delete=The original file ''{0}'' has been deleted.
-
-Editor.AddMenu.label=&Add
-
-Editor.ConvertLineDelimiters.label=C&onvert Line Delimiters To
-
-Editor.ConvertToWindows.label=&Windows
-Editor.ConvertToWindows.tooltip=Converts Line Delimiters to Windows
-Editor.ConvertToWindows.image=
-Editor.ConvertToWindows.description=Converts line delimiters to Windows
-
-Editor.ConvertToUNIX.label=&UNIX
-Editor.ConvertToUNIX.tooltip=Converts Line Delimiters to UNIX
-Editor.ConvertToUNIX.image=
-Editor.ConvertToUNIX.description=Converts line delimiters to UNIX
-
-Editor.ConvertToMac.label=&Mac
-Editor.ConvertToMac.tooltip=Converts line delimiters to Mac
-Editor.ConvertToMac.image=
-Editor.ConvertToMac.description=Converts line delimiters to Mac
-
-
-Editor.error.unreadable_encoding.header=Character Encoding Problems
-Editor.error.unreadable_encoding.banner=
-Editor.error.unreadable_encoding.message_arg=This file is unreadable using the \"{0}\" character encoding.
-Editor.error.unreadable_encoding.message=This file is unreadable using the current character encoding.
-
-Editor.error.unsupported_encoding.header=Unsupported Character Encoding
-Editor.error.unsupported_encoding.banner=
-Editor.error.unsupported_encoding.message_arg=Character encoding \"{0}\" is not supported by this platform.
-Editor.error.unsupported_encoding.message= The current character encoding is not supported by this platform.
-
-Editor.ConvertEncoding.submenu.label=Enc&oding
-
-Editor.ConvertEncoding.default_suffix=(default)
-
-Editor.ConvertEncoding.default.label= Default
-Editor.ConvertEncoding.default.tooltip=Use the Default Character Encoding
-Editor.ConvertEncoding.default.image=
-Editor.ConvertEncoding.default.description=Use the default character encoding
-
-Editor.ConvertEncoding.System.label=Platform encoding
-Editor.ConvertEncoding.System.tooltip=Use the Platform Character Encoding
-Editor.ConvertEncoding.System.image=
-Editor.ConvertEncoding.System.description=Use the platform character encoding
-
-Editor.ConvertEncoding.US-ASCII.label=ASCII
-Editor.ConvertEncoding.US-ASCII.tooltip=Use US-ASCII Character Encoding
-Editor.ConvertEncoding.US-ASCII.image=
-Editor.ConvertEncoding.US-ASCII.description=Use US-ASCII character encoding
-
-Editor.ConvertEncoding.ISO-8859-1.label=Latin 1
-Editor.ConvertEncoding.ISO-8859-1.tooltip=Use ISO-8859-1 Character Encoding
-Editor.ConvertEncoding.ISO-8859-1.image=
-Editor.ConvertEncoding.ISO-8859-1.description=Use ISO-8859-1 character encoding
-
-Editor.ConvertEncoding.UTF-8.label=UTF-8
-Editor.ConvertEncoding.UTF-8.tooltip=Use UTF-8 Character Encoding
-Editor.ConvertEncoding.UTF-8.image=
-Editor.ConvertEncoding.UTF-8.description=Use UTF-8 character encoding
-
-Editor.ConvertEncoding.UTF-16BE.label=UTF-16 (big-endian)
-Editor.ConvertEncoding.UTF-16BE.tooltip=Use UTF-16BE Character Encoding
-Editor.ConvertEncoding.UTF-16BE.image=
-Editor.ConvertEncoding.UTF-16BE.description=Use UTF-16BE character encoding
-
-Editor.ConvertEncoding.UTF-16LE.label=UTF-16 (little-endian)
-Editor.ConvertEncoding.UTF-16LE.tooltip=Use UTF-16LE Character Encoding
-Editor.ConvertEncoding.UTF-16LE.image=
-Editor.ConvertEncoding.UTF-16LE.description=Use UTF-16LE character encoding
-
-Editor.ConvertEncoding.UTF-16.label=UTF-16
-Editor.ConvertEncoding.UTF-16.tooltip=Use UTF-16 Character Encoding
-Editor.ConvertEncoding.UTF-16.image=
-Editor.ConvertEncoding.UTF-16.description=Use UTF-16 character encoding
-
-Editor.ConvertEncoding.Custom.label=&Others...
-Editor.ConvertEncoding.Custom.tooltip=Use a Custom Character Encoding
-Editor.ConvertEncoding.Custom.image=
-Editor.ConvertEncoding.Custom.description=Use a custom character encoding
-Editor.ConvertEncoding.Custom.dialog.title=Character Encoding
-Editor.ConvertEncoding.Custom.dialog.message=Enter the name of the character encoding:
-
-Editor.AddTask.label=&Task...
-Editor.AddTask.tooltip=Add Task
-Editor.AddTask.image=
-Editor.AddTask.description=Add Task
-Editor.AddTask.dialog.title=Add Task
-Editor.AddTask.dialog.message=Enter Task description
-Editor.AddTask.error.dialog.title=Add Task
-Editor.AddTask.error.dialog.message=Problems adding new task
-
-NullProvider.error= ERROR
-
-# Copied from org.eclipse.ui.ide/org/eclipse/ui/internal/ide/messages.properties
-ResourceInfo.fileContentEncodingFormat= Default (determined from content: {0})
-ResourceInfo.fileContainerEncodingFormat= Default (inherited from container: {0})
-WorkbenchPreference.encoding.BOM_UTF_8= UTF-8 (BOM)
-WorkbenchPreference.encoding.BOM_UTF_16BE= UTF-16 Big-Endian (BOM)
-WorkbenchPreference.encoding.BOM_UTF_16LE= UTF-16 Little-Endian (BOM)
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferenceConstants.java
deleted file mode 100644
index 2aa451386..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferenceConstants.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-
-
-/**
- * Preference constants used in the default text editor preference store.
- * @since 2.1
- */
-public class TextEditorPreferenceConstants {
-
- /**
- * Prevent initialization.
- */
- private TextEditorPreferenceConstants() {
- }
-
- /**
- * 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>
- * @deprecated As of 3.0,, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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
- * @deprecated As of 3.0, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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>
- * @deprecated As of 3.0,, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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
- * @deprecated As of 3.0,, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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>
- * @deprecated As of 3.0,, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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>
- * @deprecated As of 3.0, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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>
- * @deprecated As of 3.0, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- 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
- * @deprecated As of 3.0, replaced by {@link org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants}
- */
- public final static String EDITOR_LINE_NUMBER_RULER_COLOR= "lineNumberColor"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_PROBLEM_INDICATION= "problemIndication"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_PROBLEM_INDICATION_COLOR= "problemIndicationColor"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_WARNING_INDICATION= "warningIndication"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_WARNING_INDICATION_COLOR= "warningIndicationColor"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_INFO_INDICATION= "infoIndication"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_INFO_INDICATION_COLOR= "infoIndicationColor"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_TASK_INDICATION= "taskIndication"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_TASK_INDICATION_COLOR= "taskIndicationColor"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_BOOKMARK_INDICATION= "bookmarkIndication"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_BOOKMARK_INDICATION_COLOR= "bookmarkIndicationColor"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_SEARCH_RESULT_INDICATION= "searchResultIndication"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_SEARCH_RESULT_INDICATION_COLOR= "searchResultIndicationColor"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_ERROR_INDICATION_IN_OVERVIEW_RULER= "errorIndicationInOverviewRuler"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_WARNING_INDICATION_IN_OVERVIEW_RULER= "warningIndicationInOverviewRuler"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_INFO_INDICATION_IN_OVERVIEW_RULER= "infoIndicationInOverviewRuler"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_TASK_INDICATION_IN_OVERVIEW_RULER= "taskIndicationInOverviewRuler"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_BOOKMARK_INDICATION_IN_OVERVIEW_RULER= "bookmarkIndicationInOverviewRuler"; //$NON-NLS-1$
-
- /**
- * @deprecated As of 2.1, provided by <code>org.eclipse.ui.editors.markerAnnotationSpecification</code> extension point
- */
- public final static String EDITOR_SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER= "searchResultIndicationInOverviewRuler"; //$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) {
-
- // set defaults from AbstractDecoratedTextEditor
- AbstractDecoratedTextEditorPreferenceConstants.initializeDefaultValues(store);
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, true);
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferencePage.java
deleted file mode 100644
index fd0dd1821..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextEditorPreferencePage.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.preference.FieldEditorPreferencePage;
-import org.eclipse.jface.preference.FontFieldEditor;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.JFaceResources;
-
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AbstractTextEditor;
-
-
-/**
- * A preference page to set the font used in the default text editor.
- * <p>
- * This preference page uses the text editor's preference bundle and
- * uses the key <code>"PreferencePage.description"</code> to look up
- * the page description. In addition, it uses <code>"PreferencePage.fontEditor"</code>
- * for the editor description.
- * </p>
- * @deprecated As of 2.1, fonts are managed by the workbench, no longer supported
- */
-public class TextEditorPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {
-
- /**
- * Indicates whether the preferences that this page manipulates have been initialized.
- *
- * @since 2.0
- */
- private static boolean fgInitialized= false;
-
- /**
- * Creates and returns the text editor preference page.
- */
- public TextEditorPreferencePage() {
- super(GRID);
-
- setDescription(TextEditorMessages.getString("PreferencePage.description")); //$NON-NLS-1$
- Plugin plugin= Platform.getPlugin("org.eclipse.ui.workbench"); //$NON-NLS-1$
- if (plugin instanceof AbstractUIPlugin) {
- AbstractUIPlugin uiPlugin= (AbstractUIPlugin) plugin;
- setPreferenceStore(uiPlugin.getPreferenceStore());
- }
- }
-
- /*
- * @see IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), ITextEditorHelpContextIds.TEXT_EDITOR_PREFERENCE_PAGE);
- }
-
- /*
- * @see FieldEditorPreferencePage#createFieldEditors()
- */
- public void createFieldEditors() {
- addField(new FontFieldEditor(JFaceResources.TEXT_FONT, TextEditorMessages.getString("PreferencePage.fontEditor"), getFieldEditorParent())); //$NON-NLS-1$
- }
-
- /*
- * @see IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * Initializes the defaults for the given store.
- *
- * @param store the preference store
- * @since 2.0
- */
- public static void initDefaults(IPreferenceStore store) {
-
- if (fgInitialized)
- return;
-
- fgInitialized= true;
-
- Font font= JFaceResources.getTextFont();
- if (font != null) {
- FontData[] data= font.getFontData();
- if (data != null && data.length > 0)
- PreferenceConverter.setDefault(store, JFaceResources.TEXT_FONT, data[0]);
- }
-
- Display display= Display.getDefault();
- Color color= display.getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- PreferenceConverter.setDefault(store, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, color.getRGB());
- store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT, true);
-
- color= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- PreferenceConverter.setDefault(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, color.getRGB());
- store.setDefault(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true);
- }
-}
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
deleted file mode 100644
index 75afd913a..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextFileDocumentProvider.java
+++ /dev/null
@@ -1,1119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.io.BufferedReader;
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.StringReader;
-import java.io.UnsupportedEncodingException;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.NoSuchElementException;
-
-import org.osgi.framework.Bundle;
-
-import org.eclipse.core.internal.filebuffers.ContainerGenerator;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceRuleFactory;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.IFileBuffer;
-import org.eclipse.core.filebuffers.IFileBufferListener;
-import org.eclipse.core.filebuffers.IFileBufferManager;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.editors.text.UISynchronizationContext;
-import org.eclipse.ui.internal.editors.text.WorkspaceOperationRunner;
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-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;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension3;
-import org.eclipse.ui.texteditor.IElementStateListener;
-import org.eclipse.ui.texteditor.IElementStateListenerExtension;
-import org.eclipse.ui.texteditor.ISchedulingRuleProvider;
-
-/**
- * @since 3.0
- */
-public class TextFileDocumentProvider implements IDocumentProvider, IDocumentProviderExtension, IDocumentProviderExtension2, IDocumentProviderExtension3, IStorageDocumentProvider {
-
- /**
- * Operation created by the document provider and to be executed by the providers runnable context.
- */
- protected static abstract class DocumentProviderOperation implements IRunnableWithProgress, ISchedulingRuleProvider {
-
- /**
- * The actual functionality of this operation.
- *
- * @param monitor the progress monitor
- * @throws CoreException
- */
- protected abstract void execute(IProgressMonitor monitor) throws CoreException;
-
- /*
- * @see org.eclipse.jface.operation.IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
- execute(monitor);
- } catch (CoreException x) {
- throw new InvocationTargetException(x);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.ISchedulingRuleProvider#getSchedulingRule()
- */
- public ISchedulingRule getSchedulingRule() {
- return ResourcesPlugin.getWorkspace().getRoot();
- }
- }
-
- static protected class NullProvider implements IDocumentProvider, IDocumentProviderExtension, IDocumentProviderExtension2, IDocumentProviderExtension3, IStorageDocumentProvider {
-
- static final private IStatus STATUS_ERROR= new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.INFO, TextEditorMessages.getString("NullProvider.error"), null); //$NON-NLS-1$
-
- public void connect(Object element) throws CoreException {}
- public void disconnect(Object element) {}
- public IDocument getDocument(Object element) { return null; }
- public void resetDocument(Object element) throws CoreException {}
- public void saveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {}
- public long getModificationStamp(Object element) { return 0; }
- public long getSynchronizationStamp(Object element) { return 0; }
- public boolean isDeleted(Object element) { return true; }
- public boolean mustSaveDocument(Object element) { return false; }
- public boolean canSaveDocument(Object element) { return false; }
- public IAnnotationModel getAnnotationModel(Object element) { return null; }
- public void aboutToChange(Object element) {}
- public void changed(Object element) {}
- public void addElementStateListener(IElementStateListener listener) {}
- public void removeElementStateListener(IElementStateListener listener) {}
- public boolean isReadOnly(Object element) { return true; }
- public boolean isModifiable(Object element) { return false; }
- public void validateState(Object element, Object computationContext) throws CoreException {}
- public boolean isStateValidated(Object element) { return true; }
- public void updateStateCache(Object element) throws CoreException {}
- public void setCanSaveDocument(Object element) {}
- public IStatus getStatus(Object element) { return STATUS_ERROR; }
- public void synchronize(Object element) throws CoreException {}
- public void setProgressMonitor(IProgressMonitor progressMonitor) {}
- public IProgressMonitor getProgressMonitor() { return new NullProgressMonitor(); }
- public boolean isSynchronized(Object element) { return true; }
- public String getDefaultEncoding() { return null; }
- public String getEncoding(Object element) { return null; }
- public void setEncoding(Object element, String encoding) {}
- }
-
- static protected class FileInfo {
- public Object fElement;
- public int fCount;
- public ITextFileBuffer fTextFileBuffer;
- public IAnnotationModel fModel;
- public boolean fCachedReadOnlyState;
- }
-
- static private class SingleElementIterator implements Iterator {
-
- private Object fElement;
-
- public SingleElementIterator(Object element) {
- fElement= element;
- }
-
- /*
- * @see java.util.Iterator#hasNext()
- */
- public boolean hasNext() {
- return fElement != null;
- }
-
- /*
- * @see java.util.Iterator#next()
- */
- public Object next() {
- if (fElement != null) {
- Object result= fElement;
- fElement= null;
- return result;
- }
- throw new NoSuchElementException();
- }
-
- /*
- * @see java.util.Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- protected class FileBufferListener implements IFileBufferListener {
-
- public FileBufferListener() {
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#bufferContentAboutToBeReplaced(org.eclipse.core.buffer.text.IBufferedFile)
- */
- public void bufferContentAboutToBeReplaced(IFileBuffer file) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
- while (i.hasNext())
- l.elementContentAboutToBeReplaced(i.next());
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#bufferContentReplaced(org.eclipse.core.buffer.text.IBufferedFile)
- */
- public void bufferContentReplaced(IFileBuffer file) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
- while (i.hasNext())
- l.elementContentReplaced(i.next());
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#stateChanging(org.eclipse.core.buffer.text.IBufferedFile)
- */
- public void stateChanging(IFileBuffer file) {
- Iterator i= getElements(file);
- while (i.hasNext())
- fireElementStateChanging(i.next());
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#dirtyStateChanged(org.eclipse.core.buffer.text.IBufferedFile, boolean)
- */
- public void dirtyStateChanged(IFileBuffer file, boolean isDirty) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
- while (i.hasNext())
- l.elementDirtyStateChanged(i.next(), isDirty);
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#stateValidationChanged(org.eclipse.core.buffer.text.IBufferedFile, boolean)
- */
- public void stateValidationChanged(IFileBuffer file, boolean isStateValidated) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- Object l= e.next();
- if (l instanceof IElementStateListenerExtension) {
- IElementStateListenerExtension x= (IElementStateListenerExtension) l;
- Iterator i= getElements(file);
- while (i.hasNext())
- x.elementStateValidationChanged(i.next(), isStateValidated);
- }
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#underlyingFileMoved(org.eclipse.core.buffer.text.IBufferedFile, org.eclipse.core.runtime.IPath)
- */
- public void underlyingFileMoved(IFileBuffer file, IPath newLocation) {
- IWorkspace workspace=ResourcesPlugin.getWorkspace();
- IFile newFile= workspace.getRoot().getFile(newLocation);
- IEditorInput input= newFile == null ? null : new FileEditorInput(newFile);
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
- while (i.hasNext())
- l.elementMoved(i.next(), input);
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#underlyingFileDeleted(org.eclipse.core.buffer.text.IBufferedFile)
- */
- public void underlyingFileDeleted(IFileBuffer file) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- Iterator i= getElements(file);
- while (i.hasNext())
- l.elementDeleted(i.next());
- }
- }
-
- /*
- * @see org.eclipse.core.buffer.text.IBufferedFileListener#stateChangeFailed(org.eclipse.core.buffer.text.IBufferedFile)
- */
- public void stateChangeFailed(IFileBuffer file) {
- Iterator i= getElements(file);
- while (i.hasNext())
- fireElementStateChangeFailed(i.next());
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferCreated(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void bufferCreated(IFileBuffer buffer) {
- // ignore
- }
-
- /*
- * @see org.eclipse.core.filebuffers.IFileBufferListener#bufferDisposed(org.eclipse.core.filebuffers.IFileBuffer)
- */
- public void bufferDisposed(IFileBuffer buffer) {
- // ignore
- }
- }
-
- /** The parent document provider */
- private IDocumentProvider fParentProvider;
- /** Element information of all connected elements */
- private final Map fFileInfoMap= new HashMap();
- /** Map from file buffers to their connected elements */
- private final Map fFileBufferMap= new HashMap();
- /** The list of element state listeners */
- private List fElementStateListeners= new ArrayList();
- /** The file buffer listener */
- private final IFileBufferListener fFileBufferListener= new FileBufferListener();
- /** The progress monitor */
- private IProgressMonitor fProgressMonitor;
- /** The operation runner */
- private WorkspaceOperationRunner fOperationRunner;
- /** The rule factory */
- private IResourceRuleFactory fResourceRuleFactory;
-
-
- public TextFileDocumentProvider() {
- this(null);
- }
-
- public TextFileDocumentProvider(IDocumentProvider parentProvider) {
- IFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.setSynchronizationContext(new UISynchronizationContext());
- if (parentProvider != null)
- setParentDocumentProvider(parentProvider);
-
- fResourceRuleFactory= ResourcesPlugin.getWorkspace().getRuleFactory();
- }
-
- final public void setParentDocumentProvider(IDocumentProvider parentProvider) {
-
- Assert.isTrue(parentProvider instanceof IDocumentProviderExtension);
- Assert.isTrue(parentProvider instanceof IDocumentProviderExtension2);
- Assert.isTrue(parentProvider instanceof IDocumentProviderExtension3);
- Assert.isTrue(parentProvider instanceof IStorageDocumentProvider);
-
- fParentProvider= parentProvider;
- if (fParentProvider == null)
- fParentProvider= new NullProvider();
- }
-
- /**
- * Returns the parent document provider.
- *
- * @return the parent document provider
- */
- final protected IDocumentProvider getParentProvider() {
- if (fParentProvider == null)
- fParentProvider= new StorageDocumentProvider();
- return fParentProvider;
- }
-
- /**
- * Returns the runnable context for this document provider.
- *
- * @param monitor the progress monitor
- * @return the runnable context for this document provider
- */
- protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
- if (fOperationRunner == null)
- fOperationRunner = new WorkspaceOperationRunner();
- fOperationRunner.setProgressMonitor(monitor);
- return fOperationRunner;
- }
-
- /**
- * Executes the given operation in the providers runnable context.
- *
- * @param operation the operation to be executes
- * @param monitor the progress monitor
- * @exception CoreException the operation's core exception
- */
- protected void executeOperation(DocumentProviderOperation operation, IProgressMonitor monitor) throws CoreException {
- try {
- IRunnableContext runner= getOperationRunner(monitor);
- if (runner != null)
- runner.run(false, false, operation);
- else
- operation.run(monitor);
- } catch (InvocationTargetException x) {
- Throwable e= x.getTargetException();
- if (e instanceof CoreException)
- throw (CoreException) e;
- String message= (e.getMessage() != null ? e.getMessage() : ""); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.ERROR, message, e));
- } catch (InterruptedException x) {
- String message= (x.getMessage() != null ? x.getMessage() : ""); //$NON-NLS-1$
- throw new CoreException(new Status(IStatus.CANCEL, EditorsUI.PLUGIN_ID, IStatus.OK, message, x));
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#connect(java.lang.Object)
- */
- public void connect(Object element) throws CoreException {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info == null) {
-
- info= createFileInfo(element);
- if (info == null) {
- getParentProvider().connect(element);
- return;
- }
-
- info.fElement= element;
- fFileInfoMap.put(element, info);
- storeFileBufferMapping(element, info);
- }
- ++ info.fCount;
- }
-
- /**
- * Updates the file buffer map with a new relation between the file buffer
- * of the given info and the given element.
- *
- * @param element the element
- * @param info the element info
- */
- private void storeFileBufferMapping(Object element, FileInfo info) {
- Object value= fFileBufferMap.get(info.fTextFileBuffer);
-
- if (value instanceof List) {
- List list= (List) value;
- list.add(element);
- return;
- }
-
- if (value == null) {
- value= element;
- } else {
- List list= new ArrayList(2);
- list.add(value);
- list.add(element);
- value= list;
- }
- fFileBufferMap.put(info.fTextFileBuffer, value);
- }
-
- protected FileInfo createEmptyFileInfo() {
- return new FileInfo();
- }
-
- protected FileInfo createFileInfo(Object element) throws CoreException {
-
- IPath location= null;
- if (element instanceof IAdaptable) {
- IAdaptable adaptable= (IAdaptable) element;
- ILocationProvider provider= (ILocationProvider) adaptable.getAdapter(ILocationProvider.class);
- if (provider != null)
- location= provider.getPath(element);
- }
-
- if (location != null) {
- ITextFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.connect(location, getProgressMonitor());
- manager.requestSynchronizationContext(location);
- ITextFileBuffer fileBuffer= manager.getTextFileBuffer(location);
-
- FileInfo info= createEmptyFileInfo();
- info.fTextFileBuffer= fileBuffer;
- info.fCachedReadOnlyState= isSystemFileReadOnly(info);
-
- IFile file= FileBuffers.getWorkspaceFileAtLocation(location);
- if (file != null && file.exists())
- info.fModel= createAnnotationModel(file);
- return info;
- }
- return null;
- }
-
- protected IAnnotationModel createAnnotationModel(IFile file) {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#disconnect(java.lang.Object)
- */
- public void disconnect(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
-
- if (info == null) {
- getParentProvider().disconnect(element);
- return;
- }
-
- if (info.fCount == 1) {
-
- fFileInfoMap.remove(element);
- removeFileBufferMapping(element, info);
- disposeFileInfo(element, info);
-
- } else
- -- info.fCount;
- }
-
- /**
- * Removes the relation between the file buffer of the given info and the
- * given element from the file buffer mapping.
- *
- * @param element the element
- * @param info the given element info
- */
- private void removeFileBufferMapping(Object element, FileInfo info) {
- Object value= fFileBufferMap.get(info.fTextFileBuffer);
- if (value == null)
- return;
-
- if (value instanceof List) {
- List list= (List) value;
- list.remove(element);
- if (list.size() == 1)
- fFileBufferMap.put(info.fTextFileBuffer, list.get(0));
- } else if (value == element) {
- fFileBufferMap.remove(info.fTextFileBuffer);
- }
- }
-
- protected void disposeFileInfo(Object element, FileInfo info) {
- IFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- try {
- IPath location= info.fTextFileBuffer.getLocation();
- manager.releaseSynchronizationContext(location);
- manager.disconnect(location, getProgressMonitor());
- } catch (CoreException x) {
- handleCoreException(x, "FileDocumentProvider.disposeElementInfo"); //$NON-NLS-1$
- }
- }
-
- /**
- *Returns an iterator for all the elements that are connected to this file buffer.
- *
- * @param file the file buffer
- * @return an iterator for all elements connected with the given file buffer
- */
- protected Iterator getElements(IFileBuffer file) {
- Object value= fFileBufferMap.get(file);
- if (value instanceof List)
- return new ArrayList((List) value).iterator();
- return new SingleElementIterator(value);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getDocument(java.lang.Object)
- */
- public IDocument getDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.getDocument();
- return getParentProvider().getDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#resetDocument(java.lang.Object)
- */
- public void resetDocument(Object element) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null) {
- DocumentProviderOperation operation= new DocumentProviderOperation() {
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException {
- info.fTextFileBuffer.revert(monitor);
-
- if (info.fModel instanceof AbstractMarkerAnnotationModel) {
- AbstractMarkerAnnotationModel markerModel= (AbstractMarkerAnnotationModel) info.fModel;
- markerModel.resetMarkers();
- }
- }
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
- */
- public ISchedulingRule getSchedulingRule() {
- if (info.fElement instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) info.fElement;
- return fResourceRuleFactory.modifyRule((input).getFile());
- } else
- return null;
- }
- };
- executeOperation(operation, getProgressMonitor());
- } else {
- getParentProvider().resetDocument(element);
- }
- }
-
- /*
- * @see IDocumentProvider#saveDocument(IProgressMonitor, Object, IDocument, boolean)
- */
- public final void saveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
-
- if (element == null)
- return;
-
- DocumentProviderOperation operation= createSaveOperation(element, document, overwrite);
- if (operation != null)
- executeOperation(operation, monitor);
- else
- getParentProvider().saveDocument(monitor, element, document, overwrite);
- }
-
- protected DocumentProviderOperation createSaveOperation(final Object element, final IDocument document, final boolean overwrite) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null) {
-
- if (info.fTextFileBuffer.getDocument() != document) {
- Status status= new Status(IStatus.WARNING, EditorsUI.PLUGIN_ID, IStatus.ERROR, "not the same document", null); //$NON-NLS-1$
- throw new CoreException(status);
- }
-
- return new DocumentProviderOperation() {
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CoreException {
- commitFileBuffer(monitor, info, overwrite);
- }
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
- */
- public ISchedulingRule getSchedulingRule() {
- if (info.fElement instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) info.fElement;
- return computeSchedulingRule(input.getFile());
- } else
- return null;
- }
- };
-
- } else if (element instanceof IFileEditorInput) {
-
- final IFile file= ((IFileEditorInput) element).getFile();
- return new DocumentProviderOperation() {
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void execute(IProgressMonitor monitor) throws CoreException {
- createFileFromDocument(monitor, file, document);
- }
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
- */
- public ISchedulingRule getSchedulingRule() {
- return computeSchedulingRule(file);
- }
- };
- }
-
- return null;
- }
-
- protected void commitFileBuffer(IProgressMonitor monitor, FileInfo info, boolean overwrite) throws CoreException {
- Assert.isNotNull(info);
- info.fTextFileBuffer.commit(monitor, overwrite);
- if (info.fModel instanceof AbstractMarkerAnnotationModel) {
- AbstractMarkerAnnotationModel model= (AbstractMarkerAnnotationModel) info.fModel;
- model.updateMarkers(info.fTextFileBuffer.getDocument());
- }
- }
-
- protected void createFileFromDocument(IProgressMonitor monitor, IFile file, IDocument document) throws CoreException {
- String encoding= getCharsetForNewFile(file, document);
- try {
- monitor.beginTask(TextEditorMessages.getString("TextFileDocumentProvider.beginTask.saving"), 2000); //$NON-NLS-1$
- InputStream stream= new ByteArrayInputStream(document.get().getBytes(encoding));
- ContainerGenerator generator = new ContainerGenerator(file.getWorkspace(), file.getParent().getFullPath());
- generator.generateContainer(new SubProgressMonitor(monitor, 1000));
- file.create(stream, false, new SubProgressMonitor(monitor, 1000));
- } catch (UnsupportedEncodingException x) {
- String message= TextEditorMessages.getFormattedString("Editor.error.unsupported_encoding.message_arg", encoding); //$NON-NLS-1$
- IStatus s= new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, message, x);
- throw new CoreException(s);
- } finally {
- monitor.done();
- }
- }
-
- private String getCharsetForNewFile(IFile targetFile, IDocument document) {
- // User-defined encoding has first priority
- String encoding;
- try {
- encoding= targetFile.getCharset(false);
- } catch (CoreException ex) {
- encoding= null;
- }
- if (encoding != null)
- return encoding;
-
- // Probe content
- Reader reader= new BufferedReader(new StringReader(document.get()));
- try {
- QualifiedName[] options= new QualifiedName[] { IContentDescription.CHARSET, IContentDescription.BYTE_ORDER_MARK };
- IContentDescription description= Platform.getContentTypeManager().getDescriptionFor(reader, targetFile.getName(), options);
- if (description != null) {
- encoding= description.getCharset();
- if (encoding != null)
- return encoding;
- }
- } catch (IOException ex) {
- // continue with next strategy
- } finally {
- try {
- reader.close();
- } catch (IOException ex) {
- TextEditorPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, "TextFileDocumentProvider.getCharsetForNewFile(...): Could not close reader", ex)); //$NON-NLS-1$
- }
- }
-
- // Use parent chain
- try {
- return targetFile.getParent().getDefaultCharset();
- } catch (CoreException ex) {
- // Use global default
- return ResourcesPlugin.getEncoding();
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getModificationStamp(java.lang.Object)
- */
- public long getModificationStamp(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.getModificationStamp();
- return getParentProvider().getModificationStamp(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getSynchronizationStamp(java.lang.Object)
- */
- public long getSynchronizationStamp(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return 0;
- return getParentProvider().getSynchronizationStamp(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#isDeleted(java.lang.Object)
- */
- public boolean isDeleted(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null) {
- File file= getSystemFile(info);
- return file == null ? true : !file.exists();
- }
- return getParentProvider().isDeleted(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#mustSaveDocument(java.lang.Object)
- */
- public boolean mustSaveDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return (info.fCount == 1) && info.fTextFileBuffer.isDirty();
- return getParentProvider().mustSaveDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#canSaveDocument(java.lang.Object)
- */
- public boolean canSaveDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.isDirty();
- return getParentProvider().canSaveDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object)
- */
- public IAnnotationModel getAnnotationModel(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null) {
- if (info.fModel != null)
- return info.fModel;
- return info.fTextFileBuffer.getAnnotationModel();
- }
- return getParentProvider().getAnnotationModel(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#aboutToChange(java.lang.Object)
- */
- public void aboutToChange(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info == null)
- getParentProvider().aboutToChange(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#changed(java.lang.Object)
- */
- public void changed(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info == null)
- getParentProvider().changed(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#addElementStateListener(org.eclipse.ui.texteditor.IElementStateListener)
- */
- public void addElementStateListener(IElementStateListener listener) {
- Assert.isNotNull(listener);
- if (!fElementStateListeners.contains(listener)) {
- fElementStateListeners.add(listener);
- if (fElementStateListeners.size() == 1) {
- IFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.addFileBufferListener(fFileBufferListener);
- }
- }
- getParentProvider().addElementStateListener(listener);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProvider#removeElementStateListener(org.eclipse.ui.texteditor.IElementStateListener)
- */
- public void removeElementStateListener(IElementStateListener listener) {
- Assert.isNotNull(listener);
- fElementStateListeners.remove(listener);
- if (fElementStateListeners.size() == 0) {
- IFileBufferManager manager= FileBuffers.getTextFileBufferManager();
- manager.removeFileBufferListener(fFileBufferListener);
- }
- getParentProvider().removeElementStateListener(listener);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isReadOnly(java.lang.Object)
- */
- public boolean isReadOnly(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fCachedReadOnlyState;
- return ((IDocumentProviderExtension) getParentProvider()).isReadOnly(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isModifiable(java.lang.Object)
- */
- public boolean isModifiable(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.isStateValidated() ? !isSystemFileReadOnly(info) : true;
- return ((IDocumentProviderExtension) getParentProvider()).isModifiable(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#validateState(java.lang.Object, java.lang.Object)
- */
- public void validateState(Object element, final Object computationContext) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null) {
- DocumentProviderOperation operation= new DocumentProviderOperation() {
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException {
- info.fTextFileBuffer.validateState(monitor, computationContext);
- }
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
- */
- public ISchedulingRule getSchedulingRule() {
- if (info.fElement instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) info.fElement;
- return fResourceRuleFactory.validateEditRule(new IResource[] { input.getFile() });
- } else
- return null;
- }
- };
- executeOperation(operation, getProgressMonitor());
- } else
- ((IDocumentProviderExtension) getParentProvider()).validateState(element, computationContext);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#isStateValidated(java.lang.Object)
- */
- public boolean isStateValidated(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.isStateValidated();
- return ((IDocumentProviderExtension) getParentProvider()).isStateValidated(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#updateStateCache(java.lang.Object)
- */
- public void updateStateCache(Object element) throws CoreException {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null) {
- boolean isReadOnly= isSystemFileReadOnly(info);
- // See http://bugs.eclipse.org/bugs/show_bug.cgi?id=14469 for the dirty bit check
- // See https://bugs.eclipse.org/bugs/show_bug.cgi?id=50699 for commenting that out
- if (!info.fCachedReadOnlyState && isReadOnly /*&& !info.fTextFileBuffer.isDirty()*/)
- info.fTextFileBuffer.resetStateValidation();
- info.fCachedReadOnlyState= isReadOnly;
- } else {
- ((IDocumentProviderExtension) getParentProvider()).updateStateCache(element);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#setCanSaveDocument(java.lang.Object)
- */
- public void setCanSaveDocument(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info == null)
- ((IDocumentProviderExtension) getParentProvider()).setCanSaveDocument(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#getStatus(java.lang.Object)
- */
- public IStatus getStatus(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.getStatus();
- return ((IDocumentProviderExtension) getParentProvider()).getStatus(element);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#synchronize(java.lang.Object)
- */
- public void synchronize(Object element) throws CoreException {
- final FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null) {
- DocumentProviderOperation operation= new DocumentProviderOperation() {
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor monitor) throws CoreException {
- info.fTextFileBuffer.revert(monitor);
- }
- /*
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider.DocumentProviderOperation#getSchedulingRule()
- */
- public ISchedulingRule getSchedulingRule() {
- if (info.fElement instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) info.fElement;
- return fResourceRuleFactory.refreshRule(input.getFile());
- } else
- return null;
- }
- };
- executeOperation(operation, getProgressMonitor());
- } else {
- ((IDocumentProviderExtension) getParentProvider()).synchronize(element);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor progressMonitor) {
- fProgressMonitor= progressMonitor;
- ((IDocumentProviderExtension2) getParentProvider()).setProgressMonitor(progressMonitor);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#getProgressMonitor()
- */
- public IProgressMonitor getProgressMonitor() {
- return fProgressMonitor;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3#isSynchronized(java.lang.Object)
- */
- public boolean isSynchronized(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.isSynchronized();
- return ((IDocumentProviderExtension3) getParentProvider()).isSynchronized(element);
- }
-
- /*
- * @see org.eclipse.ui.editors.text.IStorageDocumentProvider#getDefaultEncoding()
- */
- public String getDefaultEncoding() {
- return FileBuffers.getTextFileBufferManager().getDefaultEncoding();
- }
-
- /*
- * @see org.eclipse.ui.editors.text.IStorageDocumentProvider#getEncoding(java.lang.Object)
- */
- public String getEncoding(Object element) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- return info.fTextFileBuffer.getEncoding();
- return ((IStorageDocumentProvider) getParentProvider()).getEncoding(element);
- }
-
- /*
- * @see org.eclipse.ui.editors.text.IStorageDocumentProvider#setEncoding(java.lang.Object, java.lang.String)
- */
- public void setEncoding(Object element, String encoding) {
- FileInfo info= (FileInfo) fFileInfoMap.get(element);
- if (info != null)
- info.fTextFileBuffer.setEncoding(encoding);
- else
- ((IStorageDocumentProvider) getParentProvider()).setEncoding(element, encoding);
- }
-
- /**
- * Defines the standard procedure to handle <code>CoreExceptions</code>. Exceptions
- * are written to the plug-in log.
- *
- * @param exception the exception to be logged
- * @param message the message to be logged
- */
- protected void handleCoreException(CoreException exception, String message) {
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log= Platform.getLog(bundle);
- IStatus status= message != null ? new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, exception) : exception.getStatus();
- log.log(status);
- }
-
- protected File getSystemFile(FileInfo info) {
- IPath path= info.fTextFileBuffer.getLocation();
- return FileBuffers.getSystemFileAtLocation(path);
- }
-
- protected boolean isSystemFileReadOnly(FileInfo info) {
- File file= getSystemFile(info);
- return file == null ? true : !file.canWrite();
- }
-
- protected FileInfo getFileInfo(Object element) {
- return (FileInfo) fFileInfoMap.get(element);
- }
-
- protected Iterator getConnectedElementsIterator() {
- return new HashSet(fFileInfoMap.keySet()).iterator();
- }
-
- protected Iterator getFileInfosIterator() {
- return new ArrayList(fFileInfoMap.values()).iterator();
- }
-
- protected void fireElementStateChanging(Object element) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- Object l= e.next();
- if (l instanceof IElementStateListenerExtension) {
- IElementStateListenerExtension x= (IElementStateListenerExtension) l;
- x.elementStateChanging(element);
- }
- }
- }
-
- protected void fireElementStateChangeFailed(Object element) {
- List list= new ArrayList(fElementStateListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- Object l= e.next();
- if (l instanceof IElementStateListenerExtension) {
- IElementStateListenerExtension x= (IElementStateListenerExtension) l;
- x.elementStateChangeFailed(element);
- }
- }
- }
-
- /**
- * Computes the scheduling rule needed to create or modify a resource. If
- * the resource exists, its modify rule is returned. If it does not, the
- * resource hierarchy is iterated towards the workspace root to find the
- * first parent of <code>toCreateOrModify</code> that exists. Then the
- * 'create' rule for the last non-existing resource is returned.
- * <p>
- * XXX to be made protected after 3.0
- * </p>
- *
- * @param toCreateOrModify the resource to create or modify
- * @return the minimal scheduling rule needed to modify or create a resource
- */
- private ISchedulingRule computeSchedulingRule(IResource toCreateOrModify) {
- if (toCreateOrModify.exists()) {
- return fResourceRuleFactory.modifyRule(toCreateOrModify);
- } else {
- IResource parent= toCreateOrModify;
- do {
- toCreateOrModify= parent;
- parent= toCreateOrModify.getParent();
- } while (parent != null && !parent.exists());
-
- return fResourceRuleFactory.createRule(toCreateOrModify);
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
deleted file mode 100644
index 4ac3c636d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/TextSourceViewerConfiguration.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-
-
-/**
- * Source viewer configuration for the text editor.
- *
- * @since 3.0
- */
-public class TextSourceViewerConfiguration extends SourceViewerConfiguration {
-
- /** The preference store used to initialize this configuration. */
- private IPreferenceStore fPreferenceStore;
-
- /**
- * A no-op implementation of <code>IAnnotationHover</code> that will trigger the text editor
- * to set up annotation hover support.
- */
- private static class NullHover implements IAnnotationHover {
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- return null;
- }
-
- }
-
- /**
- * Creates a text source viewer configuration.
- */
- public TextSourceViewerConfiguration() {
- }
-
- /**
- * Creates a text source viewer configuration and
- * initializes it with the given preference store.
- *
- * @param preferenceStore the preference store used to initialize this configuration
- */
- public TextSourceViewerConfiguration(IPreferenceStore preferenceStore) {
- fPreferenceStore= preferenceStore;
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getAnnotationHover(org.eclipse.jface.text.source.ISourceViewer)
- */
- public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
- return new NullHover();
- }
-
- /*
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTabWidth(org.eclipse.jface.text.source.ISourceViewer)
- */
- public int getTabWidth(ISourceViewer sourceViewer) {
- if (fPreferenceStore == null)
- return super.getTabWidth(sourceViewer);
- return fPreferenceStore.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/package.html b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/package.html
deleted file mode 100644
index 688aefd2d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/package.html
+++ /dev/null
@@ -1,12 +0,0 @@
-<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Package-level Javadoc</title>
-</head>
-<body>
-Provides a standard text editor and concrete document providers based
-<tt>IFileBuffer</tt> and others directly handling <tt>IFile</tt> and
-<tt>IStorage</tt> as editor input.
-</body>
-</html>
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
deleted file mode 100644
index 37153c4f6..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionContextTypeRegistry.java
+++ /dev/null
@@ -1,195 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.templates;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-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.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.TemplateVariableResolver;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-
-
-/**
- * A registry for context types. Editor implementors will usually instantiate a
- * registry and configure the context types available in their editor.
- * <code>ContextType</code>s can be added either directly using
- * {@link #addContextType(TemplateContextType)} or by instantiating and adding a
- * contributed context type using {@link #addContextType(String)}.
- *
- * @since 3.0
- */
-public class ContributionContextTypeRegistry extends ContextTypeRegistry {
-
- /* extension point string literals */
- private static final String TEMPLATES_EXTENSION_POINT= "org.eclipse.ui.editors.templates"; //$NON-NLS-1$
-
- private static final String CONTEXT_TYPE= "contextType"; //$NON-NLS-1$
- private static final String ID= "id"; //$NON-NLS-1$
- private static final String NAME= "name"; //$NON-NLS-1$
- private static final String CLASS= "class"; //$NON-NLS-1$
-
- private static final String RESOLVER= "resolver"; //$NON-NLS-1$
- private static final String CONTEXT_TYPE_ID= "contextTypeId"; //$NON-NLS-1$
- private static final String DESCRIPTION= "description"; //$NON-NLS-1$
- private static final String TYPE= "type"; //$NON-NLS-1$
-
- /**
- * Tries to create a context type given an id. If there is already a context
- * type registered under the given id, nothing happens. Otherwise,
- * contributions to the <code>org.eclipse.ui.editors.templates</code>
- * extension point are searched for the given identifier and the specified
- * context type instantiated if it is found.
- *
- * @param id the id for the context type as specified in XML
- */
- public void addContextType(String id) {
- Assert.isNotNull(id);
- if (getContextType(id) != null)
- return;
-
- TemplateContextType type= createContextType(id);
- if (type != null)
- addContextType(type);
-
- }
-
- /**
- * Tries to create a context type given an id. Contributions to the
- * <code>org.eclipse.ui.editors.templates</code> extension point are
- * searched for the given identifier and the specified context type
- * instantiated if it is found. Any contributed
- * {@link org.eclipse.jface.text.templates.TemplateVariableResolver}s
- * are also instantiated and added to the context type.
- *
- * @param id the id for the context type as specified in XML
- * @return the instantiated and configured context type, or
- * <code>null</code> if it is not found or cannot be instantiated
- */
- public static TemplateContextType createContextType(String id) {
- Assert.isNotNull(id);
-
- IConfigurationElement[] extensions= getTemplateExtensions();
- TemplateContextType type;
- try {
- type= createContextType(extensions, id);
- if (type != null) {
- TemplateVariableResolver[] resolvers= createResolvers(extensions, id);
- for (int i= 0; i < resolvers.length; i++)
- type.addResolver(resolvers[i]);
- }
- } catch (CoreException e) {
- EditorsPlugin.log(e);
- type= null;
- }
-
- return type;
- }
-
- private static TemplateContextType createContextType(IConfigurationElement[] extensions, String contextTypeId) throws CoreException {
- for (int i= 0; i < extensions.length; i++) {
- // TODO create half-order over contributions
- if (extensions[i].getName().equals(CONTEXT_TYPE)) {
- String id= extensions[i].getAttributeAsIs(ID);
- if (contextTypeId.equals(id))
- return createContextType(extensions[i]);
- }
- }
-
- return null;
- }
-
- /**
- * Instantiates the resolvers contributed to the context type with id
- * <code>contextTypeId</code>. If instantiation of one resolver fails,
- * the exception are logged and operation continues.
- *
- * @param extensions the configuration elements to parse
- * @param contextTypeId the id of the context type for which resolvers are
- * instantiated
- * @return the instantiated resolvers
- */
- private static TemplateVariableResolver[] createResolvers(IConfigurationElement[] extensions, String contextTypeId) {
- List resolvers= new ArrayList();
- for (int i= 0; i < extensions.length; i++) {
- if (extensions[i].getName().equals(RESOLVER)) {
- String declaredId= extensions[i].getAttributeAsIs(CONTEXT_TYPE_ID);
- if (contextTypeId.equals(declaredId)) {
- try {
- TemplateVariableResolver resolver= createResolver(extensions[i]);
- if (resolver != null)
- resolvers.add(resolver);
- } catch (CoreException e) {
- EditorsPlugin.log(e);
- }
- }
- }
- }
-
- return (TemplateVariableResolver[]) resolvers.toArray(new TemplateVariableResolver[resolvers.size()]);
-
- }
-
- private static IConfigurationElement[] getTemplateExtensions() {
- return Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATES_EXTENSION_POINT);
- }
-
- private static TemplateContextType createContextType(IConfigurationElement element) throws CoreException {
- String id= element.getAttributeAsIs(ID);
- try {
- TemplateContextType contextType= (TemplateContextType) element.createExecutableExtension(CLASS);
- String name= element.getAttribute(NAME);
- if (name == null)
- name= id;
-
- contextType.setId(id);
- contextType.setName(name);
-
- return contextType;
- } catch (ClassCastException e) {
- throw new CoreException(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, "extension does not implement " + TemplateContextType.class.getName(), e)); //$NON-NLS-1$
- }
- }
-
- private static TemplateVariableResolver createResolver(IConfigurationElement element) throws CoreException {
- try {
- String type= element.getAttributeAsIs(TYPE);
- if (type != null) {
-
- TemplateVariableResolver resolver= (TemplateVariableResolver) element.createExecutableExtension(CLASS);
- resolver.setType(type);
-
- String desc= element.getAttribute(DESCRIPTION);
- if (desc == null)
- desc= new String();
- resolver.setDescription(desc);
-
- return resolver;
- }
- } catch (ClassCastException e) {
- throw new CoreException(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, "extension does not implement " + TemplateVariableResolver.class.getName(), e)); //$NON-NLS-1$
- }
-
- return null;
- }
-}
-
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.java
deleted file mode 100644
index 8782b4946..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.templates;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Helper class to get NLSed messages.
- *
- * @since 3.0
- */
-class ContributionTemplateMessages {
-
- private static final String BUNDLE_NAME= "org.eclipse.ui.editors.text.templates.ContributionTemplateMessages";//$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- private ContributionTemplateMessages() {}
-
- /**
- * Gets a string from the resource bundle.
- *
- * @param key the string used to get the bundle value, must not be <code>null<code>
- * @return the string from the resource bundle
- */
- public static String getString(String key) {
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.properties
deleted file mode 100644
index c5b779f5a..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateMessages.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 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
-###############################################################################
-ContributionTemplateStore.ignore_prefix=Ignoring template
-ContributionTemplateStore.ignore_postfix_no_id= since it has no id.
-ContributionTemplateStore.ignore_postfix_deleted= since it is deleted.
-ContributionTemplateStore.ignore_postfix_validation_failed= since validation failed.
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
deleted file mode 100644
index c80f22363..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/ContributionTemplateStore.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.templates;
-
-import java.io.BufferedInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-import java.util.PropertyResourceBundle;
-import java.util.ResourceBundle;
-
-import org.osgi.framework.Bundle;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateException;
-import org.eclipse.jface.text.templates.persistence.TemplatePersistenceData;
-import org.eclipse.jface.text.templates.persistence.TemplateReaderWriter;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-
-
-/**
- * Manages templates. Handles reading default templates contributed via XML and
- * user-defined (or overridden) templates stored in the preferences.
- * <p>
- * Clients may instantiate but not subclass this class.
- * </p>
- *
- * @since 3.0
- */
-public class ContributionTemplateStore extends TemplateStore {
- /* extension point string literals */
- private static final String TEMPLATES_EXTENSION_POINT= "org.eclipse.ui.editors.templates"; //$NON-NLS-1$
-
- private static final String ID= "id"; //$NON-NLS-1$
- private static final String NAME= "name"; //$NON-NLS-1$
-
- private static final String CONTEXT_TYPE_ID= "contextTypeId"; //$NON-NLS-1$
- private static final String DESCRIPTION= "description"; //$NON-NLS-1$
-
- private static final String TEMPLATE= "template"; //$NON-NLS-1$
- private static final String PATTERN= "pattern"; //$NON-NLS-1$
-
- private static final String INCLUDE= "include"; //$NON-NLS-1$
- private static final String FILE= "file"; //$NON-NLS-1$
- private static final String TRANSLATIONS= "translations"; //$NON-NLS-1$
-
- /**
- * Creates a new template store.
- *
- * @param store the preference store in which to store custom templates
- * under <code>key</code>
- * @param key the key into <code>store</code> where to store custom
- * templates
- */
- public ContributionTemplateStore(IPreferenceStore store, String key) {
- super(store, key);
- }
-
- /**
- * Creates a new template store with a context type registry. Only templates
- * that specify a context type contained in the registry will be loaded by
- * this store if the registry is not <code>null</code>.
- *
- * @param registry a context type registry, or <code>null</code> if all
- * templates should be loaded
- * @param store the preference store in which to store custom templates
- * under <code>key</code>
- * @param key the key into <code>store</code> where to store custom
- * templates
- */
- public ContributionTemplateStore(ContextTypeRegistry registry, IPreferenceStore store, String key) {
- super(registry, store, key);
- }
-
- /**
- * Loads the templates contributed via the templates extension point.
- *
- * @throws IOException {@inheritDoc}
- */
- protected void loadContributedTemplates() throws IOException {
- IConfigurationElement[] extensions= getTemplateExtensions();
- Collection contributed= readContributedTemplates(extensions);
- for (Iterator it= contributed.iterator(); it.hasNext();) {
- TemplatePersistenceData data= (TemplatePersistenceData) it.next();
- internalAdd(data);
- }
- }
-
- private Collection readContributedTemplates(IConfigurationElement[] extensions) throws IOException {
- Collection templates= new ArrayList();
- for (int i= 0; i < extensions.length; i++) {
- if (extensions[i].getName().equals(TEMPLATE))
- createTemplate(templates, extensions[i]);
- else if (extensions[i].getName().equals(INCLUDE)) {
- readIncludedTemplates(templates, extensions[i]);
- }
- }
-
- return templates;
- }
-
- private void readIncludedTemplates(Collection templates, IConfigurationElement element) throws IOException {
- String file= element.getAttributeAsIs(FILE);
- if (file != null) {
- Bundle plugin = Platform.getBundle(element.getDeclaringExtension().getNamespace());
- URL url= Platform.find(plugin, new Path(file));
- if (url != null) {
- ResourceBundle bundle= null;
- String translations= element.getAttributeAsIs(TRANSLATIONS);
- if (translations != null) {
- URL bundleURL= Platform.find(plugin, new Path(translations));
- if (url != null) {
- bundle= new PropertyResourceBundle(bundleURL.openStream());
- }
- }
-
- InputStream stream= new BufferedInputStream(url.openStream());
- TemplateReaderWriter reader= new TemplateReaderWriter();
- TemplatePersistenceData[] datas= reader.read(stream, bundle);
- for (int i= 0; i < datas.length; i++) {
- TemplatePersistenceData data= datas[i];
- if (data.isCustom()) {
- if (data.getId() == null)
- EditorsPlugin.logErrorMessage(ContributionTemplateMessages.getString("ContributionTemplateStore.ignore_prefix") + data.getTemplate().getName() + " " + ContributionTemplateMessages.getString("ContributionTemplateStore.ignore_postfix_no_id")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- else
- EditorsPlugin.logErrorMessage(ContributionTemplateMessages.getString("ContributionTemplateStore.ignore_prefix") + data.getTemplate().getName() + " " + ContributionTemplateMessages.getString("ContributionTemplateStore.ignore_postfix_deleted")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else if (!validateTemplate(data.getTemplate())) {
- if (contextExists(data.getTemplate().getContextTypeId()))
- EditorsPlugin.logErrorMessage(ContributionTemplateMessages.getString("ContributionTemplateStore.ignore_prefix") + data.getTemplate().getName() + " " + ContributionTemplateMessages.getString("ContributionTemplateStore.ignore_postfix_validation_failed")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- } else {
- templates.add(data);
- }
- }
- }
- }
- }
-
- /**
- * Validates a template against the context type registered in the context
- * type registry. Returns always <code>true</code> if no registry is
- * present.
- *
- * @param template the template to validate
- * @return <code>true</code> if validation is successful or no context
- * type registry is specified, <code>false</code> if validation
- * fails
- */
- private boolean validateTemplate(Template template) {
- String contextTypeId= template.getContextTypeId();
- if (contextExists(contextTypeId)) {
- if (getRegistry() != null)
- try {
- getRegistry().getContextType(contextTypeId).validate(template.getPattern());
- } catch (TemplateException e) {
- return false;
- }
- return true;
- } else
- return false;
- }
-
- /**
- * Returns <code>true</code> if a context type id specifies a valid context type
- * or if no context type registry is present.
- *
- * @param contextTypeId the context type id to look for
- * @return <code>true</code> if the context type specified by the id
- * is present in the context type registry, or if no registry is
- * specified
- */
- private boolean contextExists(String contextTypeId) {
- return contextTypeId != null && (getRegistry() == null || getRegistry().getContextType(contextTypeId) != null);
- }
-
- private static IConfigurationElement[] getTemplateExtensions() {
- return Platform.getExtensionRegistry().getConfigurationElementsFor(TEMPLATES_EXTENSION_POINT);
- }
-
- private void createTemplate(Collection map, IConfigurationElement element) {
- String contextTypeId= element.getAttributeAsIs(CONTEXT_TYPE_ID);
- // log failures since extension point id and name are mandatory
- if (contextExists(contextTypeId)) {
- String id= element.getAttributeAsIs(ID);
- if (isValidTemplateId(id)) {
-
- String name= element.getAttribute(NAME);
- if (name != null) {
-
- String desc= element.getAttribute(DESCRIPTION);
- if (desc == null)
- desc= new String();
-
- String pattern= element.getChildren(PATTERN)[0].getValue();
- if (pattern != null) {
-
- Template template= new Template(name, desc, contextTypeId, pattern);
- TemplatePersistenceData data= new TemplatePersistenceData(template, true, id);
- if (validateTemplate(template))
- map.add(data);
- }
- }
- }
- }
- }
-
- private static boolean isValidTemplateId(String id) {
- return id != null && id.trim().length() != 0; // TODO test validity?
- }
-}
-
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/package.html b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/package.html
deleted file mode 100644
index e70145a0f..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/templates/package.html
+++ /dev/null
@@ -1,113 +0,0 @@
-<!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en">
-<html>
-<head>
- <meta content="text/html; charset=iso-8859-1"
- http-equiv="Content-Type">
- <meta content="IBM" name="Author">
- <meta content="Mozilla/4.75 [en] (Windows NT 5.0; U) [Netscape]"
- name="GENERATOR">
- <title>Templates</title>
- <meta content="Template Infrastructure package description"
- name="description">
-</head>
-<body>
-Application programming interfaces for interaction
-with the Eclipse Java User Interface text support.
-<h2>Templates<br>
-</h2>
-<h3>packages</h3>
-<ul>
- <li style="font-weight: bold;"><big><span
- style="font-family: monospace;">org.eclipse.jface.text.templates</span></big></li>
- <li style="font-weight: bold;"><big><span
- style="font-family: monospace;">org.eclipse.ui.workbench.texteditor.templates</span><br>
- <span style="font-family: monospace;"></span></big></li>
- <li><big><span style="font-family: monospace; font-weight: bold;">org.eclipse.ui.editors.templates</span></big><br>
- <span style="font-family: monospace;"></span></li>
-</ul>
-<h3><code></code></h3>
-Templates are shortcuts for frequently used fragments of text such as
-code patterns or complex text entities. They may contain variables
-which are only resolved at the time when the template is inserted
-within a context. Together with linked mode, inserting a template can
-create a on-the-fly edit mask within a text viewer.<br>
-<br>
-Templates are specified as text, variables are defined using the <span
- style="font-family: monospace;">${variable}</span> notation known from
-Ant, for example. The following snippet shows an example template for
-an instance check in Java:<br>
-<pre>if (${name} instanceof ${type}) {<br>&nbsp;&nbsp;&nbsp; ${type} ${new_name} = (${type})${name};<br>&nbsp;&nbsp;&nbsp; ${cursor}<br>}<br></pre>
-In this template, the variables (<span style="font-family: monospace;">name,
-type, ...</span><span style="font-family: sans-serif;">) are resolved
-when inserted into java source and changing one variable instance will
-also change the other. When leaving linked mode, the caret is placed at
-the </span><span style="font-family: monospace;">cursor</span><span
- style="font-family: sans-serif;"> variable.<br>
-<br>
-Template functionality can be added to a custom text editor by offering
-</span><span style="font-family: monospace;">TemplateProposal</span><span
- style="font-family: sans-serif;">s as content assist choices, which is
-simplified by using a </span><span style="font-family: sans-serif;"><span
- style="font-family: sans-serif;">subclass of </span></span><span
- style="font-family: monospace;">TemplateCompletionProcessor</span><span
- style="font-family: sans-serif;">. User template management can be
-offered by including a </span><span style="font-family: monospace;">TemplatePreferencePage</span><span
- style="font-family: sans-serif;"> which uses a </span><span
- style="font-family: monospace;">TemplateStore</span><span
- style="font-family: sans-serif;"> and <span
- style="font-family: monospace;">ContextTypeRegistry</span> as the
-underlying model to store templates. The <span
- style="font-family: monospace;">org.eclipse.ui.editors.templates</span>
-extension point can be used to allow other plug-ins to contribute
-templates to an editor. This is accomplished by using the <span
- style="font-family: monospace;">ContributionTemplateStore</span> and <span
- style="font-family: monospace;">ContributionContextTypeRegistry</span>
-subclasses of the above types.<br>
-<br>
-Template variables are resolved by a <span
- style="font-family: monospace;">TemplateVariableResolver.</span> <span
- style="font-family: monospace;">GlobalTemplateVariables</span> offers
-some default variables such as date, user, and selection, but advanced
-features such as resolving to language constructs can be performed in
-subclasses.<br>
-</span>
-<h4>Classes</h4>
-<ul>
- <li><span style="font-family: monospace;">Template</span><span
- style="font-family: sans-serif;"> a template consists of name, context
-type identifier, and a pattern.</span></li>
- <li><span style="font-family: sans-serif;"><span
- style="font-family: monospace;">TemplateTranslator</span> and <span
- style="font-family: monospace;">TemplateBuffer</span> are used to
-parse the template grammar and don't need to be used usually.</span></li>
- <li><span style="font-family: sans-serif;">A <span
- style="font-family: monospace;">TemplateProposal </span>can be
-offered in content assist, possibly created by a subclass of <span
- style="font-family: monospace;">TemplateCompletionProcessor.</span></span></li>
- <li><span style="font-family: sans-serif;"><span
- style="font-family: monospace;">TemplateStore</span> and <span
- style="font-family: monospace;">ContextTypeRegistry</span> manage a
-set of templates within a plug-in and offer ways to store them in the
-preferences or externally in XML streams via a <span
- style="font-family: monospace;">TemplateReaderWriter</span>.<br>
- </span></li>
- <li><span style="font-family: sans-serif;"><span
- style="font-family: monospace;">ContributionTemplateStore</span> and <span
- style="font-family: monospace;">ContributionContextTypeRegistry</span>
-add awareness for the </span><span style="font-family: sans-serif;"><span
- style="font-family: sans-serif;"> <span
- style="font-family: monospace;">org.eclipse.ui.editors.templates</span>
-extension point.</span></span></li>
- <li style="font-family: monospace;"><span
- style="font-family: sans-serif;"><span style="font-family: sans-serif;"><span
- style="font-family: monospace;">TemplatePreferencePage</span> allows
-the user to access the templates within a <span
- style="font-family: monospace;">TemplateStore</span>.</span></span></li>
-</ul>
-<ul>
-</ul>
-<h4>Example</h4>
-<pre><span style="font-family: sans-serif;">See the Template Editor Example in the <span
- style="font-weight: bold;">org.eclipse.ui.examples.javaeditor</span> project.<br></span></pre>
-</body>
-</html>
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java
deleted file mode 100644
index a00ceac0d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/LastSaveReferenceProvider.java
+++ /dev/null
@@ -1,436 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.quickdiff;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-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.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.jobs.IJobManager;
-import org.eclipse.core.runtime.jobs.Job;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.editors.text.IStorageDocumentProvider;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.IElementStateListener;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider;
-
-/**
- * Default provider for the quickdiff display - the saved document is taken as
- * the reference.
- *
- * @since 3.0
- */
-public class LastSaveReferenceProvider implements IQuickDiffReferenceProvider, IElementStateListener {
-
- /** <code>true</code> if the document has been read. */
- private boolean fDocumentRead= false;
- /**
- * The reference document - might be <code>null</code> even if <code>fDocumentRead</code>
- * is <code>true</code>.
- */
- private IDocument fReference= null;
- /**
- * Our unique id that makes us comparable to another instance of the same
- * provider. See extension point reference.
- */
- private String fId;
- /** The current document provider. */
- private IDocumentProvider fDocumentProvider;
- /** The current editor input. */
- private IEditorInput fEditorInput;
- /** Private lock no one else will synchronize on. */
- private final Object fLock= new Object();
- /**
- * The progress monitor for a currently running <code>getReference</code>
- * operation, or <code>null</code>.
- */
- private IProgressMonitor fProgressMonitor;
- /** The text editor we run upon. */
- private ITextEditor fEditor;
-
- /**
- * A job to put the reading of file contents into a background.
- */
- private final class ReadJob extends Job {
-
- /**
- * Creates a new instance.
- */
- public ReadJob() {
- super(QuickDiffMessages.getString("LastSaveReferenceProvider.LastSaveReferenceProvider.readJob.label")); //$NON-NLS-1$
- setSystem(true);
- setPriority(SHORT);
- }
-
- /**
- * Calls
- * {@link LastSaveReferenceProvider#readDocument(IProgressMonitor, boolean)}
- * and returns {@link Status#OK_STATUS}.
- *
- * {@inheritdoc}
- *
- * @param monitor {@inheritDoc}
- * @return {@link Status#OK_STATUS}
- */
- protected IStatus run(IProgressMonitor monitor) {
- readDocument(monitor, false);
- return Status.OK_STATUS;
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider#getReference(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IDocument getReference(IProgressMonitor monitor) {
- if (!fDocumentRead)
- readDocument(monitor, true); // force reading it
- return fReference;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider#dispose()
- */
- public void dispose() {
- IProgressMonitor monitor= fProgressMonitor;
- if (monitor != null) {
- monitor.setCanceled(true);
- }
-
- IDocumentProvider provider= fDocumentProvider;
-
- synchronized (fLock) {
- if (provider != null)
- provider.removeElementStateListener(this);
- fEditorInput= null;
- fDocumentProvider= null;
- fReference= null;
- fDocumentRead= false;
- fProgressMonitor= null;
- fEditor= null;
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider#getId()
- */
- public String getId() {
- return fId;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffProviderImplementation#setActiveEditor(org.eclipse.ui.texteditor.ITextEditor)
- */
- public void setActiveEditor(ITextEditor targetEditor) {
- IDocumentProvider provider= null;
- IEditorInput input= null;
- if (targetEditor != null) {
- provider= targetEditor.getDocumentProvider();
- input= targetEditor.getEditorInput();
- }
-
-
- // dispose if the editor input or document provider have changed
- // note that they may serve multiple editors
- if (provider != fDocumentProvider || input != fEditorInput) {
- dispose();
- synchronized (fLock) {
- fEditor= targetEditor;
- fDocumentProvider= provider;
- fEditorInput= input;
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffProviderImplementation#isEnabled()
- */
- public boolean isEnabled() {
- return fEditorInput != null && fDocumentProvider != null;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.quickdiff.IQuickDiffProviderImplementation#setId(java.lang.String)
- */
- public void setId(String id) {
- fId= id;
- }
-
- /**
- * Reads in the saved document into <code>fReference</code>.
- *
- * @param monitor a progress monitor, or <code>null</code>
- * @param force <code>true</code> if the reference document should also
- * be read if the current document is <code>null</code>,<code>false</code>
- * if it should only be updated if it already existed.
- */
- private void readDocument(IProgressMonitor monitor, boolean force) {
-
- // protect against concurrent disposal
- IDocumentProvider prov= fDocumentProvider;
- IEditorInput inp= fEditorInput;
- IDocument doc= fReference;
- ITextEditor editor= fEditor;
-
- if (prov instanceof IStorageDocumentProvider && inp instanceof IFileEditorInput) {
-
- IFileEditorInput input= (IFileEditorInput) inp;
- IStorageDocumentProvider provider= (IStorageDocumentProvider) prov;
-
- if (doc == null)
- if (force || fDocumentRead)
- doc= new Document();
- else
- return;
-
- IJobManager jobMgr= Platform.getJobManager();
- IFile file= input.getFile();
-
- try {
- fProgressMonitor= monitor;
-
- // this protects others from not being able to delete the file,
- // and protects ourselves from concurrent access to fReference
- // (in the case there already is a valid fReference)
-
- // one might argue that this rule should already be in the Job
- // description we're running in, however:
- // 1) we don't mind waiting for someone else here
- // 2) we do not take long, or require other locks etc. -> short
- // delay for any other job requiring the lock on file
- jobMgr.beginRule(file, monitor);
-
- InputStream stream= getFileContents(file);
- if (stream == null)
- return;
-
- String encoding= file.getCharset();
- if (encoding == null)
- return;
-
- boolean skipUTF8BOM= isUTF8BOM(encoding, file);
-
- setDocumentContent(doc, stream, encoding, monitor, skipUTF8BOM);
-
- } catch (IOException e) {
- return;
- } catch (CoreException e) {
- return;
- } finally {
- jobMgr.endRule(file);
- fProgressMonitor= null;
- }
-
- if (monitor != null && monitor.isCanceled())
- return;
-
- // update state
- synchronized (fLock) {
- if (fDocumentProvider == provider && fEditorInput == input) {
- // only update state if our provider / input pair has not
- // been updated in between (dispose or setActiveEditor)
- fReference= doc;
- fDocumentRead= true;
- addElementStateListener(editor, prov);
- }
- }
- }
- }
-
- /* utility methods */
-
- /**
- * Adds this as element state listener in the UI thread as it can otherwise
- * conflict with other listener additions, since DocumentProvider is not
- * thread-safe.
- *
- * @param editor the editor to get the display from
- * @param provider the document provider to register as element state listener
- */
- private void addElementStateListener(ITextEditor editor, final IDocumentProvider provider) {
- // addElementStateListener adds at most once - no problem to call
- provider.addElementStateListener(this);
-
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=66686 and
- // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=56871
-
-// // repeatedly
-// Runnable runnable= new Runnable() {
-// public void run() {
-// synchronized (fLock) {
-// if (fDocumentProvider == provider)
-// provider.addElementStateListener(LastSaveReferenceProvider.this);
-// }
-// }
-// };
-//
-// Display display= null;
-// if (editor != null) {
-// IWorkbenchPartSite site= editor.getSite();
-// if (site != null)
-// site.getWorkbenchWindow().getShell().getDisplay();
-// }
-//
-// if (display != null && !display.isDisposed())
-// display.asyncExec(runnable);
-// else
-// runnable.run();
- }
-
- /**
- * Gets the contents of <code>file</code> as an input stream.
- *
- * @param file the <code>IFile</code> which we want the content for
- * @return an input stream for the file's content
- */
- private static InputStream getFileContents(IFile file) {
- InputStream stream= null;
- try {
- if (file != null)
- stream= file.getContents();
- } catch (CoreException e) {
- // ignore
- }
- return stream;
- }
-
- /**
- * Initializes the given document with the given stream using the given
- * encoding.
- *
- * @param document the document to be initialized
- * @param contentStream the stream which delivers the document content
- * @param encoding the character encoding for reading the given stream
- * @param monitor a progress monitor for cancellation, or <code>null</code>
- * @param skipUTF8BOM whether to skip three bytes before reading the stream
- * @exception IOException if the given stream can not be read
- */
- private static void setDocumentContent(IDocument document, InputStream contentStream, String encoding, IProgressMonitor monitor, boolean skipUTF8BOM) throws IOException {
- Reader in= null;
- try {
-
- if (skipUTF8BOM) {
- for (int i= 0; i < 3; i++)
- if (contentStream.read() == -1) {
- throw new IOException(QuickDiffMessages.getString("LastSaveReferenceProvider.LastSaveReferenceProvider.error.notEnoughBytesForBOM")); //$NON-NLS-1$
- }
- }
-
- final int DEFAULT_FILE_SIZE= 15 * 1024;
-
- in= new BufferedReader(new InputStreamReader(contentStream, encoding), DEFAULT_FILE_SIZE);
- StringBuffer buffer= new StringBuffer(DEFAULT_FILE_SIZE);
- char[] readBuffer= new char[2048];
- int n= in.read(readBuffer);
- while (n > 0) {
- if (monitor != null && monitor.isCanceled())
- return;
-
- buffer.append(readBuffer, 0, n);
- n= in.read(readBuffer);
- }
-
- document.set(buffer.toString());
-
- } finally {
- if (in != null) {
- try {
- in.close();
- } catch (IOException x) {
- // ignore
- }
- }
- }
- }
-
- /**
- * Returns <code>true</code> if the <code>encoding</code> is UTF-8 and
- * the file contains a BOM. Taken from ResourceTextFileBuffer.java.
- *
- * <p>
- * XXX:
- * This is a workaround for a corresponding bug in Java readers and writer,
- * see: http://developer.java.sun.com/developer/bugParade/bugs/4508058.html
- * </p>
- * @throws CoreException if
- * - reading of file's content description fails
- * - byte order mark is not valid for UTF-8
- */
- private static boolean isUTF8BOM(String encoding, IFile file) throws CoreException {
- if ("UTF-8".equals(encoding)) { //$NON-NLS-1$
- IContentDescription description= file.getContentDescription();
- if (description != null) {
- byte[] bom= (byte[]) description.getProperty(IContentDescription.BYTE_ORDER_MARK);
- if (bom != null) {
- if (bom != IContentDescription.BOM_UTF_8)
- throw new CoreException(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IStatus.OK, QuickDiffMessages.getString("LastSaveReferenceProvider.LastSaveReferenceProvider.error.wrongByteOrderMark"), null)); //$NON-NLS-1$
- return true;
- }
- }
- }
- return false;
- }
-
- /* IElementStateListener implementation */
-
- /*
- * @see org.eclipse.ui.texteditor.IElementStateListener#elementDirtyStateChanged(java.lang.Object, boolean)
- */
- public void elementDirtyStateChanged(Object element, boolean isDirty) {
- if (!isDirty && element == fEditorInput) {
- // document has been saved or reverted - recreate reference
- new ReadJob().schedule();
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IElementStateListener#elementContentAboutToBeReplaced(java.lang.Object)
- */
- public void elementContentAboutToBeReplaced(Object element) {
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IElementStateListener#elementContentReplaced(java.lang.Object)
- */
- public void elementContentReplaced(Object element) {
- if (element == fEditorInput) {
- // document has been reverted or replaced
- new ReadJob().schedule();
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IElementStateListener#elementDeleted(java.lang.Object)
- */
- public void elementDeleted(Object element) {
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IElementStateListener#elementMoved(java.lang.Object, java.lang.Object)
- */
- public void elementMoved(Object originalElement, Object movedElement) {
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.java
deleted file mode 100644
index 6fafa97e6..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.quickdiff;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * @since 3.0
- */
-public class QuickDiffMessages {
- private static final String BUNDLE_NAME= "org.eclipse.ui.internal.editors.quickdiff.QuickDiffMessages";//$NON-NLS-1$
-
- private static final ResourceBundle RESOURCE_BUNDLE= ResourceBundle.getBundle(BUNDLE_NAME);
-
- /**
- *
- */
- private QuickDiffMessages() {
-
- // TODO Auto-generated constructor stub
- }
-
- /**
- * @param key
- * @return
- */
- public static String getString(String key) {
- // TODO Auto-generated method stub
- try {
- return RESOURCE_BUNDLE.getString(key);
- } catch (MissingResourceException e) {
- return '!' + key + '!';
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.properties
deleted file mode 100644
index 1c29d4c49..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/quickdiff/QuickDiffMessages.properties
+++ /dev/null
@@ -1,14 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 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
-###############################################################################
-
-LastSaveReferenceProvider.LastSaveReferenceProvider.readJob.label=Reading saved version of file for quick diff
-LastSaveReferenceProvider.LastSaveReferenceProvider.error.notEnoughBytesForBOM=Stream is shorter than its declared UTF-8 BOM
-LastSaveReferenceProvider.LastSaveReferenceProvider.error.wrongByteOrderMark=Stream has declared as UTF-8 BOM, but BOM does not match
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AbstractConfigurationBlockPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AbstractConfigurationBlockPreferencePage.java
deleted file mode 100644
index b6c552791..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AbstractConfigurationBlockPreferencePage.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.PreferencePage;
-
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-
-/**
- * Abstract preference page which is used to wrap a
- * {@link org.eclipse.ui.internal.editors.text.IPreferenceConfigurationBlock}.
- *
- * @since 3.0
- */
-abstract class AbstractConfigurationBlockPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
-
- private IPreferenceConfigurationBlock fConfigurationBlock;
- private OverlayPreferenceStore fOverlayStore;
-
-
- /**
- * Creates a new preference page.
- */
- public AbstractConfigurationBlockPreferencePage() {
- setDescription();
- setPreferenceStore();
- fOverlayStore= new OverlayPreferenceStore(getPreferenceStore(), new OverlayPreferenceStore.OverlayKey[] {});
- fConfigurationBlock= createConfigurationBlock(fOverlayStore);
- }
-
- protected abstract IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore);
- protected abstract String getHelpId();
- protected abstract void setDescription();
- protected abstract void setPreferenceStore();
-
- /*
- * @see IWorkbenchPreferencePage#init()
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), getHelpId());
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
-
- fOverlayStore.load();
- fOverlayStore.start();
-
- fConfigurationBlock.createControl(parent);
-
- initialize();
-
- Dialog.applyDialogFont(parent);
- return parent;
- }
-
- private void initialize() {
- fConfigurationBlock.initialize();
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
-
- fConfigurationBlock.performOk();
-
- fOverlayStore.propagate();
-
- EditorsPlugin.getDefault().savePluginPreferences();
-
- return true;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- public void performDefaults() {
-
- fOverlayStore.loadDefaults();
- fConfigurationBlock.performDefaults();
-
- super.performDefaults();
- }
-
- /*
- * @see DialogPage#dispose()
- */
- public void dispose() {
-
- fConfigurationBlock.dispose();
-
- if (fOverlayStore != null) {
- fOverlayStore.stop();
- fOverlayStore= null;
- }
-
- super.dispose();
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
deleted file mode 100644
index d68a25989..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsConfigurationBlock.java
+++ /dev/null
@@ -1,433 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.text.Collator;
-import java.util.ArrayList;
-import java.util.Comparator;
-import java.util.Iterator;
-import java.util.SortedSet;
-import java.util.TreeSet;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-
-import org.eclipse.jface.preference.PreferenceConverter;
-
-import org.eclipse.jface.text.Assert;
-
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
-
-
-/**
- * Configures Annotation preferences.
- *
- * @since 3.0
- */
-class AnnotationsConfigurationBlock implements IPreferenceConfigurationBlock {
-
- private OverlayPreferenceStore fStore;
- private ColorEditor fAnnotationForegroundColorEditor;
-
- private Button fShowInTextCheckBox;
- private Combo fDecorationStyleCombo;
- private Button fHighlightInTextCheckBox;
- private Button fShowInOverviewRulerCheckBox;
- private Button fShowInVerticalRulerCheckBox;
-
- private List fAnnotationList;
- private final String[][] fAnnotationColorListModel;
-
-
- /**
- * List of master/slave listeners when there's a dependency.
- *
- * @see #createDependency(Button, String, Control)
- * @since 3.0
- */
- private ArrayList fMasterSlaveListeners= new ArrayList();
-
- private final String[][] fAnnotationDecorationListModel= new String[][] {
- {TextEditorMessages.getString("AnnotationConfigurationBlock.NONE"), AnnotationPreference.STYLE_NONE}, //$NON-NLS-1$
- {TextEditorMessages.getString("AnnotationConfigurationBlock.SQUIGGLES"), AnnotationPreference.STYLE_SQUIGGLES}, //$NON-NLS-1$
- {TextEditorMessages.getString("AnnotationConfigurationBlock.UNDERLINE"), AnnotationPreference.STYLE_UNDERLINE}, //$NON-NLS-1$
- {TextEditorMessages.getString("AnnotationConfigurationBlock.BOX"), AnnotationPreference.STYLE_BOX}, //$NON-NLS-1$
- {TextEditorMessages.getString("AnnotationConfigurationBlock.IBEAM"), AnnotationPreference.STYLE_IBEAM} //$NON-NLS-1$
- };
-
-
- public AnnotationsConfigurationBlock(OverlayPreferenceStore store) {
- Assert.isNotNull(store);
- MarkerAnnotationPreferences markerAnnotationPreferences= new MarkerAnnotationPreferences();
- fStore= store;
- fStore.addKeys(createOverlayStoreKeys(markerAnnotationPreferences));
- fAnnotationColorListModel= createAnnotationTypeListModel(markerAnnotationPreferences);
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
-
- ArrayList overlayKeys= new ArrayList();
- Iterator e= preferences.getAnnotationPreferences().iterator();
-
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getTextPreferenceKey()));
- if (info.getHighlightPreferenceKey() != null)
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getHighlightPreferenceKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
- if (info.getVerticalRulerPreferenceKey() != null)
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getVerticalRulerPreferenceKey()));
- if (info.getTextStylePreferenceKey() != null)
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getTextStylePreferenceKey()));
- }
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- public Control createControl(Composite parent) {
-
- PixelConverter pixelConverter= new PixelConverter(parent);
-
- Composite composite= new Composite(parent, SWT.NULL);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- composite.setLayout(layout);
-
- Label label= new Label(composite, SWT.LEFT);
- label.setText(TextEditorMessages.getString("AnnotationConfigurationBlock.annotationPresentationOptions")); //$NON-NLS-1$
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- label.setLayoutData(gd);
-
- Composite editorComposite= new Composite(composite, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- editorComposite.setLayout(layout);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- gd.horizontalSpan= 2;
- editorComposite.setLayoutData(gd);
-
- fAnnotationList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
- gd.heightHint= pixelConverter.convertHeightInCharsToPixels(20);
- fAnnotationList.setLayoutData(gd);
-
- Composite optionsComposite= new Composite(editorComposite, SWT.NONE);
- layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- optionsComposite.setLayout(layout);
- optionsComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fShowInTextCheckBox= new Button(optionsComposite, SWT.CHECK);
- fShowInTextCheckBox.setText(TextEditorMessages.getString("AnnotationConfigurationBlock.showInText")); //$NON-NLS-1$
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fShowInTextCheckBox.setLayoutData(gd);
-
- fDecorationStyleCombo= new Combo(optionsComposite, SWT.READ_ONLY);
- for(int i= 0; i < fAnnotationDecorationListModel.length; i++)
- fDecorationStyleCombo.add(fAnnotationDecorationListModel[i][0]);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- gd.horizontalIndent= 20;
- fDecorationStyleCombo.setLayoutData(gd);
-
- fHighlightInTextCheckBox= new Button(optionsComposite, SWT.CHECK);
- fHighlightInTextCheckBox.setText(TextEditorMessages.getString("AnnotationConfigurationBlock.highlightInText")); //$NON-NLS-1$
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fHighlightInTextCheckBox.setLayoutData(gd);
-
- fShowInOverviewRulerCheckBox= new Button(optionsComposite, SWT.CHECK);
- fShowInOverviewRulerCheckBox.setText(TextEditorMessages.getString("AnnotationConfigurationBlock.showInOverviewRuler")); //$NON-NLS-1$
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fShowInOverviewRulerCheckBox.setLayoutData(gd);
-
- fShowInVerticalRulerCheckBox= new Button(optionsComposite, SWT.CHECK);
- fShowInVerticalRulerCheckBox.setText(TextEditorMessages.getString("AnnotationConfigurationBlock.showInVerticalRuler")); //$NON-NLS-1$
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fShowInVerticalRulerCheckBox.setLayoutData(gd);
-
- label= new Label(optionsComposite, SWT.LEFT);
- label.setText(TextEditorMessages.getString("AnnotationConfigurationBlock.color")); //$NON-NLS-1$
- gd= new GridData();
- gd.horizontalAlignment= GridData.BEGINNING;
- label.setLayoutData(gd);
-
- fAnnotationForegroundColorEditor= new ColorEditor(optionsComposite);
- Button foregroundColorButton= fAnnotationForegroundColorEditor.getButton();
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- foregroundColorButton.setLayoutData(gd);
-
- fAnnotationList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- handleAnnotationListSelection();
- }
- });
-
- fShowInTextCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i= fAnnotationList.getSelectionIndex();
- String key= fAnnotationColorListModel[i][2];
- fStore.setValue(key, fShowInTextCheckBox.getSelection());
- String decorationKey= fAnnotationColorListModel[i][6];
- fDecorationStyleCombo.setEnabled(decorationKey != null && fShowInTextCheckBox.getSelection());
- }
- });
-
- fHighlightInTextCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i= fAnnotationList.getSelectionIndex();
- String key= fAnnotationColorListModel[i][4];
- fStore.setValue(key, fHighlightInTextCheckBox.getSelection());
- }
- });
-
- fShowInOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i= fAnnotationList.getSelectionIndex();
- String key= fAnnotationColorListModel[i][3];
- fStore.setValue(key, fShowInOverviewRulerCheckBox.getSelection());
- }
- });
-
- fShowInVerticalRulerCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i= fAnnotationList.getSelectionIndex();
- String key= fAnnotationColorListModel[i][5];
- fStore.setValue(key, fShowInVerticalRulerCheckBox.getSelection());
- }
- });
-
- foregroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i= fAnnotationList.getSelectionIndex();
- String key= fAnnotationColorListModel[i][1];
- PreferenceConverter.setValue(fStore, key, fAnnotationForegroundColorEditor.getColorValue());
- }
- });
-
- fDecorationStyleCombo.addSelectionListener(new SelectionListener() {
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- /*
- * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent)
- */
- public void widgetSelected(SelectionEvent e) {
- int i= fAnnotationList.getSelectionIndex();
- String key= fAnnotationColorListModel[i][6];
- if (key != null) {
- for (int j= 0; j < fAnnotationDecorationListModel.length; j++) {
- if (fAnnotationDecorationListModel[j][0].equals(fDecorationStyleCombo.getText())) {
- fStore.setValue(key, fAnnotationDecorationListModel[j][1]);
- break;
- }
- }
- }
- }
- });
-
- return composite;
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public void performOk() {
-// restoreFromPreferences();
-// initializeFields();
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- public void performDefaults() {
-
- fStore.loadDefaults();
- handleAnnotationListSelection();
- }
-
- private void handleAnnotationListSelection() {
- int i= fAnnotationList.getSelectionIndex();
-
- String key= fAnnotationColorListModel[i][1];
- RGB rgb= PreferenceConverter.getColor(fStore, key);
- fAnnotationForegroundColorEditor.setColorValue(rgb);
-
- key= fAnnotationColorListModel[i][2];
- boolean showInText = fStore.getBoolean(key);
- fShowInTextCheckBox.setSelection(showInText);
-
- key= fAnnotationColorListModel[i][6];
- if (key != null) {
- fDecorationStyleCombo.setEnabled(showInText);
- for (int j= 0; j < fAnnotationDecorationListModel.length; j++) {
- String value= fStore.getString(key);
- if (fAnnotationDecorationListModel[j][1].equals(value)) {
- fDecorationStyleCombo.setText(fAnnotationDecorationListModel[j][0]);
- break;
- }
- }
- } else {
- fDecorationStyleCombo.setEnabled(false);
- fDecorationStyleCombo.setText(fAnnotationDecorationListModel[1][0]); // set selection to squiggles if the key is not there (legacy support)
- }
-
- key= fAnnotationColorListModel[i][3];
- fShowInOverviewRulerCheckBox.setSelection(fStore.getBoolean(key));
-
- key= fAnnotationColorListModel[i][4];
- if (key != null) {
- fHighlightInTextCheckBox.setSelection(fStore.getBoolean(key));
- fHighlightInTextCheckBox.setEnabled(true);
- } else {
- fHighlightInTextCheckBox.setSelection(false);
- fHighlightInTextCheckBox.setEnabled(false);
- }
-
- key= fAnnotationColorListModel[i][5];
- if (key != null) {
- fShowInVerticalRulerCheckBox.setSelection(fStore.getBoolean(key));
- fShowInVerticalRulerCheckBox.setEnabled(true);
- } else {
- fShowInVerticalRulerCheckBox.setSelection(true);
- fShowInVerticalRulerCheckBox.setEnabled(false);
- }
- }
-
- public void initialize() {
-
- for (int i= 0; i < fAnnotationColorListModel.length; i++)
- fAnnotationList.add(fAnnotationColorListModel[i][0]);
- fAnnotationList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (fAnnotationList != null && !fAnnotationList.isDisposed()) {
- fAnnotationList.select(0);
- handleAnnotationListSelection();
- }
- }
- });
- }
-
- private String[][] createAnnotationTypeListModel(MarkerAnnotationPreferences preferences) {
- ArrayList listModelItems= new ArrayList();
- SortedSet sortedPreferences= new TreeSet(new Comparator() {
- /*
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(Object o1, Object o2) {
- if (!(o2 instanceof AnnotationPreference))
- return -1;
- if (!(o1 instanceof AnnotationPreference))
- return 1;
-
- AnnotationPreference a1= (AnnotationPreference)o1;
- AnnotationPreference a2= (AnnotationPreference)o2;
-
- return Collator.getInstance().compare(a1.getPreferenceLabel(), a2.getPreferenceLabel());
-
- }
- });
- sortedPreferences.addAll(preferences.getAnnotationPreferences());
- Iterator e= sortedPreferences.iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
- if (info.isIncludeOnPreferencePage())
- listModelItems.add(new String[] { info.getPreferenceLabel(), info.getColorPreferenceKey(), info.getTextPreferenceKey(), info.getOverviewRulerPreferenceKey(), info.getHighlightPreferenceKey(), info.getVerticalRulerPreferenceKey(), info.getTextStylePreferenceKey()});
- }
- String[][] items= new String[listModelItems.size()][];
- listModelItems.toArray(items);
- return items;
- }
-
- private static void indent(Control control) {
- GridData gridData= new GridData();
- gridData.horizontalIndent= 20;
- control.setLayoutData(gridData);
- }
-
- private void createDependency(final Button master, String masterKey, final Control slave) {
- indent(slave);
- boolean masterState= fStore.getBoolean(masterKey);
- slave.setEnabled(masterState);
- SelectionListener listener= new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- slave.setEnabled(master.getSelection());
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {}
- };
- master.addSelectionListener(listener);
- fMasterSlaveListeners.add(listener);
- }
-
- /*
- * @see IPreferenceConfigurationBlock#dispose()
- */
- public void dispose() {
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsPreferencePage.java
deleted file mode 100644
index e19533ea3..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/AnnotationsPreferencePage.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-
-
-/**
- * Annotations preference page.
- * <p>
- * Note: Must be public since it is referenced from plugin.xml
- * </p>
- *
- * @since 3.0
- */
-public class AnnotationsPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return null; // FIXME: Needs help context ID
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= TextEditorMessages.getString("AnnotationConfigurationBlock.description"); //$NON-NLS-1$
- setDescription(description);
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new AnnotationsConfigurationBlock(overlayPreferenceStore);
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ColorEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ColorEditor.java
deleted file mode 100644
index d9d43e15d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/ColorEditor.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.ColorDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.jface.resource.JFaceResources;
-
-/**
- * A "button" of a certain color determined by the color picker.
- *
- * @since 2.1
- */
-class ColorEditor {
-
- /** The extent. */
- private Point fExtent;
- /** The image for the push button. */
- private Image fImage;
- /** The current RGB color value. */
- private RGB fColorValue;
- /** The current color. */
- private Color fColor;
- /** The image push button which open the color dialog. */
- private Button fButton;
-
- /**
- * Creates and returns a new color editor.
- *
- * @param parent the parent composite of this color editor
- */
- public ColorEditor(Composite parent) {
-
- fButton= new Button(parent, SWT.PUSH);
- fExtent= computeImageSize(parent);
- fImage= new Image(parent.getDisplay(), fExtent.x, fExtent.y);
-
- GC gc= new GC(fImage);
- gc.setBackground(fButton.getBackground());
- gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
- gc.dispose();
-
- fButton.setImage(fImage);
- fButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- ColorDialog colorDialog= new ColorDialog(fButton.getShell());
- colorDialog.setRGB(fColorValue);
- RGB newColor = colorDialog.open();
- if (newColor != null) {
- fColorValue= newColor;
- updateColorImage();
- }
- }
- });
-
- fButton.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- if (fImage != null) {
- fImage.dispose();
- fImage= null;
- }
- if (fColor != null) {
- fColor.dispose();
- fColor= null;
- }
- }
- });
- }
-
- /**
- * Returns the current RGB color value.
- *
- * @return an rgb with the current color value
- */
- public RGB getColorValue() {
- return fColorValue;
- }
-
- /**
- * Sets the current RGB color value.
- *
- * @param rgb the new value for the rgb color value
- */
- public void setColorValue(RGB rgb) {
- fColorValue= rgb;
- updateColorImage();
- }
-
- /**
- * Returns the image push button.
- *
- * @return the button which shows the current color as image
- */
- public Button getButton() {
- return fButton;
- }
-
- /**
- * Updates the color of the button image.
- */
- protected void updateColorImage() {
-
- Display display= fButton.getDisplay();
-
- GC gc= new GC(fImage);
- gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
- gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4);
-
- if (fColor != null)
- fColor.dispose();
-
- fColor= new Color(display, fColorValue);
- gc.setBackground(fColor);
- gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5);
- gc.dispose();
-
- fButton.setImage(fImage);
- }
-
-
- /**
- * Computes the size for the image.
- *
- * @param window the window on which to render the image
- * @return the point with the image size
- */
- protected Point computeImageSize(Control window) {
- GC gc= new GC(window);
- Font f= JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
- gc.setFont(f);
- int height= gc.getFontMetrics().getHeight();
- gc.dispose();
- Point p= new Point(height * 3 - 6, height);
- return p;
- }
-}
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
deleted file mode 100644
index ef3bd096d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/EditorsPlugin.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.osgi.framework.BundleContext;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IAdapterManager;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.source.ISharedTextColors;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.editors.text.TextEditorPreferenceConstants;
-
-import org.eclipse.ui.internal.texteditor.AnnotationTypeHierarchy;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
-import org.eclipse.ui.texteditor.AnnotationTypeLookup;
-
-/**
- * Represents the editors plug-in. It provides a series of convenience methods such as
- * access to the shared text colors and the log.
- *
- * @since 2.1
- */
-public class EditorsPlugin extends AbstractUIPlugin {
- private static EditorsPlugin fgInstance;
-
- public static EditorsPlugin getDefault() {
- return fgInstance;
- }
-
- public static void log(IStatus status) {
- getDefault().getLog().log(status);
- }
-
- public static void logErrorMessage(String message) {
- if (message == null)
- message= ""; //$NON-NLS-1$
- log(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IEditorsStatusConstants.INTERNAL_ERROR, message, null));
- }
-
- public static void logErrorStatus(String message, IStatus status) {
- if (status == null) {
- logErrorMessage(message);
- return;
- }
- MultiStatus multi= new MultiStatus(EditorsUI.PLUGIN_ID, IEditorsStatusConstants.INTERNAL_ERROR, message, null);
- multi.add(status);
- log(multi);
- }
-
- public static void log(Throwable e) {
- log(new Status(IStatus.ERROR, EditorsUI.PLUGIN_ID, IEditorsStatusConstants.INTERNAL_ERROR, TextEditorMessages.getString("EditorsPlugin.internal_error"), e)); //$NON-NLS-1$
- }
-
-
-
- private FileEditorInputAdapterFactory fFileEditorInputAdapterFactory;
- private ISharedTextColors fSharedTextColors;
- private AnnotationTypeLookup fAnnotationTypeLookup;
- private AnnotationPreferenceLookup fAnnotationPreferenceLookup;
- private AnnotationTypeHierarchy fAnnotationTypeHierarchy;
-
- public EditorsPlugin() {
- Assert.isTrue(fgInstance == null);
- fgInstance= this;
- }
-
- /*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#initializeDefaultPreferences(org.eclipse.jface.preference.IPreferenceStore)
- */
- protected void initializeDefaultPreferences(IPreferenceStore store) {
- TextEditorPreferenceConstants.initializeDefaultValues(store);
- }
-
-
- /**
- * Returns the shared text colors of this plug-in.
- *
- * @return the shared text colors
- * @since 3.0
- */
- public ISharedTextColors getSharedTextColors() {
- if (fSharedTextColors == null)
- fSharedTextColors= new SharedTextColors();
- return fSharedTextColors;
- }
-
- /**
- * Returns the annotation type lookup of this plug-in.
- *
- * @return the annotation type lookup
- * @since 3.0
- */
- public AnnotationTypeLookup getAnnotationTypeLookup() {
- if (fAnnotationTypeLookup == null)
- fAnnotationTypeLookup= new AnnotationTypeLookup();
- return fAnnotationTypeLookup;
- }
-
- /**
- * Returns the annotation preference lookup of this plug-in.
- *
- * @return the annotation preference lookup
- * @since 3.0
- */
- public AnnotationPreferenceLookup getAnnotationPreferenceLookup() {
- if (fAnnotationPreferenceLookup == null)
- fAnnotationPreferenceLookup= new AnnotationPreferenceLookup();
- return fAnnotationPreferenceLookup;
- }
-
- /**
- * Returns the annotation type hierarchy for this plug-in.
- *
- * @return the annotation type hierarchy
- * @since 3.0
- */
- public AnnotationTypeHierarchy getAnnotationTypeHierarchy() {
- if (fAnnotationTypeHierarchy == null)
- fAnnotationTypeHierarchy= new AnnotationTypeHierarchy();
- return fAnnotationTypeHierarchy;
- }
-
- /*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- * @since 3.0
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- fFileEditorInputAdapterFactory= new FileEditorInputAdapterFactory();
- IAdapterManager manager= Platform.getAdapterManager();
- manager.registerAdapters(fFileEditorInputAdapterFactory, IFile.class);
- }
-
- /*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- * @since 3.0
- */
- public void stop(BundleContext context) throws Exception {
- IAdapterManager manager= Platform.getAdapterManager();
- manager.unregisterAdapters(fFileEditorInputAdapterFactory);
-
- if (fSharedTextColors != null) {
- fSharedTextColors.dispose();
- fSharedTextColors= null;
- }
-
- fAnnotationTypeLookup= null;
- fAnnotationPreferenceLookup= null;
- fAnnotationTypeHierarchy= null;
-
- super.stop(context);
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java
deleted file mode 100644
index 97cd5b045..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/FileEditorInputAdapterFactory.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.core.resources.IFile;
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.core.runtime.IPath;
-
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.editors.text.ILocationProvider;
-
-/**
- * @since 3.0
- */
-public class FileEditorInputAdapterFactory implements IAdapterFactory {
-
- private static class LocationProvider implements ILocationProvider {
- /*
- * @see org.eclipse.ui.editors.text.ILocationProvider#getLocation(java.lang.Object)
- */
- public IPath getPath(Object element) {
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input= (IFileEditorInput) element;
- return input.getFile().getFullPath();
- }
- return null;
- }
- }
-
- /** The list of provided adapters. */
- private static final Class[] ADAPTER_LIST= new Class[] { ILocationProvider.class };
-
- /** The provided location provider */
- private ILocationProvider fLocationProvider= new LocationProvider();
-
- /*
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (ILocationProvider.class.equals(adapterType)) {
- if (adaptableObject instanceof IFile)
- return fLocationProvider;
- }
- return null;
- }
-
- /*
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList() {
- return ADAPTER_LIST;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IEditorsStatusConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IEditorsStatusConstants.java
deleted file mode 100644
index 2a9d7fb6d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IEditorsStatusConstants.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-/**
- * Defines plug-in-specific status codes.
- *
- * @see org.eclipse.core.runtime.IStatus#getCode()
- * @see org.eclipse.core.runtime.Status#Status(int, java.lang.String, int, java.lang.String, java.lang.Throwable)
- * @since 2.1
- */
-interface IEditorsStatusConstants {
-
- /**
- * Status constant indicating that an internal error occurred.
- * Value: <code>1001</code>
- */
- public static final int INTERNAL_ERROR= 10001;
-
- }
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IPreferenceConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IPreferenceConfigurationBlock.java
deleted file mode 100644
index 536434bf1..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/IPreferenceConfigurationBlock.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-
-/**
- * Interface for preference configuration blocks which can either be
- * wrapped by a {@link org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage}
- * or be included some preference page.
- * <p>
- * Clients may implement this interface.
- * </p>
- *
- * @since 3.0
- */
-interface IPreferenceConfigurationBlock {
-
- /**
- * Creates the preference control.
- *
- * @param parent the parent composite to which to add the preferences control
- * @return the control that was added to <code>parent</code>
- */
- Control createControl(Composite parent);
-
- /**
- * Called after creating the control. Implementations should load the
- * preferences values and update the controls accordingly.
- */
- void initialize();
-
- /**
- * Called when the <code>OK</code> button is pressed on the preference
- * page. Implementations should commit the configured preference settings
- * into their form of preference storage.
- */
- void performOk();
-
- /**
- * Called when the <code>Defaults</code> button is pressed on the
- * preference page. Implementation should reset any preference settings to
- * their default values and adjust the controls accordingly.
- */
- void performDefaults();
-
- /**
- * Called when the preference page is being disposed. Implementations should
- * free any resources they are holding on to.
- */
- void dispose();
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/JavaFileEditorInput.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/JavaFileEditorInput.java
deleted file mode 100644
index 048618fab..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/JavaFileEditorInput.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.editors.text.ILocationProvider;
-
-/**
- * @since 3.0
- */
-public class JavaFileEditorInput implements IEditorInput, ILocationProvider {
-
- private File fFile;
-
- public JavaFileEditorInput(File file) {
- super();
- fFile= file;
- }
- /*
- * @see org.eclipse.ui.IEditorInput#exists()
- */
- public boolean exists() {
- return fFile.exists();
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getName()
- */
- public String getName() {
- return fFile.getName();
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- return fFile.getAbsolutePath();
- }
-
- /*
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (ILocationProvider.class.equals(adapter))
- return this;
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /*
- * @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object)
- */
- public IPath getPath(Object element) {
- if (element instanceof JavaFileEditorInput) {
- JavaFileEditorInput input= (JavaFileEditorInput) element;
- return new Path(input.fFile.getAbsolutePath());
- }
- return null;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o == this)
- return true;
-
- if (o instanceof JavaFileEditorInput) {
- JavaFileEditorInput input = (JavaFileEditorInput) o;
- return fFile.equals(input.fFile);
- }
-
- return false;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fFile.hashCode();
- }
-}
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
deleted file mode 100644
index 45b4f1396..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPreviousPulldownActionDelegate.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
- * @param store the preference store
- * @param key the preference key
- */
- 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>.
- *
- * @param annotationPreference the annotation preference
- * @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
deleted file mode 100644
index d6b44d4e0..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/NextPulldownActionDelegate.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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/OpenExternalFileAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OpenExternalFileAction.java
deleted file mode 100644
index c1309eb7a..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OpenExternalFileAction.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.io.File;
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.FileDialog;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.window.Window;
-
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.dialogs.ElementListSelectionDialog;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.part.FileEditorInput;
-
-/**
- * @since 3.0
- */
-public class OpenExternalFileAction extends Action implements IWorkbenchWindowActionDelegate {
-
- static class FileLabelProvider extends LabelProvider {
- /*
- * @see org.eclipse.jface.viewers.LabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- if (element instanceof IFile) {
- IPath path= ((IFile) element).getFullPath();
- return path != null ? path.toString() : ""; //$NON-NLS-1$
- }
- return super.getText(element);
- }
- }
-
-
- private IWorkbenchWindow fWindow;
-
- public OpenExternalFileAction() {
- setEnabled(true);
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- fWindow= null;
- }
-
- /*
- * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- /*
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- run();
- }
-
- /*
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- }
-
- private File queryFile() {
- FileDialog dialog= new FileDialog(fWindow.getShell(), SWT.OPEN);
- dialog.setText(TextEditorMessages.getString("OpenExternalFileAction.dialog.text")); //$NON-NLS-1$
- String path= dialog.open();
- if (path != null && path.length() > 0)
- return new File(path);
- return null;
- }
-
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- File file= queryFile();
- if (file != null && file.exists()) {
- IEditorInput input= createEditorInput(file);
- String editorId= getEditorId(file);
- IWorkbenchPage page= fWindow.getActivePage();
- try {
- page.openEditor(input, editorId);
- } catch (PartInitException e) {
- e.printStackTrace();
- }
- } else if (file != null) {
- String msgFmt = TextEditorMessages.getString("OpenExternalFileAction.FileNotFound"); //$NON-NLS-1$
- String msg = MessageFormat.format(msgFmt, new String[] {file.getName()});
- MessageDialog.openWarning(fWindow.getShell(), TextEditorMessages.getString("OpenExternalFileAction.dialog.text"), msg); //$NON-NLS-1$
- }
- }
-
- private String getEditorId(File file) {
- IWorkbench workbench= fWindow.getWorkbench();
- IEditorRegistry editorRegistry= workbench.getEditorRegistry();
- IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(file.getName());
- if (descriptor != null)
- return descriptor.getId();
- return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
- }
-
- private IEditorInput createEditorInput(File file) {
- IFile workspaceFile= getWorkspaceFile(file);
- if (workspaceFile != null)
- return new FileEditorInput(workspaceFile);
- return new JavaFileEditorInput(file);
- }
-
- private IFile getWorkspaceFile(File file) {
- IWorkspace workspace= ResourcesPlugin.getWorkspace();
- IPath location= new Path(file.getAbsolutePath());
- IFile[] files= workspace.getRoot().findFilesForLocation(location);
- if (files == null || files.length == 0)
- return null;
- if (files.length == 1)
- return files[0];
- return selectWorkspaceFile(files);
- }
-
- private IFile selectWorkspaceFile(IFile[] files) {
- ElementListSelectionDialog dialog= new ElementListSelectionDialog(fWindow.getShell(), new FileLabelProvider());
- dialog.setElements(files);
- dialog.setTitle(TextEditorMessages.getString("OpenExternalFileAction.SelectWorkspaceFile")); //$NON-NLS-1$
- dialog.setMessage(TextEditorMessages.getString("OpenExternalFileAction.FileLinkedtoMultiple")); //$NON-NLS-1$
- if (dialog.open() == Window.OK)
- return (IFile) dialog.getFirstResult();
- return null;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java
deleted file mode 100644
index c0c24edc0..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/OverlayPreferenceStore.java
+++ /dev/null
@@ -1,547 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-import org.eclipse.jface.text.Assert;
-
-/**
- * An overlaying preference store.
- *
- * @since 2.1
- */
-class OverlayPreferenceStore implements IPreferenceStore {
-
-
- /**
- * Descriptor used to denote data types.
- */
- public static final class TypeDescriptor {
- private TypeDescriptor() {
- }
- }
-
- public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
- public static final TypeDescriptor DOUBLE= new TypeDescriptor();
- public static final TypeDescriptor FLOAT= new TypeDescriptor();
- public static final TypeDescriptor INT= new TypeDescriptor();
- public static final TypeDescriptor LONG= new TypeDescriptor();
- public static final TypeDescriptor STRING= new TypeDescriptor();
-
- /**
- * Data structure for the overlay key.
- */
- public static class OverlayKey {
-
- TypeDescriptor fDescriptor;
- String fKey;
-
- public OverlayKey(TypeDescriptor descriptor, String key) {
- fDescriptor= descriptor;
- fKey= key;
- }
- }
-
- /*
- * @see IPropertyChangeListener
- */
- private class PropertyListener implements IPropertyChangeListener {
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- OverlayKey key= findOverlayKey(event.getProperty());
- if (key != null)
- propagateProperty(fParent, key, fStore);
- }
- }
-
-
- /** The parent preference store. */
- private IPreferenceStore fParent;
- /** This store. */
- private IPreferenceStore fStore;
- /** The keys of this store. */
- private OverlayKey[] fOverlayKeys;
- /** The property listener. */
- private PropertyListener fPropertyListener;
- private boolean fLoaded;
-
-
- /**
- * Creates and returns a new overlay preference store.
- *
- * @param parent the parent preference store
- * @param overlayKeys the overlay keys
- */
- public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
- fParent= parent;
- fOverlayKeys= overlayKeys;
- fStore= new PreferenceStore();
- }
-
- /**
- * Tries to find and return the overlay key for the given preference key string.
- *
- * @param key the preference key string
- * @return the overlay key or <code>null</code> if none can be found
- */
- private OverlayKey findOverlayKey(String key) {
- for (int i= 0; i < fOverlayKeys.length; i++) {
- if (fOverlayKeys[i].fKey.equals(key))
- return fOverlayKeys[i];
- }
- return null;
- }
-
- /**
- * Tells whether the given preference key string is
- * covered by this overlay store.
- *
- * @param key the preference key string
- * @return <code>true</code> if this overlay store covers the given key
- */
- private boolean covers(String key) {
- return (findOverlayKey(key) != null);
- }
-
- /**
- * Propagates the given overlay key from the orgin to the target preference store.
- *
- * @param orgin the source preference store
- * @param key the overlay key
- * @param target the preference store to which the key is propagated
- */
- private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
-
- if (orgin.isDefault(key.fKey)) {
- if (!target.isDefault(key.fKey))
- target.setToDefault(key.fKey);
- return;
- }
-
- TypeDescriptor d= key.fDescriptor;
- if (BOOLEAN == d) {
-
- boolean originValue= orgin.getBoolean(key.fKey);
- boolean targetValue= target.getBoolean(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (DOUBLE == d) {
-
- double originValue= orgin.getDouble(key.fKey);
- double targetValue= target.getDouble(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (FLOAT == d) {
-
- float originValue= orgin.getFloat(key.fKey);
- float targetValue= target.getFloat(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (INT == d) {
-
- int originValue= orgin.getInt(key.fKey);
- int targetValue= target.getInt(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (LONG == d) {
-
- long originValue= orgin.getLong(key.fKey);
- long targetValue= target.getLong(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (STRING == d) {
-
- String originValue= orgin.getString(key.fKey);
- String targetValue= target.getString(key.fKey);
- if (targetValue != null && originValue != null && !targetValue.equals(originValue))
- target.setValue(key.fKey, originValue);
-
- }
- }
-
- /**
- * Propagates all overlay keys from this store to the parent store.
- */
- public void propagate() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- propagateProperty(fStore, fOverlayKeys[i], fParent);
- }
-
- /**
- * Loads the given key from the orgin into the target.
- *
- * @param orgin the source preference store
- * @param key the overlay key
- * @param target the preference store to which the key is propagated
- * @param forceInitialization if <code>true</code> the value in the target gets initialized before loading
- */
- private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
- TypeDescriptor d= key.fDescriptor;
- if (BOOLEAN == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, true);
- target.setValue(key.fKey, orgin.getBoolean(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
-
- } else if (DOUBLE == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1.0D);
- target.setValue(key.fKey, orgin.getDouble(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
-
- } else if (FLOAT == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1.0F);
- target.setValue(key.fKey, orgin.getFloat(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
-
- } else if (INT == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1);
- target.setValue(key.fKey, orgin.getInt(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
-
- } else if (LONG == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1L);
- target.setValue(key.fKey, orgin.getLong(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
-
- } else if (STRING == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, "1"); //$NON-NLS-1$
- target.setValue(key.fKey, orgin.getString(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
-
- }
- }
-
- /**
- * Loads the values from the parent into this store.
- */
- public void load() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- loadProperty(fParent, fOverlayKeys[i], fStore, true);
-
- fLoaded= true;
- }
-
- /**
- * Loads the default values.
- */
- public void loadDefaults() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- setToDefault(fOverlayKeys[i].fKey);
- }
-
- /**
- * Starts to listen for changes.
- */
- public void start() {
- if (fPropertyListener == null) {
- fPropertyListener= new PropertyListener();
- fParent.addPropertyChangeListener(fPropertyListener);
- }
- }
-
- /**
- * Stops to listen for changes.
- */
- public void stop() {
- if (fPropertyListener != null) {
- fParent.removePropertyChangeListener(fPropertyListener);
- fPropertyListener= null;
- }
- }
-
- /*
- * @see IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- fStore.addPropertyChangeListener(listener);
- }
-
- /*
- * @see IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fStore.removePropertyChangeListener(listener);
- }
-
- /*
- * @see IPreferenceStore#firePropertyChangeEvent(java.lang.String, java.lang.Object, java.lang.Object)
- */
- public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- fStore.firePropertyChangeEvent(name, oldValue, newValue);
- }
-
- /*
- * @see IPreferenceStore#contains(java.lang.String)
- */
- public boolean contains(String name) {
- return fStore.contains(name);
- }
-
- /*
- * @see IPreferenceStore#getBoolean(java.lang.String)
- */
- public boolean getBoolean(String name) {
- return fStore.getBoolean(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultBoolean(java.lang.String)
- */
- public boolean getDefaultBoolean(String name) {
- return fStore.getDefaultBoolean(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultDouble(java.lang.String)
- */
- public double getDefaultDouble(String name) {
- return fStore.getDefaultDouble(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultFloat(String)
- */
- public float getDefaultFloat(String name) {
- return fStore.getDefaultFloat(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultInt(String)
- */
- public int getDefaultInt(String name) {
- return fStore.getDefaultInt(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultLong(String)
- */
- public long getDefaultLong(String name) {
- return fStore.getDefaultLong(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultString(String)
- */
- public String getDefaultString(String name) {
- return fStore.getDefaultString(name);
- }
-
- /*
- * @see IPreferenceStore#getDouble(String)
- */
- public double getDouble(String name) {
- return fStore.getDouble(name);
- }
-
- /*
- * @see IPreferenceStore#getFloat(String)
- */
- public float getFloat(String name) {
- return fStore.getFloat(name);
- }
-
- /*
- * @see IPreferenceStore#getInt(String)
- */
- public int getInt(String name) {
- return fStore.getInt(name);
- }
-
- /*
- * @see IPreferenceStore#getLong(String)
- */
- public long getLong(String name) {
- return fStore.getLong(name);
- }
-
- /*
- * @see IPreferenceStore#getString(String)
- */
- public String getString(String name) {
- return fStore.getString(name);
- }
-
- /*
- * @see IPreferenceStore#isDefault(String)
- */
- public boolean isDefault(String name) {
- return fStore.isDefault(name);
- }
-
- /*
- * @see IPreferenceStore#needsSaving()
- */
- public boolean needsSaving() {
- return fStore.needsSaving();
- }
-
- /*
- * @see IPreferenceStore#putValue(String, String)
- */
- public void putValue(String name, String value) {
- if (covers(name))
- fStore.putValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, double)
- */
- public void setDefault(String name, double value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, float)
- */
- public void setDefault(String name, float value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, int)
- */
- public void setDefault(String name, int value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, long)
- */
- public void setDefault(String name, long value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, String)
- */
- public void setDefault(String name, String value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, boolean)
- */
- public void setDefault(String name, boolean value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setToDefault(String)
- */
- public void setToDefault(String name) {
- fStore.setToDefault(name);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, double)
- */
- public void setValue(String name, double value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, float)
- */
- public void setValue(String name, float value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, int)
- */
- public void setValue(String name, int value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, long)
- */
- public void setValue(String name, long value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, String)
- */
- public void setValue(String name, String value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, boolean)
- */
- public void setValue(String name, boolean value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /**
- * The keys to add to the list of overlay keys.
- * <p>
- * Note: This method must be called before {@link #load()} is called.
- * </p>
- *
- * @param keys
- * @since 3.0
- */
- public void addKeys(OverlayKey[] keys) {
- Assert.isTrue(!fLoaded);
- Assert.isNotNull(keys);
-
- int overlayKeysLength= fOverlayKeys.length;
- OverlayKey[] result= new OverlayKey[keys.length + overlayKeysLength];
-
- for (int i= 0, length= overlayKeysLength; i < length; i++)
- result[i]= fOverlayKeys[i];
-
- for (int i= 0, length= keys.length; i < length; i++)
- result[overlayKeysLength + i]= keys[i];
-
- fOverlayKeys= result;
-
- if (fLoaded)
- load();
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PixelConverter.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PixelConverter.java
deleted file mode 100644
index 3dc591f02..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PixelConverter.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.jface.dialogs.Dialog;
-
-/**
- * Pixel conversion utility.
- *
- * @since 3.0
- */
-class PixelConverter {
-
- private FontMetrics fFontMetrics;
-
- public PixelConverter(Control control) {
- GC gc = new GC(control);
- gc.setFont(control.getFont());
- fFontMetrics= gc.getFontMetrics();
- gc.dispose();
- }
-
- /*
- * @see org.eclipse.jface.dialogs.DialogPage#convertHeightInCharsToPixels(int)
- */
- public int convertHeightInCharsToPixels(int chars) {
- return Dialog.convertHeightInCharsToPixels(fFontMetrics, chars);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.DialogPage#convertHorizontalDLUsToPixels(int)
- */
- public int convertHorizontalDLUsToPixels(int dlus) {
- return Dialog.convertHorizontalDLUsToPixels(fFontMetrics, dlus);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.DialogPage#convertVerticalDLUsToPixels(int)
- */
- public int convertVerticalDLUsToPixels(int dlus) {
- return Dialog.convertVerticalDLUsToPixels(fFontMetrics, dlus);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.DialogPage#convertWidthInCharsToPixels(int)
- */
- public int convertWidthInCharsToPixels(int chars) {
- return Dialog.convertWidthInCharsToPixels(fFontMetrics, chars);
- }
-}
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
deleted file mode 100644
index 62e39dd4c..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/PreviousPulldownActionDelegate.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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/QuickDiffConfigurationBlock.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
deleted file mode 100644
index 61ae568b1..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffConfigurationBlock.java
+++ /dev/null
@@ -1,406 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-
-import org.eclipse.jface.preference.PreferenceConverter;
-
-import org.eclipse.jface.text.Assert;
-
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.MarkerAnnotationPreferences;
-import org.eclipse.ui.texteditor.quickdiff.QuickDiff;
-import org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor;
-
-/**
- * Configures quick diff preferences
- *
- * @since 3.0
- */
-class QuickDiffConfigurationBlock implements IPreferenceConfigurationBlock {
-
- private OverlayPreferenceStore fStore;
-
- private Map fCheckBoxes= new HashMap();
- private SelectionListener fCheckBoxListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
- fStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
-
- /**
- * List for the reference provider default.
- * @since 3.0
- */
- private org.eclipse.swt.widgets.List fQuickDiffProviderList;
- /**
- * The reference provider default's list model.
- * @since 3.0
- */
- private String[][] fQuickDiffProviderListModel;
- /**
- * Button controlling default setting of the selected reference provider.
- * @since 3.0
- */
- private Button fSetDefaultButton;
- /**
- * The quick diff color model.
- * @since 3.0
- */
- private String[][] fQuickDiffModel;
- /**
- * The color editors for quick diff.
- * @since 3.0
- */
- private ColorEditor[] fQuickDiffColorEditors;
- /**
- * The checkbox for the quick diff overview ruler property.
- * @since 3.0
- */
- private Button fQuickDiffOverviewRulerCheckBox;
-
-
-
- public QuickDiffConfigurationBlock(OverlayPreferenceStore store) {
- Assert.isNotNull(store);
- fStore= store;
- MarkerAnnotationPreferences markerAnnotationPreferences= new MarkerAnnotationPreferences();
- fStore.addKeys(createOverlayStoreKeys(markerAnnotationPreferences));
- fQuickDiffModel= createQuickDiffModel(markerAnnotationPreferences);
- fQuickDiffProviderListModel= createQuickDiffReferenceListModel();
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys(MarkerAnnotationPreferences preferences) {
- ArrayList overlayKeys= new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE));
-
- Iterator e= preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
-
- if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$
- || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
- || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$
- ) {
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, info.getColorPreferenceKey()));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, info.getOverviewRulerPreferenceKey()));
- }
- }
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- private String[][] createQuickDiffModel(MarkerAnnotationPreferences preferences) {
- String[][] items= new String[3][];
-
- Iterator e= preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
- if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange")) //$NON-NLS-1$
- items[0]= new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.getString("QuickDiffConfigurationBlock.changeColor") }; //$NON-NLS-1$
- else if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
- items[1]= new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.getString("QuickDiffConfigurationBlock.additionColor") }; //$NON-NLS-1$
- else if (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$
- items[2]= new String[] { info.getColorPreferenceKey(), info.getOverviewRulerPreferenceKey(), TextEditorMessages.getString("QuickDiffConfigurationBlock.deletionColor") }; //$NON-NLS-1$
- }
- return items;
- }
-
- private String[][] createQuickDiffReferenceListModel() {
- java.util.List descriptors= new QuickDiff().getReferenceProviderDescriptors();
- ArrayList listModelItems= new ArrayList();
- for (Iterator it= descriptors.iterator(); it.hasNext();) {
- ReferenceProviderDescriptor descriptor= (ReferenceProviderDescriptor) it.next();
- String label= descriptor.getLabel();
- int i= label.indexOf('&');
- while (i >= 0) {
- if (i < label.length())
- label= label.substring(0, i) + label.substring(i+1);
- else
- label.substring(0, i);
- i= label.indexOf('&');
- }
- listModelItems.add(new String[] { descriptor.getId(), label });
- }
- String[][] items= new String[listModelItems.size()][];
- listModelItems.toArray(items);
- return items;
- }
-
- private Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(label);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- /**
- * Creates page for hover preferences.
- *
- * @param parent the parent composite
- * @return the created child composite
- */
- public Control createControl(Composite parent) {
- Composite composite= new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- composite.setLayout(layout);
-
- String label= TextEditorMessages.getString("QuickDiffConfigurationBlock.showForNewEditors"); //$NON-NLS-1$
- addCheckBox(composite, label, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, 0);
-
- label= TextEditorMessages.getString("QuickDiffConfigurationBlock.characterMode"); //$NON-NLS-1$
- addCheckBox(composite, label, AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, 0);
-
- label= TextEditorMessages.getString("QuickDiffConfigurationBlock.showInOverviewRuler"); //$NON-NLS-1$
- fQuickDiffOverviewRulerCheckBox= new Button(composite, SWT.CHECK);
- fQuickDiffOverviewRulerCheckBox.setText(label);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= 0;
- gd.horizontalSpan= 2;
- fQuickDiffOverviewRulerCheckBox.setLayoutData(gd);
- fQuickDiffOverviewRulerCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- for (int i= 0; i < fQuickDiffModel.length; i++) {
- fStore.setValue(fQuickDiffModel[i][1], fQuickDiffOverviewRulerCheckBox.getSelection());
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- // spacer
- Label l= new Label(composite, SWT.LEFT );
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= 5;
- l.setLayoutData(gd);
-
- Group group= new Group(composite, SWT.NONE);
- group.setText(TextEditorMessages.getString("QuickDiffConfigurationBlock.colorTitle")); //$NON-NLS-1$
- layout= new GridLayout();
- layout.numColumns= 2;
- group.setLayout(layout);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalSpan= 2;
- group.setLayoutData(gd);
-
- fQuickDiffColorEditors= new ColorEditor[3];
- for (int i= 0; i < fQuickDiffModel.length; i++) {
- label= fQuickDiffModel[i][2];
- l= new Label(group, SWT.LEFT);
- l.setText(label);
- final ColorEditor editor= new ColorEditor(group);
- fQuickDiffColorEditors[i]= editor;
- Button changeColorButton= editor.getButton();
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- changeColorButton.setLayoutData(gd);
- final int index= i;
- changeColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- String key= fQuickDiffModel[index][0];
- PreferenceConverter.setValue(fStore, key, editor.getColorValue());
- }
- });
- }
-
-
- // spacer
- l= new Label(composite, SWT.LEFT );
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= 5;
- l.setLayoutData(gd);
-
- l= new Label(composite, SWT.LEFT);
- l.setText(TextEditorMessages.getString("QuickDiffConfigurationBlock.referenceProviderTitle")); //$NON-NLS-1$
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- l.setLayoutData(gd);
-
- Composite editorComposite= new Composite(composite, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- editorComposite.setLayout(layout);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- gd.horizontalSpan= 2;
- editorComposite.setLayoutData(gd);
-
- fQuickDiffProviderList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
- gd.heightHint= 60;
- fQuickDiffProviderList.setLayoutData(gd);
-
- Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
- layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- stylesComposite.setLayout(layout);
- stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- fSetDefaultButton= new Button(stylesComposite, SWT.PUSH);
- fSetDefaultButton.setText(TextEditorMessages.getString("QuickDiffConfigurationBlock.setDefault")); //$NON-NLS-1$
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fSetDefaultButton.setLayoutData(gd);
-
- fQuickDiffProviderList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- handleProviderListSelection();
- }
-
- });
-
- fSetDefaultButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i= fQuickDiffProviderList.getSelectionIndex();
- fStore.setValue(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER, fQuickDiffProviderListModel[i][0]);
- updateProviderList();
- }
- });
-
- return composite;
- }
-
- private void updateProviderList() {
- int i= fQuickDiffProviderList.getSelectionIndex();
- int defaultIndex= -1;
- String defaultProvider= fStore.getString(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER);
- for (int j= 0; j < fQuickDiffProviderListModel.length; j++) {
- fQuickDiffProviderList.remove(j);
- if (defaultProvider.equals(fQuickDiffProviderListModel[j][0])) {
- fQuickDiffProviderList.add(fQuickDiffProviderListModel[j][1] + " " + TextEditorMessages.getString("QuickDiffConfigurationBlock.defaultlabel"), j); //$NON-NLS-1$//$NON-NLS-2$
- defaultIndex= j;
- } else
- fQuickDiffProviderList.add(fQuickDiffProviderListModel[j][1], j);
- }
- fSetDefaultButton.setEnabled(defaultIndex != i);
- fQuickDiffProviderList.setSelection(i);
- fQuickDiffProviderList.redraw();
- }
-
- public void initialize() {
-
- for (int i= 0; i < fQuickDiffProviderListModel.length; i++) {
- String label= fQuickDiffProviderListModel[i][1];
- if (fStore.getString(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER).equals(fQuickDiffProviderListModel[i][0]))
- label += " " + TextEditorMessages.getString("QuickDiffConfigurationBlock.defaultlabel"); //$NON-NLS-1$ //$NON-NLS-2$
- fQuickDiffProviderList.add(label);
- }
- fQuickDiffProviderList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (fQuickDiffProviderList != null && !fQuickDiffProviderList.isDisposed()) {
- fQuickDiffProviderList.select(0);
- handleProviderListSelection();
- }
- }
- });
-
- initializeFields();
- }
-
- private void initializeFields() {
- Iterator e= fCheckBoxes.keySet().iterator();
- while (e.hasNext()) {
- Button b= (Button) e.next();
- String key= (String) fCheckBoxes.get(b);
- b.setSelection(fStore.getBoolean(key));
- }
-
- updateQuickDiffControls();
- }
-
- public void performOk() {
- }
-
- public void performDefaults() {
- initializeFields();
- updateProviderList();
- }
-
- private void handleProviderListSelection() {
- int i= fQuickDiffProviderList.getSelectionIndex();
- if (i != -1) {
- boolean b= fStore.getString(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER).equals(fQuickDiffProviderListModel[i][0]);
- fSetDefaultButton.setEnabled(!b);
- }
- }
-
- private void updateQuickDiffControls() {
- boolean quickdiffOverviewRuler= false;
- for (int i= 0; i < fQuickDiffModel.length; i++) {
- fQuickDiffColorEditors[i].setColorValue(PreferenceConverter.getColor(fStore, fQuickDiffModel[i][0]));
- quickdiffOverviewRuler |= fStore.getBoolean(fQuickDiffModel[i][1]);
- }
- fQuickDiffOverviewRulerCheckBox.setSelection(quickdiffOverviewRuler);
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.IPreferenceConfigurationBlock#dispose()
- * @since 3.0
- */
- public void dispose() {
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffPreferencePage.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffPreferencePage.java
deleted file mode 100644
index d5c5efca6..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/QuickDiffPreferencePage.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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;
-
-
-
-/**
- * Quick Diff preference page.
- * <p>
- * Note: Must be public since it is referenced from plugin.xml
- * </p>
- *
- * @since 3.0
- */
-public class QuickDiffPreferencePage extends AbstractConfigurationBlockPreferencePage {
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#getHelpId()
- */
- protected String getHelpId() {
- return null; // FIXME: Needs help context ID
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setDescription()
- */
- protected void setDescription() {
- String description= TextEditorMessages.getString("QuickDiffConfigurationBlock.description"); //$NON-NLS-1$
- setDescription(description);
- }
-
- /*
- * @see org.org.eclipse.ui.internal.editors.text.AbstractConfigurationBlockPreferencePage#setPreferenceStore()
- */
- protected void setPreferenceStore() {
- setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.text.AbstractConfigureationBlockPreferencePage#createConfigurationBlock(org.eclipse.ui.internal.editors.text.OverlayPreferenceStore)
- */
- protected IPreferenceConfigurationBlock createConfigurationBlock(OverlayPreferenceStore overlayPreferenceStore) {
- return new QuickDiffConfigurationBlock(overlayPreferenceStore);
- }
-}
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
deleted file mode 100644
index d9bfd6300..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/SharedTextColors.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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/internal/editors/text/StatusInfo.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusInfo.java
deleted file mode 100644
index d9b7debe2..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/StatusInfo.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.core.runtime.IStatus;
-
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-
-/**
- * A settable IStatus.
- * Can be an error, warning, info or ok. For error, info and warning states,
- * a message describes the problem.
- *
- * @since 2.1
- */
-class StatusInfo implements IStatus {
-
- /** The message of this status. */
- private String fStatusMessage;
- /** The severity of this status. */
- private int fSeverity;
-
- /**
- * Creates a status set to OK (no message).
- */
- public StatusInfo() {
- this(OK, null);
- }
-
- /**
- * Creates a status with the given severity and message.
- *
- * @param severity the severity of this status: ERROR, WARNING, INFO and OK.
- * @param message the message of this status. Applies only for ERROR,
- * WARNING and INFO.
- */
- public StatusInfo(int severity, String message) {
- fStatusMessage= message;
- fSeverity= severity;
- }
-
- /*
- * @see org.eclipse.core.runtime.IStatus#isOK()
- */
- public boolean isOK() {
- return fSeverity == IStatus.OK;
- }
-
- /**
- * Returns whether this status indicates a warning.
- *
- * @return <code>true</code> if this status has severity
- * {@link IStatus#WARNING} and <code>false</code> otherwise
- */
- public boolean isWarning() {
- return fSeverity == IStatus.WARNING;
- }
-
- /**
- * Returns whether this status indicates an info.
- *
- * @return <code>true</code> if this status has severity
- * {@link IStatus#INFO} and <code>false</code> otherwise
- */
- public boolean isInfo() {
- return fSeverity == IStatus.INFO;
- }
-
- /**
- * Returns whether this status indicates an error.
- *
- * @return <code>true</code> if this status has severity
- * {@link IStatus#ERROR} and <code>false</code> otherwise
- */
- public boolean isError() {
- return fSeverity == IStatus.ERROR;
- }
-
- /*
- * @see IStatus#getMessage()
- */
- public String getMessage() {
- return fStatusMessage;
- }
-
- /**
- * Sets the status to ERROR.
- *
- * @param errorMessage the error message which can be an empty string, but not <code>null</code>
- */
- public void setError(String errorMessage) {
- Assert.isNotNull(errorMessage);
- fStatusMessage= errorMessage;
- fSeverity= IStatus.ERROR;
- }
-
- /**
- * Sets the status to WARNING.
- *
- * @param warningMessage the warning message which can be an empty string, but not <code>null</code>
- */
- public void setWarning(String warningMessage) {
- Assert.isNotNull(warningMessage);
- fStatusMessage= warningMessage;
- fSeverity= IStatus.WARNING;
- }
-
- /**
- * Sets the status to INFO.
- *
- * @param infoMessage the info message which can be an empty string, but not <code>null</code>
- */
- public void setInfo(String infoMessage) {
- Assert.isNotNull(infoMessage);
- fStatusMessage= infoMessage;
- fSeverity= IStatus.INFO;
- }
-
- /**
- * Sets the status to OK.
- */
- public void setOK() {
- fStatusMessage= null;
- fSeverity= IStatus.OK;
- }
-
- /*
- * @see IStatus#matches(int)
- */
- public boolean matches(int severityMask) {
- return (fSeverity & severityMask) != 0;
- }
-
- /**
- * Returns always <code>false</code>.
- *
- * @see IStatus#isMultiStatus()
- */
- public boolean isMultiStatus() {
- return false;
- }
-
- /*
- * @see IStatus#getSeverity()
- */
- public int getSeverity() {
- return fSeverity;
- }
-
- /*
- * @see IStatus#getPlugin()
- */
- public String getPlugin() {
- return EditorsUI.PLUGIN_ID;
- }
-
- /**
- * Returns always <code>null</code>.
- *
- * @see IStatus#getException()
- */
- public Throwable getException() {
- return null;
- }
-
- /**
- * Returns always the error severity.
- *
- * @see IStatus#getCode()
- */
- public int getCode() {
- return fSeverity;
- }
-
- /**
- * Returns always <code>null</code>.
- *
- * @see IStatus#getChildren()
- */
- public IStatus[] getChildren() {
- return new IStatus[0];
- }
-
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java
deleted file mode 100644
index a09b26bb7..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TabFolderLayout.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-/**
- * This layout controls the position and size
- * of the children of a tab folder.
- *
- * @since 2.1
- */
-class TabFolderLayout extends Layout {
-
- /*
- * @see org.eclipse.swt.widgets.Layout#computeSize(org.eclipse.swt.widgets.Composite, int, int, boolean)
- */
- protected Point computeSize (Composite composite, int wHint, int hHint, boolean flushCache) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
- return new Point(wHint, hHint);
-
- Control [] children = composite.getChildren ();
- int count = children.length;
- int maxWidth = 0, maxHeight = 0;
- for (int i=0; i<count; i++) {
- Control child = children [i];
- Point pt = child.computeSize (SWT.DEFAULT, SWT.DEFAULT, flushCache);
- maxWidth = Math.max (maxWidth, pt.x);
- maxHeight = Math.max (maxHeight, pt.y);
- }
-
- if (wHint != SWT.DEFAULT)
- maxWidth= wHint;
- if (hHint != SWT.DEFAULT)
- maxHeight= hHint;
-
- return new Point(maxWidth, maxHeight);
-
- }
-
- /*
- * @see org.eclipse.swt.widgets.Layout#layout(org.eclipse.swt.widgets.Composite, boolean)
- */
- protected void layout (Composite composite, boolean flushCache) {
- Rectangle rect= composite.getClientArea();
-
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].setBounds(rect);
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
deleted file mode 100644
index f017ee51a..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Helper class which wraps the specified resource bundle
- * and offers methods to access the bundle.
- *
- * @since 2.1
- */
-class TextEditorMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.ui.internal.editors.text.TextEditorMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private TextEditorMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static ResourceBundle getResourceBundle() {
- return fgResourceBundle;
- }
-
- public static String getFormattedString(String key, String arg) {
- return getFormattedString(key, new String[] { arg });
- }
-
- public static String getFormattedString(String key, String[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
deleted file mode 100644
index 6487df534..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorMessages.properties
+++ /dev/null
@@ -1,67 +0,0 @@
-###############################################################################
-# Copyright (c) 2000, 2004 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
-###############################################################################
-
-EditorsPlugin.internal_error=Internal Error
-
-TextEditorPreferencePage.description=Text Editor settings:
-
-TextEditorPreferencePage.general=Appeara&nce
-TextEditorPreferencePage.displayedTabWidth=Displayed &tab width:
-TextEditorPreferencePage.printMarginColumn=&Print margin column:
-TextEditorPreferencePage.showOverviewRuler=Show overview &ruler
-TextEditorPreferencePage.showLineNumbers=Show lin&e numbers
-TextEditorPreferencePage.highlightCurrentLine=Hi&ghlight current line
-TextEditorPreferencePage.showPrintMargin=Sho&w print margin
-TextEditorPreferencePage.color=C&olor:
-TextEditorPreferencePage.appearanceOptions=Appearance co&lor options:
-TextEditorPreferencePage.lineNumberForegroundColor=Line number foreground
-TextEditorPreferencePage.currentLineHighlighColor=Current line highlight
-TextEditorPreferencePage.printMarginColor=Print margin
-TextEditorPreferencePage.accessibility.disableCustomCarets= Use c&ustom caret
-TextEditorPreferencePage.accessibility.wideCaret= Ena&ble thick caret
-
-TextEditorPreferencePage.selectionForegroundColor= Selection foreground color
-TextEditorPreferencePage.selectionBackgroundColor= Selection background color
-TextEditorPreferencePage.systemDefault=System De&fault
-
-TextEditorPreferencePage.empty_input=Empty input
-TextEditorPreferencePage.invalid_input=''{0}'' is not a valid input.
-
-QuickDiffConfigurationBlock.title= &Quick Diff
-QuickDiffConfigurationBlock.description= General Quick Diff settings.
-QuickDiffConfigurationBlock.referenceProviderTitle=Quick Diff reference &providers:
-QuickDiffConfigurationBlock.setDefault=&Make Default
-QuickDiffConfigurationBlock.defaultlabel= (default)
-QuickDiffConfigurationBlock.characterMode= &Use characters to show changes on line number bar
-QuickDiffConfigurationBlock.showForNewEditors=&Enable quick diff when opening a new editor
-QuickDiffConfigurationBlock.showInOverviewRuler= Show differences in &overview ruler
-QuickDiffConfigurationBlock.colorTitle=Colo&rs
-QuickDiffConfigurationBlock.changeColor= C&hanges:
-QuickDiffConfigurationBlock.additionColor= Addi&tions:
-QuickDiffConfigurationBlock.deletionColor= De&letions:
-
-OpenExternalFileAction.dialog.text=Open External File
-OpenExternalFileAction.FileNotFound={0}\nFile not found.
-OpenExternalFileAction.SelectWorkspaceFile=Select Workspace File
-OpenExternalFileAction.FileLinkedtoMultiple=The selected file is referenced by multiple linked resources in the workspace.\nSelect a workspace resource to open the file.
-
-AnnotationConfigurationBlock.description= General annotation settings.
-AnnotationConfigurationBlock.annotationPresentationOptions= Annotation &presentation:
-AnnotationConfigurationBlock.showInText= Show in &text
-AnnotationConfigurationBlock.NONE=None
-AnnotationConfigurationBlock.SQUIGGLES=Squiggles
-AnnotationConfigurationBlock.UNDERLINE=Underline
-AnnotationConfigurationBlock.BOX=Box
-AnnotationConfigurationBlock.IBEAM=IBeam
-AnnotationConfigurationBlock.highlightInText= &Highlight in text
-AnnotationConfigurationBlock.showInOverviewRuler= Show in overview &ruler
-AnnotationConfigurationBlock.showInVerticalRuler= Show in vertical r&uler
-AnnotationConfigurationBlock.color= C&olor:
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java
deleted file mode 100644
index 3cd87aa7d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/TextEditorPreferencePage2.java
+++ /dev/null
@@ -1,550 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.preference.PreferencePage;
-
-import org.eclipse.ui.editors.text.ITextEditorHelpContextIds;
-
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-
-
-
-/**
- * The preference page for setting the editor options.
- * <p>
- * This class is internal and not intended to be used by clients.</p>
- *
- * @since 2.1
- */
-public class TextEditorPreferencePage2 extends PreferencePage implements IWorkbenchPreferencePage {
-
- private final String[][] fAppearanceColorListModel= new String[][] {
- {TextEditorMessages.getString("TextEditorPreferencePage.lineNumberForegroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, null}, //$NON-NLS-1$
- {TextEditorMessages.getString("TextEditorPreferencePage.currentLineHighlighColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, null}, //$NON-NLS-1$
- {TextEditorMessages.getString("TextEditorPreferencePage.printMarginColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, null}, //$NON-NLS-1$
- {TextEditorMessages.getString("TextEditorPreferencePage.selectionForegroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR}, //$NON-NLS-1$
- {TextEditorMessages.getString("TextEditorPreferencePage.selectionBackgroundColor"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR}, //$NON-NLS-1$
- };
-
- private OverlayPreferenceStore fOverlayStore;
-
- private Map fCheckBoxes= new HashMap();
- private SelectionListener fCheckBoxListener= new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- public void widgetSelected(SelectionEvent e) {
- Button button= (Button) e.widget;
- fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
-
- private Map fTextFields= new HashMap();
- private ModifyListener fTextFieldListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Text text= (Text) e.widget;
- fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
- }
- };
-
- private ArrayList fNumberFields= new ArrayList();
- private ModifyListener fNumberFieldListener= new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- numberFieldChanged((Text) e.widget);
- }
- };
-
- private List fAppearanceColorList;
- private ColorEditor fAppearanceColorEditor;
- private Button fAppearanceColorDefault;
-
- /**
- * Tells whether the fields are initialized.
- * @since 3.0
- */
- private boolean fFieldsInitialized= false;
-
- /**
- * List of master/slave listeners when there's a dependency.
- *
- * @see #createDependency(Button, String, Control)
- * @since 3.0
- */
- private ArrayList fMasterSlaveListeners= new ArrayList();
-
-
- public TextEditorPreferencePage2() {
- setDescription(TextEditorMessages.getString("TextEditorPreferencePage.description")); //$NON-NLS-1$
- setPreferenceStore(EditorsPlugin.getDefault().getPreferenceStore());
-
- fOverlayStore= createOverlayStore();
- }
-
- private OverlayPreferenceStore createOverlayStore() {
-
- ArrayList overlayKeys= new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return new OverlayPreferenceStore(getPreferenceStore(), keys);
- }
-
- /*
- * @see IWorkbenchPreferencePage#init()
- */
- public void init(IWorkbench workbench) {
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- WorkbenchHelp.setHelp(getControl(), ITextEditorHelpContextIds.TEXT_EDITOR_PREFERENCE_PAGE);
- }
-
- private void handleAppearanceColorListSelection() {
- int i= fAppearanceColorList.getSelectionIndex();
- String key= fAppearanceColorListModel[i][1];
- RGB rgb= PreferenceConverter.getColor(fOverlayStore, key);
- fAppearanceColorEditor.setColorValue(rgb);
- updateAppearanceColorWidgets(fAppearanceColorListModel[i][2]);
- }
-
- private void updateAppearanceColorWidgets(String systemDefaultKey) {
- if (systemDefaultKey == null) {
- fAppearanceColorDefault.setSelection(false);
- fAppearanceColorDefault.setVisible(false);
- fAppearanceColorEditor.getButton().setEnabled(true);
- } else {
- boolean systemDefault= fOverlayStore.getBoolean(systemDefaultKey);
- fAppearanceColorDefault.setSelection(systemDefault);
- fAppearanceColorDefault.setVisible(true);
- fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
- }
- }
-
- private Control createAppearancePage(Composite parent) {
-
- Composite appearanceComposite= new Composite(parent, SWT.NONE);
- GridLayout layout= new GridLayout(); layout.numColumns= 2;
- appearanceComposite.setLayout(layout);
-
- String label= TextEditorMessages.getString("TextEditorPreferencePage.displayedTabWidth"); //$NON-NLS-1$
- addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
-
- label= TextEditorMessages.getString("TextEditorPreferencePage.printMarginColumn"); //$NON-NLS-1$
- addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
-
- label= TextEditorMessages.getString("TextEditorPreferencePage.showOverviewRuler"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
-
- label= TextEditorMessages.getString("TextEditorPreferencePage.showLineNumbers"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
-
- label= TextEditorMessages.getString("TextEditorPreferencePage.highlightCurrentLine"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
-
- label= TextEditorMessages.getString("TextEditorPreferencePage.showPrintMargin"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
-
- label= TextEditorMessages.getString("TextEditorPreferencePage.accessibility.disableCustomCarets"); //$NON-NLS-1$
- Button master= addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, 0);
-
- label= TextEditorMessages.getString("TextEditorPreferencePage.accessibility.wideCaret"); //$NON-NLS-1$
- Button slave= addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, 0);
- createDependency(master, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, slave);
-
- Label l= new Label(appearanceComposite, SWT.LEFT );
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- gd.heightHint= convertHeightInCharsToPixels(1) / 2;
- l.setLayoutData(gd);
-
- l= new Label(appearanceComposite, SWT.LEFT);
- l.setText(TextEditorMessages.getString("TextEditorPreferencePage.appearanceOptions")); //$NON-NLS-1$
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan= 2;
- l.setLayoutData(gd);
-
- Composite editorComposite= new Composite(appearanceComposite, SWT.NONE);
- layout= new GridLayout();
- layout.numColumns= 2;
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- editorComposite.setLayout(layout);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- gd.horizontalSpan= 2;
- editorComposite.setLayoutData(gd);
-
- fAppearanceColorList= new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
- gd.heightHint= convertHeightInCharsToPixels(5);
- fAppearanceColorList.setLayoutData(gd);
-
- Composite stylesComposite= new Composite(editorComposite, SWT.NONE);
- layout= new GridLayout();
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- layout.numColumns= 2;
- stylesComposite.setLayout(layout);
- stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- l= new Label(stylesComposite, SWT.LEFT);
- l.setText(TextEditorMessages.getString("TextEditorPreferencePage.color")); //$NON-NLS-1$
- gd= new GridData();
- gd.horizontalAlignment= GridData.BEGINNING;
- l.setLayoutData(gd);
-
- fAppearanceColorEditor= new ColorEditor(stylesComposite);
- Button foregroundColorButton= fAppearanceColorEditor.getButton();
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- foregroundColorButton.setLayoutData(gd);
-
- SelectionListener colorDefaultSelectionListener= new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- boolean systemDefault= fAppearanceColorDefault.getSelection();
- fAppearanceColorEditor.getButton().setEnabled(!systemDefault);
-
- int i= fAppearanceColorList.getSelectionIndex();
- String key= fAppearanceColorListModel[i][2];
- if (key != null)
- fOverlayStore.setValue(key, systemDefault);
- }
- public void widgetDefaultSelected(SelectionEvent e) {}
- };
-
- fAppearanceColorDefault= new Button(stylesComposite, SWT.CHECK);
- fAppearanceColorDefault.setText(TextEditorMessages.getString("TextEditorPreferencePage.systemDefault")); //$NON-NLS-1$
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- fAppearanceColorDefault.setLayoutData(gd);
- fAppearanceColorDefault.setVisible(false);
- fAppearanceColorDefault.addSelectionListener(colorDefaultSelectionListener);
-
- fAppearanceColorList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- handleAppearanceColorListSelection();
- }
- });
- foregroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
- public void widgetSelected(SelectionEvent e) {
- int i= fAppearanceColorList.getSelectionIndex();
- String key= fAppearanceColorListModel[i][1];
-
- PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
- }
- });
-
- return appearanceComposite;
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
-
- initializeDefaultColors();
-
- fOverlayStore.load();
- fOverlayStore.start();
-
- Control control= createAppearancePage(parent);
-
- initialize();
- Dialog.applyDialogFont(control);
- return control;
- }
-
- private void initialize() {
-
- initializeFields();
-
- for (int i= 0; i < fAppearanceColorListModel.length; i++)
- fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
- fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
- fAppearanceColorList.select(0);
- handleAppearanceColorListSelection();
- }
- }
- });
- }
-
- private void initializeFields() {
-
- Iterator e= fCheckBoxes.keySet().iterator();
- while (e.hasNext()) {
- Button b= (Button) e.next();
- String key= (String) fCheckBoxes.get(b);
- b.setSelection(fOverlayStore.getBoolean(key));
- }
-
- e= fTextFields.keySet().iterator();
- while (e.hasNext()) {
- Text t= (Text) e.next();
- String key= (String) fTextFields.get(t);
- t.setText(fOverlayStore.getString(key));
- }
-
- fFieldsInitialized= true;
- updateStatus(validatePositiveNumber("0")); //$NON-NLS-1$
-
- // Update slaves
- Iterator iter= fMasterSlaveListeners.iterator();
- while (iter.hasNext()) {
- SelectionListener listener= (SelectionListener)iter.next();
- listener.widgetSelected(null);
- }
- }
-
- private void initializeDefaultColors() {
- if (!getPreferenceStore().contains(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR)) {
- RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB();
- PreferenceConverter.setDefault(fOverlayStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, rgb);
- PreferenceConverter.setDefault(getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, rgb);
- }
- if (!getPreferenceStore().contains(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR)) {
- RGB rgb= getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT).getRGB();
- PreferenceConverter.setDefault(fOverlayStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, rgb);
- PreferenceConverter.setDefault(getPreferenceStore(), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, rgb);
- }
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
- fOverlayStore.propagate();
- EditorsPlugin.getDefault().savePluginPreferences();
- return true;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
-
- fOverlayStore.loadDefaults();
-
- initializeFields();
-
- handleAppearanceColorListSelection();
-
- super.performDefaults();
- }
-
- /*
- * @see DialogPage#dispose()
- */
- public void dispose() {
-
- if (fOverlayStore != null) {
- fOverlayStore.stop();
- fOverlayStore= null;
- }
-
- super.dispose();
- }
-
- private Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox= new Button(parent, SWT.CHECK);
- checkBox.setText(label);
-
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- gd.horizontalSpan= 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- private Control addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
-
- Label labelControl= new Label(composite, SWT.NONE);
- labelControl.setText(label);
- GridData gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent= indentation;
- labelControl.setLayoutData(gd);
-
- Text textControl= new Text(composite, SWT.BORDER | SWT.SINGLE);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.widthHint= convertWidthInCharsToPixels(textLimit + 1);
- textControl.setLayoutData(gd);
- textControl.setTextLimit(textLimit);
- fTextFields.put(textControl, key);
- if (isNumber) {
- fNumberFields.add(textControl);
- textControl.addModifyListener(fNumberFieldListener);
- } else {
- textControl.addModifyListener(fTextFieldListener);
- }
-
- return textControl;
- }
-
- private void createDependency(final Button master, String masterKey, final Control slave) {
- indent(slave);
-
- boolean masterState= fOverlayStore.getBoolean(masterKey);
- slave.setEnabled(masterState);
-
- SelectionListener listener= new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- slave.setEnabled(master.getSelection());
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {}
- };
- master.addSelectionListener(listener);
- fMasterSlaveListeners.add(listener);
- }
-
- private static void indent(Control control) {
- GridData gridData= new GridData();
- gridData.horizontalIndent= 20;
- control.setLayoutData(gridData);
- }
-
- private void numberFieldChanged(Text textControl) {
- String number= textControl.getText();
- IStatus status= validatePositiveNumber(number);
- if (!status.matches(IStatus.ERROR))
- fOverlayStore.setValue((String) fTextFields.get(textControl), number);
- updateStatus(status);
- }
-
- private IStatus validatePositiveNumber(String number) {
- StatusInfo status= new StatusInfo();
- if (number.length() == 0) {
- status.setError(TextEditorMessages.getString("TextEditorPreferencePage.empty_input")); //$NON-NLS-1$
- } else {
- try {
- int value= Integer.parseInt(number);
- if (value < 0)
- status.setError(TextEditorMessages.getFormattedString("TextEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
- } catch (NumberFormatException e) {
- status.setError(TextEditorMessages.getFormattedString("TextEditorPreferencePage.invalid_input", number)); //$NON-NLS-1$
- }
- }
- return status;
- }
-
- void updateStatus(IStatus status) {
- if (!fFieldsInitialized)
- return;
-
- if (!status.matches(IStatus.ERROR)) {
- for (int i= 0; i < fNumberFields.size(); i++) {
- Text text= (Text) fNumberFields.get(i);
- IStatus s= validatePositiveNumber(text.getText());
- status= s.getSeverity() > status.getSeverity() ? s : status;
- }
- }
- setValid(!status.matches(IStatus.ERROR));
- applyToStatusLine(this, status);
- }
-
- /**
- * Applies the status to the status line of a dialog page.
- *
- * @param page the dialog page
- * @param status the status
- */
- public void applyToStatusLine(DialogPage page, IStatus status) {
- String message= status.getMessage();
- switch (status.getSeverity()) {
- case IStatus.OK:
- page.setMessage(message, IMessageProvider.NONE);
- page.setErrorMessage(null);
- break;
- case IStatus.WARNING:
- page.setMessage(message, IMessageProvider.WARNING);
- page.setErrorMessage(null);
- break;
- case IStatus.INFO:
- page.setMessage(message, IMessageProvider.INFORMATION);
- page.setErrorMessage(null);
- break;
- default:
- if (message.length() == 0) {
- message= null;
- }
- page.setMessage(null);
- page.setErrorMessage(message);
- break;
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UISynchronizationContext.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UISynchronizationContext.java
deleted file mode 100644
index 815a7d6ba..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/UISynchronizationContext.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.core.filebuffers.ISynchronizationContext;
-
-import org.eclipse.swt.widgets.Display;
-
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * Synchronization context for file buffers whose documents are shown in the UI.
- * The synchronization runnable is executed in the UI thread.
- *
- * @since 3.0
- */
-public class UISynchronizationContext implements ISynchronizationContext {
-
- /*
- * @see org.eclipse.core.filebuffers.ISynchronizationContext#run(java.lang.Runnable)
- */
- public void run(Runnable runnable) {
- IWorkbench workbench= PlatformUI.getWorkbench();
- IWorkbenchWindow[] windows= workbench.getWorkbenchWindows();
- if (windows != null && windows.length > 0) {
- Display display= windows[0].getShell().getDisplay();
- display.asyncExec(runnable);
- } else {
- runnable.run();
- }
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/WorkspaceOperationRunner.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/WorkspaceOperationRunner.java
deleted file mode 100644
index 28176fcd3..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/editors/text/WorkspaceOperationRunner.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.ui.actions.WorkspaceModifyDelegatingOperation;
-import org.eclipse.ui.texteditor.ISchedulingRuleProvider;
-
-/**
- * @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 {
- if (runnable instanceof ISchedulingRuleProvider)
- run(fork, cancelable, runnable, ((ISchedulingRuleProvider)runnable).getSchedulingRule());
- else
- run(fork, cancelable, runnable, ResourcesPlugin.getWorkspace().getRoot());
- }
-
- /*
- * @see org.eclipse.jface.operation.IRunnableContext#run(boolean, boolean, org.eclipse.jface.operation.IRunnableWithProgress)
- */
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable, ISchedulingRule schedulingRule) throws InvocationTargetException, InterruptedException {
- WorkspaceModifyDelegatingOperation operation= new WorkspaceModifyDelegatingOperation(runnable, schedulingRule);
- operation.run(getProgressMonitor());
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationType.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationType.java
deleted file mode 100644
index 33ab9dd93..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationType.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.texteditor;
-
-import org.eclipse.ui.texteditor.AnnotationPreference;
-
-/**
- * Represents an annotation type.
- *
- * @since 3.0
- */
-public final class AnnotationType {
- private String fType;
- private String[] fSuperTypes;
- private AnnotationPreference fPreference;
-
- public AnnotationType(String type, String[] superTypes) {
- fType= type;
- fSuperTypes= superTypes;
- }
-
- public String getType() {
- return fType;
- }
-
- public String[] getSuperTypes() {
- return fSuperTypes;
- }
-
- /**
- * For internal use only.
- *
- * @return the annotation preference
- */
- public AnnotationPreference getPreference() {
- return fPreference;
- }
-
- /**
- * For internal use only.
- *
- * @param preference the annotation preference
- */
- public void setAnnotationPreference(AnnotationPreference preference) {
- fPreference= preference;
- }
-
- public boolean isSubtype(String superType) {
- if (fSuperTypes == null || superType == null)
- return false;
-
- if (superType.equals(fType))
- return true;
-
- for (int i= fSuperTypes.length -1; i > -1; i--) {
- if (superType.equals(fSuperTypes[i]))
- return true;
- }
-
- return false;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
deleted file mode 100644
index 44976bf09..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/AnnotationTypeHierarchy.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.texteditor;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-
-
-/**
- * Internal annotation super type hierarchy cache.
- * TODO this cache is currently unbound, i.e. only limited by the number of annotation types
- *
- * @since 3.0
- */
-public final class AnnotationTypeHierarchy {
-
- private Map fTypeMap;
- private Map fTypesCache= new HashMap();
-
- public AnnotationTypeHierarchy() {
- }
-
- public AnnotationType getAnnotationType(String typeName) {
- AnnotationType type= (AnnotationType) fTypesCache.get(typeName);
- if (type == null) {
- String[] superTypes= computeSuperTypes(typeName);
- type= new AnnotationType(typeName, superTypes);
- fTypesCache.put(typeName, type);
- }
- return type;
- }
-
- public boolean isSubtype(String superType, String subtypeCandidate) {
- AnnotationType type= getAnnotationType(subtypeCandidate);
- return type.isSubtype(superType);
- }
-
- private String[] computeSuperTypes(String typeName) {
- ArrayList types= new ArrayList();
- append(types, getDirectSuperType(typeName));
- int index= 0;
- while (index < types.size()) {
- String type= (String) types.get(index++);
- append(types, getDirectSuperType(type));
- }
-
- String[] superTypes= new String[types.size()];
- types.toArray(superTypes);
- return superTypes;
- }
-
- private String getDirectSuperType(String typeName) {
- return (String) getTypeMap().get(typeName);
- }
-
- private void append(List list, String string) {
- if (string == null || string.trim().length() == 0)
- return;
-
- if (!list.contains(string))
- list.add(string);
- }
-
- private Map getTypeMap() {
- if (fTypeMap == null)
- fTypeMap= readTypes();
- return fTypeMap;
- }
-
- private Map readTypes() {
- HashMap allTypes= new HashMap();
-
- IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "annotationTypes"); //$NON-NLS-1$
- if (extensionPoint != null) {
- IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
-
- String name= element.getAttribute("name"); //$NON-NLS-1$
- if (name == null || name.trim().length() == 0)
- continue;
-
- String parent= element.getAttribute("super"); //$NON-NLS-1$
- if (parent == null || parent.trim().length() == 0)
- parent= ""; //$NON-NLS-1$
-
- allTypes.put(name, parent);
- }
- }
-
- return allTypes;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
deleted file mode 100644
index c0b91e628..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/DelegatingAnnotationPreference.java
+++ /dev/null
@@ -1,251 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.texteditor;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.swt.graphics.RGB;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.AnnotationPreferenceLookup;
-import org.eclipse.ui.texteditor.IAnnotationImageProvider;
-
-
-public class DelegatingAnnotationPreference extends AnnotationPreference {
-
- private AnnotationType fType;
- private AnnotationPreferenceLookup fLookup;
- private Set fCache= new HashSet();
-
- public DelegatingAnnotationPreference(AnnotationType type, AnnotationPreferenceLookup lookup) {
- fType= type;
- fLookup= lookup;
- }
-
- private boolean isCached(Object attribute) {
- return fCache.contains(attribute);
- }
-
- private void markCached(Object attribute) {
- fCache.add(attribute);
- }
-
- private AnnotationPreference getDefiningPreference(Object attribute) {
-
- AnnotationPreference p= fLookup.getAnnotationPreferenceFragment(fType.getType());
- if (p != null && p.hasValue(attribute))
- return p;
-
- String[] superTypes= fType.getSuperTypes();
- for (int i= 0; i < superTypes.length; i++) {
- p= fLookup.getAnnotationPreferenceFragment(superTypes[i]);
- if (p != null && p.hasValue(attribute))
- return p;
- }
-
- return null;
- }
-
- private Object getAttributeValue(Object attribute) {
- if (!isCached(attribute)) {
- AnnotationPreference preference= getDefiningPreference(attribute);
- if (preference != null)
- setValue(attribute, preference.getValue(attribute));
- markCached(attribute);
- }
- return getValue(attribute);
- }
-
- private boolean getBooleanAttributeValue(Object attribute) {
- Object value= getAttributeValue(attribute);
- if (value instanceof Boolean)
- return ((Boolean) value).booleanValue();
- return false;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getAnnotationType()
- */
- public Object getAnnotationType() {
- return fType.getType();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#contributesToHeader()
- */
- public boolean contributesToHeader() {
- return getBooleanAttributeValue(HEADER_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getAnnotationImageProvider()
- */
- public IAnnotationImageProvider getAnnotationImageProvider() {
- if (!isCached(IMAGE_PROVIDER)) {
- AnnotationPreference preference= getDefiningPreference(IMAGE_PROVIDER);
- if (preference != null) {
- fAnnotationImageProvider= preference.fAnnotationImageProvider;
- fAnnotationImageProviderAttribute= preference.fAnnotationImageProviderAttribute;
- fConfigurationElement= preference.fConfigurationElement;
- }
- markCached(IMAGE_PROVIDER);
- }
- return super.getAnnotationImageProvider();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getColorPreferenceKey()
- */
- public String getColorPreferenceKey() {
- return (String) getAttributeValue(COLOR_PREFERENCE_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getColorPreferenceValue()
- */
- public RGB getColorPreferenceValue() {
- return (RGB) getAttributeValue(COLOR_PREFERENCE_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getHighlightPreferenceKey()
- */
- public String getHighlightPreferenceKey() {
- return (String) getAttributeValue(HIGHLIGHT_PREFERENCE_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getHighlightPreferenceValue()
- */
- public boolean getHighlightPreferenceValue() {
- return getBooleanAttributeValue(HIGHLIGHT_PREFERENCE_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return (ImageDescriptor) getAttributeValue(IMAGE_DESCRIPTOR);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getIsGoToNextNavigationTargetKey()
- */
- public String getIsGoToNextNavigationTargetKey() {
- return (String) getAttributeValue(IS_GO_TO_NEXT_TARGET_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getIsGoToPreviousNavigationTargetKey()
- */
- public String getIsGoToPreviousNavigationTargetKey() {
- return (String) getAttributeValue(IS_GO_TO_PREVIOUS_TARGET_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getOverviewRulerPreferenceKey()
- */
- public String getOverviewRulerPreferenceKey() {
- return (String) getAttributeValue(OVERVIEW_RULER_PREFERENCE_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getOverviewRulerPreferenceValue()
- */
- public boolean getOverviewRulerPreferenceValue() {
- return getBooleanAttributeValue(OVERVIEW_RULER_PREFERENCE_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getPreferenceLabel()
- */
- public String getPreferenceLabel() {
- return (String) getAttributeValue(PREFERENCE_LABEL);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getPresentationLayer()
- */
- public int getPresentationLayer() {
- Object value= getAttributeValue(PRESENTATION_LAYER);
- if (value instanceof Integer)
- return ((Integer) value).intValue();
- return IAnnotationAccessExtension.DEFAULT_LAYER;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getShowInNextPrevDropdownToolbarActionKey()
- */
- public String getShowInNextPrevDropdownToolbarActionKey() {
- return (String) getAttributeValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getSymbolicImageName()
- */
- public String getSymbolicImageName() {
- return (String) getAttributeValue(SYMBOLIC_IMAGE_NAME);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getTextPreferenceKey()
- */
- public String getTextPreferenceKey() {
- return (String) getAttributeValue(TEXT_PREFERENCE_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getTextPreferenceValue()
- */
- public boolean getTextPreferenceValue() {
- return getBooleanAttributeValue(TEXT_PREFERENCE_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getVerticalRulerPreferenceKey()
- */
- public String getVerticalRulerPreferenceKey() {
- return (String) getAttributeValue(VERTICAL_RULER_PREFERENCE_KEY);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#getVerticalRulerPreferenceValue()
- */
- public boolean getVerticalRulerPreferenceValue() {
- return getBooleanAttributeValue(VERTICAL_RULER_PREFERENCE_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#isGoToNextNavigationTarget()
- */
- public boolean isGoToNextNavigationTarget() {
- return getBooleanAttributeValue(IS_GO_TO_NEXT_TARGET_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#isGoToPreviousNavigationTarget()
- */
- public boolean isGoToPreviousNavigationTarget() {
- return getBooleanAttributeValue(IS_GO_TO_PREVIOUS_TARGET_VALUE);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AnnotationPreference#isShowInNextPrevDropdownToolbarAction()
- */
- public boolean isShowInNextPrevDropdownToolbarAction() {
- return getBooleanAttributeValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE);
- }
-
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java
deleted file mode 100644
index be324115b..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/SourceViewerInformationControl.java
+++ /dev/null
@@ -1,367 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.texteditor;
-
-import java.util.Arrays;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.resource.JFaceResources;
-
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlExtension;
-import org.eclipse.jface.text.source.SourceViewer;
-
-import org.eclipse.ui.editors.text.TextSourceViewerConfiguration;
-
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-
-/**
- * Source viewer based implementation of <code>IInformationControl</code>.
- * Displays information in a source viewer configured with the text editor
- * preference store.
- *
- * @since 3.0
- */
-class SourceViewerInformationControl implements IInformationControl, IInformationControlExtension, DisposeListener {
-
- /** Border thickness in pixels. */
- private static final int BORDER= 1;
-
-
- /** The control's shell */
- private Shell fShell;
- /** The control's text widget */
- private StyledText fText;
- /** The control's source viewer */
- private SourceViewer fViewer;
- /** The optional status field. */
- private Label fStatusField;
- /** The separator for the optional status field. */
- private Label fSeparator;
- /** The font of the optional status text label.*/
- private Font fStatusTextFont;
- /** The maximal widget width. */
- private int fMaxWidth;
- /** The maximal widget height. */
- private int fMaxHeight;
- /** The horizontal scroll index. */
- private int fHorizontalScrollPixel;
-
- /**
- * Creates a source viewer information control with the given shell as
- * parent and the given font.
- *
- * @param parent the parent shell
- * @param symbolicFontName the symbolic font name
- */
- public SourceViewerInformationControl(Shell parent, String symbolicFontName) {
- this(parent, SWT.NO_TRIM, SWT.NONE, symbolicFontName, null);
- }
-
- /**
- * Creates a source viewer information control with the given shell as
- * parent. The given shell styles are applied to the created shell. The
- * given styles are applied to the created styled text widget. The text
- * widget will be initialized with the given font. The status field will
- * contain the given text or be hidden.
- *
- * @param parent the parent shell
- * @param shellStyle the additional styles for the shell
- * @param style the additional styles for the styled text widget
- * @param symbolicFontName the symbolic font name
- * @param statusFieldText the text to be used in the optional status field
- * or <code>null</code> if the status field should be hidden
- */
- public SourceViewerInformationControl(Shell parent, int shellStyle, int style, String symbolicFontName, String statusFieldText) {
- GridLayout layout;
- GridData gd;
-
- fShell= new Shell(parent, SWT.NO_FOCUS | SWT.ON_TOP | shellStyle);
- Display display= fShell.getDisplay();
- fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
-
- Composite composite= fShell;
- layout= new GridLayout(1, false);
- int border= ((shellStyle & SWT.NO_TRIM) == 0) ? 0 : BORDER;
- layout.marginHeight= border;
- layout.marginWidth= border;
- composite.setLayout(layout);
- gd= new GridData(GridData.FILL_HORIZONTAL);
- composite.setLayoutData(gd);
-
- if (statusFieldText != null) {
- composite= new Composite(composite, SWT.NONE);
- layout= new GridLayout(1, false);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- composite.setLayout(layout);
- gd= new GridData(GridData.FILL_BOTH);
- composite.setLayoutData(gd);
- composite.setForeground(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- composite.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- // Source viewer
- fViewer= new SourceViewer(composite, null, style);
- fViewer.configure(new TextSourceViewerConfiguration(EditorsPlugin.getDefault().getPreferenceStore()));
- fViewer.setEditable(false);
-
- fText= fViewer.getTextWidget();
- gd= new GridData(GridData.BEGINNING | GridData.FILL_BOTH);
- fText.setLayoutData(gd);
- fText.setForeground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- fText.setFont(JFaceResources.getFont(symbolicFontName));
-
- fText.addKeyListener(new KeyListener() {
-
- public void keyPressed(KeyEvent e) {
- if (e.character == 0x1B) // ESC
- fShell.dispose();
- }
-
- public void keyReleased(KeyEvent e) {}
- });
-
- // Status field
- if (statusFieldText != null) {
-
- // Horizontal separator line
- fSeparator= new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.LINE_DOT);
- fSeparator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- // Status field label
- fStatusField= new Label(composite, SWT.RIGHT);
- fStatusField.setText(statusFieldText);
- Font font= fStatusField.getFont();
- FontData[] fontDatas= font.getFontData();
- for (int i= 0; i < fontDatas.length; i++)
- fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10);
- fStatusTextFont= new Font(fStatusField.getDisplay(), fontDatas);
- fStatusField.setFont(fStatusTextFont);
- GridData gd2= new GridData(GridData.FILL_VERTICAL | GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING);
- fStatusField.setLayoutData(gd2);
-
- // Regarding the color see bug 41128
- fStatusField.setForeground(display.getSystemColor(SWT.COLOR_WIDGET_DARK_SHADOW));
-
- fStatusField.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- addDisposeListener(this);
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
- */
- public void setInput(Object input) {
- if (input instanceof String)
- setInformation((String)input);
- else
- setInformation(null);
- }
-
- /*
- * @see IInformationControl#setInformation(String)
- */
- public void setInformation(String content) {
- if (content == null) {
- fViewer.setInput(null);
- return;
- }
-
- String spaces= getSpacesForHorizontalScrolling();
-
- IDocument doc= new Document(content + spaces);
- fViewer.setInput(doc);
- fViewer.getTextWidget().setHorizontalPixel(fHorizontalScrollPixel);
- }
-
- /**
- * Returns a run of spaces the length of which is at least
- * <code>fHorizontalScrollPixel</code>.
- *
- * @return the spaces to add to the document content to ensure that it can
- * be scrolled at least <code>fHorizontalScrollPixel</code>
- */
- private String getSpacesForHorizontalScrolling() {
- char[] spaces= new char[300];
- Arrays.fill(spaces, ' ');
- return new String(spaces);
- }
-
- /*
- * @see IInformationControl#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- fShell.setVisible(visible);
- }
-
- /*
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent event) {
- if (fStatusTextFont != null && !fStatusTextFont.isDisposed())
- fStatusTextFont.dispose();
-
- fStatusTextFont= null;
- fShell= null;
- fText= null;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#dispose()
- */
- public final void dispose() {
- if (fShell != null && !fShell.isDisposed())
- fShell.dispose();
- else
- widgetDisposed(null);
- }
-
- /*
- * @see IInformationControl#setSize(int, int)
- */
- public void setSize(int width, int height) {
-
- if (fStatusField != null) {
- GridData gd= (GridData)fViewer.getTextWidget().getLayoutData();
- Point statusSize= fStatusField.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- Point separatorSize= fSeparator.computeSize(SWT.DEFAULT, SWT.DEFAULT, true);
- gd.heightHint= height - statusSize.y - separatorSize.y;
- }
- fShell.setSize(width, height);
-
- if (fStatusField != null)
- fShell.pack(true);
- }
-
- /*
- * @see IInformationControl#setLocation(Point)
- */
- public void setLocation(Point location) {
- Rectangle trim= fShell.computeTrim(0, 0, 0, 0);
- Point textLocation= fText.getLocation();
- location.x += trim.x - textLocation.x;
- location.y += trim.y - textLocation.y;
- fShell.setLocation(location);
- }
-
- /*
- * @see IInformationControl#setSizeConstraints(int, int)
- */
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- fMaxWidth= maxWidth;
- fMaxHeight= maxHeight;
- }
-
- /*
- * @see IInformationControl#computeSizeHint()
- */
- public Point computeSizeHint() {
- Point size= fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- size.x= Math.min(size.x, fMaxWidth);
- size.y= Math.min(size.y, fMaxHeight);
- return size;
- }
-
- /*
- * @see IInformationControl#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- fShell.addDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- fShell.removeDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#setForegroundColor(Color)
- */
- public void setForegroundColor(Color foreground) {
- fText.setForeground(foreground);
- }
-
- /*
- * @see IInformationControl#setBackgroundColor(Color)
- */
- public void setBackgroundColor(Color background) {
- fText.setBackground(background);
- }
-
- /*
- * @see IInformationControl#isFocusControl()
- */
- public boolean isFocusControl() {
- return fText.isFocusControl();
- }
-
- /*
- * @see IInformationControl#setFocus()
- */
- public void setFocus() {
- fShell.forceFocus();
- fText.setFocus();
- }
-
- /*
- * @see IInformationControl#addFocusListener(FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- fText.addFocusListener(listener);
- }
-
- /*
- * @see IInformationControl#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- fText.removeFocusListener(listener);
- }
-
- /*
- * @see IInformationControlExtension#hasContents()
- */
- public boolean hasContents() {
- return fText.getCharCount() > 0;
- }
-
- /**
- * @param scrollIndex the new horizontal scroll index.
- */
- void setHorizontalScrollPixel(int scrollIndex) {
- scrollIndex= Math.max(0, scrollIndex);
- fHorizontalScrollPixel= scrollIndex;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/TextChangeHover.java b/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/TextChangeHover.java
deleted file mode 100644
index ef15190a2..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/internal/texteditor/TextChangeHover.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.texteditor;
-
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.resource.JFaceResources;
-
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.source.ILineRange;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.LineChangeHover;
-
-
-
-/**
- * Change hover for text editors. Respects tab settings and text editor font.
- *
- * @since 3.0
- */
-public class TextChangeHover extends LineChangeHover {
-
- /** The last created information control. */
- private int fLastScrollIndex= 0;
-
- /*
- * @see org.eclipse.jface.text.source.LineChangeHover#getTabReplacement()
- */
- protected String getTabReplacement() {
- return Character.toString('\t');
- }
-
-
- /*
- * @see org.eclipse.jface.text.source.LineChangeHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, org.eclipse.jface.text.source.ILineRange, int)
- */
- public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) {
- fLastScrollIndex= sourceViewer.getTextWidget().getHorizontalPixel();
- return super.getHoverInfo(sourceViewer, lineRange, visibleLines);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator()
- */
- public IInformationControlCreator getHoverControlCreator() {
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- SourceViewerInformationControl control= new SourceViewerInformationControl(parent, JFaceResources.TEXT_FONT);
- control.setHorizontalScrollPixel(fLastScrollIndex);
- return control;
- }
- };
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
deleted file mode 100644
index 999861f30..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditor.java
+++ /dev/null
@@ -1,1078 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.CoreException;
-import org.eclipse.core.runtime.IStatus;
-
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Composite;
-
-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.Annotation;
-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.ForwardingDocumentProvider;
-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.TextChangeHover;
-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.
- *
- * @since 3.0
- */
-public abstract class AbstractDecoratedTextEditor extends StatusTextEditor {
- /**
- * Preference key for showing the line number ruler.
- */
- private final static String LINE_NUMBER_RULER= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER;
- /**
- * Preference key for the foreground color of the line numbers.
- */
- private final static String LINE_NUMBER_COLOR= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR;
- /**
- * Preference key for showing the overview ruler.
- */
- private final static String OVERVIEW_RULER= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER;
- /**
- * Preference key for highlighting current line.
- */
- private final static String CURRENT_LINE= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE;
- /**
- * Preference key for highlight color of current line.
- */
- private final static String CURRENT_LINE_COLOR= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR;
- /**
- * Preference key for showing print margin ruler.
- */
- private final static String PRINT_MARGIN= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN;
- /**
- * Preference key for print margin ruler color.
- */
- private final static String PRINT_MARGIN_COLOR= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR;
- /**
- * Preference key for print margin ruler column.
- */
- private final static String PRINT_MARGIN_COLUMN= AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN;
-
- /**
- * Adapter class for <code>IGotoMarker</code>.
- */
- private class GotoMarkerAdapter implements IGotoMarker {
- public void gotoMarker(IMarker marker) {
- AbstractDecoratedTextEditor.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.
- */
- private AnnotationRulerColumn fAnnotationRulerColumn;
- /**
- * The editor's implicit document provider.
- */
- private IDocumentProvider fImplicitDocumentProvider;
- /**
- * The editor's goto marker adapter.
- */
- private Object fGotoMarkerAdapter= new GotoMarkerAdapter();
-
-
- /**
- * Creates a new text editor.
- */
- public AbstractDecoratedTextEditor() {
- super();
- fAnnotationPreferences= new MarkerAnnotationPreferences();
- setRangeIndicator(new DefaultRangeIndicator());
- initializeKeyBindingScopes();
- initializeEditor();
- }
-
- /**
- * Initializes this editor. Subclasses may re-implement. If sub-classes do
- * not change the contract, this method should not be extended, i.e. do not
- * call <code>super.initializeEditor()</code> in order to avoid the
- * temporary creation of objects that are immediately overwritten by
- * subclasses.
- */
- 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 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();
- }
-
- /**
- * Configures the decoration support for this editor's source viewer. Subclasses may override this
- * method, but should call their superclass' implementation at some point.
- *
- * @param support the decoration support to configure
- */
- 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.
- *
- * @return 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 de-installing the model
- } else {
- ensureChangeInfoCanBeDisplayed();
- installChangeRulerModel();
- }
-
- if (getChangeColumn() != null && getChangeColumn().getModel() != null)
- fIsChangeInformationShown= true;
- else
- fIsChangeInformationShown= false;
- }
-
- /**
- * 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= getDiffer();
- 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 line differ, or <code>null</code> if none could be found or created
- */
- private IAnnotationModel getOrCreateDiffer() {
- IAnnotationModel differ= getDiffer();
- // create diff model if it doesn't
- if (differ == null) {
- IPreferenceStore store= getPreferenceStore();
- if (store != null) {
- String defaultId= store.getString(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER);
- differ= new QuickDiff().createQuickDiffAnnotationModel(this, defaultId);
- if (differ != null) {
- ISourceViewer viewer= getSourceViewer();
- if (viewer == null)
- return null;
-
- IAnnotationModel m= viewer.getAnnotationModel();
- IAnnotationModelExtension model;
- if (m instanceof IAnnotationModelExtension)
- model= (IAnnotationModelExtension) m;
- else
- return null;
- model.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, differ);
- }
- }
- } else if (differ instanceof DocumentLineDiffer && !fIsChangeInformationShown)
- ((DocumentLineDiffer)differ).resume();
-
- return differ;
- }
-
- /**
- * Extracts the line differ from the displayed document's annotation model. If none can be found,
- * <code>null</code> is returned.
- *
- * @return the line differ, or <code>null</code> if none could be found
- */
- private IAnnotationModel getDiffer() {
- // 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
- return model.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
- }
-
- /**
- * 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 != null ? store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON) : false;
- }
-
- /**
- * 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.ui.workbench.texteditor.quickdiffChange".equals(pref.getAnnotationType())) { //$NON-NLS-1$
- RGB rgb= getColorPreference(store, pref);
- changeColumn.setChangedColor(sharedColors.getColor(rgb));
- } else if ("org.eclipse.ui.workbench.texteditor.quickdiffAddition".equals(pref.getAnnotationType())) { //$NON-NLS-1$
- RGB rgb= getColorPreference(store, pref);
- changeColumn.setAddedColor(sharedColors.getColor(rgb));
- } else if ("org.eclipse.ui.workbench.texteditor.quickdiffDeletion".equals(pref.getAnnotationType())) { //$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(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE));
- }
- }
-
- changeColumn.redraw();
- }
-
- /**
- * Extracts the color preference for the given preference from the given store.
- * If the given store 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
- * </p>
- *
- * @param store the preference store
- * @param pref the annotation preference
- * @return the RGB color preference, not <code>null</code>
- */
- 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.
- *
- * @return the created line number column
- */
- 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 TextChangeHover();
- }
-
- /**
- * 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();
- IPreferenceStore store= getPreferenceStore();
- if (ruler != null && store != 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 && store.contains(key))
- showAnnotation= store.getBoolean(key);
- if (showAnnotation)
- fAnnotationRulerColumn.addAnnotationType(preference.getAnnotationType());
- }
- fAnnotationRulerColumn.addAnnotationType(Annotation.TYPE_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 (AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH.equals(property)) {
- sourceViewer.getTextWidget().setTabs(getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
- 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
- && AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE.equals(property)) {
- initializeChangeRulerColumn(getChangeColumn());
- }
-
- AnnotationPreference pref= getAnnotationPreference(property);
- if (pref != null) {
- IChangeRulerColumn column= getChangeColumn();
- if (column != null) {
- Object type= pref.getAnnotationType();
- if (type instanceof String) {
- String annotationType= (String) type;
- if (annotationType.startsWith("org.eclipse.ui.workbench.texteditor.quickdiff")) //$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
- */
- 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 annotation preference lookup.
- *
- * @return the annotation preference lookup
- */
- protected AnnotationPreferenceLookup getAnnotationPreferenceLookup() {
- return EditorsPlugin.getDefault().getAnnotationPreferenceLookup();
- }
-
- /**
- * 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.
- *
- * @param viewer the viewer for which to return a 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)
- */
- protected boolean isErrorStatus(IStatus status) {
- // see bug 42230
- return super.isErrorStatus(status) && status.getCode() != IResourceStatus.READ_ONLY_LOCAL && status.getSeverity() != IStatus.CANCEL;
- }
-
- /*
- * @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)
- */
- public Object getAdapter(Class adapter) {
- if (IGotoMarker.class.equals(adapter))
- return fGotoMarkerAdapter;
- if (IAnnotationAccess.class.equals(adapter))
- return getAnnotationAccess();
- 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)
- */
- protected void setDocumentProvider(IEditorInput input) {
- fImplicitDocumentProvider= DocumentProviderRegistry.getDefault().getDocumentProvider(input);
- IDocumentProvider provider= super.getDocumentProvider();
- if (provider instanceof ForwardingDocumentProvider) {
- ForwardingDocumentProvider forwarder= (ForwardingDocumentProvider) provider;
- forwarder.setParentProvider(fImplicitDocumentProvider);
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.ITextEditor#getDocumentProvider()
- */
- public IDocumentProvider getDocumentProvider() {
- IDocumentProvider provider= super.getDocumentProvider();
- if (provider == null)
- return fImplicitDocumentProvider;
- return provider;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#disposeDocumentProvider()
- */
- protected void disposeDocumentProvider() {
- super.disposeDocumentProvider();
- fImplicitDocumentProvider= null;
- }
-
- /*
- * @see AbstractTextEditor#doSetInput(IEditorInput)
- *
- * This implementation also updates change information in the quick diff
- * ruler.
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
- if (fIsChangeInformationShown) {
- if (isPrefQuickDiffAlwaysOn()) {
- // only uninstall the model since we will reuse the change ruler
- uninstallChangeRulerModel();
- fIsChangeInformationShown= false;
- } else
- showChangeInformation(false);
- }
-
- super.doSetInput(input);
-
- if (isPrefQuickDiffAlwaysOn())
- showChangeInformation(true);
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
deleted file mode 100644
index f9e296727..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractDecoratedTextEditorPreferenceConstants.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 AbstractDecoratedTextEditorPreferenceConstants {
-
-
- /**
- * Prevent initialization.
- */
- private AbstractDecoratedTextEditorPreferenceConstants() {
- }
-
- /**
- * 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 PreferenceConverter
- */
- public final static String EDITOR_CURRENT_LINE_COLOR= "currentLineColor"; //$NON-NLS-1$
-
- /**
- * A named preference that holds the number of spaces used per tab in the text editor.
- * <p>
- * Value is of type <code>int</code>: positive int value specifying the number of
- * spaces per tab.
- * </p>
- */
- public final static String EDITOR_TAB_WIDTH= "tabWidth"; //$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 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>
- * @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 PreferenceConverter
- * @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>
- * @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 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 this plug-in's
- * Annotations preference page is used to configure annotations.
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String USE_ANNOTATIONS_PREFERENCE_PAGE= "useAnnotationsPrefPage"; //$NON-NLS-1$
-
- /**
- * A named preference that controls whether this plug-in's
- * Quick Diff preference page is used to configure Quick Diff.
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String USE_QUICK_DIFF_PREFERENCE_PAGE= "useQuickDiffPrefPage"; //$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>.
- * </p>
- */
- 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>.
- * </p>
- */
- 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>.
- * </p>
- */
- public static final String QUICK_DIFF_CHARACTER_MODE= "quickdiff.characterMode"; //$NON-NLS-1$
-
- /**
- * A named preference that controls whether custom carets are used in the
- * editor or not.
- * <p>
- * Value is of type <code>Boolean</code>. If <code>false</code>, only
- * the default caret is used in the editor.
- * </p>
- */
- public static final String EDITOR_USE_CUSTOM_CARETS= AbstractTextEditor.PREFERENCE_USE_CUSTOM_CARETS;
-
- /**
- * A named preference that controls whether carets are drawn wide or not.
- * <p>
- * Value is of type <code>Boolean</code>. If <code>true</code>, the caret is
- * twice as wide as the default caret.
- * </p>
- */
- public static final String EDITOR_WIDE_CARET= AbstractTextEditor.PREFERENCE_WIDE_CARET;
-
- /**
- * A named preference that holds the color used as the text selection foreground.
- * This value has no effect if the system default color is used.
- * <p>
- * 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 PreferenceConverter
- */
- public final static String EDITOR_SELECTION_FOREGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND;
-
- /**
- * A named preference that describes if the system default selection foreground color
- * is used as the text selection foreground.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public final static String EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT;
-
- /**
- * A named preference that holds the color used as the text selection background.
- * This value has no effect if the system default color is used.
- * <p>
- * 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 PreferenceConverter
- */
- public final static String EDITOR_SELECTION_BACKGROUND_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND;
-
- /**
- * A named preference that describes if the system default selection background color
- * is used as the text selection background.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public final static String EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR= AbstractTextEditor.PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT;
-
- /**
- * 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(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, false);
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, false);
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, true);
- PreferenceConverter.setDefault(store, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR, new RGB(232, 242, 254));
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 4);
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, false);
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 80);
- PreferenceConverter.setDefault(store, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR, new RGB(176, 180 , 185));
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, false);
- PreferenceConverter.setDefault(store, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR, new RGB(0, 0, 0));
-
- if (!store.getBoolean(USE_QUICK_DIFF_PREFERENCE_PAGE)) {
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, true);
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_CHARACTER_MODE, false);
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_DEFAULT_PROVIDER, "org.eclipse.ui.internal.editors.quickdiff.LastSaveReferenceProvider"); //$NON-NLS-1$
- }
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, true);
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION, false);
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_IN_OVERVIEW_RULER, false);
- PreferenceConverter.setDefault(store, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_UNKNOWN_INDICATION_COLOR, new RGB(0, 0, 0));
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_USE_CUSTOM_CARETS, false);
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_WIDE_CARET, true);
-
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR, true);
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR, true);
-
- MarkerAnnotationPreferences.initializeDefaultValues(store);
- }
-}
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
deleted file mode 100644
index 11495db74..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AbstractMarkerAnnotationModel.java
+++ /dev/null
@@ -1,645 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.osgi.framework.Bundle;
-
-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.core.filebuffers.IPersistableAnnotationModel;
-
-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.jface.text.source.IAnnotationMap;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-
-import org.eclipse.ui.PlatformUI;
-
-
-/**
- * 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 {@link #updateMarkers(IDocument)} 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 a {@link org.eclipse.ui.texteditor.IMarkerUpdater}
- * 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 implements IPersistableAnnotationModel {
-
- /** 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
- * @throws 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
- * @throws 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 consistency
- * 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) {
-
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log= Platform.getLog(bundle);
- 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 {
- MarkerAnnotation annotation= createMarkerAnnotation(marker);
- if (annotation != null)
- addAnnotation(annotation, 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.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "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) getAnnotationMap().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) {
- Position p= createPositionFromMarker(marker);
- if (p != null) {
- a.update();
- modifyAnnotationPosition(a, p, false);
- }
- }
- }
-
- /*
- * @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>.
- *
- * @throws 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
- * @return <code>false</code> if the marker is invalid
- * @throws CoreException if there is a problem updating the marker
- * @since 2.0
- * @deprecated use <code>updateMarker(IDocument, IMarker, Position)</code> instead. This method will be changed to protected.
- */
- 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 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
- * @return <code>false</code> if the marker is invalid
- * @throws CoreException if there is a problem updating the marker
- * @since 3.0
- */
- public boolean updateMarker(IDocument document, IMarker marker, Position position) throws CoreException {
- listenToMarkerChanges(false);
- try {
- return updateMarker(marker, document, position);
- } finally {
- listenToMarkerChanges(true);
- }
- }
-
- /**
- * 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
- * @throws CoreException if there is a problem updating the markers
- */
- public void updateMarkers(IDocument document) throws CoreException {
-
- Assert.isTrue(fDocument == document);
-
- IAnnotationMap annotationMap= getAnnotationMap();
-
- if (annotationMap.size() == 0 && fDeletedAnnotations.size() == 0)
- return;
-
- if (fMarkerUpdaterSpecifications == null)
- installMarkerUpdaters();
-
- listenToMarkerChanges(false);
-
- try {
-
- // 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) annotationMap.get(a);
- if ( !updateMarker(marker, document, position)) {
- if ( !fDeletedAnnotations.contains(a))
- fDeletedAnnotations.add(a);
- }
- }
- }
-
- if (!fDeletedAnnotations.isEmpty()) {
- removeAnnotations(fDeletedAnnotations, true, true);
- fDeletedAnnotations.clear();
- }
-
- } finally {
-
- listenToMarkerChanges(true);
-
- }
- }
-
- /**
- * Resets all the markers to their original state.
- */
- public void resetMarkers() {
-
- // re-initializes 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();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IPersistableAnnotationModel#commit(org.eclipse.jface.text.IDocument)
- */
- public void commit(IDocument document) throws CoreException {
- updateMarkers(document);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IPersistableAnnotationModel#revert(org.eclipse.jface.text.IDocument)
- */
- public void revert(IDocument document) {
- resetMarkers();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IPersistableAnnotationModel#reinitialize(org.eclipse.jface.text.IDocument)
- */
- public void reinitialize(IDocument document) {
- resetMarkers();
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
deleted file mode 100644
index 50c3454f1..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddMarkerAction.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.osgi.framework.Bundle;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.ILog;
-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.window.Window;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-
-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 to be subclassed.
- * </p>
- */
-public class AddMarkerAction extends TextEditorAction {
-
-
- /** The maximum length of an proposed label. */
- private static final int MAX_LABEL_LENGTH= 80;
- /** 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 TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor)
- */
- 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) {
-
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log= Platform.getLog(bundle);
- log.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/AddTaskAction.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java
deleted file mode 100644
index 4b4417d6f..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AddTaskAction.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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 java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-
-import org.eclipse.ui.views.tasklist.TaskPropertiesDialog;
-
-
-/**
- * Creates a new task marker. Uses the Workbench's task properties dialog.
- * @since 2.0
- */
-public class AddTaskAction extends AddMarkerAction {
-
- /**
- * 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 editor the text editor
- * @see AddMarkerAction#AddMarkerAction(ResourceBundle, String, ITextEditor, String, boolean)
- * @since 3.0
- */
- public AddTaskAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor, IMarker.TASK, false);
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
-
- IResource resource= getResource();
- if (resource == null)
- return;
- Map attributes= getInitialAttributes();
-
- TaskPropertiesDialog dialog = new TaskPropertiesDialog(getTextEditor().getSite().getShell());
- dialog.setResource(resource);
- dialog.setInitialAttributes(attributes);
- dialog.open();
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java
deleted file mode 100644
index e45495db4..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationPreferenceLookup.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.texteditor;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.text.source.Annotation;
-
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-import org.eclipse.ui.internal.texteditor.*;
-
-/**
- * Provides the strategy for finding the annotation preference for a given
- * annotation.
- *
- * @since 3.0
- */
-public class AnnotationPreferenceLookup {
-
- /** The map between annotation types and annotation preference fragments. */
- private Map fFragments;
-
- /**
- * Creates a new annotation preference lookup object.
- */
- public AnnotationPreferenceLookup() {
- }
-
- /**
- * Returns the annotation preference of a given annotation.
- *
- * @param annotation the annotation
- * @return the annotation preference for the given annotation or <code>null</code>
- */
- public AnnotationPreference getAnnotationPreference(Annotation annotation) {
- return getAnnotationPreference(annotation.getType());
- }
-
- /**
- * Returns the annotation preference defined for the given annotation type.
- *
- * @param annotationType the annotation type
- * @return the annotation preference for the given annotation type or <code>null</code>
- */
- public AnnotationPreference getAnnotationPreference(String annotationType) {
- if (annotationType == null || annotationType == Annotation.TYPE_UNKNOWN)
- return null;
-
- AnnotationTypeHierarchy hierarchy= getAnnotationTypeHierarchy();
- AnnotationType type= hierarchy.getAnnotationType(annotationType);
- AnnotationPreference preference= type.getPreference();
- if (preference == null) {
- preference= new DelegatingAnnotationPreference(type, this);
- type.setAnnotationPreference(preference);
- }
-
- return preference;
- }
-
- /**
- * Returns the annotation preference fragment defined for the given
- * annotation type.
- * <p>
- * For internal use only. Not intended to be called by clients.
- *
- * @param annotationType the annotation type
- * @return the defined annotation preference fragment
- */
- public AnnotationPreference getAnnotationPreferenceFragment(String annotationType) {
- Map fragments= getPreferenceFragments();
- return (AnnotationPreference) fragments.get(annotationType);
- }
-
- /**
- * Returns the annotation type hierarchy and creates it when not yet done.
- *
- * @return the annotation type hierarchy
- */
- private AnnotationTypeHierarchy getAnnotationTypeHierarchy() {
- return EditorsPlugin.getDefault().getAnnotationTypeHierarchy();
- }
-
- /**
- * Returns a map between annotation type names and annotation preference
- * fragments and creates it if not yet done.
- *
- * @return the map between annotation type names and annotation preference fragments
- */
- private Map getPreferenceFragments() {
- if (fFragments == null) {
- fFragments= new HashMap();
- MarkerAnnotationPreferences p= new MarkerAnnotationPreferences();
- Iterator e= p.getAnnotationPreferenceFragments().iterator();
- while (e.hasNext()) {
- AnnotationPreference fragment= (AnnotationPreference) e.next();
- Object annotationType = fragment.getAnnotationType();
- AnnotationPreference preference= (AnnotationPreference) fFragments.get(annotationType);
- if (preference == null)
- fFragments.put(annotationType, fragment);
- else
- preference.merge(fragment);
- }
- }
- return fFragments;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
deleted file mode 100644
index c56b0d6bc..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/AnnotationTypeLookup.java
+++ /dev/null
@@ -1,208 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.texteditor;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jface.resource.StringConverter;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-
-
-/**
- * Provides the strategy for determining annotation types for given markers.
- *
- * @since 3.0
- */
-public final class AnnotationTypeLookup {
-
- /**
- * Record representing an annotation type mapping.
- */
- private static class AnnotationTypeMapping {
-
- final static int UNDEFINED= -1;
-
- String fAnnotationType;
- String fMarkerType;
- int fMarkerSeverity= UNDEFINED;
-
- boolean isMarkerSeverityDefined() {
- return fMarkerSeverity != UNDEFINED;
- }
- }
-
- /** The lookup table for marker to annotation type mappings. */
- private Map fMapping;
-
- /**
- * Creates a new annotation lookup object.
- */
- public AnnotationTypeLookup() {
- }
-
- /**
- * Computes the annotation type that corresponds to the state of
- * the given marker.
- *
- * @param marker the marker
- * @return the annotation type or <code>null</code>
- */
- public String getAnnotationType(IMarker marker) {
- String markerType= MarkerUtilities.getMarkerType(marker);
- if (markerType != null) {
- int severity= MarkerUtilities.getSeverity(marker);
- return getAnnotationType(markerType, severity);
- }
- return null;
- }
-
- /**
- * Computes the annotation type that corresponds to the given marker type and
- * the given marker severity.
- *
- * @param markerType the marker type
- * @param markerSeverity the marker severity
- * @return the annotation type or <code>null</code>
- */
- public String getAnnotationType(String markerType, int markerSeverity) {
- String annotationType= lookupAnnotationType(markerType, markerSeverity);
- if (annotationType != null)
- return annotationType;
- String[] superTypes= MarkerUtilities.getSuperTypes(markerType);
- for (int i= 0; i < superTypes.length; i++) {
- annotationType= lookupAnnotationType(superTypes[i], markerSeverity);
- if (annotationType != null)
- return annotationType;
- }
- return null;
- }
-
- /**
- * Returns the annotation type for the given marker type and the given
- * marker severity.
- *
- * @param markerType the marker type
- * @param severity the marker severity
- * @return the annotation type
- */
- private String lookupAnnotationType(String markerType, int severity) {
- if (fMapping == null)
- initializeMapping();
-
- Object value= fMapping.get(markerType);
-
- if (value instanceof String)
- return (String) value;
-
- if (value instanceof Map) {
- Map severityMap= (Map) value;
- return (String) severityMap.get(new Integer(severity));
- }
-
- return null;
- }
-
- /**
- * Initializes the mapping between markers and their property values and
- * annotation types.
- */
- private void initializeMapping() {
- fMapping= new HashMap();
- List mappings= getAnnotationTypeMappings();
- for (int i= 0, l= mappings.size(); i < l; i++) {
- AnnotationTypeMapping atm= (AnnotationTypeMapping) mappings.get(i);
- if (atm.isMarkerSeverityDefined()) {
- Object severityMap= fMapping.get(atm.fMarkerType);
- if (!(severityMap instanceof Map)) {
- severityMap= new HashMap();
- fMapping.put(atm.fMarkerType, severityMap);
- }
- Map map= (Map) severityMap;
- map.put(new Integer(atm.fMarkerSeverity), atm.fAnnotationType);
- } else {
- fMapping.put(atm.fMarkerType, atm.fAnnotationType);
- }
- }
- }
-
- /**
- * Returns the list of annotation type mappings generated from the
- * extensions provided for the annotation type extension point.
- *
- * @return a list of annotation type mappings
- */
- private List getAnnotationTypeMappings() {
- List annotationTypeMappings= new ArrayList();
- // read compatibility mode
- readExtensionPoint(annotationTypeMappings, "markerAnnotationSpecification", "annotationType"); //$NON-NLS-1$ //$NON-NLS-2$
- // read new extension point
- readExtensionPoint(annotationTypeMappings, "annotationTypes", "name"); //$NON-NLS-1$ //$NON-NLS-2$
- return annotationTypeMappings;
- }
-
- /**
- * Reads the extensions provided for the given extension point name. Uses
- * the given type attribute name to create annotation type mappings that
- * are appended to the given list.
- *
- * @param annotationTypeMappings the list to be populated
- * @param extensionPointName the name of the extension point to read
- * @param typeAttributeName the name of attribute specifying the annotation
- * type
- */
- private void readExtensionPoint(List annotationTypeMappings, String extensionPointName, String typeAttributeName) {
- IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, extensionPointName);
- if (extensionPoint != null) {
- IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- AnnotationTypeMapping mapping= createMapping(elements[i], typeAttributeName);
- if (mapping != null)
- annotationTypeMappings.add(mapping);
- }
- }
- }
-
- /**
- * Creates an annotation type mapping from the given configuration element.
- *
- * @param element the configuration element
- * @param typeAttributeName the name of the attribute specifying the
- * annotation type
- * @return the annotation type mapping or <code>null</code>
- */
- private AnnotationTypeMapping createMapping(IConfigurationElement element, String typeAttributeName) {
-
- AnnotationTypeMapping mapping= new AnnotationTypeMapping();
-
- String s= element.getAttribute(typeAttributeName); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
- mapping.fAnnotationType= s;
-
- s= element.getAttribute("markerType"); //$NON-NLS-1$
- if (s == null || s.trim().length() == 0) return null;
- mapping.fMarkerType= s;
-
- s= element.getAttribute("markerSeverity"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
- mapping.fMarkerSeverity= StringConverter.asInt(s, AnnotationTypeMapping.UNDEFINED);
-
- return mapping;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java
deleted file mode 100644
index 98e46eac5..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BasicMarkerUpdater.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
deleted file mode 100644
index c9604ea4e..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/BookmarkRulerAction.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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/ChainedPreferenceStore.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
deleted file mode 100644
index 50f57beed..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ChainedPreferenceStore.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.ListenerList;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-
-/**
- * Preference store that composes multiple preference stores in a
- * chain and serves a preference value from the first preference store in the
- * chain that contains the preference.
- * <p>
- * This preference store is read-only i.e. write access
- * throws an {@link java.lang.UnsupportedOperationException}.</p>
- *
- * @since 3.0
- */
-public class ChainedPreferenceStore implements IPreferenceStore {
-
- /** Child preference stores. */
- private IPreferenceStore[] fPreferenceStores;
-
- /** Listeners on this chained preference store. */
- private ListenerList fClientListeners= new ListenerList();
-
- /** Listeners on the child preference stores. */
- private List fChildListeners= new ArrayList();
-
- /**
- * Listener on the chained preference stores. Forwards only the events
- * that are visible to clients.
- */
- private class PropertyChangeListener implements IPropertyChangeListener {
-
- /** Preference store to listen too. */
- private IPreferenceStore fPreferenceStore;
-
- /**
- * Initialize with the given preference store.
- *
- * @param preferenceStore the preference store
- */
- public PropertyChangeListener(IPreferenceStore preferenceStore) {
- setPreferenceStore(preferenceStore);
- }
-
- /*
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- IPreferenceStore childPreferenceStore= getPreferenceStore();
- handlePropertyChangeEvent(childPreferenceStore, event);
- }
-
- /**
- * Registers this listener on the preference store.
- */
- public void register() {
- getPreferenceStore().addPropertyChangeListener(this);
- }
-
- /**
- * Unregisters this listener from the preference store.
- */
- public void unregister() {
- getPreferenceStore().removePropertyChangeListener(this);
- }
-
- /**
- * Returns the preference store.
- *
- * @return the preference store
- */
- public IPreferenceStore getPreferenceStore() {
- return fPreferenceStore;
- }
-
- /**
- * Sets the preference store.
- *
- * @param preferenceStore the preference store to set
- */
- public void setPreferenceStore(IPreferenceStore preferenceStore) {
- fPreferenceStore= preferenceStore;
- }
-
- }
-
- /**
- * Sets the chained preference stores.
- *
- * @param preferenceStores the chained preference stores to set
- */
- public ChainedPreferenceStore(IPreferenceStore[] preferenceStores) {
- Assert.isTrue(preferenceStores != null && preferenceStores.length > 0);
- fPreferenceStores= preferenceStores;
- // Create listeners
- for (int i= 0, length= fPreferenceStores.length; i < length; i++) {
- PropertyChangeListener listener= new PropertyChangeListener(fPreferenceStores[i]);
- fChildListeners.add(listener);
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- if (fClientListeners.size() == 0) {
- registerChildListeners();
- }
- fClientListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fClientListeners.remove(listener);
- if (fClientListeners.size() == 0) {
- unregisterChildListeners();
- }
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#contains(java.lang.String)
- */
- public boolean contains(String name) {
- return getVisibleStore(name) != null;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#firePropertyChangeEvent(java.lang.String, java.lang.Object, java.lang.Object)
- */
- public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- firePropertyChangeEvent(new PropertyChangeEvent(this, name, oldValue, newValue));
- }
-
- /**
- * Fire the given property change event.
- *
- * @param event the property change event
- */
- private void firePropertyChangeEvent(PropertyChangeEvent event) {
- Object[] listeners= fClientListeners.getListeners();
- for (int i= 0; i < listeners.length; i++)
- ((IPropertyChangeListener) listeners[i]).propertyChange(event);
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getBoolean(java.lang.String)
- */
- public boolean getBoolean(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getBoolean(name);
- return BOOLEAN_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultBoolean(java.lang.String)
- */
- public boolean getDefaultBoolean(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getDefaultBoolean(name);
- return BOOLEAN_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultDouble(java.lang.String)
- */
- public double getDefaultDouble(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getDefaultDouble(name);
- return DOUBLE_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultFloat(java.lang.String)
- */
- public float getDefaultFloat(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getDefaultFloat(name);
- return FLOAT_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultInt(java.lang.String)
- */
- public int getDefaultInt(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getDefaultInt(name);
- return INT_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultLong(java.lang.String)
- */
- public long getDefaultLong(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getDefaultLong(name);
- return LONG_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getDefaultString(java.lang.String)
- */
- public String getDefaultString(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getDefaultString(name);
- return STRING_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getDouble(java.lang.String)
- */
- public double getDouble(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getDouble(name);
- return DOUBLE_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getFloat(java.lang.String)
- */
- public float getFloat(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getFloat(name);
- return FLOAT_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getInt(java.lang.String)
- */
- public int getInt(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getInt(name);
- return INT_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getLong(java.lang.String)
- */
- public long getLong(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getLong(name);
- return LONG_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#getString(java.lang.String)
- */
- public String getString(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.getString(name);
- return STRING_DEFAULT_DEFAULT;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#isDefault(java.lang.String)
- */
- public boolean isDefault(String name) {
- IPreferenceStore visibleStore= getVisibleStore(name);
- if (visibleStore != null)
- return visibleStore.isDefault(name);
- return false;
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#needsSaving()
- */
- public boolean needsSaving() {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#putValue(java.lang.String, java.lang.String)
- */
- public void putValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, double)
- */
- public void setDefault(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, float)
- */
- public void setDefault(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, int)
- */
- public void setDefault(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, long)
- */
- public void setDefault(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, java.lang.String)
- */
- public void setDefault(String name, String defaultObject) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setDefault(java.lang.String, boolean)
- */
- public void setDefault(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setToDefault(java.lang.String)
- */
- public void setToDefault(String name) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, double)
- */
- public void setValue(String name, double value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, float)
- */
- public void setValue(String name, float value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, int)
- */
- public void setValue(String name, int value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, long)
- */
- public void setValue(String name, long value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, java.lang.String)
- */
- public void setValue(String name, String value) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.preference.IPreferenceStore#setValue(java.lang.String, boolean)
- */
- public void setValue(String name, boolean value) {
- throw new UnsupportedOperationException();
- }
-
- /**
- * Handle property change event from the child listener with the given child preference store.
- *
- * @param childPreferenceStore the child preference store
- * @param event the event
- */
- private void handlePropertyChangeEvent(IPreferenceStore childPreferenceStore, PropertyChangeEvent event) {
- String property= event.getProperty();
- Object oldValue= event.getOldValue();
- Object newValue= event.getNewValue();
-
- IPreferenceStore visibleStore= getVisibleStore(property);
-
- /*
- * Assume that the property is there but has no default value (its owner relies on the default-default value)
- * see: https://bugs.eclipse.org/bugs/show_bug.cgi?id=52827
- */
- if (visibleStore == null && newValue != null)
- visibleStore= childPreferenceStore;
-
- if (visibleStore == null) {
- // no visible store
- Assert.isTrue(newValue == null);
- if (oldValue != null)
- // removal in child, last in chain -> removal in this chained preference store
- firePropertyChangeEvent(event);
- } else if (visibleStore == childPreferenceStore) {
- // event from visible store
- Assert.isNotNull(newValue);
- if (oldValue != null) {
- // change in child, visible store -> change in this chained preference store
- firePropertyChangeEvent(event);
- } else {
- // insertion in child
- IPreferenceStore oldVisibleStore= null;
- int i= 0;
- int length= fPreferenceStores.length;
- while (i < length && fPreferenceStores[i++] != visibleStore) {
- // do nothing
- }
- while (oldVisibleStore == null && i < length) {
- if (fPreferenceStores[i].contains(property))
- oldVisibleStore= fPreferenceStores[i];
- i++;
- }
-
- if (oldVisibleStore == null) {
- // insertion in child, first in chain -> insertion in this chained preference store
- firePropertyChangeEvent(event);
- } else {
- // insertion in child, not first in chain
- oldValue= getOtherValue(property, oldVisibleStore, newValue);
- if (!oldValue.equals(newValue))
- // insertion in child, different old value -> change in this chained preference store
- firePropertyChangeEvent(property, oldValue, newValue);
- // else: insertion in child, same old value -> no change in this chained preference store
- }
- }
- } else {
- // event from other than the visible store
- boolean eventBeforeVisibleStore= false;
- for (int i= 0, length= fPreferenceStores.length; i < length; i++) {
- IPreferenceStore store= fPreferenceStores[i];
- if (store == visibleStore)
- break;
- if (store == childPreferenceStore) {
- eventBeforeVisibleStore= true;
- break;
- }
- }
-
- if (eventBeforeVisibleStore) {
- // removal in child, before visible store
- Assert.isTrue(newValue == null);
- newValue= getOtherValue(property, visibleStore, oldValue);
- if (!newValue.equals(oldValue))
- // removal in child, before visible store, different old value -> change in this chained preference store
- firePropertyChangeEvent(property, oldValue, newValue);
- // else: removal in child, before visible store, same old value -> no change in this chained preference store
- }
- // else: event behind visible store -> no change in this chained preference store
- }
- }
-
- /**
- * Returns an object of the same dynamic type as <code>thisValue</code>, the returned object
- * encapsulates the value of the <code>property</code> from the preference <code>store</code>.
- *
- * @param property the name of the considered property
- * @param store the preference store
- * @param thisValue the given value
- * @return the other value
- * @throws java.lang.IllegalArgumentException if <code>thisValue</code> has a different type than
- * <code>Boolean</code>, <code>Double</code>, <code>Float</code>, <code>Integer</code>,
- * <code>Long</code> or <code>String</code>
- */
- private Object getOtherValue(String property, IPreferenceStore store, Object thisValue) {
- Object otherValue;
- if (thisValue instanceof Boolean)
- otherValue= new Boolean(store.getBoolean(property));
- else if (thisValue instanceof Double)
- otherValue= new Double(store.getDouble(property));
- else if (thisValue instanceof Float)
- otherValue= new Float(store.getFloat(property));
- else if (thisValue instanceof Integer)
- otherValue= new Integer(store.getInt(property));
- else if (thisValue instanceof Long)
- otherValue= new Long(store.getLong(property));
- else if (thisValue instanceof String)
- otherValue= store.getString(property);
- else
- throw new IllegalArgumentException();
- return otherValue;
- }
-
- /**
- * Returns the preference store from which the given property's value
- * is visible.
- *
- * @param property the name of the property
- * @return the preference store from which the property's value is visible,
- * <code>null</code> if the property is unknown
- */
- private IPreferenceStore getVisibleStore(String property) {
- IPreferenceStore visibleStore= null;
-
- for (int i= 0, length= fPreferenceStores.length; i < length && visibleStore == null; i++) {
- IPreferenceStore store= fPreferenceStores[i];
- if (store.contains(property))
- visibleStore= store;
- }
- return visibleStore;
- }
-
- /**
- * Register the child listeners on the child preference stores.
- */
- private void registerChildListeners() {
- Iterator iter= fChildListeners.iterator();
- while (iter.hasNext()) {
- PropertyChangeListener listener= (PropertyChangeListener) iter.next();
- listener.register();
- }
- }
-
- /**
- * Unregister the child listeners from the child preference stores.
- */
- private void unregisterChildListeners() {
- Iterator iter= fChildListeners.iterator();
- while (iter.hasNext()) {
- PropertyChangeListener listener= (PropertyChangeListener) iter.next();
- listener.unregister();
- }
- }
-}
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
deleted file mode 100644
index 2c8d97dd3..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DefaultMarkerAnnotationAccess.java
+++ /dev/null
@@ -1,364 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationAccess;
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.IAnnotationPresentation;
-import org.eclipse.jface.text.source.ImageUtilities;
-
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-import org.eclipse.ui.internal.texteditor.*;
-
-
-/**
- * Default class for accessing marker annotation properties.
- *
- * @since 2.1
- */
-public class DefaultMarkerAnnotationAccess implements IAnnotationAccess, IAnnotationAccessExtension {
-
- /**
- * Constant for the unknown marker type.
- *
- * @deprecated As of 3.0, replaced by Annotation.TYPE_UNKNOWN
- */
- public static final String UNKNOWN= Annotation.TYPE_UNKNOWN;
-
- /**
- * Constant for the error system image.
- * Value: <code>error</code>
- *
- * @since 3.0
- */
- public static final String ERROR_SYSTEM_IMAGE= "error"; //$NON-NLS-1$
- /**
- * Constant for the warning system image.
- * Value: <code>warning</code>
- *
- * @since 3.0
- */
- public static final String WARNING_SYSTEM_IMAGE= "warning"; //$NON-NLS-1$
- /**
- * Constant for the info system image.
- * Value: <code>info</code>
- *
- * @since 3.0
- */
- public static final String INFO_SYSTEM_IMAGE= "info"; //$NON-NLS-1$
- /**
- * Constant for the task system image.
- * Value: <code>task</code>
- *
- * @since 3.0
- */
- public static final String TASK_SYSTEM_IMAGE= "task"; //$NON-NLS-1$
- /**
- * Constant for the bookmark system image.
- * Value: <code>bookmark</code>
- *
- * @since 3.0
- */
- public static final String BOOKMARK_SYSTEM_IMAGE= "bookmark"; //$NON-NLS-1$
-
- /**
- * The mapping between external and internal symbolic system image names.
- *
- * @since 3.0
- */
- private final static Map MAPPING;
-
- static {
- MAPPING= new HashMap();
- MAPPING.put(ERROR_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_ERROR_TSK);
- MAPPING.put(WARNING_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_WARN_TSK);
- MAPPING.put(INFO_SYSTEM_IMAGE, ISharedImages.IMG_OBJS_INFO_TSK);
- MAPPING.put(TASK_SYSTEM_IMAGE, IDE.SharedImages.IMG_OBJS_TASK_TSK);
- MAPPING.put(BOOKMARK_SYSTEM_IMAGE, IDE.SharedImages.IMG_OBJS_BKMRK_TSK);
- }
-
-
- /**
- * The marker annotation preferences.
- *
- * @deprecated As of 3.0, no replacement
- */
- protected MarkerAnnotationPreferences fMarkerAnnotationPreferences;
-
- /**
- * Returns a new default marker annotation access with the given preferences.
- *
- * @param markerAnnotationPreferences
- * @deprecated As of 3.0, replaced by {@link org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess#DefaultMarkerAnnotationAccess()}
- */
- public DefaultMarkerAnnotationAccess(MarkerAnnotationPreferences markerAnnotationPreferences) {
- fMarkerAnnotationPreferences= markerAnnotationPreferences;
- }
-
- /**
- * Creates a new default marker annotation access using the standard
- * preference lookup strategy which is the one provided by the enclosing
- * plug-in.
- *
- * @since 3.0
- */
- public DefaultMarkerAnnotationAccess() {
- }
-
- /**
- * Returns the annotation preference for the given annotation.
- *
- * @param annotation the annotation
- * @return the annotation preference for the given annotation or <code>null</code>
- */
- private AnnotationPreference getAnnotationPreference(Annotation annotation) {
- AnnotationPreferenceLookup lookup= getAnnotationPreferenceLookup();
- if (lookup != null)
- return lookup.getAnnotationPreference(annotation);
- return null;
- }
-
- /**
- * Returns the annotation preference lookup used by this annotation access.
- *
- * @return the annotation preference lookup
- * @since 3.0
- */
- protected AnnotationPreferenceLookup getAnnotationPreferenceLookup() {
- return EditorsPlugin.getDefault().getAnnotationPreferenceLookup();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccess#getType(org.eclipse.jface.text.source.Annotation)
- */
- public Object getType(Annotation annotation) {
- return annotation.getType();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccess#isMultiLine(org.eclipse.jface.text.source.Annotation)
- */
- public boolean isMultiLine(Annotation annotation) {
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccess#isTemporary(org.eclipse.jface.text.source.Annotation)
- */
- public boolean isTemporary(Annotation annotation) {
- return !annotation.isPersistent();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#getLabel(org.eclipse.jface.text.source.Annotation)
- * @since 3.0
- */
- public String getTypeLabel(Annotation annotation) {
- AnnotationPreference preference= getAnnotationPreference(annotation);
- return preference != null ? preference.getPreferenceLabel() : null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#getLayer(org.eclipse.jface.text.source.Annotation)
- * @since 3.0
- */
- public int getLayer(Annotation annotation) {
- AnnotationPreference preference= getAnnotationPreference(annotation);
- if (preference != null)
- return preference.getPresentationLayer();
-
- if (annotation instanceof IAnnotationPresentation) {
- IAnnotationPresentation presentation= (IAnnotationPresentation) annotation;
- return presentation.getLayer();
- }
-
- // backward compatibility, ignore exceptions, just return default layer
- try {
-
- Method method= annotation.getClass().getMethod("getLayer", null); //$NON-NLS-1$
- Integer result= (Integer) method.invoke(annotation, null);
- return result.intValue();
-
- } catch (SecurityException x) {
- } catch (IllegalArgumentException x) {
- } catch (NoSuchMethodException x) {
- } catch (IllegalAccessException x) {
- } catch (InvocationTargetException x) {
- }
-
- return IAnnotationAccessExtension.DEFAULT_LAYER;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#paint(org.eclipse.jface.text.source.Annotation, org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
- * @since 3.0
- */
- public void paint(Annotation annotation, GC gc, Canvas canvas, Rectangle bounds) {
-
- if (annotation instanceof IAnnotationPresentation) {
- IAnnotationPresentation presentation= (IAnnotationPresentation) annotation;
- presentation.paint(gc, canvas, bounds);
- return;
- }
-
- AnnotationPreference preference= getAnnotationPreference(annotation);
- if (preference != null) {
- Object type= getType(annotation);
- String annotationType= (type == null ? null : type.toString());
- Image image= getImage(annotation, preference, annotationType);
- if (image != null) {
- ImageUtilities.drawImage(image, gc, canvas, bounds, SWT.CENTER, SWT.TOP);
- return;
- }
- }
-
- // backward compatibility, ignore exceptions, just don't paint
- try {
-
- Method method= annotation.getClass().getMethod("paint", new Class[] { GC.class, Canvas.class, Rectangle.class }); //$NON-NLS-1$
- method.invoke(annotation, new Object[] {gc, canvas, bounds });
-
- } catch (SecurityException x) {
- } catch (IllegalArgumentException x) {
- } catch (NoSuchMethodException x) {
- } catch (IllegalAccessException x) {
- } catch (InvocationTargetException x) {
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#isPaintable(org.eclipse.jface.text.source.Annotation)
- * @since 3.0
- */
- public boolean isPaintable(Annotation annotation) {
- if (annotation instanceof IAnnotationPresentation)
- return true;
-
- AnnotationPreference preference= getAnnotationPreference(annotation);
- if (preference == null)
- return false;
-
- Object type= getType(annotation);
- String annotationType= (type == null ? null : type.toString());
- Image image= getImage(annotation, preference, annotationType);
- return image != null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#isSubtype(java.lang.Object, java.lang.Object)
- */
- public boolean isSubtype(Object annotationType, Object potentialSupertype) {
- AnnotationTypeHierarchy hierarchy= getAnnotationTypeHierarchy();
- return hierarchy.isSubtype(potentialSupertype.toString(), annotationType.toString());
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationAccessExtension#getSupertypes(java.lang.Object)
- */
- public Object[] getSupertypes(Object annotationType) {
- AnnotationTypeHierarchy hierarchy= getAnnotationTypeHierarchy();
- AnnotationType type= hierarchy.getAnnotationType(annotationType.toString());
- return type.getSuperTypes();
- }
-
- /**
- * Returns the annotation type hierarchy used by this annotation access.
- *
- * @return the annotation type hierarchy
- * @since 3.0
- */
- protected AnnotationTypeHierarchy getAnnotationTypeHierarchy() {
- return EditorsPlugin.getDefault().getAnnotationTypeHierarchy();
- }
-
- /**
- * Translates the given symbolic image name into the according symbolic image name
- * the {@link org.eclipse.ui.ISharedImages} understands.
- *
- * @param symbolicImageName the symbolic system image name to be translated
- * @return the shared image name
- * @since 3.0
- */
- private String translateSymbolicImageName(String symbolicImageName) {
- return (String) MAPPING.get(symbolicImageName);
- }
-
- /**
- * Returns the image for the given annotation and the given annotation preferences or
- * <code>null</code> if there is no such image.
- *
- * @param annotation the annotation
- * @param preference the annotation preference
- * @param annotationType the annotation type
- * @return the image or <code>null</code>
- * @since 3.0
- */
- private Image getImage(Annotation annotation, AnnotationPreference preference, String annotationType) {
-
- ImageRegistry registry= EditorsPlugin.getDefault().getImageRegistry();
-
- IAnnotationImageProvider annotationImageProvider = preference.getAnnotationImageProvider();
- if (annotationImageProvider != null) {
-
- Image image= annotationImageProvider.getManagedImage(annotation);
- if (image != null)
- return image;
-
- String id= annotationImageProvider.getImageDescriptorId(annotation);
- if (id != null) {
- image= registry.get(id);
- if (image == null) {
- ImageDescriptor descriptor= annotationImageProvider.getImageDescriptor(id);
- registry.put(id, descriptor);
- image= registry.get(id);
- }
- return image;
- }
- }
-
- if (annotationType == null)
- return null;
-
- Image image= registry.get(annotationType);
- if (image == null) {
- ImageDescriptor descriptor= preference.getImageDescriptor();
- if (descriptor != null) {
- registry.put(annotationType, descriptor);
- image= registry.get(annotationType);
- } else {
- String key= translateSymbolicImageName(preference.getSymbolicImageName());
- if (key != null) {
- ISharedImages sharedImages= PlatformUI.getWorkbench().getSharedImages();
- image= sharedImages.getImage(key);
- }
- }
- }
- return image;
- }
-}
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
deleted file mode 100644
index 773584ff9..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/DocumentProviderRegistry.java
+++ /dev/null
@@ -1,322 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.osgi.framework.Bundle;
-
-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.editors.text.EditorsUI;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.PlatformUI;
-
-
-/**
- * This registry manages shared document providers. 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.
- *
- * @return the default 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 initializes it with the information
- * found in the plug-in 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.
- *
- * @param map the map
- * @param element the configuration element
- * @param attributeName the attribute name
- */
- 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.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "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$
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log= Platform.getLog(bundle);
- 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.
- *
- * @param entry the configuration element
- * @return the document provider for the given entry
- */
- 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.
- *
- * @param set the set
- * @return the first configuration element in the set or <code>null</code> if none
- */
- private IConfigurationElement selectConfigurationElement(Set set) {
- if (set != null && !set.isEmpty()) {
- Iterator e= set.iterator();
- return (IConfigurationElement) e.next();
- }
- return null;
- }
-
- /**
- * Returns a shared document provider for the given name extension.
- *
- * @param extension the name extension to be used for lookup
- * @return the shared 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.
- *
- * @param type the type
- * @return a list containing the super class hierarchy
- */
- 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.
- *
- * @param classes a list of {@link java.lang.Class} objects
- * @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.
- *
- * @param interfaces an array of {@link java.lang.Class} objects denoting interfaces
- * @param result the result list
- * @param visited map of visited interfaces
- */
- 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.
- *
- * @param classes a list of {@link java.lang.Class} objects
- * @return 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.
- *
- * @param type a {@link java.lang.Class} object
- * @return 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 shared document for the type of the given editor input.
- *
- * @param editorInput the input for whose type the provider is looked up
- * @return the shared 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/IMarkerUpdater.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java
deleted file mode 100644
index a2df9425d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/IMarkerUpdater.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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
- * {@link org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel}.
- */
-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/ImageUtilities.java b/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java
deleted file mode 100644
index 312e89b26..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/ImageUtilities.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-
-
-/**
- * @since 3.0
- * @deprecated As of 3.0, replaced by {@link org.eclipse.jface.text.source.ImageUtilities}
- */
-public class ImageUtilities {
-
- /**
- * @deprecated As of 3.0, replaced by {@link org.eclipse.jface.text.source.ImageUtilities#drawImage(Image, GC, Canvas, Rectangle, int, int)}
- */
- public static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int halign, int valign) {
- org.eclipse.jface.text.source.ImageUtilities.drawImage(image, gc, canvas, r, halign, valign);
- }
-
- /**
- * @deprecated As of 3.0, replaced by {@link org.eclipse.jface.text.source.ImageUtilities#drawImage(Image, GC, Canvas, Rectangle, int)}
- */
- public static void drawImage(Image image, GC gc, Canvas canvas, Rectangle r, int align) {
- org.eclipse.jface.text.source.ImageUtilities.drawImage(image, gc, canvas, r, align);
- }
-}
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
deleted file mode 100644
index 4904fa82d..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotation.java
+++ /dev/null
@@ -1,311 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.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.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.ImageUtilities;
-
-import org.eclipse.ui.ISharedImages;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.internal.editors.text.EditorsPlugin;
-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 SimpleMarkerAnnotation {
-
- /**
- * The layer in which markers representing problem are located.
- *
- * @since 2.0
- * @deprecated As of 3.0, replaced by {@link IAnnotationAccessExtension}
-
- */
- 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
- * @deprecated As of 3.0, visual presentation is no longer supported,
- * annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- */
- 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 registry is created.
- *
- * @param display the display
- * @return the image registry for the given display
- * @deprecated As of 3.0, visual presentation is no longer supported,
- * annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- */
- 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 image, i.e., visual presentation of this annotation. */
- private Image fImage;
- /** The image name. */
- private String fImageName;
- /** The presentation layer. */
- private int fPresentationLayer= -1;
-
- /**
- * Creates a new annotation for the given marker.
- *
- * @param marker the marker
- */
- public MarkerAnnotation(IMarker marker) {
- super(marker);
- }
-
- /**
- * Creates a new annotation of the given type for the given marker.
- *
- * @param annotationType the annotation type
- * @param marker the marker
- * @since 3.0
- */
- public MarkerAnnotation(String annotationType, IMarker marker) {
- super(annotationType, marker);
- initialize();
- }
-
- /**
- * Sets the marker image to the given image.
- *
- * @param image the new marker image
- * @deprecated As of 3.0, visual presentation is no longer supported,
- * annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- */
- protected void setImage(Image image) {
- fImage= image;
- }
-
- /**
- * Initializes the annotation's icon representation and its drawing layer
- * based upon the properties of the underlying marker.
- *
- * @deprecated As of 3.0, visual presentation is no longer supported,
- * annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- */
- protected void initialize() {
- IMarker marker= getMarker();
- String name= getUnknownImageName(marker);
-
- if (MarkerUtilities.isMarkerType(marker, IMarker.TASK)) {
- name= IDE.SharedImages.IMG_OBJS_TASK_TSK;
- } else if (MarkerUtilities.isMarkerType(marker, IMarker.BOOKMARK)) {
- name= IDE.SharedImages.IMG_OBJS_BKMRK_TSK;
- } else if (MarkerUtilities.isMarkerType(marker, IMarker.PROBLEM)) {
- switch (MarkerUtilities.getSeverity(marker)) {
- case IMarker.SEVERITY_INFO:
- name= ISharedImages.IMG_OBJS_INFO_TSK;
- break;
- case IMarker.SEVERITY_WARNING:
- name= ISharedImages.IMG_OBJS_WARN_TSK;
- break;
- case IMarker.SEVERITY_ERROR:
- name= ISharedImages.IMG_OBJS_ERROR_TSK;
- break;
- }
- }
-
- fImage= null;
- fImageName= name;
- }
-
- /**
- * Returns the annotations drawing layer.
- * <p>
- * Note: This is only for backward compatibility.
- * </p>
- * @return the annotations drawing layer
- * @deprecated As of 3.0, replaced by {@link org.eclipse.jface.text.source.IAnnotationAccessExtension#getLayer(org.eclipse.jface.text.source.Annotation)}
- * @since 3.0
- */
- public int getLayer() {
- if (fPresentationLayer != -1)
- // Backward compatibility
- return fPresentationLayer;
-
- AnnotationPreference preference= EditorsPlugin.getDefault().getAnnotationPreferenceLookup().getAnnotationPreference(this);
- if (preference != null)
- return preference.getPresentationLayer();
- else
- return IAnnotationAccessExtension.DEFAULT_LAYER;
- }
-
- /**
- * Sets the layer of this annotation.
- * <p>
- * Note: This is only for backward compatibility.
- * </p>
- * @param layer the layer of this annotation
- * @deprecated As of 3.0, annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- *
- * @since 3.0
- */
- protected void setLayer(int layer) {
- fPresentationLayer= layer;
- }
-
- /**
- * Implement this method to draw a graphical representation of this
- * annotation within the given bounds. This default implementation does
- * nothing.
- * <p>
- * Note: This is only for backward compatibility.
- * </p>
- * @param gc the drawing GC
- * @param canvas the canvas to draw on
- * @param r the bounds inside the canvas to draw on
- * @deprecated As of 3.0 replaced by {@link org.eclipse.jface.text.source.IAnnotationAccessExtension#paint(org.eclipse.jface.text.source.Annotation, GC, Canvas, Rectangle)}
- * @since 3.0
- */
- public void paint(GC gc, Canvas canvas, Rectangle r) {
- Image image= getImage(canvas.getDisplay());
- if (image != null)
- ImageUtilities.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() {
- super.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 unknown type
- * @return the name of an image for markers of unknown type.
- * @deprecated As of 3.0, visual presentation is no longer supported,
- * annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- */
- 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
- * @deprecated As of 3.0, visual presentation is no longer supported,
- * annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- */
- 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
- * @deprecated As of 3.0, visual presentation is no longer supported,
- * annotation with a visible presentation should implement
- * {@link org.eclipse.jface.text.source.IAnnotationPresentation}
- */
- protected Image getImage(Display display) {
- if (fImage == null) {
-
- IMarker marker= getMarker();
- if (marker.exists()) {
- IWorkbenchAdapter adapter= (IWorkbenchAdapter) marker.getAdapter(IWorkbenchAdapter.class);
- if (adapter != null) {
- ImageDescriptor descriptor= adapter.getImageDescriptor(marker);
- if (descriptor != null)
- fImage= getImage(display, descriptor);
- }
- }
-
- if (fImage == null)
- fImage= getImage(fImageName);
-
- }
- return fImage;
- }
-}
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
deleted file mode 100644
index 9a4aa9e42..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerAnnotationPreferences.java
+++ /dev/null
@@ -1,495 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.net.MalformedURLException;
-import java.net.URL;
-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.osgi.framework.Bundle;
-
-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.ImageDescriptor;
-import org.eclipse.jface.resource.StringConverter;
-
-import org.eclipse.ui.editors.text.EditorsUI;
-
-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 {@link org.eclipse.ui.texteditor.AnnotationPreference}.
- *
- * @since 2.1
- */
-public class MarkerAnnotationPreferences {
-
- /**
- * Initializes the given preference store with the default marker annotation values.
- *
- * @param store the preference store to be initialized
- * @since 3.0
- */
- public static void initializeDefaultValues(IPreferenceStore store) {
-
- boolean ignoreAnnotationsPrefPage= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE);
- boolean ignoreQuickDiffPrefPage= store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE);
-
- MarkerAnnotationPreferences preferences= new MarkerAnnotationPreferences();
- Iterator e= preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
-
- if (ignoreAnnotationsPrefPage && info.isIncludeOnPreferencePage() && isComplete(info))
- continue;
-
- if (ignoreQuickDiffPrefPage && (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$
- || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
- || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$
- ))
- continue;
-
- 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());
- if (info.getTextStylePreferenceKey() != null)
- store.setDefault(info.getTextStylePreferenceKey(), info.getTextStyleValue());
- }
- }
-
- /**
- * Removes the marker annotation values which are shown on the
- * general Annotations page from the given store and prevents
- * setting the default values in the future.
- * <p>
- * Note: In order to work this method must be called before any
- * call to {@link #initializeDefaultValues(IPreferenceStore)}
- * </p>
- * <p>
- * This method is not part of the API and must only be called
- * by {@link org.eclipse.ui.editors.text.EditorsUI}
- * </p>
- *
- * @param store the preference store to be initialized
- * @throws IllegalStateException if not called by {@link org.eclipse.ui.editors.text.EditorsUI}
- * @since 3.0
- */
- public static void useAnnotationsPreferencePage(IPreferenceStore store) throws IllegalStateException {
- checkAccess();
-
- store.putValue(AbstractDecoratedTextEditorPreferenceConstants.USE_ANNOTATIONS_PREFERENCE_PAGE, Boolean.toString(true));
-
- MarkerAnnotationPreferences preferences= new MarkerAnnotationPreferences();
- Iterator e= preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
-
- // Only reset annotations shown on Annotations preference page
- if (!info.isIncludeOnPreferencePage() || !isComplete(info))
- continue;
-
- store.setToDefault(info.getTextPreferenceKey());
- store.setToDefault(info.getOverviewRulerPreferenceKey());
- if (info.getVerticalRulerPreferenceKey() != null)
- store.setToDefault(info.getVerticalRulerPreferenceKey());
- store.setToDefault(info.getColorPreferenceKey());
- if (info.getShowInNextPrevDropdownToolbarActionKey() != null)
- store.setToDefault(info.getShowInNextPrevDropdownToolbarActionKey());
- if (info.getIsGoToNextNavigationTargetKey() != null)
- store.setToDefault(info.getIsGoToNextNavigationTargetKey());
- if (info.getIsGoToPreviousNavigationTargetKey() != null)
- store.setToDefault(info.getIsGoToPreviousNavigationTargetKey());
- if (info.getHighlightPreferenceKey() != null)
- store.setToDefault(info.getHighlightPreferenceKey());
- if (info.getTextStylePreferenceKey() != null)
- store.setToDefault(info.getTextStylePreferenceKey());
- }
- }
-
- /**
- * Removes the Quick Diff marker annotation values which are shown on the
- * general Quick Diff page from the given store and prevents
- * setting the default values in the future.
- * <p>
- * Note: In order to work this method must be called before any
- * call to {@link #initializeDefaultValues(IPreferenceStore)}
- * </p>
- * <p>
- * This method is not part of the API and must only be called
- * by {@link EditorsUI}
- * </p>
- *
- * @param store the preference store to be initialized
- * @throws IllegalStateException if not called by {@link EditorsUI}
- * @since 3.0
- */
- public static void useQuickDiffPreferencePage(IPreferenceStore store) throws IllegalStateException {
- checkAccess();
-
- store.putValue(AbstractDecoratedTextEditorPreferenceConstants.USE_QUICK_DIFF_PREFERENCE_PAGE, Boolean.toString(true));
-
- MarkerAnnotationPreferences preferences= new MarkerAnnotationPreferences();
- Iterator e= preferences.getAnnotationPreferences().iterator();
- while (e.hasNext()) {
- AnnotationPreference info= (AnnotationPreference) e.next();
-
- // Only reset annotations shown on Quick Diff preference page
-
- if (!(info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffChange") //$NON-NLS-1$
- || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffAddition")) //$NON-NLS-1$
- || (info.getAnnotationType().equals("org.eclipse.ui.workbench.texteditor.quickdiffDeletion")) //$NON-NLS-1$
- ))
- continue;
-
- store.setToDefault(info.getTextPreferenceKey());
- store.setToDefault(info.getOverviewRulerPreferenceKey());
- if (info.getVerticalRulerPreferenceKey() != null)
- store.setToDefault(info.getVerticalRulerPreferenceKey());
- store.setToDefault(info.getColorPreferenceKey());
- if (info.getShowInNextPrevDropdownToolbarActionKey() != null)
- store.setToDefault(info.getShowInNextPrevDropdownToolbarActionKey());
- if (info.getIsGoToNextNavigationTargetKey() != null)
- store.setToDefault(info.getIsGoToNextNavigationTargetKey());
- if (info.getIsGoToPreviousNavigationTargetKey() != null)
- store.setToDefault(info.getIsGoToPreviousNavigationTargetKey());
- if (info.getHighlightPreferenceKey() != null)
- store.setToDefault(info.getHighlightPreferenceKey());
- if (info.getTextStylePreferenceKey() != null)
- store.setToDefault(info.getTextStylePreferenceKey());
- }
- }
-
- /**
- * Checks correct access.
- *
- * @throws IllegalStateException if not called by {@link EditorsUI}
- * @since 3.0
- */
- private static void checkAccess() throws IllegalStateException {
- StackTraceElement[] elements= new Throwable().getStackTrace();
- if (!(elements[2].getClassName().equals(EditorsUI.class.getName())
- || elements[3].getClassName().equals(EditorsUI.class.getName())))
- throw new IllegalStateException();
- }
-
-
- /** The list of extension fragments. */
- private List fFragments;
- /** The list of extensions. */
- private List fPreferences;
-
- /**
- * Creates a new marker annotation preferences to access
- * marker annotation preferences.
- */
- 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;
- }
-
- /**
- * Returns all extensions provided for the <code>markerAnnotationSpecification</code>
- * extension point including fragments. Fragments share the preference part
- * with a marker annotation specifications provided for a super type but do
- * change the presentation part.
- *
- * @return all extensions provided for the <code>markerAnnotationSpecification</code>
- * extension point including fragments
- */
- public List getAnnotationPreferenceFragments() {
- if (fFragments == null)
- initialize();
- return fFragments;
- }
-
- /**
- * Reads all extensions provided for the <code>markerAnnotationSpecification</code> extension point and
- * translates them into <code>AnnotationPreference</code> objects.
- */
- private void initialize() {
-
- // initialize lists - indicates that the initialization happened
- fFragments= new ArrayList(2);
- fPreferences= new ArrayList(2);
-
- // populate list
- IExtensionPoint extensionPoint= Platform.getExtensionRegistry().getExtensionPoint(EditorsUI.PLUGIN_ID, "markerAnnotationSpecification"); //$NON-NLS-1$
- if (extensionPoint != null) {
- IConfigurationElement[] elements= extensionPoint.getConfigurationElements();
- for (int i= 0; i < elements.length; i++) {
- AnnotationPreference spec= createSpec(elements[i]);
- if (spec != null)
- fFragments.add(spec);
- if (isComplete(spec))
- fPreferences.add(spec);
- }
- }
-
- final Collator collator= Collator.getInstance();
- Collections.sort(fFragments, 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);
- }
- });
- }
-
- /**
- * Checks if <code>spec</code> has all the attributes previously required
- * by the marker annotation preference extension point. These are: color, text
- * and overview ruler preference keys.
- *
- * @param spec the <code>AnnotationPreference</code> to check
- * @return <code>true</code> if <code>spec</code> is complete, <code>false</code> otherwise
- * @since 3.0
- */
- private static boolean isComplete(AnnotationPreference spec) {
- return spec.getColorPreferenceKey() != null
- && spec.getColorPreferenceValue() != null
- && spec.getTextPreferenceKey() != null
- && spec.getOverviewRulerPreferenceKey() != null;
- }
-
- /**
- * 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)
- info.setPreferenceLabel(s);
-
- s= element.getAttribute("markerType"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
- info.setMarkerType(s);
-
- 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)
- info.setTextPreferenceKey(s);
-
- 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)
- info.setHighlightPreferenceKey(s);
-
- 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)
- info.setOverviewRulerPreferenceKey(s);
-
- 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)
- info.setVerticalRulerPreferenceKey(s);
-
- 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)
- info.setColorPreferenceKey(s);
-
- s= element.getAttribute("colorPreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
- RGB rgb= StringConverter.asRGB(s);
- info.setColorPreferenceValue(rgb == null ? new RGB(0,0,0) : rgb);
- }
-
- s= element.getAttribute("presentationLayer"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
- i= StringConverter.asInt(s, 0);
- info.setPresentationLayer(i);
- }
-
- 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)
- info.setShowInNextPrevDropdownToolbarActionKey(s);
-
- 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)
- info.setIsGoToNextNavigationTargetKey(s);
-
- 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)
- info.setIsGoToPreviousNavigationTargetKey(s);
-
- s= element.getAttribute("isGoToPreviousNavigationTarget"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
- b= StringConverter.asBoolean(s, false);
- info.setIsGoToPreviousNavigationTarget(b);
- }
-
- s= element.getAttribute("symbolicIcon"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
- info.setSymbolicImageName(s);
-
- s= element.getAttribute("icon"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
- info.setImageDescriptor(getImageDescriptor(s, element));
-
- s= element.getAttribute("annotationImageProvider"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
- info.setAnnotationImageProviderData(element, "annotationImageProvider"); //$NON-NLS-1$
-
- s= element.getAttribute("textStylePreferenceKey"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0)
- info.setTextStylePreferenceKey(s);
-
- s= element.getAttribute("textStylePreferenceValue"); //$NON-NLS-1$
- if (s != null && s.trim().length() > 0) {
-
- if (AnnotationPreference.STYLE_BOX.equals(s)
- || AnnotationPreference.STYLE_IBEAM.equals(s)
- || AnnotationPreference.STYLE_SQUIGGLES.equals(s)
- || AnnotationPreference.STYLE_UNDERLINE.equals(s))
- info.setTextStyleValue(s);
- else
- info.setTextStyleValue(AnnotationPreference.STYLE_NONE);
-
- }
-
- s= element.getAttribute("includeOnPreferencePage"); //$NON-NLS-1$
- info.setIncludeOnPreferencePage(s == null || StringConverter.asBoolean(s, true));
-
- return info;
- }
-
- /**
- * Returns the image descriptor for the icon path specified by the given configuration
- * element.
- *
- * @param iconPath the icon path
- * @param element the configuration element
- * @return the image descriptor
- * @since 3.0
- */
- private ImageDescriptor getImageDescriptor(String iconPath, IConfigurationElement element) {
- String pluginId= element.getDeclaringExtension().getNamespace();
- Bundle bundle= Platform.getBundle(pluginId);
- if (bundle == null)
- return null;
-
- try {
- return ImageDescriptor.createFromURL(new URL(bundle.getEntry("/"), iconPath)); //$NON-NLS-1$
- } catch (MalformedURLException x) {
- EditorsPlugin.log(x);
- }
- return null;
- }
-}
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
deleted file mode 100644
index 6fb18bc1e..000000000
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/texteditor/MarkerRulerAction.java
+++ /dev/null
@@ -1,458 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 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.osgi.framework.Bundle;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.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.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.window.Window;
-
-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.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 sub-classing.
- * </p>
- */
-public class MarkerRulerAction extends ResourceAction implements IUpdate {
-
- /** The maximum length of an proposed label. */
- private static final int MAX_LABEL_LENGTH= 80;
-
- /** 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 {@link org.eclipse.ui.texteditor.ResourceAction} 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(ResourceBundle, String)
- * @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 MarkerRulerA