Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ui.editors/src/org/eclipse/ui/editors/text')
-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
28 files changed, 0 insertions, 5966 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>

Back to the top