Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.ui.workbench.texteditor')
-rw-r--r--org.eclipse.ui.workbench.texteditor/.classpath7
-rw-r--r--org.eclipse.ui.workbench.texteditor/.cvsignore1
-rw-r--r--org.eclipse.ui.workbench.texteditor/.project31
-rw-r--r--org.eclipse.ui.workbench.texteditor/about.html30
-rw-r--r--org.eclipse.ui.workbench.texteditor/build.properties18
-rw-r--r--org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gifbin590 -> 0 bytes
-rw-r--r--org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gifbin241 -> 0 bytes
-rw-r--r--org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gifbin590 -> 0 bytes
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.properties158
-rw-r--r--org.eclipse.ui.workbench.texteditor/plugin.xml1079
-rw-r--r--org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd149
-rw-r--r--org.eclipse.ui.workbench.texteditor/scripts/exportplugin.xml32
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java238
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java82
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.properties14
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java305
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java795
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java87
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.java35
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties16
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java176
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java58
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java180
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java205
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java1405
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java93
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.java52
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties35
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java161
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java170
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java100
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java91
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java89
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java102
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.java79
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java349
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java62
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.java57
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.java60
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java110
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java289
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java555
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/package.html12
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html13
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java1028
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java147
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java5129
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java1058
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java273
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java112
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java167
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java122
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java273
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java175
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java179
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java353
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.java36
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorMessages.properties426
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/EditorStatusLine.java140
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindNextAction.java398
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceAction.java250
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceDialog.java1814
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/FindReplaceTarget.java222
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/GotoLineAction.java188
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAbstractTextEditorHelpContextIds.java301
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IAnnotationImageProvider.java55
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProvider.java220
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension.java115
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension2.java38
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IDocumentProviderExtension3.java29
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IEditorStatusLine.java35
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListener.java77
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IElementStateListenerExtension.java47
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IFindReplaceTargetExtension2.java29
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IReadOnlyDependent.java37
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ISchedulingRuleProvider.java30
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusField.java50
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IStatusFieldExtension.java65
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditor.java198
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionConstants.java418
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorActionDefinitionIds.java450
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorDropTargetListener.java32
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension.java65
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension2.java47
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ITextEditorExtension3.java72
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IUpdate.java24
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IWorkbenchActionDefinitionIds.java147
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindAction.java119
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/IncrementalFindTarget.java786
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java229
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InsertLineAction.java177
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkAction.java79
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MarkRegionTarget.java125
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/MoveLinesAction.java504
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/PropagatingFontFieldEditor.java29
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RegExContentAssistProcessor.java356
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ResourceAction.java149
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RetargetTextEditorAction.java239
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/RevertToSavedAction.java56
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SaveAction.java56
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SelectAnnotationRulerAction.java102
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ShiftAction.java161
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/SourceViewerDecorationSupport.java981
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusLineContributionItem.java288
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java197
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextEditorAction.java151
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextNavigationAction.java302
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextOperationAction.java156
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/TextSelectionNavigationLocation.java343
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ValidateStateException.java32
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/WorkbenchChainedTextFontFieldEditor.java70
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/link/EditorLinkedModeUI.java97
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/package.html30
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/IQuickDiffReferenceProvider.java78
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiff.java143
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/QuickDiffToggleAction.java211
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/ReferenceProviderDescriptor.java132
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/quickdiff/package.html13
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/EditTemplateDialog.java547
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/MessageLine.java82
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusDialog.java180
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/StatusInfo.java184
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateContentProvider.java51
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java820
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProcessor.java160
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplateVariableProposal.java109
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.java61
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TextEditorTemplateMessages.properties88
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/package.html113
129 files changed, 0 insertions, 31437 deletions
diff --git a/org.eclipse.ui.workbench.texteditor/.classpath b/org.eclipse.ui.workbench.texteditor/.classpath
deleted file mode 100644
index 065ac06e1..000000000
--- a/org.eclipse.ui.workbench.texteditor/.classpath
+++ /dev/null
@@ -1,7 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
diff --git a/org.eclipse.ui.workbench.texteditor/.cvsignore b/org.eclipse.ui.workbench.texteditor/.cvsignore
deleted file mode 100644
index c5e82d745..000000000
--- a/org.eclipse.ui.workbench.texteditor/.cvsignore
+++ /dev/null
@@ -1 +0,0 @@
-bin \ No newline at end of file
diff --git a/org.eclipse.ui.workbench.texteditor/.project b/org.eclipse.ui.workbench.texteditor/.project
deleted file mode 100644
index ba6f6a379..000000000
--- a/org.eclipse.ui.workbench.texteditor/.project
+++ /dev/null
@@ -1,31 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<projectDescription>
- <name>org.eclipse.ui.workbench.texteditor</name>
- <comment></comment>
- <projects>
- <project>org.eclipse.core.runtime.compatibility</project>
- <project>org.eclipse.jface.text</project>
- <project>org.eclipse.ui</project>
- </projects>
- <buildSpec>
- <buildCommand>
- <name>org.eclipse.jdt.core.javabuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.ManifestBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- <buildCommand>
- <name>org.eclipse.pde.SchemaBuilder</name>
- <arguments>
- </arguments>
- </buildCommand>
- </buildSpec>
- <natures>
- <nature>org.eclipse.pde.PluginNature</nature>
- <nature>org.eclipse.jdt.core.javanature</nature>
- </natures>
-</projectDescription>
diff --git a/org.eclipse.ui.workbench.texteditor/about.html b/org.eclipse.ui.workbench.texteditor/about.html
deleted file mode 100644
index 9db411aab..000000000
--- a/org.eclipse.ui.workbench.texteditor/about.html
+++ /dev/null
@@ -1,30 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
-<html>
-<head>
-<title>About</title>
-<meta http-equiv=Content-Type content="text/html; charset=ISO-8859-1">
-</head>
-<body lang="EN-US">
-<h2>About This Content</h2>
-
-<p>20th June, 2002</p>
-<h3>License</h3>
-<p>Eclipse.org makes available all content in this plug-in (&quot;Content&quot;). Unless otherwise indicated below, the Content is provided to you under the terms and conditions of the
-Common Public License Version 1.0 (&quot;CPL&quot;). A copy of the CPL is available at <a href="http://www.eclipse.org/legal/cpl-v10.html">http://www.eclipse.org/legal/cpl-v10.html</a>.
-For purposes of the CPL, &quot;Program&quot; will mean the Content.</p>
-
-<h3>Contributions</h3>
-
-<p>If this Content is licensed to you under the terms and conditions of the CPL, any Contributions, as defined in the CPL, uploaded, submitted, or otherwise
-made available to Eclipse.org, members of Eclipse.org and/or the host of Eclipse.org web site, by you that relate to such
-Content are provided under the terms and conditions of the CPL and can be made available to others under the terms of the CPL.</p>
-
-<p>If this Content is licensed to you under license terms and conditions other than the CPL (&quot;Other License&quot;), any modifications, enhancements and/or
-other code and/or documentation (&quot;Modifications&quot;) uploaded, submitted, or otherwise made available to Eclipse.org, members of Eclipse.org and/or the
-host of Eclipse.org, by you that relate to such Content are provided under terms and conditions of the Other License and can be made available
-to others under the terms of the Other License. In addition, with regard to Modifications for which you are the copyright holder, you are also
-providing the Modifications under the terms and conditions of the CPL and such Modifications can be made available to others under the terms of
-the CPL.</p>
-
-</body>
-</html> \ No newline at end of file
diff --git a/org.eclipse.ui.workbench.texteditor/build.properties b/org.eclipse.ui.workbench.texteditor/build.properties
deleted file mode 100644
index ddb08d5fb..000000000
--- a/org.eclipse.ui.workbench.texteditor/build.properties
+++ /dev/null
@@ -1,18 +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
-###############################################################################
-bin.includes = *.jar,\
- plugin.xml,\
- plugin.properties,\
- icons/,\
- about.html
-src.includes = about.html,\
- schema/
-source.texteditor.jar = src/
diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gif b/org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gif
deleted file mode 100644
index 1b50ff8d6..000000000
--- a/org.eclipse.ui.workbench.texteditor/icons/full/ctool16/segment_edit.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gif b/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gif
deleted file mode 100644
index e55a884d6..000000000
--- a/org.eclipse.ui.workbench.texteditor/icons/full/dtool16/segment_edit.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gif b/org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gif
deleted file mode 100644
index 1b50ff8d6..000000000
--- a/org.eclipse.ui.workbench.texteditor/icons/full/etool16/segment_edit.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.properties b/org.eclipse.ui.workbench.texteditor/plugin.properties
deleted file mode 100644
index c3b6c951a..000000000
--- a/org.eclipse.ui.workbench.texteditor/plugin.properties
+++ /dev/null
@@ -1,158 +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
-###############################################################################
-pluginName= Text Editor Framework
-providerName= Eclipse.org
-
-category.textEditor.name= Text Editing
-category.textEditor.description= Text Editing Commands
-
-ExtPoint.referenceProvider= Reference Provider
-
-textEditorPresentationActionSet.label= Editor Presentation
-
-onlyShowSelectedElement.label= Show Selected Element Only
-onlyShowSelectedElement.tooltip= Show Selected Element Only
-onlyShowSelectedElement.description= Show Selected Element Only
-
-smartEnter.label= Insert Line Below Current Line
-smartEnter.description= Adds a new line below the current line
-smartEnterInverse.label= Insert Line Above Current Line
-smartEnterInverse.description= Adds a new line above the current line
-moveLineUp.label= Move Lines Up
-moveLineUp.description= Moves the selected lines up
-moveLineDown.label= Move Lines Down
-moveLineDown.description= Moves the selected lines down
-copyLineUp.label= Duplicate Lines
-copyLineUp.description= Duplicates the selected lines and leaves the selection unchanged
-copyLineDown.label= Copy Lines
-copyLineDown.description= Duplicates the selected lines and moves the selection to the copy
-upperCase.description= Changes the selection to upper case
-upperCase.label= To Upper Case
-lowerCase.description= Changes the selection to lower case
-lowerCase.label= To Lower Case
-
-goToLastEditPosition.label= Last Edit Location
-goToLastEditPosition.description= Last edit location
-
-command.clearMark.description = Clear the mark
-command.clearMark.name = Clear Mark
-command.contentAssistContextInformation.description= Show Context Information
-command.contentAssistContextInformation.name= Context Information
-command.contentAssistProposals.description= Content Assist
-command.contentAssistProposals.name= Content Assist
-command.deleteLine.description = Delete a line of text
-command.deleteLine.name = Delete Line
-command.cutLine.description = Cut a line of text
-command.cutLine.name = Cut Line
-command.deleteLineBeginning.description = Delete to the beginning of a line of text
-command.deleteLineBeginning.name = Delete to Beginning of Line
-command.cutLineBeginning.description = Cut to the beginning of a line of text
-command.cutLineBeginning.name = Cut to Beginning of Line
-command.deleteLineEnd.description = Delete to the end of a line of text
-command.deleteLineEnd.name = Delete to End of Line
-command.cutLineEnd.description = Cut to the end of a line of text
-command.cutLineEnd.name = Cut to End of Line
-command.deleteNext.description = Delete the next character
-command.deleteNext.name = Delete Next
-command.deletePreviousWord.description = Delete the previous word
-command.deletePreviousWord.name = Delete Previous Word
-command.deleteNextWord.description = Delete the next word
-command.deleteNextWord.name = Delete Next Word
-command.deletePrevious.description = Delete the previous character
-command.deletePrevious.name = Delete Previous
-command.findIncremental.description = Incremental find
-command.findIncremental.name = Incremental Find
-command.findIncrementalReverse.description = Incremental find reverse
-command.findIncrementalReverse.name = Incremental Find Reverse
-command.findNext.description = Find next item
-command.findNext.name = Find Next
-command.findPrevious.description = Find previous item
-command.findPrevious.name = Find Previous
-command.goToLine.description = Go to a specified line of text
-command.goToLine.name = Go to Line
-command.lineDown.description = Go down one line of text
-command.lineDown.name = Line Down
-command.lineEnd.description = Go to the end of the line of text
-command.lineEnd.name = Line End
-command.lineStart.description = Go to the start of the line of text
-command.lineStart.name = Line Start
-command.lineUp.description = Go up one line of text
-command.lineUp.name = Line Up
-command.nextColumn.description = Go to the next column
-command.nextColumn.name = Next Column
-command.nextWord.description = Go to the next word
-command.nextWord.name = Next Word
-command.pageDown.description = Go down one page
-command.pageDown.name = Page Down
-command.pageUp.description = Go up one page
-command.pageUp.name = Page Up
-command.previousColumn.description = Go to the previous column
-command.previousColumn.name = Previous Column
-command.previousWord.description = Go to the previous word
-command.previousWord.name = Previous Word
-command.revertToSaved.description = Revert to the last saved state
-command.revertToSaved.name = Revert to Saved
-command.scrollLineDown.description = Scroll down one line of text
-command.scrollLineDown.name = Scroll Line Down
-command.scrollLineUp.description = Scroll up one line of text
-command.scrollLineUp.name = Scroll Line Up
-command.selectAll.description = Select all
-command.selectAll.name = Select All
-command.selectLineDown.description = Extend the selection to the next line of text
-command.selectLineDown.name = Select Line Down
-command.selectLineEnd.description = Select to the end of the line of text
-command.selectLineEnd.name = Select Line End
-command.selectLineStart.description = Select to the beginning of the line of text
-command.selectLineStart.name = Select Line Start
-command.selectLineUp.description = Extend the selection to the previous line of text
-command.selectLineUp.name = Select Line Up
-command.selectNextColumn.description = Select the next column
-command.selectNextColumn.name = Select Next Column
-command.selectPageDown.description = Select to the bottom of the page
-command.selectPageDown.name = Select Page Down
-command.selectPageUp.description = Select to the top of the page
-command.selectPageUp.name = Select Page Up
-command.selectPreviousColumn.description = Select the previous column
-command.selectPreviousColumn.name = Select Previous Column
-command.selectTextEnd.description = Select to the end of the text
-command.selectTextEnd.name = Select Text End
-command.selectTextStart.description = Select to the beginning of the text
-command.selectTextStart.name = Select Text Start
-command.selectWindowEnd.description = Select to the end of the window
-command.selectWindowEnd.name = Select Window End
-command.selectWindowStart.description = Select to the start of the window
-command.selectWindowStart.name = Select Window Start
-command.selectWordNext.description = Select the next word
-command.selectWordNext.name = Select Next Word
-command.selectWordPrevious.description = Select the previous word
-command.selectWordPrevious.name = Select Previous Word
-command.setMark.description = Set the mark
-command.setMark.name = Set Mark
-command.shiftLeft.description = Shift a block of text to the left
-command.shiftLeft.name = Shift Left
-command.shiftRight.description = Shift a block of text to the right
-command.shiftRight.name = Shift Right
-command.showRulerContextMenu.description = Show the context menu for the ruler
-command.showRulerContextMenu.name = Show Ruler Context Menu
-command.swapMark.description = Swap the mark with the cursor position
-command.swapMark.name = Swap Mark
-command.textEnd.description = Go to the end of the text
-command.textEnd.name = Text End
-command.textStart.description = Go to the beginning of the text
-command.textStart.name = Text Start
-command.toggleOverwrite.description = Toggle overwrite mode
-command.toggleOverwrite.name = Toggle Overwrite
-command.toggleInsertMode.description = Toggle insert mode
-command.toggleInsertMode.name = Toggle Insert Mode
-command.windowEnd.description = Go to the end of the window
-command.windowEnd.name = Window End
-command.windowStart.description = Go to the start of the window
-command.windowStart.name = Window Start
diff --git a/org.eclipse.ui.workbench.texteditor/plugin.xml b/org.eclipse.ui.workbench.texteditor/plugin.xml
deleted file mode 100644
index 987ab3d47..000000000
--- a/org.eclipse.ui.workbench.texteditor/plugin.xml
+++ /dev/null
@@ -1,1079 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.ui.workbench.texteditor"
- name="%pluginName"
- version="3.0.0"
- provider-name="%providerName"
- class="org.eclipse.ui.internal.texteditor.TextEditorPlugin">
-
- <runtime>
- <library name="texteditor.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.jface.text"/>
- <import plugin="org.eclipse.ui"/>
- </requires>
-
-
- <extension-point id="quickDiffReferenceProvider" name="%ExtPoint.referenceProvider" schema="schema/quickDiffReferenceProvider.exsd"/>
-
-
- <extension
- point="org.eclipse.ui.commands">
- <category
- name="%category.textEditor.name"
- description="%category.textEditor.description"
- id="org.eclipse.ui.category.textEditor">
- </category>
- <command
- name="%command.deleteLine.name"
- description="%command.deleteLine.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.delete.line">
- </command>
- <command
- name="%command.cutLine.name"
- description="%command.cutLine.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.cut.line">
- </command>
- <command
- name="%command.deleteLineBeginning.name"
- description="%command.deleteLineBeginning.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.delete.line.to.beginning">
- </command>
- <command
- name="%command.cutLineBeginning.name"
- description="%command.cutLineBeginning.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.cut.line.to.beginning">
- </command>
- <command
- name="%command.deleteLineEnd.name"
- description="%command.deleteLineEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.delete.line.to.end">
- </command>
- <command
- name="%command.cutLineEnd.name"
- description="%command.cutLineEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.cut.line.to.end">
- </command>
- <command
- name="%command.setMark.name"
- description="%command.setMark.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.set.mark">
- </command>
- <command
- name="%command.clearMark.name"
- description="%command.clearMark.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.clear.mark">
- </command>
- <command
- name="%command.swapMark.name"
- description="%command.swapMark.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.swap.mark">
- </command>
- <command
- name="%command.findNext.name"
- description="%command.findNext.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.findNext">
- </command>
- <command
- name="%command.findPrevious.name"
- description="%command.findPrevious.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.findPrevious">
- </command>
- <command
- name="%command.findIncremental.name"
- description="%command.findIncremental.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.findIncremental">
- </command>
- <command
- name="%command.findIncrementalReverse.name"
- description="%command.findIncrementalReverse.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.findIncrementalReverse">
- </command>
- <command
- name="%command.revertToSaved.name"
- description="%command.revertToSaved.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.revertToSaved">
- </command>
- <command
- name="%command.lineUp.name"
- description="%command.lineUp.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.lineUp">
- </command>
- <command
- name="%command.lineDown.name"
- description="%command.lineDown.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.lineDown">
- </command>
- <command
- name="%command.lineStart.name"
- description="%command.lineStart.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.lineStart">
- </command>
- <command
- name="%command.lineEnd.name"
- description="%command.lineEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.lineEnd">
- </command>
- <command
- name="%command.goToLine.name"
- description="%command.goToLine.description"
- categoryId="org.eclipse.ui.category.navigate"
- id="org.eclipse.ui.edit.text.goto.line">
- </command>
- <command
- name="%command.previousColumn.name"
- description="%command.previousColumn.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.columnPrevious">
- </command>
- <command
- name="%command.nextColumn.name"
- description="%command.nextColumn.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.columnNext">
- </command>
- <command
- name="%command.pageUp.name"
- description="%command.pageUp.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.pageUp">
- </command>
- <command
- name="%command.pageDown.name"
- description="%command.pageDown.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.pageDown">
- </command>
- <command
- name="%command.previousWord.name"
- description="%command.previousWord.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.wordPrevious">
- </command>
- <command
- name="%command.nextWord.name"
- description="%command.nextWord.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.wordNext">
- </command>
- <command
- name="%command.textStart.name"
- description="%command.textStart.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.textStart">
- </command>
- <command
- name="%command.textEnd.name"
- description="%command.textEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.textEnd">
- </command>
- <command
- name="%command.windowStart.name"
- description="%command.windowStart.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.windowStart">
- </command>
- <command
- name="%command.windowEnd.name"
- description="%command.windowEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.goto.windowEnd">
- </command>
- <command
- name="%command.scrollLineUp.name"
- description="%command.scrollLineUp.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.scroll.lineUp">
- </command>
- <command
- name="%command.scrollLineDown.name"
- description="%command.scrollLineDown.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.scroll.lineDown">
- </command>
- <command
- name="%command.selectLineUp.name"
- description="%command.selectLineUp.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.lineUp">
- </command>
- <command
- name="%command.selectLineDown.name"
- description="%command.selectLineDown.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.lineDown">
- </command>
- <command
- name="%command.selectLineStart.name"
- description="%command.selectLineStart.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.lineStart">
- </command>
- <command
- name="%command.selectLineEnd.name"
- description="%command.selectLineEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.lineEnd">
- </command>
- <command
- name="%command.selectPreviousColumn.name"
- description="%command.selectPreviousColumn.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.columnPrevious">
- </command>
- <command
- name="%command.selectNextColumn.name"
- description="%command.selectNextColumn.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.columnNext">
- </command>
- <command
- name="%command.selectPageUp.name"
- description="%command.selectPageUp.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.pageUp">
- </command>
- <command
- name="%command.selectPageDown.name"
- description="%command.selectPageDown.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.pageDown">
- </command>
- <command
- name="%command.selectWordPrevious.name"
- description="%command.selectWordPrevious.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.wordPrevious">
- </command>
- <command
- name="%command.selectWordNext.name"
- description="%command.selectWordNext.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.wordNext">
- </command>
- <command
- name="%command.selectTextStart.name"
- description="%command.selectTextStart.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.textStart">
- </command>
- <command
- name="%command.selectTextEnd.name"
- description="%command.selectTextEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.textEnd">
- </command>
- <command
- name="%command.selectWindowStart.name"
- description="%command.selectWindowStart.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.windowStart">
- </command>
- <command
- name="%command.selectWindowEnd.name"
- description="%command.selectWindowEnd.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.select.windowEnd">
- </command>
- <command
- name="%command.deletePrevious.name"
- description="%command.deletePrevious.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.deletePrevious">
- </command>
- <command
- name="%command.deleteNext.name"
- description="%command.deleteNext.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.deleteNext">
- </command>
- <command
- name="%command.deletePreviousWord.name"
- description="%command.deletePreviousWord.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.deletePreviousWord">
- </command>
- <command
- name="%command.deleteNextWord.name"
- description="%command.deleteNextWord.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.deleteNextWord">
- </command>
- <command
- name="%command.shiftRight.name"
- description="%command.shiftRight.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.text.shiftRight">
- </command>
- <command
- name="%command.shiftLeft.name"
- description="%command.shiftLeft.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.text.shiftLeft">
- </command>
- <command
- name="%command.toggleOverwrite.name"
- description="%command.toggleOverwrite.description"
- categoryId="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.toggleOverwrite">
- </command>
- <command
- name="%command.showRulerContextMenu.name"
- description="%command.showRulerContextMenu.description"
- categoryId="org.eclipse.ui.category.window"
- id="org.eclipse.ui.edit.text.showRulerContextMenu">
- </command>
- <command
- name="%goToLastEditPosition.label"
- description="%goToLastEditPosition.description"
- category="org.eclipse.ui.category.navigate"
- id="org.eclipse.ui.edit.text.gotoLastEditPosition">
- </command>
- <command
- name="%smartEnter.label"
- description="%smartEnter.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.smartEnter">
- </command>
- <command
- name="%smartEnterInverse.label"
- description="%smartEnterInverse.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.smartEnterInverse">
- </command>
- <command
- name="%moveLineUp.label"
- description="%moveLineUp.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.moveLineUp">
- </command>
- <command
- name="%moveLineDown.label"
- description="%moveLineDown.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.moveLineDown">
- </command>
- <command
- name="%copyLineUp.label"
- description="%copyLineUp.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.copyLineUp">
- </command>
- <command
- name="%copyLineDown.label"
- description="%copyLineDown.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.copyLineDown">
- </command>
- <command
- name="%upperCase.label"
- description="%upperCase.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.upperCase">
- </command>
- <command
- name="%lowerCase.label"
- description="%lowerCase.description"
- category="org.eclipse.ui.category.textEditor"
- id="org.eclipse.ui.edit.text.lowerCase">
- </command>
- <command
- name="%onlyShowSelectedElement.label"
- description="%onlyShowSelectedElement.description"
- category="org.eclipse.ui.category.window"
- id="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly">
- </command>
- <command
- name="%command.contentAssistProposals.name"
- description="%command.contentAssistProposals.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.text.contentAssist.proposals">
- </command>
- <command
- name="%command.contentAssistContextInformation.name"
- description="%command.contentAssistContextInformation.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.text.contentAssist.contextInformation">
- </command>
- <command
- name="%command.toggleInsertMode.name"
- description="%command.toggleInsertMode.description"
- categoryId="org.eclipse.ui.category.edit"
- id="org.eclipse.ui.edit.text.toggleInsertMode">
- </command>
-
- <keyBinding
- commandId="org.eclipse.ui.edit.text.delete.line"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+D">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.delete.line.to.end"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+Delete">
- </keyBinding>
- <keyBinding
- platform="gtk"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+Delete">
- </keyBinding>
- <keyBinding
- platform="gtk"
- commandId="org.eclipse.ui.edit.text.delete.line.to.end"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Esc Ctrl+Delete">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.findNext"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+K">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.findPrevious"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+K">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.findIncremental"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+J">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.findIncrementalReverse"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+J">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.line"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+L">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.scroll.lineUp"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Arrow_Up">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.scroll.lineDown"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Arrow_Down">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.toggleOverwrite"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Insert">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.showRulerContextMenu"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+F10">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.contentAssist.proposals"
- contextId="org.eclipse.ui.contexts.dialogAndWindow"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Space">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+Space">
- </keyBinding>
- <keyBinding
- string="Ctrl+Q"
- scope="org.eclipse.ui.globalScope"
- command="org.eclipse.ui.edit.text.gotoLastEditPosition"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Shift+ENTER"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.smartEnter"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+ENTER"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.smartEnterInverse"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Alt+ARROW_UP"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.moveLineUp"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Alt+ARROW_DOWN"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.moveLineDown"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Alt+Ctrl+ARROW_UP"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.copyLineUp"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Alt+Ctrl+ARROW_DOWN"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.copyLineDown"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+X"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.upperCase"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+Y"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.lowerCase"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string=""
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Arrow_Right"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.goto.wordNext"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Arrow_Left"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.goto.wordPrevious"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Delete"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.deleteNextWord"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Backspace"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.deletePreviousWord"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+Arrow_Right"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.select.wordNext"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+Arrow_Left"
- scope="org.eclipse.ui.textEditorScope"
- command="org.eclipse.ui.edit.text.select.wordPrevious"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- locale="zh"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Space">
- </keyBinding>
- <keyBinding
- locale="zh"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+Space">
- </keyBinding>
- <keyBinding
- locale="zh"
- commandId="org.eclipse.ui.edit.text.contentAssist.proposals"
- contextId="org.eclipse.ui.contexts.dialogAndWindow"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Alt+/">
- </keyBinding>
- <keyBinding
- locale="zh"
- commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Alt+?">
- </keyBinding>
- <keyBinding
- locale="zh"
- commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Alt+Shift+?">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+D">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+Delete">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+K">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+K">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+J">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Shift+J">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+L">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Arrow_Up">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+Arrow_Down">
- </keyBinding>
- <keyBinding
- platform="carbon"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Ctrl+F10">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.showRulerContextMenu"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+F10">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.delete.line"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+D">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.delete.line.to.end"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+Shift+Delete">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.findNext"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+K">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.findPrevious"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Command+Shift+K">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.findIncremental"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+J">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.findIncrementalReverse"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+Shift+J">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.goto.line"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+L">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.scroll.lineUp"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+Arrow_Up">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.scroll.lineDown"
- contextId="org.eclipse.ui.textEditorScope"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+Arrow_Down">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.contentAssist.proposals"
- contextId="org.eclipse.ui.contexts.dialogAndWindow"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+Space">
- </keyBinding>
- <keyBinding
- platform="carbon"
- commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration"
- keySequence="Command+Shift+Space">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.toggleInsertMode"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+Shift+Insert"
- keyConfigurationId="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.cut.line.to.beginning"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+0 Ctrl+K"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.cut.line.to.beginning"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc 0 Ctrl+K"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.cut.line.to.end"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+K"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.set.mark"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+Space"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.set.mark"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+2"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.clear.mark"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+G"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.swap.mark"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+X Ctrl+X"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.findIncremental"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+S"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.findIncrementalReverse"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+R"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.lineUp"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+P"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.lineDown"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+N"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.lineStart"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+A"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.lineEnd"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+E"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.line"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+X G"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.columnPrevious"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+B"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.columnNext"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+F"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.pageUp"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+V"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.pageUp"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc V"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.pageDown"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+V"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.wordPrevious"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+B"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.wordPrevious"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc B"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.wordNext"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+F"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.wordNext"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc F"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textStart"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+&lt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textStart"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+Shift+&lt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textStart"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc &lt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textStart"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc Shift+&lt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textStart"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+X ["
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textEnd"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+&gt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textEnd"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+Shift+&gt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textEnd"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc &gt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textEnd"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc Shift+&gt;"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.goto.textEnd"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+X ]"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.scroll.lineUp"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+Z"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.scroll.lineUp"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc Z"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.scroll.lineDown"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+Z"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.deleteNext"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Ctrl+D"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.deletePreviousWord"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+Bs"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.deletePreviousWord"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc Bs"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.deleteNextWord"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Alt+D"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.deleteNextWord"
- contextId="org.eclipse.ui.textEditorScope"
- keySequence="Esc D"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.contentAssist.proposals"
- contextId="org.eclipse.ui.contexts.dialogAndWindow"
- keySequence="Alt+/"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation"
- keySequence="Alt+?"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- commandId="org.eclipse.ui.edit.text.contentAssist.contextInformation"
- keySequence="Alt+Shift+?"
- keyConfigurationId="org.eclipse.ui.emacsAcceleratorConfiguration">
- </keyBinding>
- </extension>
-
- <extension
- point="org.eclipse.ui.actionSets">
- <actionSet
- label="%textEditorPresentationActionSet.label"
- visible="false"
- id="org.eclipse.ui.edit.text.actionSet.presentation">
- <action
- allowLabelUpdate="true"
- style="toggle"
- toolbarPath="Normal/Presentation"
- id="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"
- hoverIcon="icons/full/ctool16/segment_edit.gif"
- definitionId="org.eclipse.ui.edit.text.toggleShowSelectedElementOnly"
- disabledIcon="icons/full/dtool16/segment_edit.gif"
- icon="icons/full/etool16/segment_edit.gif"
- helpContextId="only_show_selected_element_action_context"
- label="%onlyShowSelectedElement.label"
- retarget="true"
- tooltip="%onlyShowSelectedElement.tooltip">
- </action>
- </actionSet>
- </extension>
-</plugin>
diff --git a/org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd b/org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd
deleted file mode 100644
index 7e26c6d92..000000000
--- a/org.eclipse.ui.workbench.texteditor/schema/quickDiffReferenceProvider.exsd
+++ /dev/null
@@ -1,149 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.ui.workbench.texteditor">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.ui.workbench.texteditor" id="quickdiffReferenceProvider" name="Reference Provider"/>
- </appInfo>
- <documentation>
- Allows contributors to add reference providers for the quick diff display.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <sequence>
- <element ref="referenceprovider" minOccurs="1" maxOccurs="unbounded"/>
- </sequence>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
- The fully qualified name of the extension point.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
- The optional id of this extension.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
- The optional name of this extension.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="referenceprovider">
- <annotation>
- <appInfo>
- <meta.element labelAttribute="name"/>
- </appInfo>
- <documentation>
- The definition of a reference provider for the quick diff display.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- The class of the reference provider, which must implement &lt;code&gt;org.eclipse.ui.editors.quickdiff.IQuickDiffReferenceProvider&lt;/code&gt;.
- </documentation>
- <appInfo>
- <meta.attribute kind="java"/>
- </appInfo>
- </annotation>
- </attribute>
- <attribute name="label" type="string">
- <annotation>
- <documentation>
- The display label for the provider, which will show up in the menu that allows the user to set the quick diff reference to this provider.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string" use="required">
- <annotation>
- <documentation>
- A string uniquely identifying this reference provider.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="default" type="boolean">
- <annotation>
- <documentation>
- If this flag is set to &lt;code&gt;true&lt;/code&gt;, this reference provider will be installed per default the first time quick diff is enabled for a document. If multiple providers are installed with the flag set are encountered, the first one is taken.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- The following is an example of a reference provider definition. It contributes a provider that uses the version of a document saved on disk as a reference.
-
-&lt;p&gt;
-&lt;pre&gt;
- &lt;extension point=&quot;quickdiff.referenceprovider&quot;&gt;
- &lt;referenceprovider
- id=&quot;default&quot;
- name=&quot;%LastSavedProvider.name&quot;
- label=&quot;%quickdiff.referenceprovider.label&quot;
- class=&quot;org.eclipse.ui.internal.editors.quickdiff.providers.LastSaveReferenceProvider&quot;&gt;
- &lt;/referenceprovider&gt;
- &lt;/extension&gt;
-&lt;/pre&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
- There is no additional API for managing reference providers.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- The &lt;code&gt;org.eclipse.ui.editors&lt;/code&gt; plugin contributes &lt;code&gt;LastSaveReferenceProvider&lt;/code&gt;. See its implementation as an example.
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
- &lt;p&gt;
-&lt;a href=&quot;hglegal.htm&quot;&gt;
- &lt;img SRC=&quot;ngibmcpy.gif&quot;
- ALT=&quot;Copyright (c) 2000, 2003 IBM Corporation and others. All Rights Reserved.&quot;
- BORDER=0 height=14 width=324&gt;&lt;/a&gt;
-&lt;/p&gt;
- </documentation>
- </annotation>
-
-</schema>
diff --git a/org.eclipse.ui.workbench.texteditor/scripts/exportplugin.xml b/org.eclipse.ui.workbench.texteditor/scripts/exportplugin.xml
deleted file mode 100644
index f6a1c5c73..000000000
--- a/org.eclipse.ui.workbench.texteditor/scripts/exportplugin.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<project name="Export Workbench Text Editor Fragment" default="export" basedir="..">
- <target name="init">
- <tstamp/>
- <property name="destdir" value="../../plugin-export" />
- <property name="plugin" value="org.eclipse.ui.workbench.texteditor" />
- <property name="version" value="_3.0.0" />
- <property name="dest" value="${destdir}/${plugin}${version}" />
- </target>
-
- <target name="build" depends="init">
- <eclipse.incrementalBuild project="${plugin}" kind="incr"/>
- </target>
-
- <target name="export" depends="build">
- <mkdir dir="${destdir}" />
- <delete dir="${dest}" />
- <mkdir dir="${dest}" />
- <jar
- jarfile="${dest}/texteditor.jar"
- basedir="bin"
- />
- <copy file="plugin.xml" todir="${dest}"/>
- <copy file="plugin.properties" todir="${dest}"/>
- <copy todir= "${dest}/icons">
- <fileset dir="icons"/>
- </copy>
- <zip zipfile="${dest}/texteditorsrc.jar">
- <fileset dir="src" />
- </zip>
- </target>
-
-</project> \ No newline at end of file
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java
deleted file mode 100644
index 0689fe5a9..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistHandler.java
+++ /dev/null
@@ -1,238 +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.contentassist;
-
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-
-import org.eclipse.jface.contentassist.AbstractControlContentAssistSubjectAdapter;
-import org.eclipse.jface.contentassist.ComboContentAssistSubjectAdapter;
-import org.eclipse.jface.contentassist.SubjectControlContentAssistant;
-import org.eclipse.jface.contentassist.TextContentAssistSubjectAdapter;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.commands.AbstractHandler;
-import org.eclipse.ui.commands.ExecutionException;
-import org.eclipse.ui.commands.HandlerSubmission;
-import org.eclipse.ui.commands.ICommand;
-import org.eclipse.ui.commands.ICommandManager;
-import org.eclipse.ui.commands.IHandler;
-import org.eclipse.ui.commands.IKeySequenceBinding;
-import org.eclipse.ui.commands.IWorkbenchCommandSupport;
-import org.eclipse.ui.commands.Priority;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-
-/**
- * A content assistant handler which handles the key binding and
- * the cue for a {@link org.eclipse.jface.text.contentassist.ContentAssistant}
- * and its subject adapter.
- *
- * @since 3.0
- */
-public class ContentAssistHandler {
- /**
- * The target control.
- */
- private Control fControl;
- /**
- * The content assist subject adapter.
- */
- private AbstractControlContentAssistSubjectAdapter fContentAssistSubjectAdapter;
- /**
- * The content assistant.
- */
- private SubjectControlContentAssistant fContentAssistant;
- /**
- * The currently installed HandlerSubmission, or <code>null</code> iff none installed.
- * This is also used as flag to tell whether content assist is enabled
- */
- private FocusListener fFocusListener;
- /**
- * The currently installed HandlerSubmission, or <code>null</code> iff none installed.
- */
- private HandlerSubmission fHandlerSubmission;
-
- /**
- * Creates a new {@link ContentAssistHandler} for the given {@link Combo}.
- * Only a single {@link ContentAssistHandler} may be installed on a {@link Combo} instance.
- * Content Assist is enabled by default.
- *
- * @param combo target combo
- * @param contentAssistant a configured content assistant
- * @return a new {@link ContentAssistHandler}
- */
- public static ContentAssistHandler createHandlerForCombo(Combo combo, SubjectControlContentAssistant contentAssistant) {
- return new ContentAssistHandler(combo, new ComboContentAssistSubjectAdapter(combo), contentAssistant);
- }
-
- /**
- * Creates a new {@link ContentAssistHandler} for the given {@link Text}.
- * Only a single {@link ContentAssistHandler} may be installed on a {@link Text} instance.
- * Content Assist is enabled by default.
- *
- * @param text target text
- * @param contentAssistant a configured content assistant
- * @return a new {@link ContentAssistHandler}
- */
- public static ContentAssistHandler createHandlerForText(Text text, SubjectControlContentAssistant contentAssistant) {
- return new ContentAssistHandler(text, new TextContentAssistSubjectAdapter(text), contentAssistant);
- }
-
- /**
- * Internal constructor.
- *
- * @param control target control
- * @param subjectAdapter content assist subject adapter
- * @param contentAssistant content assistant
- */
- private ContentAssistHandler(
- Control control,
- AbstractControlContentAssistSubjectAdapter subjectAdapter,
- SubjectControlContentAssistant contentAssistant) {
- fControl= control;
- fContentAssistant= contentAssistant;
- fContentAssistSubjectAdapter= subjectAdapter;
- setEnabled(true);
- fControl.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- setEnabled(false);
- }
- });
- }
-
- /**
- * @return <code>true</code> iff content assist is enabled
- */
- public boolean isEnabled() {
- return fFocusListener != null;
- }
-
- /**
- * Controls enablement of content assist.
- * When enabled, a cue is shown next to the focused field
- * and the affordance hover shows the shortcut.
- *
- * @param enable enable content assist iff true
- */
- public void setEnabled(boolean enable) {
- if (enable == isEnabled())
- return;
-
- if (enable)
- enable();
- else
- disable();
- }
-
- /**
- * Enable content assist.
- */
- private void enable() {
- if (! fControl.isDisposed()) {
- fContentAssistant.install(fContentAssistSubjectAdapter);
- installCueLabelProvider();
- installFocusListener();
- if (fControl.isFocusControl())
- activateHandler();
- }
- }
-
- /**
- * Disable content assist.
- */
- private void disable() {
- if (! fControl.isDisposed()) {
- fContentAssistant.uninstall();
- fContentAssistSubjectAdapter.setContentAssistCueProvider(null);
- fControl.removeFocusListener(fFocusListener);
- fFocusListener= null;
- if (fHandlerSubmission != null)
- deactivateHandler();
- }
- }
-
- /**
- * Create and install the {@link LabelProvider} for fContentAssistSubjectAdapter.
- */
- private void installCueLabelProvider() {
- ILabelProvider labelProvider= new LabelProvider() {
- /**
- * @inheritDoc
- */
- public String getText(Object element) {
- ICommandManager commandManager= PlatformUI.getWorkbench().getCommandSupport().getCommandManager();
- ICommand command= commandManager.getCommand(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- List bindings= command.getKeySequenceBindings();
- if (bindings.size() == 0) {
- return ContentAssistMessages.getString("ContentAssistHandler.contentAssistAvailable"); //$NON-NLS-1$
- } else {
- IKeySequenceBinding ksb= (IKeySequenceBinding) bindings.get(0);
- Object[] args= { ksb.getKeySequence().format() };
- return ContentAssistMessages.getFormattedString("ContentAssistHandler.contentAssistAvailableWithKeyBinding", args); //$NON-NLS-1$
- }
- }
- };
- fContentAssistSubjectAdapter.setContentAssistCueProvider(labelProvider);
- }
-
- /**
- * Create fFocusListener and install it on fControl.
- */
- private void installFocusListener() {
- fFocusListener= new FocusListener() {
- public void focusGained(final FocusEvent e) {
- activateHandler();
- }
- public void focusLost(FocusEvent e) {
- if (fHandlerSubmission != null)
- deactivateHandler();
- }
- };
- fControl.addFocusListener(fFocusListener);
- }
-
- /**
- * Create and register fHandlerSubmission.
- */
- private void activateHandler() {
- final IHandler handler= new AbstractHandler() {
- public Object execute(Map parameterValuesByName) throws ExecutionException {
- if (isEnabled())
- fContentAssistant.showPossibleCompletions();
- return null;
- }
- };
- fHandlerSubmission= new HandlerSubmission(null, fControl.getShell(), null,
- ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS, handler, Priority.MEDIUM);
- IWorkbenchCommandSupport commandSupport= PlatformUI.getWorkbench().getCommandSupport();
- commandSupport.addHandlerSubmission(fHandlerSubmission);
- }
-
- /**
- * Unregister the {@link HandlerSubmission} from the shell.
- */
- private void deactivateHandler() {
- IWorkbenchCommandSupport commandSupport= PlatformUI.getWorkbench().getCommandSupport();
- commandSupport.removeHandlerSubmission(fHandlerSubmission);
- fHandlerSubmission= null;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java
deleted file mode 100644
index b992262a2..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.java
+++ /dev/null
@@ -1,82 +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.contentassist;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-
-/**
- * Helper class to get NLSed messages.
- *
- * @since 3.0
- */
-class ContentAssistMessages {
-
- private static final String RESOURCE_BUNDLE= ContentAssistMessages.class.getName();
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private ContentAssistMessages() {
- }
-
- /**
- * Gets a string from the resource bundle.
- *
- * @param key the string used to get the bundle value, must not be null
- * @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 arguments.
- *
- * @param key the string used to get the bundle value, must not be null
- * @param args the arguments used to format the string
- * @return the formatted string
- */
- public static String getFormattedString(String key, Object[] args) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- return MessageFormat.format(format, args);
- }
-
- /**
- * Gets a string from the resource bundle and formats it with the 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
- */
- public static String getFormattedString(String key, Object arg) {
- String format= null;
- try {
- format= fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- if (arg == null)
- arg= ""; //$NON-NLS-1$
- return MessageFormat.format(format, new Object[] { arg });
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.properties
deleted file mode 100644
index 4e4f8b1f6..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/contentassist/ContentAssistMessages.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
-###############################################################################
-
-
-ContentAssistHandler.contentAssistAvailable= Content Assist Available
-ContentAssistHandler.contentAssistAvailableWithKeyBinding= Content Assist Available ({0})
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java
deleted file mode 100644
index 7c8094e7e..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpandHover.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.viewers.IDoubleClickListener;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IInformationControlCreatorExtension;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.CompositeRuler;
-import org.eclipse.jface.text.source.IAnnotationAccess;
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.IAnnotationHoverExtension;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ILineRange;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRulerListener;
-import org.eclipse.jface.text.source.LineRange;
-import org.eclipse.jface.text.source.VerticalRulerEvent;
-
-import org.eclipse.ui.internal.texteditor.AnnotationExpansionControl.AnnotationHoverInput;
-
-/**
- * @since 3.0
- */
-public class AnnotationExpandHover implements IAnnotationHover, IAnnotationHoverExtension {
-
- private class InformationControlCreator implements IInformationControlCreator, IInformationControlCreatorExtension {
-
- /*
- * @see org.eclipse.jface.text.IInformationControlCreator#createInformationControl(org.eclipse.swt.widgets.Shell)
- */
- public IInformationControl createInformationControl(Shell parent) {
- return new AnnotationExpansionControl(parent, SWT.NONE, fAnnotationAccess);
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReuse(org.eclipse.jface.text.IInformationControl)
- */
- public boolean canReuse(IInformationControl control) {
- return control instanceof AnnotationExpansionControl;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlCreatorExtension#canReplace(org.eclipse.jface.text.IInformationControlCreator)
- */
- public boolean canReplace(IInformationControlCreator creator) {
- return creator == this;
- }
- }
-
- private class VerticalRulerListener implements IVerticalRulerListener {
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationSelected(org.eclipse.jface.text.source.VerticalRulerEvent)
- */
- public void annotationSelected(VerticalRulerEvent event) {
- fCompositeRuler.fireAnnotationSelected(event);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationDefaultSelected(org.eclipse.jface.text.source.VerticalRulerEvent)
- */
- public void annotationDefaultSelected(VerticalRulerEvent event) {
- fCompositeRuler.fireAnnotationDefaultSelected(event);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IVerticalRulerListener#annotationContextMenuAboutToShow(org.eclipse.jface.text.source.VerticalRulerEvent, org.eclipse.swt.widgets.Menu)
- */
- public void annotationContextMenuAboutToShow(VerticalRulerEvent event, Menu menu) {
- fCompositeRuler.fireAnnotationContextMenuAboutToShow(event, menu);
- }
- }
-
-
- private final IInformationControlCreator fgCreator= new InformationControlCreator();
- protected final IVerticalRulerListener fgListener= new VerticalRulerListener();
- protected CompositeRuler fCompositeRuler;
- protected IDoubleClickListener fDblClickListener;
- protected IAnnotationAccess fAnnotationAccess;
-
- /**
- * Creates a new hover instance.
- *
- * @param ruler
- * @param access
- * @param doubleClickListener
- */
- public AnnotationExpandHover(CompositeRuler ruler, IAnnotationAccess access, IDoubleClickListener doubleClickListener) {
- fCompositeRuler= ruler;
- fAnnotationAccess= access;
- fDblClickListener= doubleClickListener;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int line) {
- // we don't have any sensible return value as text
- return null;
- }
-
- protected Object getHoverInfoForLine(ISourceViewer viewer, int line) {
- IAnnotationModel model= viewer.getAnnotationModel();
- IDocument document= viewer.getDocument();
-
- if (model == null)
- return null;
-
- List exact= new ArrayList();
- HashMap messagesAtPosition= new HashMap();
-
- Iterator e= model.getAnnotationIterator();
- while (e.hasNext()) {
- Annotation annotation= (Annotation) e.next();
- Position position= model.getPosition(annotation);
- if (position == null)
- continue;
-
- if (compareRulerLine(position, document, line) == 1) {
- if (isDuplicateMessage(messagesAtPosition, position, annotation.getText()))
- continue;
-
- exact.add(annotation);
- }
- }
-
- if (exact.size() < 1)
- return null;
-
- sort(exact, model);
-
- if (exact.size() > 0)
- setLastRulerMouseLocation(viewer, line);
-
- AnnotationHoverInput input= new AnnotationHoverInput();
- input.fAnnotations= (Annotation[]) exact.toArray(new Annotation[0]);
- input.fViewer= viewer;
- input.fRulerInfo= fCompositeRuler;
- input.fAnnotationListener= fgListener;
- input.fDoubleClickListener= fDblClickListener;
- input.model= model;
-
- return input;
- }
-
- protected void sort(List exact, final IAnnotationModel model) {
- class AnnotationComparator implements Comparator {
-
- /*
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compare(Object o1, Object o2) {
- Annotation a1= (Annotation) o1;
- Annotation a2= (Annotation) o2;
-
- Position p1= model.getPosition(a1);
- Position p2= model.getPosition(a2);
-
- // annotation order:
- // primary order: by position in line
- // secondary: annotation importance
- if (p1.offset == p2.offset)
- return getOrder(a2) - getOrder(a1);
- else
- return p1.offset - p2.offset;
- }
- }
-
- Collections.sort(exact, new AnnotationComparator());
-
- }
-
- protected int getOrder(Annotation annotation) {
- if (fAnnotationAccess instanceof IAnnotationAccessExtension) {
- IAnnotationAccessExtension extension= (IAnnotationAccessExtension) fAnnotationAccess;
- return extension.getLayer(annotation);
- }
- return IAnnotationAccessExtension.DEFAULT_LAYER;
- }
-
- protected boolean isDuplicateMessage(Map messagesAtPosition, Position position, String message) {
- if (messagesAtPosition.containsKey(position)) {
- Object value= messagesAtPosition.get(position);
- if (message == null || message.equals(value))
- return true;
-
- if (value instanceof List) {
- List messages= (List)value;
- if (messages.contains(message))
- return true;
- else
- messages.add(message);
- } else {
- ArrayList messages= new ArrayList();
- messages.add(value);
- messages.add(message);
- messagesAtPosition.put(position, messages);
- }
- } else
- messagesAtPosition.put(position, message);
- return false;
- }
-
- protected void setLastRulerMouseLocation(ISourceViewer viewer, int line) {
- // set last mouse activity in order to get the correct context menu
- if (fCompositeRuler != null) {
- StyledText st= viewer.getTextWidget();
- if (st != null && !st.isDisposed()) {
- if (viewer instanceof ITextViewerExtension5) {
- int widgetLine= ((ITextViewerExtension5)viewer).modelLine2WidgetLine(line);
- Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine));
- fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y);
- } else if (viewer instanceof TextViewer) {
- // TODO remove once TextViewer implements the extension
- int widgetLine= ((TextViewer)viewer).modelLine2WidgetLine(line);
- Point loc= st.getLocationAtOffset(st.getOffsetAtLine(widgetLine));
- fCompositeRuler.setLocationOfLastMouseButtonActivity(0, loc.y);
- }
- }
- }
- }
-
- /**
- * Returns the distance to the ruler line.
- *
- * @param position the position
- * @param document the document
- * @param line the line number
- * @return the distance to the ruler line
- */
- protected int compareRulerLine(Position position, IDocument document, int line) {
-
- if (position.getOffset() > -1 && position.getLength() > -1) {
- try {
- int firstLine= document.getLineOfOffset(position.getOffset());
- if (line == firstLine)
- return 1;
- if (firstLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()))
- return 2;
- } catch (BadLocationException x) {
- }
- }
-
- return 0;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverControlCreator()
- */
- public IInformationControlCreator getHoverControlCreator() {
- return fgCreator;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, org.eclipse.jface.text.source.ILineRange, int)
- */
- public Object getHoverInfo(ISourceViewer sourceViewer, ILineRange lineRange, int visibleLines) {
- return getHoverInfoForLine(sourceViewer, lineRange.getStartLine());
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getHoverLineRange(org.eclipse.jface.text.source.ISourceViewer, int)
- */
- public ILineRange getHoverLineRange(ISourceViewer viewer, int lineNumber) {
- return new LineRange(lineNumber, 1);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#canHandleMouseCursor()
- */
- public boolean canHandleMouseCursor() {
- return true;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java
deleted file mode 100644
index 043e5f58a..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/AnnotationExpansionControl.java
+++ /dev/null
@@ -1,795 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.events.MenuEvent;
-import org.eclipse.swt.events.MenuListener;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.events.MouseTrackListener;
-import org.eclipse.swt.events.PaintEvent;
-import org.eclipse.swt.events.PaintListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Layout;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Widget;
-
-import org.eclipse.jface.viewers.IDoubleClickListener;
-
-import org.eclipse.jface.text.AbstractInformationControlManager;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IInformationControlExtension;
-import org.eclipse.jface.text.IInformationControlExtension2;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IViewportListener;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextViewer;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationAccess;
-import org.eclipse.jface.text.source.IAnnotationAccessExtension;
-import org.eclipse.jface.text.source.IVerticalRulerListener;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.jface.text.source.VerticalRulerEvent;
-
-
-/**
- * A control that can display a number of annotations. The control can decide how it layouts the
- * annotations to present them to the user.
- *
- * <p>Each annotation can have its custom context menu and hover.</p>
- *
- * @since 3.0
- */
-public class AnnotationExpansionControl implements IInformationControl, IInformationControlExtension, IInformationControlExtension2 {
-
-
- public interface ICallback {
- void run(IInformationControlExtension2 control);
- }
-
- /**
- * Input used by the control to display the annotations.
- * TODO move to top-level class
- * TODO encapsulate fields
- *
- * @since 3.0
- */
- public static class AnnotationHoverInput {
- public Annotation[] fAnnotations;
- public ISourceViewer fViewer;
- public IVerticalRulerInfo fRulerInfo;
- public IVerticalRulerListener fAnnotationListener;
- public IDoubleClickListener fDoubleClickListener;
- public ICallback redoAction;
- public IAnnotationModel model;
- }
-
- private final class Item {
- Annotation fAnnotation;
- Canvas canvas;
- StyleRange[] oldStyles;
-
- public void selected() {
- Display disp= fShell.getDisplay();
- canvas.setCursor(fHandCursor);
- // TODO: shade - for now: set grey background
- canvas.setBackground(getSelectionColor(disp));
-
- // highlight the viewer background at its position
- oldStyles= setViewerBackground(fAnnotation);
-
- // set the selection
- fSelection= this;
-
- if (fHoverManager != null)
- fHoverManager.showInformation();
-
- if (fInput.fAnnotationListener != null) {
- VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation);
- fInput.fAnnotationListener.annotationSelected(event);
- }
-
- }
-
- public void defaultSelected() {
- if (fInput.fAnnotationListener != null) {
- VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation);
- fInput.fAnnotationListener.annotationDefaultSelected(event);
- }
-
- dispose();
- }
-
- public void showContextMenu(Menu menu) {
- if (fInput.fAnnotationListener != null) {
- VerticalRulerEvent event= new VerticalRulerEvent(fAnnotation);
- fInput.fAnnotationListener.annotationContextMenuAboutToShow(event, menu);
- }
- }
-
- public void deselect() {
- // hide the popup
-// fHoverManager.disposeInformationControl();
-
- // deselect
- fSelection= null;
-
- resetViewerBackground(oldStyles);
- oldStyles= null;
-
- Display disp= fShell.getDisplay();
- canvas.setCursor(null);
- // TODO: remove shading - for now: set standard background
- canvas.setBackground(disp.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- }
-
- }
-
- /**
- * Disposes of an item
- */
- private final class MyDisposeListener implements DisposeListener {
- /*
- * @see org.eclipse.swt.events.DisposeListener#widgetDisposed(org.eclipse.swt.events.DisposeEvent)
- */
- public void widgetDisposed(DisposeEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
- item.deselect();
- item.canvas= null;
- item.fAnnotation= null;
- item.oldStyles= null;
-
- ((Widget) e.getSource()).setData(null);
- }
- }
-
- /**
- * Listener on context menu invocation on the items
- */
- private final class MyMenuDetectListener implements Listener {
- /*
- * @see org.eclipse.swt.widgets.Listener#handleEvent(org.eclipse.swt.widgets.Event)
- */
- public void handleEvent(Event event) {
- if (event.type == SWT.MenuDetect) {
- // TODO: show per-item menu
- // for now: show ruler context menu
- if (fInput != null) {
- Control ruler= fInput.fRulerInfo.getControl();
- if (ruler != null && !ruler.isDisposed()) {
- Menu menu= ruler.getMenu();
- if (menu != null && !menu.isDisposed()) {
- menu.setLocation(event.x, event.y);
- menu.addMenuListener(new MenuListener() {
-
- public void menuHidden(MenuEvent e) {
- dispose();
- }
-
- public void menuShown(MenuEvent e) {
- }
-
- });
- menu.setVisible(true);
- }
- }
- }
- }
- }
- }
-
- /**
- * Listener on mouse events on the items.
- */
- private final class MyMouseListener extends MouseAdapter {
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
- if (e.button == 1 && item.fAnnotation == fInput.fAnnotations[0] && fInput.fDoubleClickListener != null) {
- fInput.fDoubleClickListener.doubleClick(null);
- // special code for JDT to renew the annotation set.
- if (fInput.redoAction != null)
- fInput.redoAction.run(AnnotationExpansionControl.this);
- }
-// dispose();
- // TODO special action to invoke double-click action on the vertical ruler
- // how about
-// Canvas can= (Canvas) e.getSource();
-// Annotation a= (Annotation) can.getData();
-// if (a != null) {
-// a.getDoubleClickAction().run();
-// }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
- // TODO for now, to make double click work: disable single click on the first item
- // disable later when the annotationlistener selectively handles input
- if (item != null && e.button == 1) // && item.fAnnotation != fInput.fAnnotations[0])
- item.defaultSelected();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseAdapter#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- // TODO Auto-generated method stub
- super.mouseDown(e);
- }
- }
-
- /**
- * Listener on mouse track events on the items.
- */
- private final class MyMouseTrackListener implements MouseTrackListener {
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseEnter(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseEnter(MouseEvent e) {
- Item item= (Item) ((Widget) e.getSource()).getData();
- if (item != null)
- item.selected();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseExit(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseExit(MouseEvent e) {
-
- Item item= (Item) ((Widget) e.getSource()).getData();
- if (item != null)
- item.deselect();
-
- // if the event lies outside the entire popup, dispose
- org.eclipse.swt.graphics.Region region= fShell.getRegion();
- Canvas can= (Canvas) e.getSource();
- Point p= can.toDisplay(e.x, e.y);
- if (region == null) {
- Rectangle bounds= fShell.getBounds();
-// p= fShell.toControl(p);
- if (!bounds.contains(p))
- dispose();
- } else {
- p= fShell.toControl(p);
- if (!region.contains(p))
- dispose();
- }
-
-
- }
-
- /*
- * @see org.eclipse.swt.events.MouseTrackListener#mouseHover(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseHover(MouseEvent e) {
- if (fHoverManager == null) {
- fHoverManager= new HoverManager();
- fHoverManager.takesFocusWhenVisible(false);
- fHoverManager.install(fComposite);
- fHoverManager.showInformation();
- }
- }
- }
-
- /**
- * Listener on paint events on the items. Paints the annotation image on the given <code>GC</code>.
- */
- private final class MyPaintListener implements PaintListener {
- /*
- * @see org.eclipse.swt.events.PaintListener#paintControl(org.eclipse.swt.events.PaintEvent)
- */
- public void paintControl(PaintEvent e) {
- Canvas can= (Canvas) e.getSource();
- Annotation a= ((Item) can.getData()).fAnnotation;
- if (a != null) {
- Rectangle rect= new Rectangle(fLayouter.getBorderWidth(), fLayouter.getBorderWidth(), fLayouter.getAnnotationSize(), fLayouter.getAnnotationSize());
- if (fAnnotationAccessExtension != null)
- fAnnotationAccessExtension.paint(a, e.gc, can, rect);
- }
- }
- }
-
- /**
- * Our own private hover manager used to shop per-item pop-ups.
- */
- private final class HoverManager extends AbstractInformationControlManager {
-
- /**
- *
- */
- public HoverManager() {
- super(new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent);
- }
- });
-
- setMargins(5, 10);
- setAnchor(ANCHOR_BOTTOM);
- setFallbackAnchors(new Anchor[] { ANCHOR_LEFT, ANCHOR_RIGHT} );
- }
-
- /*
- * @see org.eclipse.jface.text.AbstractInformationControlManager#computeInformation()
- */
- protected void computeInformation() {
- if (fSelection != null) {
- Rectangle subjectArea= fSelection.canvas.getBounds();
- Annotation annotation= fSelection.fAnnotation;
- String msg;
- if (annotation != null)
- msg= annotation.getText();
- else
- msg= null;
-
- setInformation(msg, subjectArea);
- }
- }
-
-
- }
-
- /** Model data. */
- protected AnnotationHoverInput fInput;
- /** The control's shell */
- private Shell fShell;
- /** The composite combining all the items. */
- protected Composite fComposite;
- /** The hand cursor. */
- private Cursor fHandCursor;
- /** The currently selected item, or <code>null</code> if none is selected. */
- private Item fSelection;
- /** The hover manager for the per-item hovers. */
- private HoverManager fHoverManager;
- /** The annotation access extension. */
- private IAnnotationAccessExtension fAnnotationAccessExtension;
-
-
- /* listener legion */
- private final MyPaintListener fPaintListener;
- private final MyMouseTrackListener fMouseTrackListener;
- private final MyMouseListener fMouseListener;
- private final MyMenuDetectListener fMenuDetectListener;
- private final DisposeListener fDisposeListener;
- private final IViewportListener fViewportListener;
-
- private LinearLayouter fLayouter;
-
- /**
- * Creates a new control.
- *
- * @param parent
- * @param shellStyle
- * @param access
- */
- public AnnotationExpansionControl(Shell parent, int shellStyle, IAnnotationAccess access) {
- fPaintListener= new MyPaintListener();
- fMouseTrackListener= new MyMouseTrackListener();
- fMouseListener= new MyMouseListener();
- fMenuDetectListener= new MyMenuDetectListener();
- fDisposeListener= new MyDisposeListener();
- fViewportListener= new IViewportListener() {
-
- public void viewportChanged(int verticalOffset) {
- dispose();
- }
-
- };
- fLayouter= new LinearLayouter();
-
- if (access instanceof IAnnotationAccessExtension)
- fAnnotationAccessExtension= (IAnnotationAccessExtension) access;
-
- fShell= new Shell(parent, shellStyle | SWT.NO_FOCUS | SWT.ON_TOP);
- Display display= fShell.getDisplay();
- fShell.setBackground(display.getSystemColor(SWT.COLOR_BLACK));
- fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM);
-// fComposite= new Composite(fShell, SWT.NO_FOCUS | SWT.NO_REDRAW_RESIZE | SWT.NO_TRIM | SWT.V_SCROLL);
-
- GridLayout layout= new GridLayout(1, true);
- layout.marginHeight= 0;
- layout.marginWidth= 0;
- fShell.setLayout(layout);
-
- GridData data= new GridData(GridData.FILL_BOTH);
- data.heightHint= fLayouter.getAnnotationSize() + 2 * fLayouter.getBorderWidth() + 4;
- fComposite.setLayoutData(data);
- fComposite.addMouseTrackListener(new MouseTrackAdapter() {
-
- public void mouseExit(MouseEvent e) {
- if (fComposite == null)
- return;
- Control[] children= fComposite.getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i].getBounds().contains(e.x, e.y))
- return;
- }
-
- // if none of the children contains the event, we left the popup
- dispose();
- }
-
- });
-
-// fComposite.getVerticalBar().addListener(SWT.Selection, new Listener() {
-//
-// public void handleEvent(Event event) {
-// Rectangle bounds= fShell.getBounds();
-// int x= bounds.x - fLayouter.getAnnotationSize() - fLayouter.getBorderWidth();
-// int y= bounds.y;
-// fShell.setBounds(x, y, bounds.width, bounds.height);
-// }
-//
-// });
-
- fHandCursor= new Cursor(display, SWT.CURSOR_HAND);
- fShell.setCursor(fHandCursor);
- fComposite.setCursor(fHandCursor);
-
- setInfoSystemColor();
- }
-
- private void setInfoSystemColor() {
- Display display= fShell.getDisplay();
- setForegroundColor(display.getSystemColor(SWT.COLOR_INFO_FOREGROUND));
- setBackgroundColor(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#setInformation(java.lang.String)
- */
- public void setInformation(String information) {
- setInput(null);
- }
-
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension2#setInput(java.lang.Object)
- */
- public void setInput(Object input) {
- if (fInput != null && fInput.fViewer != null)
- fInput.fViewer.removeViewportListener(fViewportListener);
-
- if (input instanceof AnnotationHoverInput)
- fInput= (AnnotationHoverInput) input;
- else
- fInput= null;
-
- inputChanged(fInput, null);
- }
-
- protected void inputChanged(Object newInput, Object newSelection) {
- refresh();
- }
-
- protected void refresh() {
- adjustItemNumber();
-
- if (fInput == null)
- return;
-
- if (fInput.fAnnotations == null)
- return;
-
- if (fInput.fViewer != null)
- fInput.fViewer.addViewportListener(fViewportListener);
-
- fShell.setRegion(fLayouter.getShellRegion(fInput.fAnnotations.length));
-
- Layout layout= fLayouter.getLayout(fInput.fAnnotations.length);
- fComposite.setLayout(layout);
-
- Control[] children= fComposite.getChildren();
- for (int i= 0; i < fInput.fAnnotations.length; i++) {
- Canvas canvas= (Canvas) children[i];
- Item item= new Item();
- item.canvas= canvas;
- item.fAnnotation= fInput.fAnnotations[i];
- canvas.setData(item);
- canvas.redraw();
- }
-
- }
-
- protected void adjustItemNumber() {
- if (fComposite == null)
- return;
-
- Control[] children= fComposite.getChildren();
- int oldSize= children.length;
- int newSize= fInput == null ? 0 : fInput.fAnnotations.length;
-
- Display display= fShell.getDisplay();
-
- // add missing items
- for (int i= oldSize; i < newSize; i++) {
- Canvas canvas= new Canvas(fComposite, SWT.NONE);
- Object gridData= fLayouter.getLayoutData();
- canvas.setLayoutData(gridData);
- canvas.setBackground(display.getSystemColor(SWT.COLOR_INFO_BACKGROUND));
-
- canvas.addPaintListener(fPaintListener);
-
- canvas.addMouseTrackListener(fMouseTrackListener);
-
- canvas.addMouseListener(fMouseListener);
-
- canvas.addListener(SWT.MenuDetect, fMenuDetectListener);
-
- canvas.addDisposeListener(fDisposeListener);
- }
-
- // dispose of exceeding resources
- for (int i= oldSize; i > newSize; i--) {
- Item item= (Item) children[i - 1].getData();
- item.deselect();
- children[i - 1].dispose();
- }
-
- }
-
- /*
- * @see IInformationControl#setVisible(boolean)
- */
- public void setVisible(boolean visible) {
- fShell.setVisible(visible);
- }
-
- /*
- * @see IInformationControl#dispose()
- */
- public void dispose() {
- if (fShell != null) {
- if (!fShell.isDisposed())
- fShell.dispose();
- fShell= null;
- fComposite= null;
- if (fHandCursor != null)
- fHandCursor.dispose();
- fHandCursor= null;
- if (fHoverManager != null)
- fHoverManager.dispose();
- fHoverManager= null;
- fSelection= null;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControlExtension#hasContents()
- */
- public boolean hasContents() {
- return fInput.fAnnotations != null && fInput.fAnnotations.length > 0;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#setSizeConstraints(int, int)
- */
- public void setSizeConstraints(int maxWidth, int maxHeight) {
- //fMaxWidth= maxWidth;
- //fMaxHeight= maxHeight;
- }
-
- /*
- * @see org.eclipse.jface.text.IInformationControl#computeSizeHint()
- */
- public Point computeSizeHint() {
- return fShell.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- }
-
- /*
- * @see IInformationControl#setLocation(Point)
- */
- public void setLocation(Point location) {
- fShell.setLocation(location);
- }
-
- /*
- * @see IInformationControl#setSize(int, int)
- */
- public void setSize(int width, int height) {
- fShell.setSize(width, height);
- }
-
- /*
- * @see IInformationControl#addDisposeListener(DisposeListener)
- */
- public void addDisposeListener(DisposeListener listener) {
- fShell.addDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#removeDisposeListener(DisposeListener)
- */
- public void removeDisposeListener(DisposeListener listener) {
- fShell.removeDisposeListener(listener);
- }
-
- /*
- * @see IInformationControl#setForegroundColor(Color)
- */
- public void setForegroundColor(Color foreground) {
- fComposite.setForeground(foreground);
- }
-
- /*
- * @see IInformationControl#setBackgroundColor(Color)
- */
- public void setBackgroundColor(Color background) {
- fComposite.setBackground(background);
- }
-
- /*
- * @see IInformationControl#isFocusControl()
- */
- public boolean isFocusControl() {
- if (fComposite.isFocusControl())
- return true;
- else {
- Control[] children= fComposite.getChildren();
- for (int i= 0; i < children.length; i++) {
- if (children[i].isFocusControl())
- return true;
- }
- }
- return false;
- }
-
- /*
- * @see IInformationControl#setFocus()
- */
- public void setFocus() {
- fShell.forceFocus();
- }
-
- /*
- * @see IInformationControl#addFocusListener(FocusListener)
- */
- public void addFocusListener(FocusListener listener) {
- fShell.addFocusListener(listener);
- }
-
- /*
- * @see IInformationControl#removeFocusListener(FocusListener)
- */
- public void removeFocusListener(FocusListener listener) {
- fShell.removeFocusListener(listener);
- }
-
- private StyleRange[] setViewerBackground(Annotation annotation) {
- StyledText text= fInput.fViewer.getTextWidget();
- if (text == null || text.isDisposed())
- return null;
-
- Display disp= text.getDisplay();
-
- Position pos= fInput.model.getPosition(annotation);
- if (pos == null)
- return null;
-
- IRegion region= ((TextViewer)fInput.fViewer).modelRange2WidgetRange(new Region(pos.offset, pos.length));
-
- StyleRange[] ranges= text.getStyleRanges(region.getOffset(), region.getLength());
-
- List undoRanges= new ArrayList(ranges.length);
- for (int i= 0; i < ranges.length; i++) {
- undoRanges.add(ranges[i].clone());
- }
-
- int offset= region.getOffset();
- StyleRange current= undoRanges.size() > 0 ? (StyleRange) undoRanges.get(0) : null;
- int curStart= current != null ? current.start : region.getOffset() + region.getLength();
- int curEnd= current != null ? current.start + current.length : -1;
- int index= 0;
-
- // fill no-style regions
- while (curEnd < region.getOffset() + region.getLength()) {
- // add empty range
- if (curStart > offset) {
- StyleRange undoRange= new StyleRange(offset, curStart - offset, null, null);
- undoRanges.add(index, undoRange);
- index++;
- }
-
- // step
- index++;
- if (index < undoRanges.size()) {
- offset= curEnd;
- current= (StyleRange) undoRanges.get(index);
- curStart= current.start;
- curEnd= current.start + current.length;
- } else if (index == undoRanges.size()) {
- // last one
- offset= curEnd;
- current= null;
- curStart= region.getOffset() + region.getLength();
- curEnd= -1;
- } else
- curEnd= region.getOffset() + region.getLength();
- }
-
- // create modified styles (with background)
- List shadedRanges= new ArrayList(undoRanges.size());
- for (Iterator it= undoRanges.iterator(); it.hasNext(); ) {
- StyleRange range= (StyleRange) ((StyleRange) it.next()).clone();
- shadedRanges.add(range);
- range.background= getHighlightColor(disp);
- }
-
- // set the ranges one by one
- for (Iterator iter= shadedRanges.iterator(); iter.hasNext(); ) {
- text.setStyleRange((StyleRange) iter.next());
-
- }
-
- return (StyleRange[]) undoRanges.toArray(undoRanges.toArray(new StyleRange[0]));
- }
-
- private void resetViewerBackground(StyleRange[] oldRanges) {
-
- if (oldRanges == null)
- return;
-
- if (fInput == null)
- return;
-
- StyledText text= fInput.fViewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
- // set the ranges one by one
- for (int i= 0; i < oldRanges.length; i++) {
- text.setStyleRange(oldRanges[i]);
- }
- }
-
- private Color getHighlightColor(Display disp) {
- return disp.getSystemColor(SWT.COLOR_GRAY);
- }
-
- private Color getSelectionColor(Display disp) {
- return disp.getSystemColor(SWT.COLOR_GRAY);
- }
-
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java
deleted file mode 100644
index f6ad5d1b6..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditPosition.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.ui.IEditorInput;
-
-/**
- * Data structure representing an edit position.
- *
- * @since 2.1
- */
-public final class EditPosition {
-
- /** The editor input */
- private final IEditorInput fEditorInput;
- /** The editor ID */
- private final String fEditorId;
- /** The selection */
- private final ISelection fSelection;
- /** The position */
- private final Position fPosition;
-
- /**
- * Creates a new edit position.
- *
- * @param editorInput the editor input
- * @param editorId the editor ID
- * @param selection the selection
- * @param pos the position
- */
- public EditPosition(IEditorInput editorInput, String editorId, ISelection selection, Position pos) {
- Assert.isNotNull(editorInput);
- Assert.isNotNull(editorId);
- fEditorId= editorId;
- fEditorInput= editorInput;
- fSelection= selection;
- fPosition= pos;
- }
-
- /**
- * Returns the editor input for this edit position.
- *
- * @return the editor input of this edit position
- */
- IEditorInput getEditorInput() {
- return fEditorInput;
- }
-
- /**
- * Returns the editor id for this edit position.
- *
- * @return the editor input of this edit position
- */
- String getEditorId() {
- return fEditorId;
- }
-
- /**
- * Returns the selection of this edit position.
- *
- * @return the selection of this edit position
- */
- ISelection getSelection() {
- return fSelection;
- }
-
- /**
- * Returns the the position.
- *
- * @return the position
- */
- Position getPosition() {
- return fPosition;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.java
deleted file mode 100644
index 9f3739260..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.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.internal.texteditor;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-class EditorMessages {
-
- private static final String RESOURCE_BUNDLE= EditorMessages.class.getName();
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private EditorMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static ResourceBundle getResourceBundle() {
- return fgResourceBundle;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties
deleted file mode 100644
index c14d15ebe..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/EditorMessages.properties
+++ /dev/null
@@ -1,16 +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
-###############################################################################
-
-
-## Errors ##
-
-Editor.error.gotoLastEditPosition.title= Problems going to last edit position
-Editor.error.gotoLastEditPosition.message= Unable to go to the last edit position.
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java
deleted file mode 100644
index 3368f18ae..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/GotoLastEditPositionAction.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.ISelection;
-
-import org.eclipse.jface.text.Position;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.IWorkbenchWindowActionDelegate;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-
-/**
- * Goes to last edit position.
- *
- * @see org.eclipse.ui.internal.texteditor.EditPosition
- * @since 2.1
- */
-public class GotoLastEditPositionAction extends Action implements IWorkbenchWindowActionDelegate {
-
- /** The worbench window */
- private IWorkbenchWindow fWindow;
- /** The action */
- private IAction fAction;
-
- /**
- * Creates a goto last edit action.
- */
- public GotoLastEditPositionAction() {
- WorkbenchHelp.setHelp(this, IAbstractTextEditorHelpContextIds.GOTO_LAST_EDIT_POSITION_ACTION);
- setId(ITextEditorActionDefinitionIds.GOTO_LAST_EDIT_POSITION);
- setActionDefinitionId(ITextEditorActionDefinitionIds.GOTO_LAST_EDIT_POSITION);
- setEnabled(false);
- }
-
- /*
- * @see IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
- */
- public void init(IWorkbenchWindow window) {
- fWindow= window;
- }
-
- /*
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- run();
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- EditPosition editPosition= TextEditorPlugin.getDefault().getLastEditPosition();
- if (editPosition == null)
- return;
-
- final Position pos= editPosition.getPosition();
- if (pos == null || pos.isDeleted)
- return;
-
- IWorkbenchWindow window= getWindow();
- if (window == null)
- return;
-
- IWorkbenchPage page= window.getActivePage();
-
- IEditorPart editor;
- try {
- editor= page.openEditor(editPosition.getEditorInput(), editPosition.getEditorId());
- } catch (PartInitException ex) {
- editor= null;
- }
-
- // Optimization - could also use else branch
- if (editor instanceof ITextEditor) {
- ITextEditor textEditor= (ITextEditor)editor;
- textEditor.selectAndReveal(pos.offset, pos.length);
- }
-// } else
-// if (editor != null) {
-// final IEditorInput input= editor.getEditorInput();
-// final IEditorPart finalEditor= editor;
-// if (input instanceof IFileEditorInput) {
-//
-// WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
-// protected void execute(IProgressMonitor monitor) throws CoreException {
-// IMarker marker= null;
-// try {
-// marker= ((IFileEditorInput)input).getFile().createMarker(IMarker.TEXT);
-// marker.setAttribute(IMarker.CHAR_START, pos.offset);
-// marker.setAttribute(IMarker.CHAR_END, pos.offset + pos.length);
-//
-// finalEditor.gotoMarker(marker);
-//
-// } finally {
-// if (marker != null)
-// marker.delete();
-// }
-// }
-// };
-//
-// try {
-// op.run(null);
-// } catch (InvocationTargetException ex) {
-// String message= EditorMessages.getString("Editor.error.gotoLastEditPosition.message"); //$NON-NLS-1$
-// if (fWindow != null) {
-// Shell shell= fWindow.getShell();
-// String title= EditorMessages.getString("Editor.error.gotoLastEditPosition.title"); //$NON-NLS-1$
-// MessageDialog.openError(shell, title, message);
-// } else {
-// Throwable t= ex.getTargetException();
-// IStatus status= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, 0, message, t);
-// TextEditorPlugin.getDefault().getLog().log(status);
-// }
-// } catch (InterruptedException e) {
-// Assert.isTrue(false, "this operation can not be cancelled"); //$NON-NLS-1$
-// }
-// }
-// editor.setFocus();
-// }
- }
-
- /*
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- boolean enabled= TextEditorPlugin.getDefault().getLastEditPosition() != null;
- setEnabled(enabled);
- action.setEnabled(enabled);
-
- // This is no longer needed once the action is enabled.
- if (!enabled) {
- // adding the same action twice has no effect.
- TextEditorPlugin.getDefault().addLastEditPositionDependentAction(action);
- // this is always the same action for this instance
- fAction= action;
- }
- }
-
- /**
- * Returns the workbench window.
- *
- * @return the workbench window
- */
- private IWorkbenchWindow getWindow() {
- if (fWindow == null)
- fWindow= PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- return fWindow;
- }
-
- /*
- * @see IWorkbenchWindowActionDelegate#dispose()
- */
- public void dispose() {
- fWindow= null;
- TextEditorPlugin.getDefault().removeLastEditPositionDependentAction(fAction);
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java
deleted file mode 100644
index c85569d38..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/LinearLayouter.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor;
-
-import org.eclipse.swt.graphics.Region;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Layout;
-
-/**
- *
- *
- * @since 3.0
- */
-public class LinearLayouter {
-
- private static final int ANNOTATION_SIZE= 14;
- private static final int BORDER_WIDTH= 2;
-
- public Layout getLayout(int itemCount) {
- // simple layout: a row of items
- GridLayout layout= new GridLayout(itemCount, true);
- layout.horizontalSpacing= 1;
- layout.verticalSpacing= 0;
- layout.marginHeight= 1;
- layout.marginWidth= 1;
- return layout;
- }
-
- public Object getLayoutData() {
- GridData gridData= new GridData(ANNOTATION_SIZE + 2 * BORDER_WIDTH, ANNOTATION_SIZE + 2 * BORDER_WIDTH);
- gridData.horizontalAlignment= GridData.CENTER;
- gridData.verticalAlignment= GridData.CENTER;
- return gridData;
- }
-
- public int getAnnotationSize() {
- return ANNOTATION_SIZE;
- }
-
- public int getBorderWidth() {
- return BORDER_WIDTH;
- }
-
- public Region getShellRegion(int itemCount) {
- // no special region - set to null for default shell size
- return null;
- }
-
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java
deleted file mode 100644
index c21aaf24b..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/TextEditorPlugin.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor;
-
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.osgi.framework.BundleContext;
-
-import org.eclipse.core.runtime.IRegistryChangeEvent;
-import org.eclipse.core.runtime.IRegistryChangeListener;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.jface.action.IAction;
-
-import org.eclipse.jface.text.Assert;
-
-import org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffExtensionsRegistry;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-
-/**
- * The plug-in runtime class for the text editor UI plug-in (id <code>"org.eclipse.ui.workbench.texteditor"</code>).
- * This class provides static methods for:
- * <ul>
- * <li> getting the last editor position.</li>
- * </ul>
- * <p>
- * This class provides static methods and fields only; it is not intended to be
- * instantiated or subclassed by clients.
- * </p>
- *
- * @since 2.1
- */
-public final class TextEditorPlugin extends AbstractUIPlugin implements IRegistryChangeListener {
-
- /** The plug-in instance */
- private static TextEditorPlugin fgPlugin;
-
- /** The last edit position */
- private EditPosition fLastEditPosition;
- /** The action which goes to the last edit position */
- private Set fLastEditPositionDependentActions;
-
- /**
- * The the quick diff extension registry.
- * @since 3.0
- */
- private QuickDiffExtensionsRegistry fQuickDiffExtensionRegistry;
-
- /**
- * Creates a plug-in instance.
- */
- public TextEditorPlugin() {
- super();
- Assert.isTrue(fgPlugin == null);
- fgPlugin= this;
- }
-
- /**
- * Returns the plug-in instance.
- *
- * @return the text editor plug-in instance
- * @since 3.0
- */
- public static TextEditorPlugin getDefault() {
- return fgPlugin;
- }
-
- /**
- * Text editor UI plug-in Id (value <code>"org.eclipse.ui.workbench.texteditor"</code>).
- */
- public static final String PLUGIN_ID= "org.eclipse.ui.workbench.texteditor"; //$NON-NLS-1$
-
- /**
- * Extension Id of quick diff reference provider extension point.
- * (value <code>"quickDiffReferenceProvider"</code>).
- * @since 3.0
- */
- public static final String REFERENCE_PROVIDER_EXTENSION_POINT= "quickDiffReferenceProvider"; //$NON-NLS-1$
-
- /**
- * Returns the last edit position.
- *
- * @return the last edit position or <code>null</code> if there is no last edit position
- * @see EditPosition
- */
- EditPosition getLastEditPosition() {
- return fLastEditPosition;
- }
-
- /**
- * Sets the last edit position.
- *
- * @param lastEditPosition the last edit position
- * @see EditPosition
- */
- public void setLastEditPosition(EditPosition lastEditPosition) {
- fLastEditPosition= lastEditPosition;
- if (fLastEditPosition != null && fLastEditPositionDependentActions != null) {
- Iterator iter= fLastEditPositionDependentActions.iterator();
- while (iter.hasNext())
- ((IAction)iter.next()).setEnabled(true);
- fLastEditPositionDependentActions= null;
- }
- }
-
- /**
- * Adds the given action to the last edit position dependent actions.
- *
- * @param action the goto last edit position action
- */
- void addLastEditPositionDependentAction(IAction action) {
- if (fLastEditPosition != null)
- return;
- if (fLastEditPositionDependentActions == null)
- fLastEditPositionDependentActions= new HashSet();
- fLastEditPositionDependentActions.add(action);
- }
-
- /**
- * Removes the given action from the last edit position dependent actions.
- *
- * @param action the action that depends on the last edit position
- */
- void removeLastEditPositionDependentAction(IAction action) {
- if (fLastEditPosition != null)
- return;
- if (fLastEditPositionDependentActions != null)
- fLastEditPositionDependentActions.remove(action);
- }
-
-
- /*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
- * @since 3.0
- */
- public void start(BundleContext context) throws Exception {
- super.start(context);
- fQuickDiffExtensionRegistry= new QuickDiffExtensionsRegistry();
- Platform.getExtensionRegistry().addRegistryChangeListener(this, PLUGIN_ID);
- }
-
- /*
- * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
- * @since 3.0
- */
- public void stop(BundleContext context) throws Exception {
- Platform.getExtensionRegistry().removeRegistryChangeListener(this);
- fQuickDiffExtensionRegistry= null;
- super.stop(context);
- }
-
- /*
- * @see org.eclipse.core.runtime.IRegistryChangeListener#registryChanged(org.eclipse.core.runtime.IRegistryChangeEvent)
- * @since 3.0
- */
- public void registryChanged(IRegistryChangeEvent event) {
- if (fQuickDiffExtensionRegistry != null && event.getExtensionDeltas(PLUGIN_ID, REFERENCE_PROVIDER_EXTENSION_POINT).length > 0)
- fQuickDiffExtensionRegistry.reloadExtensions();
- }
-
- /**
- * Returns this plug-ins quick diff extension registry.
- *
- * @return the quick diff extension registry or <code>null</code> if this plug-in has been shutdown
- * @since 3.0
- */
- public QuickDiffExtensionsRegistry getQuickDiffExtensionRegistry() {
- return fQuickDiffExtensionRegistry;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java
deleted file mode 100644
index 989a67eef..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DiffRegion.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.ILineDiffInfo;
-
-import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifference;
-
-
-/**
- * The local implementation of <code>ILineDiffInfo</code>. As instances are
- * also <code>Annotation</code>s, they can be used in
- * <code>DocumentLineDiffer</code>s <code>IAnnotationModel</code> protocol.
- *
- * @since 3.0
- */
-public final class DiffRegion extends Annotation implements ILineDiffInfo {
- private final RangeDifference fDifference;
-
- private final int fOffset;
-
- private final List fList;
-
- private final IDocument fDocument;
-
- /**
- * Creates a new diff region.
- *
- * @param difference
- * @param offset
- * @param differences
- * @param source
- */
- public DiffRegion(RangeDifference difference, int offset, List differences, IDocument source) {
- super("org.eclipse.ui.workbench.texteditor.quickdiffChange", false, null); //$NON-NLS-1$
- fOffset= offset;
- fDifference= difference;
- fList= differences;
- fDocument= source;
- }
-
- /*
- * @see org.eclipse.jface.text.source.Annotation#getType()
- */
- public String getType() {
- // we return unknown for unchanged regions to avoid
- // them getting displayed.
- switch (getChangeType()) {
- case CHANGED:
- return "org.eclipse.ui.workbench.texteditor.quickdiffChange"; //$NON-NLS-1$
- case ADDED:
- return "org.eclipse.ui.workbench.texteditor.quickdiffAddition"; //$NON-NLS-1$
- case UNCHANGED:
- return "org.eclipse.ui.workbench.texteditor.quickdiffUnchanged"; //$NON-NLS-1$
- default:
- return TYPE_UNKNOWN;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesBelow()
- */
- public int getRemovedLinesBelow() {
- if (fOffset == fDifference.rightLength() - 1) {
- if (getChangeType() != UNCHANGED) {
- return Math.max(fDifference.leftLength() - fDifference.rightLength(), 0);
- } else {
- for (ListIterator it= fList.listIterator(); it.hasNext();) {
- if (fDifference.equals(it.next())) {
- if (it.hasNext()) {
- RangeDifference next= (RangeDifference) it.next();
- if (next.rightLength() == 0)
- return Math.max(next.leftLength() - next.rightLength(), 0);
- }
- return 0;
- }
- }
- return 0;
- }
- } else
- return 0;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getChangeType()
- */
- public int getChangeType() {
- if (fDifference.kind() == RangeDifference.NOCHANGE)
- return UNCHANGED;
- else {
- if (fOffset >= fDifference.leftLength())
- return ADDED;
- else
- return CHANGED;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesAbove()
- */
- public int getRemovedLinesAbove() {
- if (getChangeType() != UNCHANGED || fOffset != 0)
- return 0;
- else {
- for (ListIterator it= fList.listIterator(fList.size()); it.hasPrevious();) {
- if (fDifference.equals(it.previous())) {
- if (it.hasPrevious()) {
- RangeDifference previous= (RangeDifference) it.previous();
- return Math.max(previous.leftLength() - previous.rightLength(), 0);
- } else
- return 0;
- }
- }
- return 0;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#hasChanges()
- */
- public boolean hasChanges() {
- return getChangeType() != UNCHANGED || getRemovedLinesAbove() > 0 || getRemovedLinesBelow() > 0;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getOriginalText()
- */
- public String[] getOriginalText() {
- IDocument doc= fDocument;
- if (doc != null) {
- int startLine= fDifference.leftStart() + fOffset;
- if (startLine >= fDifference.leftEnd())
- return new String[0]; // original text of an added line is
- // empty
-
- int endLine= startLine + getRemovedLinesBelow();
- if (getChangeType() == UNCHANGED)
- startLine++;
- String[] ret= new String[endLine - startLine + 1];
- for (int i= 0; i < ret.length; i++) {
- try {
- ret[i]= doc.get(doc.getLineOffset(startLine + i), doc.getLineLength(startLine + i));
- } catch (BadLocationException e) {
- ret[i]= new String();
- }
- }
- return ret;
- }
-
- // in initialization phase?
- return new String[0];
- }
-
- /*
- * @see org.eclipse.jface.text.source.Annotation#getText()
- */
- public String getText() {
- int r= fDifference.rightLength();
- int l= fDifference.leftLength();
- int c= Math.min(r, l);
- int a= r - l;
- String changed= c > 0 ? QuickDiffMessages.getFormattedString("quickdiff.annotation.changed", new Integer(c)) : null; //$NON-NLS-1$
- String added;
- if (a > 0)
- added= QuickDiffMessages.getFormattedString("quickdiff.annotation.added", new Integer(a)); //$NON-NLS-1$
- else if (a < 0)
- added= QuickDiffMessages.getFormattedString("quickdiff.annotation.deleted", new Integer(-a)); //$NON-NLS-1$
- else
- added= null;
- String line= c > 1 || c == 0 && Math.abs(a) > 1 ? QuickDiffMessages.getString("quickdiff.annotation.line_plural") : QuickDiffMessages.getString("quickdiff.annotation.line_singular"); //$NON-NLS-1$//$NON-NLS-2$
-
- String ret= (changed != null ? changed : "") + (changed != null ? " " + line : "") //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$
- + (changed != null && added != null ? ", " : " ") + (added != null ? added : "") //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$
- + (added != null && changed == null ? " " + line : ""); //$NON-NLS-1$//$NON-NLS-2$
- return ret;
- }
-
- /**
- * @return Returns the difference.
- */
- public RangeDifference getDifference() {
- return fDifference;
- }
-
- /**
- * @return Returns the offset.
- */
- public int getOffset() {
- return fOffset;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
deleted file mode 100644
index ded517231..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/DocumentLineDiffer.java
+++ /dev/null
@@ -1,1405 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-import java.util.ArrayList;
-import java.util.ConcurrentModificationException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.ListIterator;
-
-import org.eclipse.core.runtime.CoreException;
-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.Status;
-import org.eclipse.core.runtime.jobs.Job;
-
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.AnnotationModelEvent;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelListener;
-import org.eclipse.jface.text.source.IAnnotationModelListenerExtension;
-import org.eclipse.jface.text.source.ILineDiffInfo;
-import org.eclipse.jface.text.source.ILineDiffer;
-
-import org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider;
-
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.DocLineComparator;
-import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifference;
-import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.RangeDifferencer;
-import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.LinkedRangeFactory.LowMemoryException;
-
-/**
- * Standard implementation of <code>ILineDiffer</code> as an incremental diff engine. A
- * <code>DocumentLineDiffer</code> can be initialized to some start state. Once connected to a
- * <code>IDocument</code> and a reference document has been set, changes reported via the
- * <code>IDocumentListener</code> interface will be tracked and the incremental diff updated.
- *
- * <p>The diff state can be queried using the <code>ILineDiffer</code> interface.</p>
- *
- * <p>Since diff information is model information attached to a document, this class implements
- * <code>IAnnotationModel</code> and can be attached to <code>IAnnotationModelExtension</code>s.</p>
- *
- * <p>This class is not supposed to be subclassed.</p>
- *
- * @since 3.0
- */
-public class DocumentLineDiffer implements ILineDiffer, IDocumentListener, IAnnotationModel {
-
- /**
- * Artificial line difference information indicating a change with an empty line as original text.
- */
- private static class LineChangeInfo implements ILineDiffInfo {
-
- private static final String[] ORIGINAL_TEXT= new String[] { "\n" }; //$NON-NLS-1$
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesBelow()
- */
- public int getRemovedLinesBelow() {
- return 0;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getRemovedLinesAbove()
- */
- public int getRemovedLinesAbove() {
- return 0;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getChangeType()
- */
- public int getChangeType() {
- return CHANGED;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#hasChanges()
- */
- public boolean hasChanges() {
- return true;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffInfo#getOriginalText()
- */
- public String[] getOriginalText() {
- return ORIGINAL_TEXT;
- }
- }
-
- /** Tells whether this class is in debug mode. */
- private static boolean DEBUG= "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.ui.workbench.texteditor/debug/DocumentLineDiffer")); //$NON-NLS-1$//$NON-NLS-2$
-
- /** Suspended state */
- private static final int SUSPENDED= 0;
- /** Initializing state */
- private static final int INITIALIZING= 1;
- /** Synchronized state */
- private static final int SYNCHRONIZED= 2;
-
- /** This differ's state */
- private int fState= SUSPENDED;
- /** Artificial line difference information indicating a change with an empty line as original text. */
- private final ILineDiffInfo fLineChangeInfo= new LineChangeInfo();
-
- /** The provider for the reference document. */
- IQuickDiffReferenceProvider fReferenceProvider;
- /** The number of clients connected to this model. */
- private int fOpenConnections;
- /** The current document being tracked. */
- private IDocument fLeftDocument;
- /** The reference document. */
- private IDocument fRightDocument;
- /**
- * Flag to indicate whether a change has been made to the line table and any clients should
- * update their presentation.
- */
- private boolean fUpdateNeeded;
- /** The listeners on this annotation model. */
- private List fAnnotationModelListeners= new ArrayList();
- /** The job currently initializing the differ, or <code>null</code> if there is none. */
- private Job fInitializationJob;
- /** Stores <code>DocumentEvents</code> while an initialization is going on. */
- private List fStoredEvents= new ArrayList();
- /**
- * The differences between <code>fLeftDocument</code> and <code>fRightDocument</code>.
- * This is the model we work on.
- */
- private List fDifferences= new ArrayList();
- /**
- * The differences removed in one iteration. Stored to be able to send out differentiated
- * annotation events.
- */
- private List fRemoved= new ArrayList();
- /**
- * The differences added in one iteration. Stored to be able to send out differentiated
- * annotation events.
- */
- private List fAdded= new ArrayList();
- /**
- * The differences changed in one iteration. Stored to be able to send out differentiated
- * annotation events.
- */
- private List fChanged= new ArrayList();
- /** The first line affected by a document event. */
- private int fFirstLine;
- /** The number of lines affected by a document event. */
- private int fNLines;
- /** The most recent range difference returned in a getLineInfo call, so it can be recyled. */
- private RangeDifference fLastDifference;
- /**
- * <code>true</code> if incoming document events should be ignored,
- * <code>false</code> if not.
- */
- private boolean fIgnoreDocumentEvents= true;
-
- /**
- * Creates a new differ.
- */
- public DocumentLineDiffer() {
- }
-
- /* ILineDiffer implementation */
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffer#getLineInfo(int)
- */
- public ILineDiffInfo getLineInfo(int line) {
-
- if (isSuspended())
- return fLineChangeInfo;
-
- // try cache first / speeds up linear search
- RangeDifference last= fLastDifference;
- if (last != null && last.rightStart() <= line && last.rightEnd() > line)
- return new DiffRegion(last, line - last.rightStart(), fDifferences, fLeftDocument);
-
- fLastDifference= getRangeDifferenceForRightLine(line);
- last= fLastDifference;
- if (last != null)
- return new DiffRegion(last, line - last.rightStart(), fDifferences, fLeftDocument);
- else
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffer#revertLine(int)
- */
- public synchronized void revertLine(int line) throws BadLocationException {
- if (!isInitialized())
- throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$
-
- DiffRegion region= (DiffRegion) getLineInfo(line);
- if (region == null || fRightDocument == null || fLeftDocument == null)
- return;
-
- RangeDifference diff= region.getDifference();
- int rOffset= fRightDocument.getLineOffset(line);
- int rLength= fRightDocument.getLineLength(line);
- int leftLine= diff.leftStart() + region.getOffset();
- String replacement;
- if (leftLine >= diff.leftEnd()) // restoring a deleted line?
- replacement= new String();
- else {
- int lOffset= fLeftDocument.getLineOffset(leftLine);
- int lLength= fLeftDocument.getLineLength(leftLine);
- replacement= fLeftDocument.get(lOffset, lLength);
- }
- fRightDocument.replace(rOffset, rLength, replacement);
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffer#revertBlock(int)
- */
- public synchronized void revertBlock(int line) throws BadLocationException {
- if (!isInitialized())
- throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$
-
- DiffRegion region= (DiffRegion) getLineInfo(line);
- if (region == null || fRightDocument == null || fLeftDocument == null)
- return;
-
- RangeDifference diff= region.getDifference();
- int rOffset= fRightDocument.getLineOffset(diff.rightStart());
- int rLength= fRightDocument.getLineOffset(diff.rightEnd() - 1) + fRightDocument.getLineLength(diff.rightEnd() - 1) - rOffset;
- int lOffset= fLeftDocument.getLineOffset(diff.leftStart());
- int lLength= fLeftDocument.getLineOffset(diff.leftEnd() - 1) + fLeftDocument.getLineLength(diff.leftEnd() - 1) - lOffset;
- fRightDocument.replace(rOffset, rLength, fLeftDocument.get(lOffset, lLength));
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffer#revertSelection(int, int)
- */
- public synchronized void revertSelection(int line, int nLines) throws BadLocationException {
- if (!isInitialized())
- throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$
-
- int rOffset= -1, rLength= -1, lOffset= -1, lLength= -1;
- RangeDifference diff= null;
- Iterator it= fDifferences.iterator();
-
- // get start
- while (it.hasNext()) {
- diff= (RangeDifference) it.next();
- if (line < diff.rightEnd()) {
- rOffset= fRightDocument.getLineOffset(line);
- int leftLine= Math.min(diff.leftStart() + line - diff.rightStart(), diff.leftEnd() - 1);
- lOffset= fLeftDocument.getLineOffset(leftLine);
- break;
- }
- }
-
- if (rOffset == -1 || lOffset == -1)
- return;
-
- // get end / length
- int to= line + nLines - 1;
- while (it.hasNext()) {
- diff= (RangeDifference) it.next();
- if (to < diff.rightEnd()) {
- int rEndOffset= fRightDocument.getLineOffset(to) + fRightDocument.getLineLength(to);
- rLength= rEndOffset - rOffset;
- int leftLine= Math.min(diff.leftStart() + to - diff.rightStart(), diff.leftEnd() - 1);
- int lEndOffset= fLeftDocument.getLineOffset(leftLine) + fLeftDocument.getLineLength(leftLine);
- lLength= lEndOffset - lOffset;
- break;
- }
- }
-
- if (rLength == -1 || lLength == -1)
- return;
-
- fRightDocument.replace(rOffset, rLength, fLeftDocument.get(lOffset, lLength));
- }
-
- /*
- * @see org.eclipse.jface.text.source.ILineDiffer#restoreAfterLine(int)
- */
- public synchronized int restoreAfterLine(int line) throws BadLocationException {
- if (!isInitialized())
- throw new BadLocationException(QuickDiffMessages.getString("quickdiff.nonsynchronized")); //$NON-NLS-1$
-
- DiffRegion region= (DiffRegion) getLineInfo(line);
- if (region == null || fRightDocument == null || fLeftDocument == null)
- return 0;
-
- if (region.getRemovedLinesBelow() < 1)
- return 0;
-
- RangeDifference diff= null;
- for (Iterator it= fDifferences.iterator(); it.hasNext();) {
- diff= (RangeDifference) it.next();
- if (line >= diff.rightStart() && line < diff.rightEnd()) {
- if (diff.kind() == RangeDifference.NOCHANGE && it.hasNext())
- diff= (RangeDifference) it.next();
- break;
- }
- }
-
- if (diff == null)
- return 0;
-
- int rOffset= fRightDocument.getLineOffset(diff.rightEnd());
- int rLength= 0;
- int leftLine= diff.leftStart() + diff.rightLength();
- int lOffset= fLeftDocument.getLineOffset(leftLine);
- int lLength= fLeftDocument.getLineOffset(diff.leftEnd() - 1) + fLeftDocument.getLineLength(diff.leftEnd() - 1) - lOffset;
- fRightDocument.replace(rOffset, rLength, fLeftDocument.get(lOffset, lLength));
-
- return diff.leftLength() - diff.rightLength();
- }
-
- /**
- * Returns the receivers initialization state.
- *
- * @return <code>true</code> if we are initialized and in sync with the document.
- */
- private boolean isInitialized() {
- return fState == SYNCHRONIZED;
- }
-
- /**
- * Returns the receivers synchronization state.
- *
- * @return <code>true</code> if we are initialized and in sync with the document.
- */
- public synchronized boolean isSynchronized() {
- return fState == SYNCHRONIZED;
- }
-
- /**
- * Returns <code>true</code> if the differ is suspended.
- *
- * @return <code>true</code> if the differ is suspended
- */
- private synchronized boolean isSuspended() {
- return fState == SUSPENDED;
- }
-
- /**
- * Sets the reference provider for this instance. If one has been installed before, it is
- * disposed.
- *
- * @param provider the new provider
- */
- public void setReferenceProvider(IQuickDiffReferenceProvider provider) {
- Assert.isNotNull(provider);
- if (provider != fReferenceProvider) {
- if (fReferenceProvider != null)
- fReferenceProvider.dispose();
- fReferenceProvider= provider;
- initialize();
- }
- }
-
- /**
- * Returns the reference provider currently installed, or <code>null</code> if none is installed.
- *
- * @return the current reference provider.
- */
- public IQuickDiffReferenceProvider getReferenceProvider() {
- return fReferenceProvider;
- }
-
- /**
- * (Re-)initializes the differ using the current reference and <code>DiffInitializer</code>
- */
- synchronized void initialize() {
- // make new incoming changes go into the queue of stored events, plus signal we can't restore.
- fState= INITIALIZING;
-
- if (fRightDocument == null)
- return;
-
- // there is no point in receiving updates before the job we get a new copy of the document for diffing
- fIgnoreDocumentEvents= true;
-
- if (fLeftDocument != null) {
- fLeftDocument.removeDocumentListener(this);
- fLeftDocument= null;
- }
-
- // if there already is a job:
- // return if it has not started yet, cancel it if already running
- final Job oldJob= fInitializationJob;
- if (oldJob != null) {
- // don't chain up jobs if there is one waiting already.
- if (oldJob.getState() == Job.WAITING)
- return;
- else
- oldJob.cancel();
- }
-
- fInitializationJob= new Job(QuickDiffMessages.getString("quickdiff.initialize")) { //$NON-NLS-1$
-
- /*
- * This is run in a different thread. As the documents might be synchronized, never ever
- * access the documents in a synchronized section or expect deadlocks. See
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=44692
- */
- public IStatus run(IProgressMonitor monitor) {
-
- // 1: wait for any previous job that was canceled to avoid job flooding
- // It will return relatively quickly as RangeDifferencer supports canceling
- if (oldJob != null)
- try {
- oldJob.join();
- } catch (InterruptedException e) {
- // will not happen as noone interrupts our thread
- Assert.isTrue(false);
- }
-
-
- // 2: get the reference document
- IQuickDiffReferenceProvider provider= fReferenceProvider;
- final IDocument left;
- try {
- left= provider == null ? null : provider.getReference(monitor);
- } catch (CoreException e) {
- synchronized (DocumentLineDiffer.this) {
- if (isCanceled(monitor))
- return Status.CANCEL_STATUS;
- else {
- clearModel();
- fireModelChanged();
- DocumentLineDiffer.this.notifyAll();
- return e.getStatus();
- }
- }
- } catch (OperationCanceledException e) {
- return Status.CANCEL_STATUS;
- }
-
- // Getting our own copies of the documents for offline diffing.
- //
- // We need to make sure that we do get all document modifications after
- // copying the documents as we want to reinject them later on to become consistent.
- //
- // Now this is fun. The reference documents may be PartiallySynchronizedDocuments
- // which will result in a deadlock if they get changed externally before we get
- // our exclusive copies.
- // Here's what we do: we try over and over (without synchronization) to get copies
- // without interleaving modification. If there is a document change, we just repeat.
-
- IDocument right= fRightDocument; // fRightDocument, but not subject to change
- IDocument actual= null; // the copy of the actual (right) document
- IDocument reference= null; // the copy of the reference (left) document
-
- synchronized (DocumentLineDiffer.this) {
- // 4: take an early exit if the documents are not valid
- if (left == null || right == null) {
- if (isCanceled(monitor))
- return Status.CANCEL_STATUS;
- else {
- clearModel();
- fireModelChanged();
- DocumentLineDiffer.this.notifyAll();
- return Status.OK_STATUS;
- }
- }
-
- // set the reference document
- fLeftDocument= left;
- // start listening to document events.
- fIgnoreDocumentEvents= false;
- }
-
- // accessing the reference docuent offline - reference provider need
- // to be able to deal with this.
- left.addDocumentListener(DocumentLineDiffer.this);
-
- int i= 0;
- do {
- if (i++ == 100) // XXX this is an arbitrary emergency exit in case a referenced document goes nuts
- return new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, QuickDiffMessages.getFormattedString("quickdiff.error.getting_document_content", new Object[] {left.getClass(), right.getClass()}), null); //$NON-NLS-1$
-
- // clear events
- synchronized (DocumentLineDiffer.this) {
- if (isCanceled(monitor))
- return Status.CANCEL_STATUS;
-
- fStoredEvents.clear();
- }
-
- // access documents unsynched:
- // get an exclusive copy of the actual document
- reference= createCopy(left);
- actual= createCopy(right);
-
- synchronized (DocumentLineDiffer.this) {
- if (fStoredEvents.size() == 0 && reference != null && actual != null)
- break;
- }
-
- } while (true);
-
- // 6: Do Da Diffing
- DocLineComparator ref= new DocLineComparator(reference, null, false);
- DocLineComparator act= new DocLineComparator(actual, null, false);
- List diffs;
- try {
- diffs= RangeDifferencer.findRanges(monitor, ref, act);
- } catch (LowMemoryException e) {
- handleLowMemory(e);
- return Status.CANCEL_STATUS;
- }
-
- // 7: Reset the model to the just gotten differences
- // re-inject stored events to get up to date.
- synchronized (DocumentLineDiffer.this) {
- if (isCanceled(monitor))
- return Status.CANCEL_STATUS;
-
- // set the new differences so we can operate on them
- fDifferences= diffs;
- }
-
- // reinject events accumulated in the meantime.
- try {
- do {
- DocumentEvent event;
- synchronized (DocumentLineDiffer.this) {
- if (isCanceled(monitor))
- return Status.CANCEL_STATUS;
-
- if (fStoredEvents.isEmpty()) {
- // we are done
- fInitializationJob= null;
- fState= SYNCHRONIZED;
- fLastDifference= null;
-
- // inform blocking calls.
- DocumentLineDiffer.this.notifyAll();
-
- break;
- } else {
- event= (DocumentEvent) fStoredEvents.remove(0);
- }
- }
-
- // access documents unsynched:
- handleAboutToBeChanged(event);
- handleChanged(event);
-
- } while (true);
-
- } catch (BadLocationException e) {
- left.removeDocumentListener(DocumentLineDiffer.this);
- clearModel();
- initialize();
- return Status.CANCEL_STATUS;
- } catch (LowMemoryException e) {
- handleLowMemory(e);
- return Status.CANCEL_STATUS;
- }
-
- fireModelChanged();
- return Status.OK_STATUS;
- }
-
- private boolean isCanceled(IProgressMonitor monitor) {
- return fInitializationJob != this || monitor != null && monitor.isCanceled();
- }
-
- private void clearModel() {
- fLeftDocument= null;
- fInitializationJob= null;
- fStoredEvents.clear();
- fLastDifference= null;
- fDifferences.clear();
- }
-
- /**
- * Creates a copy of <code>document</code> and catches any
- * exceptions that may occur if the document is not modified concurrently.
- * Do not call this method in a synchronized block as document.get() is called
- * and may result in a deadlock otherwise.
- *
- * @param document the document to create a copy of
- * @return a copy of the document, or <code>null</code> if an exception was thrown
- */
- private IDocument createCopy(IDocument document) {
- Assert.isNotNull(document);
- // TODO needs for sure a safer synchronization method
- // this is a temporary workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=56091
- try {
- return new Document(document.get());
- } catch (NullPointerException e) {
- } catch (ArrayStoreException e) {
- } catch (IndexOutOfBoundsException e) {
- } catch (ConcurrentModificationException e) {
- }
- return null;
- }
- };
-
- fInitializationJob.setSystem(true);
- fInitializationJob.setPriority(Job.DECORATE);
- fInitializationJob.schedule();
- }
-
- /* IDocumentListener implementation */
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public synchronized void documentAboutToBeChanged(DocumentEvent event) {
- if (fIgnoreDocumentEvents)
- return;
-
- // if a initialization is going on, we just store the events in the meantime
- if (!isInitialized() && fInitializationJob != null) {
- fStoredEvents.add(event);
- return;
- }
-
- try {
- handleAboutToBeChanged(event);
- } catch (BadLocationException e) {
- reinitOnError(e);
- return;
- } catch (NullPointerException e) {
- reinitOnError(e);
- return;
- } catch (ArrayStoreException e) {
- reinitOnError(e);
- return;
- } catch (IndexOutOfBoundsException e) {
- reinitOnError(e);
- return;
- } catch (ConcurrentModificationException e) {
- reinitOnError(e);
- return;
- }
- }
-
-
- /**
- * Unsynchronized version of <code>documentAboutToBeChanged</code>, called by <code>documentAboutToBeChanged</code>
- * and {@link #initialize()}.
- *
- * @param event the document event to be handled
- */
- void handleAboutToBeChanged(DocumentEvent event) throws BadLocationException {
- IDocument doc= event.getDocument();
- if (doc == null)
- return;
-
- // store size of replaced region (never synchronized -> not a problem)
- fFirstLine= doc.getLineOfOffset(event.getOffset()); // store change bounding lines
- fNLines= doc.getLineOfOffset(event.getOffset() + event.getLength()) - fFirstLine + 1;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public synchronized void documentChanged(DocumentEvent event) {
- if (fIgnoreDocumentEvents)
- return;
-
- if (!isInitialized())
- return;
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=44692
- // don't allow incremental update for changes from the reference document
- // as this could deadlock
- if (event.getDocument() == fLeftDocument) {
- initialize();
- return;
- }
-
- try {
- handleChanged(event);
- } catch (BadLocationException e) {
- reinitOnError(e);
- return;
- } catch (NullPointerException e) {
- reinitOnError(e);
- return;
- } catch (ArrayStoreException e) {
- reinitOnError(e);
- return;
- } catch (IndexOutOfBoundsException e) {
- reinitOnError(e);
- return;
- } catch (ConcurrentModificationException e) {
- reinitOnError(e);
- return;
- } catch (LowMemoryException e) {
- handleLowMemory(e);
- return;
- }
-
- // inform listeners about change
- if (fUpdateNeeded) {
- AnnotationModelEvent ame= new AnnotationModelEvent(this, false);
- for (Iterator it= fAdded.iterator(); it.hasNext(); ) {
- RangeDifference rd= (RangeDifference) it.next();
- ame.annotationAdded(rd.getDiffRegion(fDifferences, fLeftDocument));
- }
- for (Iterator it= fRemoved.iterator(); it.hasNext(); ) {
- RangeDifference rd= (RangeDifference) it.next();
- ame.annotationRemoved(rd.getDiffRegion(fDifferences, fLeftDocument));
- }
- for (Iterator it= fChanged.iterator(); it.hasNext(); ) {
- RangeDifference rd= (RangeDifference) it.next();
- ame.annotationChanged(rd.getDiffRegion(fDifferences, fLeftDocument));
- }
- fireModelChanged(ame);
- fUpdateNeeded= false;
- }
- }
-
- /**
- * Re-initializes the differ if an exception is thrown upon accessing the documents. This can
- * happen if the documents get concurrently modified from a background thread.
- *
- * @param e the exception thrown, which is logged in debug mode
- */
- private void reinitOnError(Exception e) {
- if (DEBUG)
- System.err.println("reinitializing quickdiff:\n" + e.getLocalizedMessage() + "\n" + e.getStackTrace()); //$NON-NLS-1$//$NON-NLS-2$
- initialize();
- }
-
- /**
- * Implementation of documentChanged, non synchronized.
- *
- * @param event the document event
- * @throws LowMemoryException if the differ runs out of memory
- */
- void handleChanged(DocumentEvent event) throws BadLocationException, LowMemoryException {
- /*
- * Now, here we have a great example of object oriented programming.
- */
-
- // documents: left, right; modified and unchanged are either of both
- IDocument left= fLeftDocument;
- IDocument right= fRightDocument;
- IDocument modified= event.getDocument();
- if (modified != left && modified != right)
- Assert.isTrue(false);
-
- String insertion= event.getText();
- int added= insertion == null ? 1 : modified.computeNumberOfLines(insertion) + 1;
- // size: the size of the document change in lines
-
- // put an upper bound to the delay we can afford
- if (added > 50 || fNLines > 50) {
- initialize();
- return;
- }
-
- int size= Math.max(fNLines, added) + 1;
- int lineDelta= added - fNLines;
- int lastLine= fFirstLine + fNLines - 1;
-
- int repetitionField;
- if (modified == left) {
- int originalLine= getRightLine(lastLine + 1);
- repetitionField= searchForRepetitionField(size - 1, right, originalLine);
- } else {
- int originalLine= getLeftLine(lastLine + 1);
- repetitionField= searchForRepetitionField(size - 1, left, originalLine);
- }
- lastLine += repetitionField;
-
-
- // get enclosing range: search for a consistent block of at least the size of our
- // change before and after the change.
- RangeDifference consistentBefore, consistentAfter;
- if (modified == left) {
- consistentBefore= findConsistentRangeBeforeLeft(fFirstLine, size);
- consistentAfter= findConsistentRangeAfterLeft(lastLine, size);
- } else {
- consistentBefore= findConsistentRangeBeforeRight(fFirstLine, size);
- consistentAfter= findConsistentRangeAfterRight(lastLine, size);
- }
-
- // optimize unchanged blocks: if the consistent blocks around the change are larger than
- // size, we redimension them (especially important when there are only very little changes.
- int shiftBefore= 0;
- if (consistentBefore.kind() == RangeDifference.NOCHANGE) {
- int unchanged;
- if (modified == left)
- unchanged= Math.min(fFirstLine, consistentBefore.leftEnd()) - consistentBefore.leftStart();
- else
- unchanged= Math.min(fFirstLine, consistentBefore.rightEnd()) - consistentBefore.rightStart();
-
- shiftBefore= Math.max(0, unchanged - size);
- }
-
- int shiftAfter= 0;
- if (consistentAfter.kind() == RangeDifference.NOCHANGE) {
- int unchanged;
- if (modified == left)
- unchanged= consistentAfter.leftEnd() - Math.max(lastLine + 1, consistentAfter.leftStart());
- else
- unchanged= consistentAfter.rightEnd() - Math.max(lastLine + 1, consistentAfter.rightStart());
-
- shiftAfter= Math.max(0, unchanged - size);
- }
-
- // get the document regions that will be rediffed, take into account that on the
- // document, the change has already happened.
- // left (reference) document
- int leftOffset= left.getLineOffset(consistentBefore.leftStart() + shiftBefore);
- int leftLine= Math.max(consistentAfter.leftEnd() - 1, 0);
- if (modified == left)
- leftLine += lineDelta;
- IRegion leftLastLine= left.getLineInformation(leftLine - shiftAfter);
- int leftEndOffset= leftLastLine.getOffset() + leftLastLine.getLength();
- IRegion leftRegion= new Region(leftOffset, leftEndOffset - leftOffset);
- DocLineComparator reference= new DocLineComparator(left, leftRegion, false);
-
- // right (actual) document
- int rightOffset= right.getLineOffset(consistentBefore.rightStart() + shiftBefore);
- int rightLine= Math.max(consistentAfter.rightEnd() - 1, 0);
- if (modified == right)
- rightLine += lineDelta;
- IRegion rightLastLine= right.getLineInformation(rightLine - shiftAfter);
- int rightEndOffset= rightLastLine.getOffset() + rightLastLine.getLength();
- IRegion rightRegion= new Region(rightOffset, rightEndOffset - rightOffset);
- DocLineComparator change= new DocLineComparator(right, rightRegion, false);
-
- // put an upper bound to the delay we can afford
- if (leftLine - shiftAfter - (consistentBefore.leftStart() + shiftBefore) > 50 || rightLine - shiftAfter - (consistentBefore.rightStart() + shiftBefore) > 50) {
- initialize();
- return;
- }
-
- // debug
-// System.out.println("compare window: "+size+"\n\n<" + left.get(leftRegion.getOffset(), leftRegion.getLength()) + //$NON-NLS-1$//$NON-NLS-2$
-// ">\n\n<" + right.get(rightRegion.getOffset(), rightRegion.getLength()) + ">\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // compare
- List diffs= RangeDifferencer.findRanges(reference, change);
- if (diffs.size() == 0) {
- diffs.add(new RangeDifference(RangeDifference.CHANGE, 0, 0, 0, 0));
- }
-
-
- // shift the partial diffs to the absolute document positions
- int leftShift= consistentBefore.leftStart() + shiftBefore;
- int rightShift= consistentBefore.rightStart() + shiftBefore;
- for (Iterator it= diffs.iterator(); it.hasNext();) {
- RangeDifference d= (RangeDifference) it.next();
- d.shiftLeft(leftShift);
- d.shiftRight(rightShift);
- }
-
- // undo optimization shifting
- if (shiftBefore > 0) {
- RangeDifference first= (RangeDifference) diffs.get(0);
- if (first.kind() == RangeDifference.NOCHANGE)
- first.extendStart(-shiftBefore);
- else
- diffs.add(0, new RangeDifference(RangeDifference.NOCHANGE, first.rightStart() - shiftBefore, shiftBefore, first.leftStart() - shiftBefore, shiftBefore));
- }
-
- RangeDifference last= (RangeDifference) diffs.get(diffs.size() - 1);
- if (shiftAfter > 0) {
- if (last.kind() == RangeDifference.NOCHANGE)
- last.extendEnd(shiftAfter);
- else
- diffs.add(new RangeDifference(RangeDifference.NOCHANGE, last.rightEnd(), shiftAfter , last.leftEnd(), shiftAfter));
- }
-
- // replace changed diff range
- ListIterator it= fDifferences.listIterator();
- Iterator newIt= diffs.iterator();
- RangeDifference current;
- boolean changed= false;
-
- // replace regions from consistentBefore to consistentAfter with new diffs
-
- // search for consistentBefore
- do {
- Assert.isTrue(it.hasNext());
- current= (RangeDifference) it.next();
- } while (current != consistentBefore);
- Assert.isTrue(current == consistentBefore);
-
- fChanged.clear();
- fRemoved.clear();
- fAdded.clear();
-
- // replace until consistentAfter
- while (current != consistentAfter) {
- if (newIt.hasNext()) {
- Object o= newIt.next();
- if (!current.equals(o)) {
- fRemoved.add(current);
- fAdded.add(o);
- changed= true;
- it.set(o);
- }
- } else {
- fRemoved.add(current);
- it.remove();
- fUpdateNeeded= true;
- }
- Assert.isTrue(it.hasNext());
- current= (RangeDifference) it.next();
- }
-
- // replace consistentAfter
- Assert.isTrue(current == consistentAfter);
- if (newIt.hasNext()) {
- Object o= newIt.next();
- if (!current.equals(o)) {
- fRemoved.add(current);
- fAdded.add(o);
- changed= true;
- it.set(o);
- }
- } else {
- fRemoved.add(current);
- it.remove();
- fUpdateNeeded= true;
- }
-
- // add remaining new diffs
- while (newIt.hasNext()) {
- Object next= newIt.next();
- fAdded.add(next);
- it.add(next);
- changed= true;
- }
-
- // shift the old remaining diffs
- boolean init= true;
- while (it.hasNext()) {
- current= (RangeDifference) it.next();
- if (init) {
- init= false;
- leftShift= last.leftEnd() - current.leftStart();
- rightShift= last.rightEnd() - current.rightStart();
- if (leftShift != 0 || rightShift != 0)
- changed= true;
- else
- break;
- }
-// fChanged.add(current); // not needed since positional shifting is not handled by an annotation model
- current.shiftLeft(leftShift);
- current.shiftRight(rightShift);
- }
-
- fUpdateNeeded= changed;
- fLastDifference= null;
-
- }
-
- /**
- * Finds a consistent range of at least size before <code>line</code> in the left document.
- *
- * @param line the line before which the range has to occur
- * @param size the minimal size of the range
- * @return the first range found, or the first range in the differ if none can be found
- */
- private RangeDifference findConsistentRangeBeforeLeft(int line, int size) {
- RangeDifference found= null;
-
- for (ListIterator it= fDifferences.listIterator(); it.hasNext();) {
- RangeDifference difference= (RangeDifference) it.next();
- if (found == null || difference.kind() == RangeDifference.NOCHANGE
- && (difference.leftEnd() < line && difference.leftLength() >= size
- || difference.leftEnd() >= line && line - difference.leftStart() >= size))
- found= difference;
-
- if (difference.leftEnd() >= line)
- break;
- }
-
- return found;
- }
-
- /**
- * Finds a consistent range of at least size after <code>line</code> in the left document.
- *
- * @param line the line after which the range has to occur
- * @param size the minimal size of the range
- * @return the first range found, or the last range in the differ if none can be found
- */
- private RangeDifference findConsistentRangeAfterLeft(int line, int size) {
- RangeDifference found= null;
-
- for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
- RangeDifference difference= (RangeDifference) it.previous();
- if (found == null || difference.kind() == RangeDifference.NOCHANGE
- && (difference.leftStart() > line && difference.leftLength() >= size
- || difference.leftStart() <= line && difference.leftEnd() - line >= size))
- found= difference;
-
- if (difference.leftStart() <= line)
- break;
-
- }
-
- return found;
- }
-
- /**
- * Finds a consistent range of at least size before <code>line</code> in the right document.
- *
- * @param line the line before which the range has to occur
- * @param size the minimal size of the range
- * @return the first range found, or the first range in the differ if none can be found
- */
- private RangeDifference findConsistentRangeBeforeRight(int line, int size) {
- RangeDifference found= null;
-
- int unchanged= -1; // the number of unchanged lines before line
- for (ListIterator it= fDifferences.listIterator(); it.hasNext();) {
- RangeDifference difference= (RangeDifference) it.next();
- if (found == null)
- found= difference;
- else if (difference.kind() == RangeDifference.NOCHANGE) {
- unchanged= Math.min(line, difference.rightEnd()) - difference.rightStart();
- if (unchanged >= size)
- found= difference;
- }
-
- if (difference.rightEnd() >= line)
- break;
- }
-
- return found;
- }
-
- /**
- * Finds a consistent range of at least size after <code>line</code> in the right document.
- *
- * @param line the line after which the range has to occur
- * @param size the minimal size of the range
- * @return the first range found, or the last range in the differ if none can be found
- */
- private RangeDifference findConsistentRangeAfterRight(int line, int size) {
- RangeDifference found= null;
-
- int unchanged= -1; // the number of unchanged lines after line
- for (ListIterator it= fDifferences.listIterator(fDifferences.size()); it.hasPrevious();) {
- RangeDifference difference= (RangeDifference) it.previous();
- if (found == null)
- found= difference;
- else if (difference.kind() == RangeDifference.NOCHANGE) {
- unchanged= difference.rightEnd() - Math.max(line + 1, difference.rightStart()); // + 1 to step over the changed line
- if (unchanged >= size)
- found= difference;
- }
-
- if (difference.rightStart() <= line)
- break;
- }
-
- return found;
- }
-
- /**
- * Returns the size of a repetition field starting a <code>line</code>.
- *
- * @param size the maximal length of the repeat window
- * @param doc the document to search
- * @param line the line to start searching
- * @return the size of a found repetition field, or zero
- * @throws BadLocationException if <code>doc</code> is modified concurrently
- */
- private int searchForRepetitionField(int size, IDocument doc, int line) throws BadLocationException {
- /*
- Repetition fields: a line wise repetition of maximal size <code>size</code>
- can urge a change to come at its end, as diffing greedily takes the longest
- unchanged range possible:
- <pre>
- before
- repeat
- repeat
- repeat
- repeat
- repeat
- repeat
- repeat
- repeat
- after
- </pre>
-
- Inserting another repeat element anywhere in the repetition field will create
- an addition at its end.
-
- Size is one less than our window size (as this is already one more than the actual number
- of affected lines.
- */
-
- /*
- * Implementation:
- * Window of maximum repetition size. Whenever the current matches the first in the window,
- * we advance it by one. If there are more free slots in the window, the current line is
- * appended.
- * We terminate if the current line does not match and there are no more free slots.
- *
- * TODO what if we have a prefix to a repetition field? Probably does not matter.
- */
- LinkedList window= new LinkedList();
- int nLines= doc.getNumberOfLines();
- int repetition= line - 1;
- int l= line;
-
- while (l >= 0 && l < nLines) {
- IRegion r= doc.getLineInformation(l);
- String current= doc.get(r.getOffset(), r.getLength());
-
- if (!window.isEmpty() && window.get(0).equals(current)) {
- // repetition found, shift
- window.removeFirst();
- window.addLast(current);
- repetition= l;
- } else {
- // no repetition, add if there is room
- // otherwise return
- if (window.size() < size)
- window.addLast(current);
- else
- break;
- }
-
- l++;
- }
-
- int fieldLength= repetition - line + 1;
- Assert.isTrue(fieldLength >= 0);
- return fieldLength;
- }
-
- /**
- * Gets the corresponding line on the left side for a line on the right.
- *
- * @param rightLine the line on the right side
- * @return the corresponding left hand line, or <code>-1</code>
- */
- private int getLeftLine(int rightLine) {
- RangeDifference d= getRangeDifferenceForRightLine(rightLine);
- if (d == null)
- return -1;
- return Math.min(d.leftEnd() - 1, d.leftStart() + rightLine - d.rightStart());
- }
-
- /**
- * Gets the corresponding line on the right side for a line on the left.
- *
- * @param leftLine the line on the left side
- * @return the corresponding right hand line, or <code>-1</code>
- */
- private int getRightLine(int leftLine) {
- RangeDifference d= getRangeDifferenceForLeftLine(leftLine);
- if (d == null)
- return -1;
- return Math.min(d.rightEnd() - 1, d.rightStart() + leftLine - d.leftStart());
- }
-
- /**
- * Gets the RangeDifference for a line on the left hand side.
- *
- * @param leftLine the line on the left side
- * @return the corresponding RangeDifference, or <code>null</code>
- */
- private RangeDifference getRangeDifferenceForLeftLine(int leftLine) {
- for (Iterator it= fDifferences.iterator(); it.hasNext();) {
- RangeDifference d= (RangeDifference) it.next();
- if (leftLine >= d.leftStart() && leftLine < d.leftEnd()) {
- return d;
- }
- }
- return null;
- }
-
- /**
- * Gets the RangeDifference for a line on the right hand side.
- *
- * @param rightLine the line on the right side
- * @return the corresponding RangeDifference, or <code>null</code>
- */
- private RangeDifference getRangeDifferenceForRightLine(int rightLine) {
- for (Iterator it= fDifferences.iterator(); it.hasNext();) {
- RangeDifference d= (RangeDifference) it.next();
- if (rightLine >= d.rightStart() && rightLine < d.rightEnd()) {
- return d;
- }
- }
- return null;
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#addAnnotationModelListener(org.eclipse.jface.text.source.IAnnotationModelListener)
- */
- public void addAnnotationModelListener(IAnnotationModelListener listener) {
- fAnnotationModelListeners.add(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#removeAnnotationModelListener(org.eclipse.jface.text.source.IAnnotationModelListener)
- */
- public void removeAnnotationModelListener(IAnnotationModelListener listener) {
- fAnnotationModelListeners.remove(listener);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#connect(org.eclipse.jface.text.IDocument)
- */
- public void connect(IDocument document) {
- Assert.isTrue(fRightDocument == null || fRightDocument == document);
-
- ++fOpenConnections;
- if (fOpenConnections == 1) {
- fRightDocument= document;
- fRightDocument.addDocumentListener(this);
- initialize();
- }
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#disconnect(org.eclipse.jface.text.IDocument)
- */
- public void disconnect(IDocument document) {
- Assert.isTrue(fRightDocument == document);
-
- --fOpenConnections;
-
- if (fOpenConnections == 0)
- uninstall();
- }
-
- /**
- * Uninstalls all components and dereferences any objects.
- */
- private void uninstall() {
- synchronized (this) {
- fState= SUSPENDED;
- fIgnoreDocumentEvents= true;
- if (fInitializationJob != null)
- fInitializationJob.cancel();
- fInitializationJob= null;
-
- if (fLeftDocument != null)
- fLeftDocument.removeDocumentListener(this);
- fLeftDocument= null;
-
- if (fRightDocument != null)
- fRightDocument.removeDocumentListener(this);
- fRightDocument= null;
- }
-
- if (fReferenceProvider != null) {
- fReferenceProvider.dispose();
- fReferenceProvider= null;
- }
-
- fDifferences.clear();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#addAnnotation(org.eclipse.jface.text.source.Annotation, org.eclipse.jface.text.Position)
- */
- public void addAnnotation(Annotation annotation, Position position) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#removeAnnotation(org.eclipse.jface.text.source.Annotation)
- */
- public void removeAnnotation(Annotation annotation) {
- throw new UnsupportedOperationException();
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#getAnnotationIterator()
- */
- public Iterator getAnnotationIterator() {
- final List copy= new ArrayList(fDifferences);
- final Iterator iter= copy.iterator();
- return new Iterator() {
-
- public void remove() {
- throw new UnsupportedOperationException();
- }
-
- public boolean hasNext() {
- return iter.hasNext();
- }
-
- public Object next() {
- RangeDifference diff= (RangeDifference) iter.next();
- return diff.getDiffRegion(copy, fLeftDocument);
- }
-
- };
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationModel#getPosition(org.eclipse.jface.text.source.Annotation)
- */
- public Position getPosition(Annotation annotation) {
- if (fRightDocument != null && annotation instanceof DiffRegion) {
- RangeDifference difference= ((DiffRegion)annotation).getDifference();
- try {
- int offset= fRightDocument.getLineOffset(difference.rightStart());
- return new Position(offset, fRightDocument.getLineOffset(difference.rightEnd() - 1) + fRightDocument.getLineLength(difference.rightEnd() - 1) - offset);
- } catch (BadLocationException e) {
- // ignore and return null;
- }
- }
- return null;
- }
-
- /**
- * Informs all annotation model listeners that this model has been changed.
- */
- protected void fireModelChanged() {
- fireModelChanged(new AnnotationModelEvent(this));
- }
-
- /**
- * Informs all annotation model listeners that this model has been changed
- * as described in the annotation model event. The event is sent out
- * to all listeners implementing <code>IAnnotationModelListenerExtension</code>.
- * All other listeners are notified by just calling <code>modelChanged(IAnnotationModel)</code>.
- *
- * @param event the event to be sent out to the listeners
- */
- protected void fireModelChanged(AnnotationModelEvent event) {
- ArrayList v= new ArrayList(fAnnotationModelListeners);
- Iterator e= v.iterator();
- while (e.hasNext()) {
- IAnnotationModelListener l= (IAnnotationModelListener)e.next();
- if (l instanceof IAnnotationModelListenerExtension)
- ((IAnnotationModelListenerExtension)l).modelChanged(event);
- else
- l.modelChanged(this);
- }
- }
-
- /**
- * Stops diffing of this differ. All differences are cleared.
- */
- public synchronized void suspend() {
- if (fInitializationJob != null) {
- fInitializationJob.cancel();
- fInitializationJob= null;
- }
- if (fRightDocument != null)
- fRightDocument.removeDocumentListener(this);
- if (fLeftDocument != null)
- fLeftDocument.removeDocumentListener(this);
- fLeftDocument= null;
-
- fLastDifference= null;
- fStoredEvents.clear();
- fDifferences.clear();
-
- fState= SUSPENDED;
-
- fireModelChanged();
- }
-
- /**
- * Resumes diffing of this differ. Must only be called after suspend.
- */
- public synchronized void resume() {
- if (fRightDocument != null)
- fRightDocument.addDocumentListener(this);
- initialize();
- }
-
- /**
- * Handle low memory situation during diffing. Called from UI and jobs.
- *
- * @param e the low memory exception
- */
- private void handleLowMemory(LowMemoryException e) {
- if (DEBUG)
- System.err.println("Disabling QuickDiff:\n" + e); //$NON-NLS-1$
- suspend();
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
deleted file mode 100644
index 8cd692eac..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffExtensionsRegistry.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-import org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor;
-
-/**
- * Access class for the quick diff reference provider extension point.
- *
- * @since 3.0
- */
-public class QuickDiffExtensionsRegistry {
-
- /** The default reference provider's descriptor. */
- private ReferenceProviderDescriptor fDefaultDescriptor;
- /** The list returned to callers of <code>getExtensions</code>. */
- private List fDescriptors;
-
- /**
- * Creates a new instance.
- */
- public QuickDiffExtensionsRegistry() {
- }
-
- /**
- * Returns the first descriptor with the <code>default</code> attribute set to <code>true</code>.
- *
- * @return the descriptor of the default reference provider.
- */
- public synchronized ReferenceProviderDescriptor getDefaultProvider() {
- ensureRegistered();
- return fDefaultDescriptor;
- }
-
- /**
- * Returns a non-modifiable list of <code>ReferenceProviderDescriptor</code> describing all extension
- * to the <code>quickDiffReferenceProvider</code> extension point.
- *
- * @return the list of extensions to the <code>quickDiffReferenceProvider</code> extension point.
- */
- public synchronized List getReferenceProviderDescriptors() {
- ensureRegistered();
- return fDescriptors;
- }
-
- /**
- * Ensures that the extensions are read and stored in <code>fDescriptors</code>.
- */
- private void ensureRegistered() {
- if (fDescriptors == null)
- reloadExtensions();
- }
-
- /**
- * Reads all extensions.
- * <p>
- * This method can be called more than once in
- * order to reload from a changed extension registry.
- * </p>
- */
- public synchronized void reloadExtensions() {
- fDefaultDescriptor= null;
- IExtensionRegistry registry= Platform.getExtensionRegistry();
- List list= new ArrayList();
-
- IConfigurationElement[] elements= registry.getConfigurationElementsFor(TextEditorPlugin.PLUGIN_ID, TextEditorPlugin.REFERENCE_PROVIDER_EXTENSION_POINT);
- for (int i= 0; i < elements.length; i++) {
- ReferenceProviderDescriptor desc= new ReferenceProviderDescriptor(elements[i]);
- if (fDefaultDescriptor == null && desc.getDefault())
- fDefaultDescriptor= desc;
- list.add(desc);
- }
-
- fDescriptors= Collections.unmodifiableList(list);
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.java
deleted file mode 100644
index f0ca8e8ad..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-/**
- * Helper class which wraps the specified resource bundle
- * and offers methods to access the bundle.
- *
- * @since 3.0
- */
-public class QuickDiffMessages {
-
- private static final String RESOURCE_BUNDLE= "org.eclipse.ui.internal.texteditor.quickdiff.QuickDiffMessages";//$NON-NLS-1$
-
- private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
-
- private QuickDiffMessages() {
- }
-
- public static String getString(String key) {
- try {
- return fgResourceBundle.getString(key);
- } catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
- }
- }
-
- public static ResourceBundle getResourceBundle() {
- return fgResourceBundle;
- }
-
- public static String getFormattedString(String key, Object arg) {
- return getFormattedString(key, new Object[] { arg });
- }
-
- public static String getFormattedString(String key, Object[] args) {
- return MessageFormat.format(getString(key), args);
- }
-
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties
deleted file mode 100644
index 36e3dad34..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffMessages.properties
+++ /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
-###############################################################################
-quickdiff.toggle.enable= Enable Q&uickDiff
-quickdiff.toggle.disable= Disable Q&uickDiff
-
-quickdiff.initialize= Initializing Quick Diff
-quickdiff.nonsynchronized= Quick Diff Is Not in Sync - Cannot Restore
-quickdiff.annotation.changed={0} changed
-quickdiff.annotation.added={0} added
-quickdiff.annotation.deleted={0} deleted
-quickdiff.annotation.line_singular=line
-quickdiff.annotation.line_plural=lines
-
-quickdiff.menu.label= Set QuickDiff Re&ference
-
-RevertLineAction.description= Reverts the current line to its original state
-RevertLineAction.label= Revert &Line
-RevertLineAction.delete.label= Delete Added &Line
-RevertBlockAction.description= Reverts a contiguous block of modified lines
-RevertBlockAction.label= R&evert Block
-RevertSelectionAction.description= Reverts any modified lines in the selection
-RevertSelectionAction.label= Revert S&election
-RestoreAction.description= Restores deleted lines into the current document
-RestoreAction.label= Restore &Deleted Line
-RestoreAction.multiple.label= Restore {0} &Deleted Lines
-
-quickdiff.error.getting_document_content= Unable to get document content. Left document type: {0}; right document type: {1}.
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java
deleted file mode 100644
index 890d9533c..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/QuickDiffRestoreAction.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.IChangeRulerColumn;
-import org.eclipse.jface.text.source.ILineDiffer;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-
-/**
- * Abstract superclass of actions that restore / revert parts of a document displayed in the action's
- * editor to the state described by the {@link ILineDiffer ILineDiffer} associated with the document's
- * {@link IAnnotationModel IAnnotationModel}.
- *
- * @since 3.0
- */
-public abstract class QuickDiffRestoreAction extends TextEditorAction {
-
- /**
- * Creates a new instance.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * @param editor the editor this action belongs to
- */
- QuickDiffRestoreAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /**
- * Called by this action's run method inside a pair of calls to <code>IRewriteTarget.beginCompoundChange</code>
- * and <code>IRewriteTarget.endCompoundChange</code>().
- *
- * @see IRewriteTarget
- */
- protected abstract void runCompoundChange();
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- ITextEditor editor= getTextEditor();
- if (editor == null || !validateEditorInputState())
- return;
- IRewriteTarget target= (IRewriteTarget)editor.getAdapter(IRewriteTarget.class);
- if (target != null)
- target.beginCompoundChange();
- runCompoundChange();
- if (target != null)
- target.endCompoundChange();
-
- }
-
- /*
- * @see org.eclipse.ui.texteditor.TextEditorAction#update()
- */
- public void update() {
- super.update();
- if (isEnabled())
- setEnabled(canModifyEditor());
- }
-
- /**
- * Returns the selection of the editor this action belongs to.
- *
- * @return the editor's selection, or <code>null</code>
- */
- protected ITextSelection getSelection() {
- if (getTextEditor() == null)
- return null;
- ISelectionProvider sp= getTextEditor().getSelectionProvider();
- if (sp == null)
- return null;
- ISelection s= sp.getSelection();
- if (s instanceof ITextSelection)
- return (ITextSelection)s;
- else
- return null;
- }
-
- /**
- * Returns the annotation model of the document displayed in this action's editor, if it
- * implements the {@link IAnnotationModelExtension IAnnotationModelExtension} interface.
- *
- * @return the displayed document's annotation model if it is an <code>IAnnotationModelExtension</code>, or <code>null</code>
- */
- private IAnnotationModelExtension getModel() {
- if (getTextEditor() == null)
- return null;
- IDocumentProvider provider= getTextEditor().getDocumentProvider();
- IEditorInput editorInput= getTextEditor().getEditorInput();
- IAnnotationModel m= provider.getAnnotationModel(editorInput);
- if (m instanceof IAnnotationModelExtension) {
- return (IAnnotationModelExtension)m;
- } else {
- return null;
- }
- }
-
- /**
- * Returns the diff model associated with the annotation model of the document currently displayed
- * in this action's editor, if any.
- *
- * @return the diff model associated with the displayed document, or <code>null</code>
- */
- protected ILineDiffer getDiffer() {
- IAnnotationModelExtension extension= getModel();
- if (extension != null)
- return (ILineDiffer)extension.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
- else
- return null;
- }
-
- /**
- * Returns a <code>IVerticalRulerInfo</code> if this action's editor adapts to one.
- *
- * @return the <code>IVerticalRulerInfo</code> for the editor's vertical ruler, or <code>null</code>
- */
- protected IVerticalRulerInfo getRuler() {
- if (getTextEditor() != null)
- return (IVerticalRulerInfo)getTextEditor().getAdapter(IVerticalRulerInfo.class);
- else
- return null;
- }
-
- /**
- * Sets the status line error message to <code>string</code>.
- *
- * @param string the message to be displayed as error.
- */
- protected void setStatus(String string) {
- if (getTextEditor() != null) {
- IEditorStatusLine statusLine= (IEditorStatusLine) getTextEditor().getAdapter(IEditorStatusLine.class);
- if (statusLine != null) {
- statusLine.setMessage(true, string, null);
- }
- }
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java
deleted file mode 100644
index 5fab0c97f..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/ReferenceSelectionAction.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-import org.eclipse.jface.action.Action;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.IChangeRulerColumn;
-
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.quickdiff.IQuickDiffReferenceProvider;
-import org.eclipse.ui.texteditor.quickdiff.ReferenceProviderDescriptor;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension3;
-import org.eclipse.ui.texteditor.IUpdate;
-
-
-/**
- * Action to set the quick diff reference for the document displayed in the editor. An instance of
- * this class is created for every extension to the extension point <code>quickdiff.referenceprovider</code>, and for
- * every editor. It acts as a proxy; its <code>run</code> method installs the reference provider
- * specified by the extension with the quick diff differ on the current document.
- *
- * @since 3.0
- */
-public class ReferenceSelectionAction extends Action implements IUpdate {
-
- /** The editor we get the document from. */
- private ITextEditor fEditor= null;
- /** The descriptor of the managed extension. */
- private final ReferenceProviderDescriptor fDescriptor;
- /** The implementation of the extension, after it has been loaded. */
- private IQuickDiffReferenceProvider fProvider;
-
- /**
- * Creates a new instance that will lazily create the implementation provided by the extension.
- *
- * @param descriptor describes the extension.
- * @param editor the editor for which this action is created.
- */
- public ReferenceSelectionAction(ReferenceProviderDescriptor descriptor, ITextEditor editor) {
- super("", AS_RADIO_BUTTON); //$NON-NLS-1$
- setChecked(false);
- setEnabled(true);
- Assert.isLegal(descriptor != null);
- fDescriptor= descriptor;
- fEditor= editor;
- update();
- }
-
- /**
- * Creates an instance of the implementation provided by the extension, if none has been created
- * before. Otherwise, the cached implementation is returned.
- * @return The <code>IQuickDiffProviderImplementation</code> instance provided by the extension.
- */
- private IQuickDiffReferenceProvider getProvider() {
- if (fProvider == null) {
- fProvider= fDescriptor.createProvider();
- }
- return fProvider;
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
-
- DocumentLineDiffer differ= getDiffer(true); // create if needed, so the user does not have to toggle display when he selects a reference
- if (differ == null)
- return;
-
- if (fEditor instanceof ITextEditorExtension3) {
- ITextEditorExtension3 extension= (ITextEditorExtension3) fEditor;
- IQuickDiffReferenceProvider provider= getProvider();
- if (provider != null) {
- provider.setActiveEditor(fEditor);
- if (provider.isEnabled()) {
- differ.setReferenceProvider(provider);
- extension.showChangeInformation(true);
- setEnabled(true);
- } else
- setEnabled(false);
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- /* two things happen here:
- * 1: checked state setting - if a provider is already installed, and its id matches
- * our id, we are in checked state.
- * 2: enablement - if the extending plugin has been loaded, we check the provider for
- * enablement and take it as our own.
- */
- setText(fDescriptor.getLabel());
- DocumentLineDiffer differ= getDiffer(false); // don't create it if we're not showing
- setChecked(false);
- if (differ != null) {
- IQuickDiffReferenceProvider provider= differ.getReferenceProvider();
- if (provider != null && provider.getId().equals(fDescriptor.getId())) {
- setChecked(true);
- }
- }
-
- if (fDescriptor.isPluginLoaded()) {
- getProvider();
- if (fProvider == null) {
- setEnabled(false);
- } else {
- fProvider.setActiveEditor(fEditor);
- setEnabled(fProvider.isEnabled());
- }
- } else {
- // optimistically enable it
- setEnabled(true);
- }
- }
-
- /**
- * Fetches the differ installed with the current editor's document's annotation model. If none
- * is installed yet, and <code>createIfNeeded</code> is true, one is created and attached to the
- * model.
- *
- * @param createIfNeeded when set to <code>true</code>, a new differ will be created if needed.
- * @return the differ installed with the annotation model, or <code>null</code>.
- */
- private DocumentLineDiffer getDiffer(boolean createIfNeeded) {
- // get annotation model
- if (fEditor == null)
- return null;
-
- IDocumentProvider provider= fEditor.getDocumentProvider();
- IEditorInput editorInput= fEditor.getEditorInput();
- if (provider == null || editorInput == null)
- return null;
-
- IAnnotationModel m= provider.getAnnotationModel(editorInput);
- IAnnotationModelExtension model= null;
- if (m instanceof IAnnotationModelExtension) {
- model= (IAnnotationModelExtension)m;
- } else {
- return null;
- }
-
- // get differ
- DocumentLineDiffer differ= (DocumentLineDiffer)model.getAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
-
- // create if needed
- if (differ == null && createIfNeeded) {
- differ= new DocumentLineDiffer();
- model.addAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID, differ);
- }
-
- return differ;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java
deleted file mode 100644
index 908e1a46c..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RestoreAction.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.source.ILineDiffInfo;
-import org.eclipse.jface.text.source.ILineDiffer;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * Action that will restore a block of deleted lines at the current caret position in an editor.
- *
- * @since 3.0
- */
-public class RestoreAction extends QuickDiffRestoreAction {
- /** Resource key prefix. */
- private static final String PREFIX= "RestoreAction."; //$NON-NLS-1$
- /** Resource key for a single deleted line. */
- private static final String SINGLE_KEY= PREFIX + "label"; //$NON-NLS-1$
- /** Resource key for multiple deleted lines. */
- private static final String MULTIPLE_KEY= PREFIX + "multiple.label"; //$NON-NLS-1$
-
- /** The line to be restored. Set in <code>update()</code>. */
- private int fLine;
-
- /**
- * Creates a new instance.
- *
- * @param editor the editor this action belongs to
- */
- public RestoreAction(ITextEditor editor) {
- super(QuickDiffMessages.getResourceBundle(), PREFIX, editor);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (!isEnabled())
- return;
-
- setEnabled(false);
- IVerticalRulerInfo ruler= getRuler();
- if (ruler == null)
- return;
- fLine= ruler.getLineOfLastMouseButtonActivity();
- ILineDiffer differ= getDiffer();
- if (differ == null)
- return;
- ILineDiffInfo info= differ.getLineInfo(fLine);
- if (info != null && (info.getRemovedLinesAbove() > 0 || info.getRemovedLinesBelow() > 0)) {
- if (info.getRemovedLinesBelow() == 0) {
- fLine--;
- } else if (info.getRemovedLinesAbove() != 0) {
-// // if there are deleted lines above and below the line, take the closer one;
-// int lineHeight= fCachedTextWidget.getLineHeight();
-// if (fMousePosition != null
-// && fMousePosition.y % lineHeight <= lineHeight / 2) {
-// fLine--;
-// }
- // take the one below for now TODO adjust to old viewer-dependent behaviour
- }
- info= differ.getLineInfo(fLine);
- if (info.getRemovedLinesBelow() == 1)
- setText(QuickDiffMessages.getString(SINGLE_KEY));
- else
- setText(QuickDiffMessages.getFormattedString(MULTIPLE_KEY, String.valueOf(info.getRemovedLinesBelow()))); //$NON-NLS-1$
- setEnabled(true);
- }
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange()
- */
- public void runCompoundChange() {
- if (!isEnabled())
- return;
- ILineDiffer differ= getDiffer();
- if (differ != null) {
- try {
- differ.restoreAfterLine(fLine);
- } catch (BadLocationException e) {
- setStatus(e.getMessage());
- }
- }
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java
deleted file mode 100644
index b8e027d04..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertBlockAction.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.source.ILineDiffInfo;
-import org.eclipse.jface.text.source.ILineDiffer;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * Action that will revert a contiguous block of added, deleted and changes lines in the currently
- * displayed document to the state in the reference document.
- *
- * @since 3.0
- */
-public class RevertBlockAction extends QuickDiffRestoreAction {
- /** Resource key prefix. */
- private static final String PREFIX= "RevertBlockAction."; //$NON-NLS-1$
-
- /** The line to be restored. Set in <code>update()</code>. */
- private int fLine;
-
- /**
- * Creates a new instance.
- *
- * @param editor the editor this action belongs to
- */
- public RevertBlockAction(ITextEditor editor) {
- super(QuickDiffMessages.getResourceBundle(), PREFIX, editor);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (!isEnabled())
- return;
-
- setEnabled(false);
- IVerticalRulerInfo ruler= getRuler();
- if (ruler == null)
- return;
- fLine= ruler.getLineOfLastMouseButtonActivity();
- ILineDiffer differ= getDiffer();
- if (differ == null)
- return;
- ILineDiffInfo info= differ.getLineInfo(fLine);
- if (info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED) {
- boolean hasBlock= false;
- if (fLine > 0) {
- info= differ.getLineInfo(fLine - 1);
- hasBlock= info != null && info.hasChanges();
- }
- if (!hasBlock) {
- info= differ.getLineInfo(fLine + 1);
- hasBlock= info != null && info.hasChanges();
- }
- if (hasBlock)
- setEnabled(true);
- }
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange()
- */
- public void runCompoundChange() {
- if (!isEnabled())
- return;
- ILineDiffer differ= getDiffer();
- if (differ != null) {
- try {
- differ.revertBlock(fLine);
- } catch (BadLocationException e) {
- setStatus(e.getMessage());
- }
- }
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java
deleted file mode 100644
index 99498afae..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertLineAction.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.source.ILineDiffInfo;
-import org.eclipse.jface.text.source.ILineDiffer;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * Action that will revert a line in the currently displayed document to the state in the
- * reference document.
- *
- * @since 3.0
- */
-public class RevertLineAction extends QuickDiffRestoreAction {
- /** Resource key prefix. */
- private static final String PREFIX= "RevertLineAction."; //$NON-NLS-1$
- /** Resource key for added lines - they will be deleted. */
- private static final String DELETE_KEY= PREFIX + "delete.label"; //$NON-NLS-1$
- /** Resource key for changed lines - they will be reverted. */
- private static final String REVERT_KEY= PREFIX + "label"; //$NON-NLS-1$
-
- /** The line to be restored. Set in <code>update()</code>. */
- private int fLine;
-
- /**
- * Creates a new instance.
- *
- * @param editor the editor this action belongs to
- */
- public RevertLineAction(ITextEditor editor) {
- super(QuickDiffMessages.getResourceBundle(), PREFIX, editor);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (!isEnabled())
- return;
-
- setEnabled(false);
- IVerticalRulerInfo ruler= getRuler();
- if (ruler == null)
- return;
- fLine= ruler.getLineOfLastMouseButtonActivity();
- ILineDiffer differ= getDiffer();
- if (differ == null)
- return;
- ILineDiffInfo info= differ.getLineInfo(fLine);
- if (info != null && info.getChangeType() != ILineDiffInfo.UNCHANGED) {
- if (info.getChangeType() == ILineDiffInfo.ADDED)
- setText(QuickDiffMessages.getString(DELETE_KEY));
- else
- setText(QuickDiffMessages.getString(REVERT_KEY));
- setEnabled(true);
- }
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange()
- */
- public void runCompoundChange() {
- if (!isEnabled())
- return;
- ILineDiffer differ= getDiffer();
- if (differ != null) {
- try {
- differ.revertLine(fLine);
- } catch (BadLocationException e) {
- setStatus(e.getMessage());
- }
- }
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java
deleted file mode 100644
index 0f04bfc54..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/RevertSelectionAction.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff;
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.source.ILineDiffInfo;
-import org.eclipse.jface.text.source.ILineDiffer;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- * Action that will revert the added, deleted and changes lines in the selection on the currently
- * displayed document to the state in the reference document.
- *
- * @since 3.0
- */
-public class RevertSelectionAction extends QuickDiffRestoreAction {
- /** The first line to be restored. Set in <code>update()</code>. */
- private int fStartLine;
- /** The last line to be restored. Set in <code>update()</code>. */
- private int fEndLine;
-
- /**
- * Creates a new instance.
- *
- * @param editor the editor this action belongs to
- */
- public RevertSelectionAction(ITextEditor editor) {
- super(QuickDiffMessages.getResourceBundle(), "RevertSelectionAction.", editor); //$NON-NLS-1$
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
-
- if (!isEnabled())
- return;
-
- setEnabled(false);
-
- ITextSelection selection= getSelection();
- if (selection == null)
- return;
- fStartLine= selection.getStartLine();
- fEndLine= selection.getEndLine();
-
- // only enable if mouse activity is inside line range
- IVerticalRulerInfo ruler= getRuler();
- if (ruler == null)
- return;
- int activityLine= ruler.getLineOfLastMouseButtonActivity();
- if (activityLine < fStartLine || activityLine > fEndLine + 1)
- // + 1 to cover the case where the selection goes to the offset of the next line
- return;
-
- ILineDiffer differ= getDiffer();
- if (differ == null)
- return;
-
- // only enable if selection covers at least two lines
- if (fEndLine > fStartLine) {
- for (int i= fStartLine; i <= fEndLine; i++) {
- ILineDiffInfo info= differ.getLineInfo(i);
- if (info != null && info.hasChanges()) {
- setEnabled(true);
- }
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.internal.editors.quickdiff.QuickDiffRestoreAction#runCompoundChange()
- */
- public void runCompoundChange() {
- // recheck if run without being enabled
- if (!isEnabled())
- return;
-
- ILineDiffer differ= getDiffer();
- if (differ != null) {
- try {
- differ.revertSelection(fStartLine, fEndLine - fStartLine + 1);
- } catch (BadLocationException e) {
- setStatus(e.getMessage());
- }
- }
- }
-
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.java
deleted file mode 100644
index cdcf9907b..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DifferencesIterator.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.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * A custom iterator to iterate over a List of <code>RangeDifferences</code>.
- * It is used internally by the <code>RangeDifferencer</code>.
- *
- * @since 3.0
- */
-/* package */ class DifferencesIterator {
-
- List fRange;
- int fIndex;
- RangeDifference[] fArray;
- RangeDifference fDifference;
-
- /**
- * Creates a differences iterator on an array of <code>RangeDifference</code>s.
- */
- DifferencesIterator(RangeDifference[] differenceRanges) {
-
- fArray= differenceRanges;
- fIndex= 0;
- fRange= new ArrayList();
- if (fIndex < fArray.length)
- fDifference= fArray[fIndex++];
- else
- fDifference= null;
- }
-
- /**
- * Returns the number of RangeDifferences
- */
- int getCount() {
- return fRange.size();
- }
-
- /**
- * Appends the edit to its list and moves to the next <code>RangeDifference</code>.
- */
- void next() {
- fRange.add(fDifference);
- if (fDifference != null) {
- if (fIndex < fArray.length)
- fDifference= fArray[fIndex++];
- else
- fDifference= null;
- }
- }
-
- /**
- * Difference iterators are used in pairs.
- * This method returns the other iterator.
- */
- DifferencesIterator other(DifferencesIterator right, DifferencesIterator left) {
- if (this == right)
- return left;
- return right;
- }
-
- /**
- * Removes all <code>RangeDifference</code>s
- */
- void removeAll() {
- fRange.clear();
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java
deleted file mode 100644
index 873409fc0..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/DocLineComparator.java
+++ /dev/null
@@ -1,349 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-import org.eclipse.jface.text.*;
-
-/**
- * Implements the <code>IRangeComparator</code> interface for lines in a document.
- * A <code>DocLineComparator</code> is used as the input for the <code>RangeDifferencer</code>
- * engine to perform a line oriented compare on documents.
- * <p>
- * A <code>DocLineComparator</code> doesn't know anything about line separators because
- * its notion of lines is solely defined in the underlying <code>IDocument</code>.
- */
-public final class DocLineComparator implements IRangeComparator {
-
- /**
- * Document based character sequence.
- */
- public static class DocumentCharSequence implements CharSequence {
-
- /** Document */
- private IDocument fDocument;
-
- /** Offset */
- private int fOffset;
-
- /** Length */
- private int fLength;
-
- /**
- * Leave uninitialized. The document, offset and length have to be set
- * before use.
- */
- public DocumentCharSequence() {
- // do nothing
- }
-
- /**
- * Initialize with the sequence of characters in the given document
- * starting at the given offset with the given length.
- *
- * @param document The document
- * @param offset The offset
- * @param length The length
- */
- public DocumentCharSequence(IDocument document, int offset, int length) {
- fDocument= document;
- fOffset= offset;
- fLength= length;
- }
-
- /*
- * @see java.lang.CharSequence#length()
- */
- public int length() {
- return fLength;
- }
-
- /*
- * @see java.lang.CharSequence#charAt(int)
- */
- public char charAt(int index) {
- try {
- return fDocument.getChar(fOffset + index);
- } catch (BadLocationException e) {
- throw new IndexOutOfBoundsException();
- }
- }
-
- /*
- * @see java.lang.CharSequence#subSequence(int, int)
- */
- public CharSequence subSequence(int start, int end) {
- return new DocumentCharSequence(fDocument, start, end - start);
- }
-
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- int hash= 0;
- for (int i= 0, n= fLength; i < n; i++)
- hash= 29*hash + charAt(i);
- return hash;
- }
-
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj == this)
- return true;
- if (!(obj instanceof DocumentCharSequence))
- return false;
- DocumentCharSequence buffer= (DocumentCharSequence) obj;
- int length= buffer.length();
- if (length != fLength)
- return false;
- for (int i= 0; i < length; i++)
- if (buffer.charAt(i) != charAt(i))
- return false;
- return true;
- }
-
- /**
- * Sets the document to the given.
- *
- * @param document the document to be set
- */
- public void setDocument(IDocument document) {
- fDocument= document;
- }
-
- /**
- * Sets the offset to the given value.
- *
- * @param offset the offset to be set
- */
- public void setOffset(int offset) {
- fOffset= offset;
- }
-
- /**
- * Sets the length to the given value.
- *
- * @param length the length to be set
- */
- public void setLength(int length) {
- fLength= length;
- }
- }
-
- private final IDocument fDocument;
- private final int fLineOffset;
- private final int fLineCount;
- private final int fLength;
- private final boolean fIgnoreWhiteSpace;
- private final int fMaxOffset;
-
-
- private boolean fSkip= false;
- private int fLastOffset;
- private int fLastLength;
-
- /** Cached document character sequence */
- private DocumentCharSequence fThisBuffer= new DocumentCharSequence();
- /** Cached document character sequence */
- private DocumentCharSequence fOtherBuffer= new DocumentCharSequence();
-
- /**
- * Creates a <code>DocLineComparator</code> for the given document range.
- * ignoreWhiteSpace controls whether comparing lines (in method
- * <code>rangesEqual<code>) should ignore whitespace.
- *
- * @param document the document from which the lines are taken
- * @param region if non-<code>null</code> only lines within this range are taken
- * @param ignoreWhiteSpace if <code>true</code> white space is ignored when comparing lines
- */
- public DocLineComparator(IDocument document, IRegion region, boolean ignoreWhiteSpace) {
-
- fDocument= document;
- fIgnoreWhiteSpace= ignoreWhiteSpace;
-
- if (region != null) {
- fLength= region.getLength();
- int start= region.getOffset();
- int lineOffset= 0;
- try {
- lineOffset= fDocument.getLineOfOffset(start);
- } catch (BadLocationException ex) {
- }
- fLineOffset= lineOffset;
-
- fMaxOffset= start + fLength;
-
- if (fLength == 0)
- fLineCount= 0;
- else {
- int endLine= fDocument.getNumberOfLines();
- try {
- endLine= fDocument.getLineOfOffset(start + fLength);
- } catch (BadLocationException ex) {
- }
- fLineCount= endLine - fLineOffset + 1;
- }
-
- } else {
- fLineOffset= 0;
- fLength= document.getLength();
- fLineCount= fDocument.getNumberOfLines();
- fMaxOffset= fDocument.getLength();
- }
- }
-
- /**
- * Returns the number of lines in the document.
- *
- * @return number of lines
- */
- public int getRangeCount() {
- return fLineCount;
- }
-
- /**
- * Computes the length of line <code>line</code>.
- *
- * @param line the line requested
- * @return the line length or <code>0</code> if <code>line</code> is not a valid line in the document
- */
- private int getLineLength(int line) {
- if (line >= fLineCount)
- return 0;
- try {
- int docLine= fLineOffset + line;
- String delim= fDocument.getLineDelimiter(docLine);
- int length= fDocument.getLineLength(docLine) - (delim == null ? 0 : delim.length());
- if (line == fLineCount - 1) {
- fLastOffset= fDocument.getLineOffset(docLine);
- fLastLength= Math.min(length, fMaxOffset - fLastOffset);
- } else {
- fLastOffset= -1;
- fLastLength= length;
- }
- return fLastLength;
- } catch (BadLocationException e) {
- fLastOffset= 0;
- fLastLength= 0;
- fSkip= true;
- return 0;
- }
- }
-
- /**
- * Returns <code>true</code> if a line given by the first index
- * matches a line specified by the other <code>IRangeComparator</code> and index.
- *
- * @param thisIndex the number of the line within this range comparator
- * @param other the range comparator to compare this with
- * @param otherIndex the number of the line within the other comparator
- * @return <code>true</code> if the lines are equal
- */
- public boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex) {
-
- if (other != null && other.getClass() == getClass()) {
- DocLineComparator dlc= (DocLineComparator) other;
-
- if (fIgnoreWhiteSpace) {
-
- extract(thisIndex, fThisBuffer);
- dlc.extract(otherIndex, fOtherBuffer);
- return compare(fThisBuffer, fOtherBuffer);
-
- } else {
-
- int tlen= getLineLength(thisIndex);
- int olen= dlc.getLineLength(otherIndex);
- if (tlen == olen) {
- extract(thisIndex, fThisBuffer);
- dlc.extract(otherIndex, fOtherBuffer);
- return fThisBuffer.equals(fOtherBuffer);
- }
- }
- }
- return false;
- }
-
- /**
- * Aborts the comparison if the number of tokens is too large.
- *
- * @return <code>true</code> to abort a token comparison
- */
- public boolean skipRangeComparison(int length, int max, IRangeComparator other) {
- return fSkip;
- }
-
- //---- private methods
-
- /**
- * Extract a single line from the underlying document without the line separator
- * into the given document based character sequence.
- *
- * @param line the number of the line to extract
- * @param buffer the document based character sequence
- */
- private void extract(int line, DocumentCharSequence buffer) {
- if (line < fLineCount) {
- try {
- int docLine= fLineOffset + line;
- if (fLastOffset == -1)
- fLastOffset= fDocument.getLineOffset(docLine);
-
- buffer.setDocument(fDocument);
- buffer.setOffset(fLastOffset);
- buffer.setLength(fLastLength);
- return;
- } catch(BadLocationException e) {
- fSkip= true;
- }
- }
- buffer.setDocument(fDocument);
- buffer.setOffset(0);
- buffer.setLength(0);
- }
-
- private boolean compare(CharSequence s1, CharSequence s2) {
- int l1= s1.length();
- int l2= s2.length();
- int c1= 0, c2= 0;
- int i1= 0, i2= 0;
-
- while (c1 != -1) {
-
- c1= -1;
- while (i1 < l1) {
- char c= s1.charAt(i1++);
- if (! Character.isWhitespace(c)) {
- c1= c;
- break;
- }
- }
-
- c2= -1;
- while (i2 < l2) {
- char c= s2.charAt(i2++);
- if (! Character.isWhitespace(c)) {
- c2= c;
- break;
- }
- }
-
- if (c1 != c2)
- return false;
- }
- return true;
- }
-
-}
-
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java
deleted file mode 100644
index 49e2dbb9c..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/IRangeComparator.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-/**
- * For breaking an object to compare into a sequence of comparable entities.
- * <p>
- * It is used by <code>RangeDifferencer</code> to find longest sequences of
- * matching and non-matching ranges.
- * <p>
- * For example, to compare two text documents and find longest common sequences
- * of matching and non-matching lines, the implementation must break the document
- * into lines. <code>getRangeCount</code> would return the number of lines in the
- * document, and <code>rangesEqual</code> would compare a specified line given
- * with one in another <code>IRangeComparator</code>.
- * </p>
- * <p>
- * Clients should implement this interface; there is no standard implementation.
- * </p>
- *
- * @since 3.0
- */
-public interface IRangeComparator {
-
- /**
- * Returns the number of comparable entities.
- *
- * @return the number of comparable entities
- */
- int getRangeCount();
-
- /**
- * Returns whether the comparable entity given by the first index
- * matches an entity specified by the other <code>IRangeComparator</code> and index.
- *
- * @param thisIndex the index of the comparable entity within this <code>IRangeComparator</code>
- * @param other the IRangeComparator to compare this with
- * @param otherIndex the index of the comparable entity within the other <code>IRangeComparator</code>
- * @return <code>true</code> if the comparable entities are equal
- */
- boolean rangesEqual(int thisIndex, IRangeComparator other, int otherIndex);
-
- /**
- * Returns whether a comparison should be skipped because it would be too costly (or lengthy).
- *
- * @param length a number on which to base the decision whether to return
- * <code>true</code> or <code>false</code>
- * @param maxLength another number on which to base the decision whether to return
- * <code>true</code> or <code>false</code>
- * @param other the other <code>IRangeComparator</code> to compare with
- * @return <code>true</code> to avoid a too lengthy range comparison
- */
- boolean skipRangeComparison(int length, int maxLength, IRangeComparator other);
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.java
deleted file mode 100644
index cca23859c..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/ITokenComparator.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-
-
-/**
- * For performing a so-called "token compare" on a line of text.
- * This interface extends the <code>IRangeComparator</code> interface
- * so that it can be used by the <code>TextMergeViewer</code>.
- * <p>
- * <code>TextMergeViewer</code> activates the token compare when navigating into
- * a range of differing lines. At first the lines are selected as a block.
- * When navigating into this block the token compare shows for every line
- * the differing token by selecting them.
- * <p>
- * <code>TextMergeViewer</code>'s default token comparator works on characters separated
- * by whitespace. If a different strategy is needed (for example, to use Java tokens in
- * a Java-aware merge viewer), clients may create their own token
- * comparators by implementing this interface (and overriding the
- * <code>TextMergeViewer.createTokenComparator</code> factory method).
- * </p>
- *
- * @see TextMergeViewer
- * @since 3.0
- */
-public interface ITokenComparator extends IRangeComparator {
-
- /**
- * Returns the start character position of the token with the given index.
- * If the index is out of range (but not negative) the character position
- * behind the last character (the length of the input string) is returned.
- *
- * @param index index of the token for which to return the start position
- * @return the start position of the token with the given index
- * @throws java.lang.IndexOutOfBoundsException if index is negative
- */
- int getTokenStart(int index);
-
- /**
- * Returns the character length of the token with the given index.
- * If the index is out of range (but not negative) the value 0 is returned.
- *
- * @param index index of the token for which to return the start position
- * @return the character length of the token with the given index
- * @throws java.lang.IndexOutOfBoundsException if index is negative
- */
- int getTokenLength(int index);
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.java
deleted file mode 100644
index fba184568..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeDifference.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-/**
- * @since 3.0
- */
-/* package */ class LinkedRangeDifference extends RangeDifference {
-
- static final int INSERT= 0;
- static final int DELETE= 1;
-
- LinkedRangeDifference fNext;
-
- /**
- * Creates a LinkedRangeDifference an initializes it to the error state
- */
- LinkedRangeDifference() {
- super(ERROR);
- fNext= null;
- }
-
- /**
- * Constructs and links a LinkeRangeDifference to another LinkedRangeDifference
- */
- LinkedRangeDifference(LinkedRangeDifference next, int operation) {
- super(operation);
- fNext= next;
- }
-
- /**
- * Follows the next link
- */
- LinkedRangeDifference getNext() {
- return fNext;
- }
-
- boolean isDelete() {
- return kind() == DELETE;
- }
-
- boolean isInsert() {
- return kind() == INSERT;
- }
-
- /**
- * Sets the next link of this LinkedRangeDifference
- */
- void setNext(LinkedRangeDifference next) {
- fNext= next;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java
deleted file mode 100644
index 704d407ea..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/LinkedRangeFactory.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-/**
- * Memory-monitoring factory for <code>LinkedRangeDifference</code>.
- *
- * @since 3.0
- */
-public class LinkedRangeFactory {
-
- /**
- * Exception that is thrown after the minimal allowed free memory is reached.
- */
- public static class LowMemoryException extends Exception {
-
- /**
- * Initialize without detail message.
- */
- public LowMemoryException() {
- super();
- }
-
- /**
- * Initialize with the given detail message.
- *
- * @param message the detail message
- */
- public LowMemoryException(String message) {
- super(message);
- }
- }
-
- /**
- * Relative amount of memory that must be free in order to allow the creation of additional instances
- */
- private static final double THRESHOLD= 0.1;
- /**
- * Number of instantiations after which the amount of free memory is checked
- */
- private static final long CHECK_INTERVAL= 5000;
- /**
- * Considered maximal size of a difference object in bytes.
- */
- private static final long OBJECT_SIZE= 100;
- /**
- * The maximal memory requirement for the next round in bytes.
- */
- private static final long MAXIMAL_INTERVAL_REQUIREMENT= CHECK_INTERVAL * OBJECT_SIZE;
- /**
- * Allowed memory consumption in bytes.
- */
- private static final long MAX_MEMORY_CONSUMPTION= 10 * 1024 * 1024;
- /**
- * The maximal number of instances.
- */
- private static final long MAX_INSTANCES= MAX_MEMORY_CONSUMPTION / OBJECT_SIZE;
-
-
- /**
- * Preallocated low memory exception
- */
- private LowMemoryException fLowMemoryException= new LowMemoryException();
-
- /**
- * Number of instantiations
- */
- private long fCount= 0;
-
- /**
- * Create a new linked range difference with the given next range and operation.
- *
- * @param next the next linked range difference
- * @param operation the operation
- * @return the new linked range difference
- * @throws LowMemoryException
- */
- public LinkedRangeDifference newRange(LinkedRangeDifference next, int operation) throws LowMemoryException {
- check();
- return new LinkedRangeDifference(next, operation);
- }
-
- /**
- * After <code>CHECK_INTERVAL</code> calls check whether at least a fraction of <code>THRESHOLD</code>
- * of the maximal available memory is free, otherwise throw an {@link LowMemoryException}.
- *
- * @throws LowMemoryException
- */
- private void check() throws LowMemoryException {
- if (fCount % CHECK_INTERVAL == 0) {
-
- Runtime runtime= Runtime.getRuntime();
- long maxMemory= runtime.maxMemory();
- long maxFreeMemory= maxMemory - (runtime.totalMemory() - runtime.freeMemory());
-
- if (((float) (maxFreeMemory - MAXIMAL_INTERVAL_REQUIREMENT)) / maxMemory < THRESHOLD)
- throw fLowMemoryException;
- }
- if (++fCount >= MAX_INSTANCES)
- throw fLowMemoryException;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java
deleted file mode 100644
index 6e84b0c87..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifference.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-import java.util.List;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.IDocument;
-
-import org.eclipse.ui.internal.texteditor.quickdiff.DiffRegion;
-
-/**
- * Description of a change between two or three ranges of comparable entities.
- * <p>
- * <code>RangeDifference</code> objects are the elements of a compare result returned from
- * the <code>RangeDifferencer</code> <code>find* </code> methods.
- * Clients use these objects as they are returned from the differencer.
- * This class is not intended to be instantiated or subclassed.
- * <p>
- * Note: A range in the <code>RangeDifference</code> object is given as a start index
- * and length in terms of comparable entities. However, these entity indices and counts
- * are not necessarily character positions. For example, if an entity represents a line
- * in a document, the start index would be a line number and the count would be in lines.
- * </p>
- *
- * @see RangeDifferencer
- * @since 3.0
- */
-public class RangeDifference {
-
- /** Two-way change constant indicating no change. */
- public final static int NOCHANGE= 0;
- /** Two-way change constant indicating two-way change (same as <code>RIGHT</code>) */
- public final static int CHANGE= 2;
-
- /** Three-way change constant indicating a change in both right and left. */
- public final static int CONFLICT= 1;
- /** Three-way change constant indicating a change in right. */
- public final static int RIGHT= 2;
- /** Three-way change constant indicating a change in left. */
- public final static int LEFT= 3;
- /**
- * Three-way change constant indicating the same change in both right and left,
- * that is only the ancestor is different.
- */
- public final static int ANCESTOR= 4;
-
- /** Constant indicating an unknown change kind. */
- public final static int ERROR= 5;
-
- /** the kind of change: NOCHANGE, CHANGE, LEFT, RIGHT, ANCESTOR, CONFLICT, ERROR */
- int fKind;
-
- int fLeftStart;
- int fLeftLength;
- int fRightStart;
- int fRightLength;
- int lAncestorStart;
- int lAncestorLength;
- private DiffRegion fRegion;
-
- /**
- * Creates a new range difference with the given change kind.
- *
- * @param changeKind the kind of change
- */
- public RangeDifference(int changeKind) {
- fKind= changeKind;
- }
-
- /**
- * Creates a new <code>RangeDifference</code> with the given change kind
- * and left and right ranges.
- *
- * @param kind the kind of change
- * @param rightStart start index of entity on right side
- * @param rightLength number of entities on right side
- * @param leftStart start index of entity on left side
- * @param leftLength number of entities on left side
- */
- public RangeDifference(int kind, int rightStart, int rightLength, int leftStart, int leftLength) {
- fKind= kind;
- fRightStart= rightStart;
- fRightLength= rightLength;
- fLeftStart= leftStart;
- fLeftLength= leftLength;
- }
-
- /**
- * Creates a new <code>RangeDifference</code> with the given change kind
- * and left, right, and ancestor ranges.
- *
- * @param kind the kind of change
- * @param rightStart start index of entity on right side
- * @param rightLength number of entities on right side
- * @param leftStart start index of entity on left side
- * @param leftLength number of entities on left side
- * @param ancestorStart start index of entity on ancestor side
- * @param ancestorLength number of entities on ancestor side
- */
- public RangeDifference(int kind, int rightStart, int rightLength, int leftStart, int leftLength,
- int ancestorStart, int ancestorLength) {
- this(kind, rightStart, rightLength, leftStart, leftLength);
- lAncestorStart= ancestorStart;
- lAncestorLength= ancestorLength;
- }
-
- /**
- * Returns the kind of difference.
- *
- * @return the kind of difference, one of
- * <code>NOCHANGE</code>, <code>CHANGE</code>, <code>LEFT</code>, <code>RIGHT</code>,
- * <code>ANCESTOR</code>, <code>CONFLICT</code>, <code>ERROR</code>
- */
- public int kind() {
- return fKind;
- }
-
- /**
- * Returns the start index of the entity range on the ancestor side.
- *
- * @return the start index of the entity range on the ancestor side
- */
- public int ancestorStart() {
- return lAncestorStart;
- }
-
- /**
- * Returns the number of entities on the ancestor side.
- *
- * @return the number of entities on the ancestor side
- */
- public int ancestorLength() {
- return lAncestorLength;
- }
-
- /**
- * Returns the end index of the entity range on the ancestor side.
- *
- * @return the end index of the entity range on the ancestor side
- */
- public int ancestorEnd() {
- return lAncestorStart + lAncestorLength;
- }
-
- /**
- * Returns the start index of the entity range on the right side.
- *
- * @return the start index of the entity range on the right side
- */
- public int rightStart() {
- return fRightStart;
- }
-
- /**
- * Returns the number of entities on the right side.
- *
- * @return the number of entities on the right side
- */
- public int rightLength() {
- return fRightLength;
- }
-
- /**
- * Returns the end index of the entity range on the right side.
- *
- * @return the end index of the entity range on the right side
- */
- public int rightEnd() {
- return fRightStart + fRightLength;
- }
-
- /**
- * Returns the start index of the entity range on the left side.
- *
- * @return the start index of the entity range on the left side
- */
- public int leftStart() {
- return fLeftStart;
- }
-
- /**
- * Returns the number of entities on the left side.
- *
- * @return the number of entities on the left side
- */
- public int leftLength() {
- return fLeftLength;
- }
-
- /**
- * Returns the end index of the entity range on the left side.
- *
- * @return the end index of the entity range on the left side
- */
- public int leftEnd() {
- return fLeftStart + fLeftLength;
- }
-
- /**
- * Returns the maximum number of entities in the left, right, and ancestor sides of this range.
- *
- * @return the maximum number of entities in the left, right, and ancestor sides of this range
- */
- public int maxLength() {
- return Math.max(fRightLength, Math.max(fLeftLength, lAncestorLength));
- }
-
- /**
- * Shifts the offset into the left document of the receiver.
- *
- * @param shift the number of elements to shift
- */
- public void shiftLeft(int shift) {
- Assert.isTrue(shift + fLeftStart >= 0);
- fLeftStart += shift;
- }
-
- /**
- * Shifts the offset into the right document of the receiver.
- *
- * @param shift the number of elements to shift
- */
- public void shiftRight(int shift) {
- Assert.isTrue(shift + fRightStart >= 0);
- fRightStart += shift;
- }
-
- /**
- * Resizes the receiver <code>shift</code> units, on both sides, by
- * moving the start of the difference.
- *
- * @param shift the number of elements to shift
- */
- public void extendStart(int shift) {
- Assert.isTrue(shift + fRightStart >= 0);
- Assert.isTrue(shift + fLeftStart >= 0);
- fRightStart += shift;
- fRightLength -= shift;
- fLeftStart += shift;
- fLeftLength -= shift;
- }
-
- /**
- * Resizes the receiver <code>shift</code> units, on both sides, by
- * moving the end of the difference.
- *
- * @param shift the number of elements to shift
- */
- public void extendEnd(int shift) {
- Assert.isTrue(shift + fRightLength >= 0);
- Assert.isTrue(shift + fLeftLength >= 0);
- fRightLength += shift;
- fLeftLength += shift;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- if (obj instanceof RangeDifference) {
- RangeDifference d= (RangeDifference) obj;
- return fKind == d.fKind && fRightStart == d.fRightStart && fRightLength == d.fRightLength && fLeftStart == d.fLeftStart && fLeftLength == d.fLeftLength;
- }
- return false;
- }
-
- /**
- * Returns the diff region corresponding to this range difference.
- *
- * @param differences the list of differences around this one difference
- * @param source the original document (left document) that this difference refers to
- * @return a <code>DiffRegion</code> corresponding to this difference
- */
- public DiffRegion getDiffRegion(List differences, IDocument source) {
- if (fRegion == null)
- fRegion= new DiffRegion(this, 0, differences, source);
- return fRegion;
- }
-}
-
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java
deleted file mode 100644
index 6ca079c6e..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/RangeDifferencer.java
+++ /dev/null
@@ -1,555 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer;
-
-import java.util.*;
-
-import org.eclipse.jface.util.Assert;
-
-import org.eclipse.ui.internal.texteditor.quickdiff.compare.rangedifferencer.LinkedRangeFactory.LowMemoryException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * A <code>RangeDifferencer</code> finds the differences between two or three <code>IRangeComparator</code>s.
- * <p>
- * To use the differencer, clients provide an <code>IRangeComparator</code>
- * that breaks their input data into a sequence of comparable entities. The differencer
- * returns the differences among these sequences as an array of <code>RangeDifference</code> objects
- * (<code>findDifferences</code> methods).
- * Every <code>RangeDifference</code> represents a single kind of difference
- * and the corresponding ranges of the underlying comparable entities in the
- * left, right, and optionally ancestor sides.
- * <p>
- * Alternatively, the <code>findRanges</code> methods not only return objects for
- * the differing ranges but for non-differing ranges too.
- * <p>
- * The algorithm used is an objectified version of one described in:
- * <it>A File Comparison Program,</it> by Webb Miller and Eugene W. Myers,
- * Software Practice and Experience, Vol. 15, Nov. 1985.
- *
- * @see IRangeComparator
- * @see RangeDifference
- * @since 3.0
- */
-public final class RangeDifferencer {
-
- private static final RangeDifference[] EMPTY_RESULT= new RangeDifference[0];
-
- /* (non Javadoc)
- * Non instantiatiable!
- */
- private RangeDifferencer() {
- }
-
- /**
- * Finds the differences between two <code>IRangeComparator</code>s.
- * The differences are returned as an array of <code>RangeDifference</code>s.
- * If no differences are detected an empty array is returned.
- *
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences, or an empty array if no differences were found
- * @throws LowMemoryException if the differencer runs out of memory
- */
- public static RangeDifference[] findDifferences(IRangeComparator left, IRangeComparator right) throws LowMemoryException {
- return findDifferences((IProgressMonitor)null, left, right);
- }
-
- /**
- * Finds the differences between two <code>IRangeComparator</code>s.
- * The differences are returned as an array of <code>RangeDifference</code>s.
- * If no differences are detected an empty array is returned.
- *
- * @param pm if not <code>null</code> used to report progress
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences, or an empty array if no differences were found
- * @throws LowMemoryException if the differencer runs out of memory
- * @since 2.0
- */
- public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) throws LowMemoryException {
-
- // assert that both IRangeComparators are of the same class
- Assert.isTrue(right.getClass().equals(left.getClass()));
-
- int rightSize= right.getRangeCount();
- int leftSize= left.getRangeCount();
- //
- // Differences matrix:
- // only the last d of each diagonal is stored, i.e., lastDiagonal[k] = row of d
- //
- int diagLen= 2 * Math.max(rightSize, leftSize); // bound on the size of edit script
- int maxDiagonal= diagLen;
- int lastDiagonal[]= new int[diagLen + 1]; // the row containing the last d
- // on diagonal k (lastDiagonal[k] = row)
- int origin= diagLen / 2; // origin of diagonal 0
-
- // script corresponding to d[k]
- LinkedRangeDifference script[]= new LinkedRangeDifference[diagLen + 1];
- int row, col;
-
- // find common prefix
- for (row= 0; row < rightSize && row < leftSize && rangesEqual(right, row, left, row) == true; ++row) {
- // do nothing
- }
-
- lastDiagonal[origin]= row;
- script[origin]= null;
- int lower= (row == rightSize) ? origin + 1 : origin - 1;
- int upper= (row == leftSize) ? origin - 1 : origin + 1;
-
- if (lower > upper)
- return EMPTY_RESULT;
-
- //System.out.println("findDifferences: " + maxDiagonal + " " + lower + " " + upper);
- LinkedRangeFactory factory= new LinkedRangeFactory();
-
- // for each value of the edit distance
- for (int d= 1; d <= maxDiagonal; ++d) { // d is the current edit distance
-
- if (pm != null)
- pm.worked(1);
-
- if (right.skipRangeComparison(d, maxDiagonal, left))
- return EMPTY_RESULT; // should be something we already found
-
- // for each relevant diagonal (-d, -d+2 ..., d-2, d)
- for (int k= lower; k <= upper; k += 2) { // k is the current diagonal
- LinkedRangeDifference edit;
-
- if (pm != null && pm.isCanceled())
- return EMPTY_RESULT;
-
- if (k == origin - d || k != origin + d && lastDiagonal[k + 1] >= lastDiagonal[k - 1]) {
- //
- // move down
- //
- row= lastDiagonal[k + 1] + 1;
- edit= factory.newRange(script[k + 1], LinkedRangeDifference.DELETE);
- } else {
- //
- // move right
- //
- row= lastDiagonal[k - 1];
- edit= factory.newRange(script[k - 1], LinkedRangeDifference.INSERT);
- }
- col= row + k - origin;
- edit.fRightStart= row;
- edit.fLeftStart= col;
- Assert.isTrue(k >= 0 && k <= maxDiagonal);
- script[k]= edit;
-
- // slide down the diagonal as far as possible
- while (row < rightSize && col < leftSize && rangesEqual(right, row, left, col) == true) {
- ++row;
- ++col;
- }
-
- Assert.isTrue(k >= 0 && k <= maxDiagonal); // Unreasonable value for diagonal index
- lastDiagonal[k]= row;
-
- if (row == rightSize && col == leftSize) {
- //showScript(script[k], right, left);
- return createDifferencesRanges(script[k]);
- }
- if (row == rightSize)
- lower= k + 2;
- if (col == leftSize)
- upper= k - 2;
- }
- --lower;
- ++upper;
- }
- // too many differences
- Assert.isTrue(false);
- return null;
- }
-
- /**
- * Finds the differences among three <code>IRangeComparator</code>s.
- * The differences are returned as a list of <code>RangeDifference</code>s.
- * If no differences are detected an empty list is returned.
- * If the ancestor range comparator is <code>null</code>, a two-way
- * comparison is performed.
- *
- * @param ancestor the ancestor range comparator or <code>null</code>
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences, or an empty array if no differences were found
- * @throws LowMemoryException if the differencer runs out of memory
- */
- public static RangeDifference[] findDifferences(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException {
- return findDifferences(null, ancestor, left, right);
- }
-
- /**
- * Finds the differences among three <code>IRangeComparator</code>s.
- * The differences are returned as a list of <code>RangeDifference</code>s.
- * If no differences are detected an empty list is returned.
- * If the ancestor range comparator is <code>null</code>, a two-way
- * comparison is performed.
- *
- * @param pm if not <code>null</code> used to report progress
- * @param ancestor the ancestor range comparator or <code>null</code>
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences, or an empty array if no differences were found
- * @throws LowMemoryException if the differencer runs out of memory
- * @since 2.0
- */
- public static RangeDifference[] findDifferences(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException {
-
- if (ancestor == null)
- return findDifferences(pm, left, right);
-
- RangeDifference[] leftAncestorScript= null;
- RangeDifference[] rightAncestorScript= findDifferences(pm, ancestor, right);
- if (rightAncestorScript != null)
- leftAncestorScript= findDifferences(pm, ancestor, left);
- if (rightAncestorScript == null || leftAncestorScript == null)
- return null;
-
- DifferencesIterator myIter= new DifferencesIterator(rightAncestorScript);
- DifferencesIterator yourIter= new DifferencesIterator(leftAncestorScript);
-
- List diff3= new ArrayList();
- diff3.add(new RangeDifference(RangeDifference.ERROR)); // add a sentinel
-
- int changeRangeStart= 0;
- int changeRangeEnd= 0;
- //
- // Combine the two two-way edit scripts into one
- //
- while (myIter.fDifference != null || yourIter.fDifference != null) {
-
- DifferencesIterator startThread;
- myIter.removeAll();
- yourIter.removeAll();
- //
- // take the next diff that is closer to the start
- //
- if (myIter.fDifference == null)
- startThread= yourIter;
- else if (yourIter.fDifference == null)
- startThread= myIter;
- else { // not at end of both scripts take the lowest range
- if (myIter.fDifference.fLeftStart <= yourIter.fDifference.fLeftStart) // 2 -> common (Ancestor) change range
- startThread= myIter;
- else
- startThread= yourIter;
- }
- changeRangeStart= startThread.fDifference.fLeftStart;
- changeRangeEnd= startThread.fDifference.leftEnd();
-
- startThread.next();
- //
- // check for overlapping changes with other thread
- // merge overlapping changes with this range
- //
- DifferencesIterator other= startThread.other(myIter, yourIter);
- while (other.fDifference != null && other.fDifference.fLeftStart <= changeRangeEnd) {
- int newMax= other.fDifference.leftEnd();
- other.next();
- if (newMax >= changeRangeEnd) {
- changeRangeEnd= newMax;
- other= other.other(myIter, yourIter);
- }
- }
- diff3.add(createRangeDifference3(myIter, yourIter, diff3, right, left, changeRangeStart, changeRangeEnd));
- }
-
- // remove sentinel
- diff3.remove(0);
- return (RangeDifference[]) diff3.toArray(EMPTY_RESULT);
- }
-
- /**
- * Finds the differences among two <code>IRangeComparator</code>s.
- * In contrast to <code>findDifferences</code>, the result
- * contains <code>RangeDifference</code> elements for non-differing ranges too.
- *
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences
- * @throws LowMemoryException if the differencer runs out of memory
- */
- public static List findRanges(IRangeComparator left, IRangeComparator right) throws LowMemoryException {
- return findRanges((IProgressMonitor)null, left, right);
- }
-
- /**
- * Finds the differences among two <code>IRangeComparator</code>s.
- * In contrast to <code>findDifferences</code>, the result
- * contains <code>RangeDifference</code> elements for non-differing ranges too.
- *
- * @param pm if not <code>null</code> used to report progress
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences
- * @throws LowMemoryException if the differencer runs out of memory
- * @since 2.0
- */
- public static List findRanges(IProgressMonitor pm, IRangeComparator left, IRangeComparator right) throws LowMemoryException {
- RangeDifference[] in= findDifferences(pm, left, right);
- List out= new ArrayList();
-
- RangeDifference rd;
-
- int mstart= 0;
- int ystart= 0;
-
- for (int i= 0; i < in.length; i++) {
- RangeDifference es= in[i];
-
- rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, es.rightStart() - mstart, ystart, es.leftStart() - ystart);
- if (rd.maxLength() != 0)
- out.add(rd);
-
- out.add(es);
-
- mstart= es.rightEnd();
- ystart= es.leftEnd();
- }
- rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, right.getRangeCount() - mstart, ystart, left.getRangeCount() - ystart);
- if (rd.maxLength() > 0)
- out.add(rd);
-
- return out;
- }
-
- /**
- * Finds the differences among three <code>IRangeComparator</code>s.
- * In contrast to <code>findDifferences</code>, the result
- * contains <code>RangeDifference</code> elements for non-differing ranges too.
- * If the ancestor range comparator is <code>null</code>, a two-way
- * comparison is performed.
- *
- * @param pm if not <code>null</code> used to report progress
- * @param ancestor the ancestor range comparator or <code>null</code>
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences
- * @throws LowMemoryException if the differencer runs out of memory
- */
- public static List findRanges(IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException {
- return findRanges(null, ancestor, left, right);
- }
-
- /**
- * Finds the differences among three <code>IRangeComparator</code>s.
- * In contrast to <code>findDifferences</code>, the result
- * contains <code>RangeDifference</code> elements for non-differing ranges too.
- * If the ancestor range comparator is <code>null</code>, a two-way
- * comparison is performed.
- *
- * @param pm if not <code>null</code> used to report progress
- * @param ancestor the ancestor range comparator or <code>null</code>
- * @param left the left range comparator
- * @param right the right range comparator
- * @return an array of range differences
- * @throws LowMemoryException if the differencer runs out of memory
- * @since 2.0
- */
- public static List findRanges(IProgressMonitor pm, IRangeComparator ancestor, IRangeComparator left, IRangeComparator right) throws LowMemoryException {
-
- if (ancestor == null)
- return findRanges(pm, left, right);
-
- RangeDifference[] in= findDifferences(pm, ancestor, left, right);
- List out= new ArrayList();
-
- RangeDifference rd;
-
- int mstart= 0;
- int ystart= 0;
- int astart= 0;
-
- for (int i= 0; i < in.length; i++) {
- RangeDifference es= in[i];
-
- rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, es.rightStart() - mstart, ystart, es.leftStart() - ystart, astart, es.ancestorStart() - astart);
- if (rd.maxLength() > 0)
- out.add(rd);
-
- out.add(es);
-
- mstart= es.rightEnd();
- ystart= es.leftEnd();
- astart= es.ancestorEnd();
- }
- rd= new RangeDifference(RangeDifference.NOCHANGE, mstart, right.getRangeCount() - mstart, ystart, left.getRangeCount() - ystart, astart, ancestor.getRangeCount() - astart);
- if (rd.maxLength() > 0)
- out.add(rd);
-
- return out;
- }
-
- //---- private methods
-
- /**
- * Creates a Vector of DifferencesRanges out of the LinkedRangeDifference.
- * It coalesces adjacent changes.
- * In addition, indices are changed such that the ranges are 1) open, i.e,
- * the end of the range is not included, and 2) are zero based.
- */
- private static RangeDifference[] createDifferencesRanges(LinkedRangeDifference start) {
-
- LinkedRangeDifference ep= reverseDifferences(start);
- ArrayList result= new ArrayList();
- RangeDifference es= null;
-
- while (ep != null) {
- es= new RangeDifference(RangeDifference.CHANGE);
-
- if (ep.isInsert()) {
- es.fRightStart= ep.fRightStart + 1;
- es.fLeftStart= ep.fLeftStart;
- RangeDifference b= ep;
- do {
- ep= ep.getNext();
- es.fLeftLength++;
- } while (ep != null && ep.isInsert() && ep.fRightStart == b.fRightStart);
- } else {
- es.fRightStart= ep.fRightStart;
- es.fLeftStart= ep.fLeftStart;
-
- RangeDifference a= ep;
- //
- // deleted lines
- //
- do {
- a= ep;
- ep= ep.getNext();
- es.fRightLength++;
- } while (ep != null && ep.isDelete() && ep.fRightStart == a.fRightStart + 1);
-
- boolean change= (ep != null && ep.isInsert() && ep.fRightStart == a.fRightStart);
-
- if (change) {
- RangeDifference b= ep;
- //
- // replacement lines
- //
- do {
- ep= ep.getNext();
- es.fLeftLength++;
- } while (ep != null && ep.isInsert() && ep.fRightStart == b.fRightStart);
- } else {
- es.fLeftLength= 0;
- }
- es.fLeftStart++; // meaning of range changes from "insert after", to "replace with"
-
- }
- //
- // the script commands are 1 based, subtract one to make them zero based
- //
- es.fRightStart--;
- es.fLeftStart--;
- result.add(es);
- }
- return (RangeDifference[]) result.toArray(EMPTY_RESULT);
- }
-
- /**
- * Creates a <code>RangeDifference3</code> given the
- * state of two DifferenceIterators.
- */
- private static RangeDifference createRangeDifference3(
- DifferencesIterator myIter,
- DifferencesIterator yourIter,
- List diff3,
- IRangeComparator right,
- IRangeComparator left,
- int changeRangeStart,
- int changeRangeEnd) {
-
- int rightStart, rightEnd;
- int leftStart, leftEnd;
- int kind= RangeDifference.ERROR;
- RangeDifference last= (RangeDifference) diff3.get(diff3.size() - 1);
-
- Assert.isTrue((myIter.getCount() != 0 || yourIter.getCount() != 0)); // At least one range array must be non-empty
- //
- // find corresponding lines to fChangeRangeStart/End in right and left
- //
- if (myIter.getCount() == 0) { // only left changed
- rightStart= changeRangeStart - last.ancestorEnd() + last.rightEnd();
- rightEnd= changeRangeEnd - last.ancestorEnd() + last.rightEnd();
- kind= RangeDifference.LEFT;
- } else {
- RangeDifference f= (RangeDifference) myIter.fRange.get(0);
- RangeDifference l= (RangeDifference) myIter.fRange.get(myIter.fRange.size() - 1);
- rightStart= changeRangeStart - f.fLeftStart + f.fRightStart;
- rightEnd= changeRangeEnd - l.leftEnd() + l.rightEnd();
- }
-
- if (yourIter.getCount() == 0) { // only right changed
- leftStart= changeRangeStart - last.ancestorEnd() + last.leftEnd();
- leftEnd= changeRangeEnd - last.ancestorEnd() + last.leftEnd();
- kind= RangeDifference.RIGHT;
- } else {
- RangeDifference f= (RangeDifference) yourIter.fRange.get(0);
- RangeDifference l= (RangeDifference) yourIter.fRange.get(yourIter.fRange.size() - 1);
- leftStart= changeRangeStart - f.fLeftStart + f.fRightStart;
- leftEnd= changeRangeEnd - l.leftEnd() + l.rightEnd();
- }
-
- if (kind == RangeDifference.ERROR) { // overlapping change (conflict) -> compare the changed ranges
- if (rangeSpansEqual(right, rightStart, rightEnd - rightStart, left, leftStart, leftEnd - leftStart))
- kind= RangeDifference.ANCESTOR;
- else
- kind= RangeDifference.CONFLICT;
- }
- return new RangeDifference(kind, rightStart, rightEnd - rightStart, leftStart, leftEnd - leftStart, changeRangeStart, changeRangeEnd - changeRangeStart);
- }
-
- /**
- * Tests if two ranges are equal
- */
- private static boolean rangesEqual(IRangeComparator a, int ai, IRangeComparator b, int bi) {
- return a.rangesEqual(ai, b, bi);
- }
-
- /**
- * Tests whether <code>right</code> and <code>left</left> changed in the same way
- */
- private static boolean rangeSpansEqual(IRangeComparator right, int rightStart, int rightLen, IRangeComparator left, int leftStart, int leftLen) {
- if (rightLen == leftLen) {
- int i= 0;
- for (i= 0; i < rightLen; i++) {
- if (!rangesEqual(right, rightStart + i, left, leftStart + i))
- break;
- }
- if (i == rightLen)
- return true;
- }
- return false;
- }
-
- /**
- * Reverses the range differences
- */
- private static LinkedRangeDifference reverseDifferences(LinkedRangeDifference start) {
- LinkedRangeDifference ep, behind, ahead;
-
- ahead= start;
- ep= null;
- while (ahead != null) {
- behind= ep;
- ep= ahead;
- ahead= ahead.getNext();
- ep.setNext(behind);
- }
- return ep;
- }
-}
-
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/package.html b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/package.html
deleted file mode 100644
index 270a74d7b..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/compare/rangedifferencer/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">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>QuickDiff Internal</title>
-</head>
-<body>
-Copy of the respective classes in org.eclipse.compare.rangedifferencer in order to avoid circular dependencies.
-</body>
-</html>
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html
deleted file mode 100644
index 610f4b03d..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/internal/texteditor/quickdiff/package.html
+++ /dev/null
@@ -1,13 +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">
- <meta name="Author" content="IBM">
- <meta name="GENERATOR" content="Mozilla/4.51 [en] (WinNT; I) [Netscape]">
- <title>QuickDiff Internal</title>
-</head>
-<body>
-Implementation for quick diff display, restore actions and the <code>org.eclipse.ui.editors.quickDiffReferenceProvider</code>
-extension point.
-</body>
-</html>
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java
deleted file mode 100644
index d445026fd..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractDocumentProvider.java
+++ /dev/null
@@ -1,1028 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.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.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.ISchedulingRule;
-
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.source.IAnnotationModel;
-
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-
-
-
-/**
- * An abstract implementation of a sharable document provider.
- * <p>
- * Subclasses must implement <code>createDocument</code>,
- * <code>createAnnotationModel</code>, and <code>doSaveDocument</code>.
- * </p>
- */
-public abstract class AbstractDocumentProvider implements IDocumentProvider, IDocumentProviderExtension, IDocumentProviderExtension2, IDocumentProviderExtension3 {
-
- /**
- * Operation created by the document provider and to be executed by the providers runnable context.
- *
- * @since 3.0
- */
- protected static abstract class DocumentProviderOperation implements IRunnableWithProgress {
-
- /**
- * The actual functionality of this operation.
- *
- * @param monitor a progress monitor to track execution
- * @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);
- }
- }
- }
-
- /**
- * Collection of all information managed for a connected element.
- */
- protected class ElementInfo implements IDocumentListener {
-
- /** The element for which the info is stored */
- public Object fElement;
- /** How often the element has been connected */
- public int fCount;
- /** Can the element be saved */
- public boolean fCanBeSaved;
- /** The element's document */
- public IDocument fDocument;
- /** The element's annotation model */
- public IAnnotationModel fModel;
- /**
- * Has element state been validated
- * @since 2.0
- */
- public boolean fIsStateValidated;
- /**
- * The status of this element
- * @since 2.0
- */
- public IStatus fStatus;
-
-
- /**
- * Creates a new element info, initialized with the given
- * document and annotation model.
- *
- * @param document the document
- * @param model the annotation model
- */
- public ElementInfo(IDocument document, IAnnotationModel model) {
- fDocument= document;
- fModel= model;
- fCount= 0;
- fCanBeSaved= false;
- fIsStateValidated= false;
- }
-
- /**
- * An element info equals another object if this object is an element info
- * and if the documents of the two element infos are equal.
- * @see Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o instanceof ElementInfo) {
- ElementInfo e= (ElementInfo) o;
- return fDocument.equals(e.fDocument);
- }
- return false;
- }
-
- /*
- * @see Object#hashCode()
- */
- public int hashCode() {
- return fDocument.hashCode();
- }
-
- /*
- * @see IDocumentListener#documentChanged(DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- fCanBeSaved= true;
- removeUnchangedElementListeners(fElement, this);
- fireElementDirtyStateChanged(fElement, fCanBeSaved);
- }
-
- /*
- * @see IDocumentListener#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
- }
-
-
- /**
- * Enables a certain behavior.
- * Indicates whether this provider should behave as described in
- * use case 5 of http://bugs.eclipse.org/bugs/show_bug.cgi?id=10806.
- * Current value: <code>true</code> since 3.0
- * @since 2.0
- */
- static final protected boolean PR10806_UC5_ENABLED= true;
-
- /**
- * Enables a certain behavior.
- * Indicates whether this provider should behave as described in
- * http://bugs.eclipse.org/bugs/show_bug.cgi?id=14469
- * Notes: This contradicts <code>PR10806_UC5_ENABLED</code>.
- * Current value: <code>false</code> since 3.0
- * @since 2.0
- */
- static final protected boolean PR14469_ENABLED= false;
-
- /**
- * Constant for representing the OK status. This is considered a value object.
- * @since 2.0
- */
- static final protected IStatus STATUS_OK= new Status(IStatus.OK, TextEditorPlugin.PLUGIN_ID, IStatus.OK, EditorMessages.getString("AbstractDocumentProvider.ok"), null); //$NON-NLS-1$
-
- /**
- * Constant for representing the error status. This is considered a value object.
- * @since 2.0
- */
- static final protected IStatus STATUS_ERROR= new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.INFO, EditorMessages.getString("AbstractDocumentProvider.error"), null); //$NON-NLS-1$
-
-
- /** Element information of all connected elements */
- private Map fElementInfoMap= new HashMap();
- /** The element state listeners */
- private List fElementStateListeners= new ArrayList();
- /**
- * The current progress monitor
- * @since 2.1
- */
- private IProgressMonitor fProgressMonitor;
-
-
- /**
- * Creates a new document provider.
- */
- protected AbstractDocumentProvider() {
- }
-
- /**
- * Creates the document for the given element.
- * <p>
- * Subclasses must implement this method.</p>
- *
- * @param element the element
- * @return the document
- * @exception CoreException if the document could not be created
- */
- protected abstract IDocument createDocument(Object element) throws CoreException;
-
- /**
- * Creates an annotation model for the given element.
- * <p>
- * Subclasses must implement this method.</p>
- *
- * @param element the element
- * @return the annotation model
- * @exception CoreException if the annotation model could not be created
- */
- protected abstract IAnnotationModel createAnnotationModel(Object element) throws CoreException;
-
- /**
- * Performs the actual work of saving the given document provided for the
- * given element.
- * <p>
- * Subclasses must implement this method.</p>
- *
- * @param monitor a progress monitor to report progress and request cancellation
- * @param element the element
- * @param document the document
- * @param overwrite indicates whether an overwrite should happen if necessary
- * @exception CoreException if document could not be stored to the given element
- */
- protected abstract void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException;
-
- /**
- * Returns the runnable context for this document provider.
- *
- * @param monitor a progress monitor to track the operation
- * @return the runnable context for this document provider
- * @since 3.0
- */
- protected abstract IRunnableContext getOperationRunner(IProgressMonitor monitor);
-
- /**
- * Returns the scheduling rule required for executing
- * <code>synchronize</code> on the given element. This default
- * implementation returns <code>null</code>.
- *
- * @param element the element
- * @return the scheduling rule for <code>synchronize</code>
- * @since 3.0
- */
- protected ISchedulingRule getSynchronizeRule(Object element) {
- return null;
- }
-
- /**
- * Returns the scheduling rule required for executing
- * <code>validateState</code> on the given element. This default
- * implementation returns <code>null</code>.
- *
- * @param element the element
- * @return the scheduling rule for <code>validateState</code>
- * @since 3.0
- */
- protected ISchedulingRule getValidateStateRule(Object element) {
- return null;
- }
-
- /**
- * Returns the scheduling rule required for executing
- * <code>save</code> on the given element. This default
- * implementation returns <code>null</code>.
- *
- * @param element the element
- * @return the scheduling rule for <code>save</code>
- * @since 3.0
- */
- protected ISchedulingRule getSaveRule(Object element) {
- return null;
- }
-
- /**
- * Returns the scheduling rule required for executing
- * <code>reset</code> on the given element. This default
- * implementation returns <code>null</code>.
- *
- * @param element the element
- * @return the scheduling rule for <code>reset</code>
- * @since 3.0
- */
- protected ISchedulingRule getResetRule(Object element) {
- return null;
- }
-
- /**
- * Returns the element info object for the given element.
- *
- * @param element the element
- * @return the element info object, or <code>null</code> if none
- */
- protected ElementInfo getElementInfo(Object element) {
- return (ElementInfo) fElementInfoMap.get(element);
- }
-
- /**
- * Creates a new element info object for the given element.
- * <p>
- * This method is called from <code>connect</code> when an element info needs
- * to be created. The <code>AbstractDocumentProvider</code> implementation
- * of this method returns a new element info object whose document and
- * annotation model are the values of <code>createDocument(element)</code>
- * and <code>createAnnotationModel(element)</code>, respectively. Subclasses
- * may override.</p>
- *
- * @param element the element
- * @return a new element info object
- * @exception CoreException if the document or annotation model could not be created
- */
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- return new ElementInfo(createDocument(element), createAnnotationModel(element));
- }
-
- /**
- * Disposes of the given element info object.
- * <p>
- * This method is called when an element info is disposed. The
- * <code>AbstractDocumentProvider</code> implementation of this
- * method does nothing. Subclasses may reimplement.</p>
- *
- * @param element the element
- * @param info the element info object
- */
- protected void disposeElementInfo(Object element, ElementInfo info) {
- }
-
- /**
- * Called on initial creation and when the dirty state of the element
- * changes to <code>false</code>. Adds all listeners which must be
- * active as long as the element is not dirty. This method is called
- * before <code>fireElementDirtyStateChanged</code> or <code>
- * fireElementContentReplaced</code> is called.
- * Subclasses may extend.
- *
- * @param element the element
- * @param info the element info object
- */
- protected void addUnchangedElementListeners(Object element, ElementInfo info) {
- if (info.fDocument != null)
- info.fDocument.addDocumentListener(info);
- }
-
- /**
- * Called when the given element gets dirty. Removes all listeners
- * which must be active only when the element is not dirty. This
- * method is called before <code>fireElementDirtyStateChanged</code>
- * or <code>fireElementContentReplaced</code> is called.
- * Subclasses may extend.
- *
- * @param element the element
- * @param info the element info object
- */
- protected void removeUnchangedElementListeners(Object element, ElementInfo info) {
- if (info.fDocument != null)
- info.fDocument.removeDocumentListener(info);
- }
-
- /**
- * Enumerates the elements connected via this document provider.
- *
- * @return the list of elements (element type: <code>Object</code>)
- */
- protected Iterator getConnectedElements() {
- Set s= new HashSet();
- Set keys= fElementInfoMap.keySet();
- if (keys != null)
- s.addAll(keys);
- return s.iterator();
- }
-
- /*
- * @see IDocumentProvider#connect(Object)
- */
- public final void connect(Object element) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info == null) {
-
- info= createElementInfo(element);
- if (info == null)
- info= new ElementInfo(null, null);
-
- info.fElement= element;
-
- addUnchangedElementListeners(element, info);
-
- fElementInfoMap.put(element, info);
- if (fElementInfoMap.size() == 1)
- connected();
- }
- ++ info.fCount;
- }
-
- /**
- * This hook method is called when this provider starts managing documents for
- * elements. I.e. it is called when the first element gets connected to this provider.
- * Subclasses may extend.
- * @since 2.0
- */
- protected void connected() {
- }
-
- /*
- * @see IDocumentProvider#disconnect
- */
- public final void disconnect(Object element) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
-
- if (info == null)
- return;
-
- if (info.fCount == 1) {
-
- fElementInfoMap.remove(element);
- removeUnchangedElementListeners(element, info);
- disposeElementInfo(element, info);
-
- if (fElementInfoMap.size() == 0)
- disconnected();
-
- } else
- -- info.fCount;
- }
-
- /**
- * This hook method is called when this provider stops managing documents for
- * element. I.e. it is called when the last element gets disconnected from this provider.
- * Subclasses may extend.
- * @since 2.0
- */
- protected void disconnected() {
- }
-
- /*
- * @see IDocumentProvider#getDocument(Object)
- */
- public IDocument getDocument(Object element) {
-
- if (element == null)
- return null;
-
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- return (info != null ? info.fDocument : null);
- }
-
- /*
- * @see IDocumentProvider#mustSaveDocument(Object)
- */
- public boolean mustSaveDocument(Object element) {
-
- if (element == null)
- return false;
-
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- return (info != null ? info.fCount == 1 && info.fCanBeSaved : false);
- }
-
- /*
- * @see IDocumentProvider#getAnnotationModel(Object)
- */
- public IAnnotationModel getAnnotationModel(Object element) {
-
- if (element == null)
- return null;
-
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- return (info != null ? info.fModel : null);
- }
-
- /*
- * @see IDocumentProvider#canSaveDocument(Object)
- */
- public boolean canSaveDocument(Object element) {
-
- if (element == null)
- return false;
-
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- return (info != null ? info.fCanBeSaved : false);
- }
-
- /**
- * Executes the actual work of reseting the given elements document.
- *
- * @param element the element
- * @param monitor the progress monitor
- * @throws CoreException
- * @since 3.0
- */
- protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info != null) {
-
- IDocument original= null;
- IStatus status= null;
-
- try {
- original= createDocument(element);
- } catch (CoreException x) {
- status= x.getStatus();
- }
-
- info.fStatus= status;
-
- if (original != null) {
- fireElementContentAboutToBeReplaced(element);
- info.fDocument.set(original.get());
- if (info.fCanBeSaved) {
- info.fCanBeSaved= false;
- addUnchangedElementListeners(element, info);
- }
- fireElementContentReplaced(element);
- fireElementDirtyStateChanged(element, false);
- }
- }
- }
-
- /**
- * 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
- * @since 3.0
- */
- 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, TextEditorPlugin.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, TextEditorPlugin.PLUGIN_ID, IStatus.OK, message, x));
- }
- }
-
- /*
- * @see IDocumentProvider#resetDocument(Object)
- */
- public final void resetDocument(final Object element) throws CoreException {
-
- if (element == null)
- return;
-
- class ResetOperation extends DocumentProviderOperation implements ISchedulingRuleProvider {
-
- protected void execute(IProgressMonitor monitor) throws CoreException {
- doResetDocument(element, monitor);
- }
-
- public ISchedulingRule getSchedulingRule() {
- return getResetRule(element);
- }
- }
-
- executeOperation(new ResetOperation(), getProgressMonitor());
- }
-
-
- /*
- * @see IDocumentProvider#saveDocument(IProgressMonitor, Object, IDocument, boolean)
- */
- public final void saveDocument(IProgressMonitor monitor, final Object element, final IDocument document, final boolean overwrite) throws CoreException {
-
- if (element == null)
- return;
-
- class SaveOperation extends DocumentProviderOperation implements ISchedulingRuleProvider {
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider.DocumentProviderOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void execute(IProgressMonitor pm) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info != null) {
- if (info.fDocument != document) {
- Status status= new Status(IStatus.WARNING, TextEditorPlugin.PLUGIN_ID, IStatus.ERROR, EditorMessages.getString("AbstractDocumentProvider.error.save.inuse"), null); //$NON-NLS-1$
- throw new CoreException(status);
- }
-
- doSaveDocument(pm, element, document, overwrite);
-
- if (pm != null && pm.isCanceled())
- return;
-
- info.fCanBeSaved= false;
- addUnchangedElementListeners(element, info);
- fireElementDirtyStateChanged(element, false);
-
- } else {
- doSaveDocument(pm, element, document, overwrite);
- }
- }
-
- public ISchedulingRule getSchedulingRule() {
- return getSaveRule(element);
- }
- }
-
- executeOperation(new SaveOperation(), monitor);
- }
-
- /**
- * The <code>AbstractDocumentProvider</code> implementation of this
- * <code>IDocumentProvider</code> method does nothing. Subclasses may
- * reimplement.
- *
- * @param element the element
- */
- public void aboutToChange(Object element) {
- }
-
- /**
- * The <code>AbstractDocumentProvider</code> implementation of this
- * <code>IDocumentProvider</code> method does nothing. Subclasses may
- * reimplement.
- *
- * @param element the element
- */
- public void changed(Object element) {
- }
-
- /*
- * @see IDocumentProvider#addElementStateListener(IElementStateListener)
- */
- public void addElementStateListener(IElementStateListener listener) {
- Assert.isNotNull(listener);
- if (!fElementStateListeners.contains(listener))
- fElementStateListeners.add(listener);
- }
-
- /*
- * @see IDocumentProvider#removeElementStateListener(IElementStateListener)
- */
- public void removeElementStateListener(IElementStateListener listener) {
- Assert.isNotNull(listener);
- fElementStateListeners.remove(listener);
- }
-
- /**
- * Informs all registered element state listeners about a change in the
- * dirty state of the given element.
- *
- * @param element the element
- * @param isDirty the new dirty state
- * @see IElementStateListener#elementDirtyStateChanged(Object, boolean)
- */
- protected void fireElementDirtyStateChanged(Object element, boolean isDirty) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- l.elementDirtyStateChanged(element, isDirty);
- }
- }
-
- /**
- * Informs all registered element state listeners about an impending
- * replace of the given element's content.
- *
- * @param element the element
- * @see IElementStateListener#elementContentAboutToBeReplaced(Object)
- */
- protected void fireElementContentAboutToBeReplaced(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- l.elementContentAboutToBeReplaced(element);
- }
- }
-
- /**
- * Informs all registered element state listeners about the just-completed
- * replace of the given element's content.
- *
- * @param element the element
- * @see IElementStateListener#elementContentReplaced(Object)
- */
- protected void fireElementContentReplaced(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- l.elementContentReplaced(element);
- }
- }
-
- /**
- * Informs all registered element state listeners about the deletion
- * of the given element.
- *
- * @param element the element
- * @see IElementStateListener#elementDeleted(Object)
- */
- protected void fireElementDeleted(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- l.elementDeleted(element);
- }
- }
-
- /**
- * Informs all registered element state listeners about a move.
- *
- * @param originalElement the element before the move
- * @param movedElement the element after the move
- * @see IElementStateListener#elementMoved(Object, Object)
- */
- protected void fireElementMoved(Object originalElement, Object movedElement) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- IElementStateListener l= (IElementStateListener) e.next();
- l.elementMoved(originalElement, movedElement);
- }
- }
-
- /*
- * @see IDocumentProvider#getModificationStamp(Object)
- * @since 2.0
- */
- public long getModificationStamp(Object element) {
- return 0;
- }
-
- /*
- * @see IDocumentProvider#getSynchronizationStamp(Object)
- * @since 2.0
- */
- public long getSynchronizationStamp(Object element) {
- return 0;
- }
-
- /*
- * @see IDocumentProvider#isDeleted(Object)
- * @since 2.0
- */
- public boolean isDeleted(Object element) {
- return false;
- }
-
- /*
- * @see IDocumentProviderExtension#isReadOnly(Object)
- * @since 2.0
- */
- public boolean isReadOnly(Object element) {
- return true;
- }
-
- /*
- * @see IDocumentProviderExtension#isModifiable(Object)
- * @since 2.0
- */
- public boolean isModifiable(Object element) {
- return false;
- }
-
- /**
- * Returns whether <code>validateState</code> has been called for the given element
- * since the element's state has potentially been invalidated.
- *
- * @param element the element
- * @return whether <code>validateState</code> has been called for the given element
- * @since 2.0
- */
- public boolean isStateValidated(Object element) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info != null)
- return info.fIsStateValidated;
- return false;
- }
-
- /**
- * Hook method for validating the state of the given element. Must not take care of cache updating etc.
- * Default implementation is empty.
- *
- * @param element the element
- * @param computationContext the context in which validation happens
- * @exception CoreException in case validation fails
- * @since 2.0
- */
- protected void doValidateState(Object element, Object computationContext) throws CoreException {
- }
-
- /*
- * @see IDocumentProviderExtension#validateState(Object, Object)
- * @since 2.0
- */
- public void validateState(final Object element, final Object computationContext) throws CoreException {
- if (element == null)
- return;
-
- class ValidateStateOperation extends DocumentProviderOperation implements ISchedulingRuleProvider {
-
- protected void execute(IProgressMonitor monitor) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info == null)
- return;
-
- doValidateState(element, computationContext);
-
- doUpdateStateCache(element);
- info.fIsStateValidated= true;
- fireElementStateValidationChanged(element, true);
- }
-
- public ISchedulingRule getSchedulingRule() {
- return getValidateStateRule(element);
- }
- }
-
- executeOperation(new ValidateStateOperation(), getProgressMonitor());
- }
-
- /**
- * Hook method for updating the state of the given element.
- * Default implementation is empty.
- *
- * @param element the element
- * @exception CoreException in case state cache updating fails
- * @since 2.0
- */
- protected void doUpdateStateCache(Object element) throws CoreException {
- }
-
- /**
- * Returns whether the state of the element must be invalidated given its
- * previous read-only state.
- *
- * @param element the element
- * @param wasReadOnly the previous read-only state
- * @return <code>true</code> if the state of the given element must be invalidated
- * @since 2.0
- */
- protected boolean invalidatesState(Object element, boolean wasReadOnly) {
- Assert.isTrue(PR10806_UC5_ENABLED != PR14469_ENABLED);
- boolean readOnlyChanged= (isReadOnly(element) != wasReadOnly && !wasReadOnly);
- if (PR14469_ENABLED)
- return readOnlyChanged && !canSaveDocument(element);
- return readOnlyChanged;
- }
-
- /*
- * @see IDocumentProviderExtension#updateStateCache(Object)
- * @since 2.0
- */
- final public void updateStateCache(Object element) throws CoreException {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info != null) {
- boolean wasReadOnly= isReadOnly(element);
- doUpdateStateCache(element);
- if (invalidatesState(element, wasReadOnly)) {
- info.fIsStateValidated= false;
- fireElementStateValidationChanged(element, false);
- }
- }
- }
-
- /*
- * @see IDocumentProviderExtension#setCanSaveDocument(Object)
- * @since 2.0
- */
- public void setCanSaveDocument(Object element) {
- if (element != null) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info != null) {
- info.fCanBeSaved= true;
- removeUnchangedElementListeners(element, info);
- fireElementDirtyStateChanged(element, info.fCanBeSaved);
- }
- }
- }
-
- /**
- * Informs all registered element state listeners about a change in the
- * state validation of the given element.
- *
- * @param element the element
- * @param isStateValidated
- * @see IElementStateListenerExtension#elementStateValidationChanged(Object, boolean)
- * @since 2.0
- */
- protected void fireElementStateValidationChanged(Object element, boolean isStateValidated) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- Object o= e.next();
- if (o instanceof IElementStateListenerExtension) {
- IElementStateListenerExtension l= (IElementStateListenerExtension) o;
- l.elementStateValidationChanged(element, isStateValidated);
- }
- }
- }
-
- /**
- * Informs all registered element state listeners about the current state
- * change of the element
- *
- * @param element the element
- * @see IElementStateListenerExtension#elementStateChanging(Object)
- * @since 2.0
- */
- protected void fireElementStateChanging(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- Object o= e.next();
- if (o instanceof IElementStateListenerExtension) {
- IElementStateListenerExtension l= (IElementStateListenerExtension) o;
- l.elementStateChanging(element);
- }
- }
- }
-
- /**
- * Informs all registered element state listeners about the failed
- * state change of the element
- *
- * @param element the element
- * @see IElementStateListenerExtension#elementStateChangeFailed(Object)
- * @since 2.0
- */
- protected void fireElementStateChangeFailed(Object element) {
- Iterator e= new ArrayList(fElementStateListeners).iterator();
- while (e.hasNext()) {
- Object o= e.next();
- if (o instanceof IElementStateListenerExtension) {
- IElementStateListenerExtension l= (IElementStateListenerExtension) o;
- l.elementStateChangeFailed(element);
- }
- }
- }
-
- /*
- * @see IDocumentProviderExtension#getStatus(Object)
- * @since 2.0
- */
- public IStatus getStatus(Object element) {
- ElementInfo info= (ElementInfo) fElementInfoMap.get(element);
- if (info != null) {
- if (info.fStatus != null)
- return info.fStatus;
- return (info.fDocument == null ? STATUS_ERROR : STATUS_OK);
- }
-
- return STATUS_ERROR;
- }
-
- /**
- * Performs the actual work of synchronizing the given element.
- *
- * @param element the element
- * @param monitor the progress monitor
- * @exception CoreException in the case that synchronization fails
- * @since 3.0
- */
- protected void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#synchronize(Object)
- * @since 2.0
- */
- public final void synchronize(final Object element) throws CoreException {
-
- if (element == null)
- return;
-
- class SynchronizeOperation extends DocumentProviderOperation implements ISchedulingRuleProvider {
-
- protected void execute(IProgressMonitor monitor) throws CoreException {
- doSynchronize(element, monitor);
- }
-
- public ISchedulingRule getSchedulingRule() {
- return getSynchronizeRule(element);
- }
- }
-
- executeOperation(new SynchronizeOperation(), getProgressMonitor());
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#getProgressMonitor()
- * @since 2.1
- */
- public IProgressMonitor getProgressMonitor() {
- return fProgressMonitor == null ? new NullProgressMonitor() : fProgressMonitor;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension2#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- * @since 2.1
- */
- public void setProgressMonitor(IProgressMonitor progressMonitor) {
- fProgressMonitor= progressMonitor;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension3#isSynchronized(java.lang.Object)
- * @since 3.0
- */
- public boolean isSynchronized(Object element) {
- return true;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java
deleted file mode 100644
index f720363ed..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractRulerActionDelegate.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-
-package org.eclipse.ui.texteditor;
-
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.widgets.Control;
-
-import org.eclipse.ui.IEditorActionDelegate;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * This class serves as an adapter for actions contributed to the vertical ruler's
- * context menu. This adapter provides the contributed actions access to their editor
- * and the editor's vertical ruler. These actions gain only limited access to the vertical
- * ruler as defined by <code>IVerticalRulerInfo</code>. The adapter updates the
- * adapter (inner) action on menu and mouse action on the vertical ruler.<p>
- * Extending classes must implement the factory method
- * <code>createAction(ITextEditor editor, IVerticalRulerInfo)</code>.
- *
- * @since 2.0
- */
-public abstract class AbstractRulerActionDelegate implements IEditorActionDelegate, MouseListener, IMenuListener {
-
- /** The editor. */
- private IEditorPart fEditor;
- /** The action calling the action delegate. */
- private IAction fCallerAction;
- /** The underlying action. */
- private IAction fAction;
-
- /**
- * The factory method creating the underlying action.
- *
- * @param editor the editor the action to be created will work on
- * @param rulerInfo the vertical ruler the action to be created will work on
- * @return the created action
- */
- protected abstract IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo);
-
-
- /*
- * @see IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart)
- */
- public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) {
- if (fEditor != null) {
- IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) fEditor.getAdapter(IVerticalRulerInfo.class);
- if (rulerInfo != null) {
- Control control= rulerInfo.getControl();
- if (control != null && !control.isDisposed())
- control.removeMouseListener(this);
- }
-
- if (fEditor instanceof ITextEditorExtension)
- ((ITextEditorExtension) fEditor).removeRulerContextMenuListener(this);
- }
-
- fEditor= targetEditor;
- fCallerAction= callerAction;
- fAction= null;
-
- if (fEditor != null && fEditor instanceof ITextEditor) {
- if (fEditor instanceof ITextEditorExtension)
- ((ITextEditorExtension) fEditor).addRulerContextMenuListener(this);
-
- IVerticalRulerInfo rulerInfo= (IVerticalRulerInfo) fEditor.getAdapter(IVerticalRulerInfo.class);
- if (rulerInfo != null) {
- fAction= createAction((ITextEditor) fEditor, rulerInfo);
- update();
-
- Control control= rulerInfo.getControl();
- if (control != null && !control.isDisposed())
- control.addMouseListener(this);
- }
- }
- }
-
- /*
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction callerAction) {
- if (fAction != null)
- fAction.run();
- }
-
- /*
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- update();
- }
-
- /**
- * Requests the adaptee to update itself to the current state.
- */
- private void update() {
- if (fAction instanceof IUpdate) {
- ((IUpdate) fAction).update();
- if (fCallerAction != null) {
- fCallerAction.setText(fAction.getText());
- fCallerAction.setEnabled(fAction.isEnabled());
- }
- }
- }
-
- /*
- * @see IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- public void menuAboutToShow(IMenuManager manager) {
- update();
- }
-
- /*
- * @see MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * @see MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent e) {
- update();
- }
-
- /*
- * @see MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
deleted file mode 100644
index 456d28807..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AbstractTextEditor.java
+++ /dev/null
@@ -1,5129 +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
- * Chris.Dennis@invidi.com - http://bugs.eclipse.org/bugs/show_bug.cgi?id=29027
- *******************************************************************************/
-package org.eclipse.ui.texteditor;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.osgi.framework.Bundle;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.ILog;
-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.Status;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.ST;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.ShellAdapter;
-import org.eclipse.swt.events.ShellEvent;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Caret;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IFindReplaceTarget;
-import org.eclipse.jface.text.IFindReplaceTargetExtension;
-import org.eclipse.jface.text.IMarkRegionTarget;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.ISelectionValidator;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextListener;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextEvent;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.IVerticalRulerExtension;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.text.source.VerticalRuler;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IKeyBindingService;
-import org.eclipse.ui.INavigationLocation;
-import org.eclipse.ui.INavigationLocationProvider;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IReusableEditor;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.internal.ActionDescriptor;
-import org.eclipse.ui.internal.EditorPluginAction;
-import org.eclipse.ui.internal.texteditor.EditPosition;
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-import org.eclipse.ui.part.EditorActionBarContributor;
-import org.eclipse.ui.part.EditorPart;
-
-
-/**
- * Abstract base implementation of a text editor.
- * <p>
- * Subclasses are responsible for configuring the editor appropriately.
- * The standard text editor, <code>TextEditor</code>, is one such example.</p>
- * <p>
- * If a subclass calls <code>setEditorContextMenuId</code> the arguments is
- * used as the id under which the editor's context menu is registered for extensions.
- * If no id is set, the context menu is registered under <b>[editor_id].EditorContext</b>
- * whereby [editor_id] is replaced with the editor's part id. If the editor is instructed to
- * run in version 1.0 context menu registration compatibility mode, the latter form of the
- * registration even happens if a context menu id has been set via <code>setEditorContextMenuId</code>.
- * If no id is set while in compatibility mode, the menu is registered under
- * <code>DEFAULT_EDITOR_CONTEXT_MENU_ID</code>.</p>
- * <p>
- * If a subclass calls <code>setRulerContextMenuId</code> the argument is
- * used as the id under which the ruler's context menu is registered for extensions.
- * If no id is set, the context menu is registered under <b>[editor_id].RulerContext</b>
- * whereby [editor_id] is replaced with the editor's part id. If the editor is instructed to
- * run in version 1.0 context menu registration compatibility mode, the latter form of the
- * registration even happens if a context menu id has been set via <code>setRulerContextMenuId</code>.
- * If no id is set while in compatibility mode, the menu is registered under
- * <code>DEFAULT_RULER_CONTEXT_MENU_ID</code>.</p>
- *
- * @see org.eclipse.ui.editors.text.TextEditor
- */
-public abstract class AbstractTextEditor extends EditorPart implements ITextEditor, IReusableEditor, ITextEditorExtension, ITextEditorExtension2, ITextEditorExtension3, INavigationLocationProvider {
-
- /**
- * Tag used in xml configuration files to specify editor action contributions.
- * Current value: <code>editorContribution</code>
- * @since 2.0
- */
- private static final String TAG_CONTRIBUTION_TYPE= "editorContribution"; //$NON-NLS-1$
-
- /**
- * The caret width for the wide (double) caret.
- * Value: {@value}
- * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=21715
- * @since 3.0
- */
- private static final int WIDE_CARET_WIDTH= 2;
-
- /**
- * The caret width for the narrow (single) caret.
- * Value: {@value}
- * @see https://bugs.eclipse.org/bugs/show_bug.cgi?id=21715
- * @since 3.0
- */
- private static final int SINGLE_CARET_WIDTH= 1;
-
- /**
- * The text input listener.
- *
- * @see ITextInputListener
- * @since 2.1
- */
- private static class TextInputListener implements ITextInputListener {
- /** Indicates whether the editor input changed during the process of state validation. */
- public boolean inputChanged;
-
- /* Detectors for editor input changes during the process of state validation. */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {}
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) { inputChanged= true; }
- }
-
- /**
- * Internal element state listener.
- */
- class ElementStateListener implements IElementStateListener, IElementStateListenerExtension {
-
- /**
- * Internal <code>VerifyListener</code> for performing the state validation of the
- * editor input in case of the first attempted manipulation via typing on the keyboard.
- * @since 2.0
- */
- class Validator implements VerifyListener {
- /*
- * @see VerifyListener#verifyText(org.eclipse.swt.events.VerifyEvent)
- */
- public void verifyText(VerifyEvent e) {
- IDocument document= getDocumentProvider().getDocument(getEditorInput());
- final boolean[] documentChanged= new boolean[1];
- IDocumentListener listener= new IDocumentListener() {
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
- public void documentChanged(DocumentEvent event) {
- documentChanged[0]= true;
- }
- };
- try {
- if (document != null)
- document.addDocumentListener(listener);
- if (! validateEditorInputState() || documentChanged[0])
- e.doit= false;
- } finally {
- if (document != null)
- document.removeDocumentListener(listener);
- }
- }
- }
-
- /**
- * The listener's validator.
- * @since 2.0
- */
- private Validator fValidator;
- /**
- * The display used for posting runnable into the UI thread.
- * @since 3.0
- */
- private Display fDisplay;
-
- /*
- * @see IElementStateListenerExtension#elementStateValidationChanged(Object, boolean)
- * @since 2.0
- */
- public void elementStateValidationChanged(final Object element, final boolean isStateValidated) {
- if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- public void run() {
- enableSanityChecking(true);
- if (isStateValidated && fValidator != null) {
- ISourceViewer viewer= getSourceViewer();
- if (viewer != null) {
- StyledText textWidget= viewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.removeVerifyListener(fValidator);
- fValidator= null;
- enableStateValidation(false);
- }
- } else if (!isStateValidated && fValidator == null) {
- ISourceViewer viewer= getSourceViewer();
- if (viewer != null) {
- StyledText textWidget= viewer.getTextWidget();
- if (textWidget != null && !textWidget.isDisposed()) {
- fValidator= new Validator();
- enableStateValidation(true);
- textWidget.addVerifyListener(fValidator);
- }
- }
- }
- }
- };
- execute(r);
- }
- }
-
-
- /*
- * @see IElementStateListener#elementDirtyStateChanged(Object, boolean)
- */
- public void elementDirtyStateChanged(Object element, boolean isDirty) {
- if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- public void run() {
- enableSanityChecking(true);
- firePropertyChange(PROP_DIRTY);
- }
- };
- execute(r);
- }
- }
-
- /*
- * @see IElementStateListener#elementContentAboutToBeReplaced(Object)
- */
- public void elementContentAboutToBeReplaced(Object element) {
- if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- public void run() {
- enableSanityChecking(true);
- rememberSelection();
- resetHighlightRange();
- }
- };
- execute(r);
- }
- }
-
- /*
- * @see IElementStateListener#elementContentReplaced(Object)
- */
- public void elementContentReplaced(Object element) {
- if (element != null && element.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- public void run() {
- enableSanityChecking(true);
- firePropertyChange(PROP_DIRTY);
- restoreSelection();
- handleElementContentReplaced();
- }
- };
- execute(r);
- }
- }
-
- /*
- * @see IElementStateListener#elementDeleted(Object)
- */
- public void elementDeleted(Object deletedElement) {
- if (deletedElement != null && deletedElement.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- public void run() {
- enableSanityChecking(true);
- close(false);
- }
- };
- execute(r);
- }
- }
-
- /*
- * @see IElementStateListener#elementMoved(Object, Object)
- */
- public void elementMoved(final Object originalElement, final Object movedElement) {
- if (originalElement != null && originalElement.equals(getEditorInput())) {
- Runnable r= new Runnable() {
- public void run() {
- enableSanityChecking(true);
-
- if (!canHandleMove((IEditorInput) originalElement, (IEditorInput) movedElement)) {
- close(true);
- return;
- }
-
- if (movedElement == null || movedElement instanceof IEditorInput) {
- rememberSelection();
-
- IDocumentProvider d= getDocumentProvider();
- IDocument changed= null;
- String previousContent= null;
- if (isDirty()) {
- changed= d.getDocument(getEditorInput());
- if (changed != null)
- previousContent= changed.get();
- }
-
- setInput((IEditorInput) movedElement);
-
- if (changed != null) {
- d.getDocument(getEditorInput()).set(previousContent);
- validateState(getEditorInput());
- updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
- }
-
- restoreSelection();
- }
- }
- };
- execute(r);
- }
- }
-
- /*
- * @see IElementStateListenerExtension#elementStateChanging(Object)
- * @since 2.0
- */
- public void elementStateChanging(Object element) {
- if (element != null && element.equals(getEditorInput()))
- enableSanityChecking(false);
- }
-
- /*
- * @see IElementStateListenerExtension#elementStateChangeFailed(Object)
- * @since 2.0
- */
- public void elementStateChangeFailed(Object element) {
- if (element != null && element.equals(getEditorInput()))
- enableSanityChecking(true);
- }
-
- /**
- * Executes the given runnable in the UI thread.
- *
- * @param runnable runnable to be executed
- * @since 3.0
- */
- private void execute(Runnable runnable) {
- if (Display.getCurrent() != null)
- runnable.run();
- else {
- if (fDisplay == null)
- fDisplay= getSite().getShell().getDisplay();
- fDisplay.asyncExec(runnable);
- }
- }
- }
-
- /**
- * Internal text listener for updating all content dependent
- * actions. The updating is done asynchronously.
- */
- class TextListener implements ITextListener, ITextInputListener {
-
- /** The posted updater code. */
- private Runnable fRunnable= new Runnable() {
- public void run() {
- fIsRunnablePosted= false;
-
- if (fSourceViewer != null) {
- updateContentDependentActions();
-
- // remember the last edit position
- if (isDirty() && fUpdateLastEditPosition) {
- fUpdateLastEditPosition= false;
- ISelection sel= getSelectionProvider().getSelection();
- IEditorInput input= getEditorInput();
- IDocument document= getDocumentProvider().getDocument(input);
-
- if (fLocalLastEditPosition != null) {
- document.removePosition(fLocalLastEditPosition);
- fLocalLastEditPosition= null;
- }
-
- if (sel instanceof ITextSelection && !sel.isEmpty()) {
- ITextSelection s= (ITextSelection) sel;
- fLocalLastEditPosition= new Position(s.getOffset(), s.getLength());
- try {
- document.addPosition(fLocalLastEditPosition);
- } catch (BadLocationException ex) {
- fLocalLastEditPosition= null;
- }
- }
- TextEditorPlugin.getDefault().setLastEditPosition(new EditPosition(input, getEditorSite().getId(), getSelectionProvider().getSelection(), fLocalLastEditPosition));
- }
- }
- }
- };
-
- /** Display used for posting the updater code. */
- private Display fDisplay;
- /**
- * The editor's last edit position
- * @since 3.0
- */
- private Position fLocalLastEditPosition;
- /**
- * Has the runnable been posted?
- * @since 3.0
- */
- private boolean fIsRunnablePosted= false;
- /**
- * Should the last edit position be updated?
- * @since 3.0
- */
- private boolean fUpdateLastEditPosition= false;
-
- /*
- * @see ITextListener#textChanged(TextEvent)
- */
- public void textChanged(TextEvent event) {
-
- /*
- * Also works for text events which do not base on a DocumentEvent.
- * This way, if the visible document of the viewer changes, all content
- * dependent actions are updated as well.
- */
-
- if (fDisplay == null)
- fDisplay= getSite().getShell().getDisplay();
-
- if (event.getDocumentEvent() != null)
- fUpdateLastEditPosition= true;
-
- if (!fIsRunnablePosted) {
- fIsRunnablePosted= true;
- fDisplay.asyncExec(fRunnable);
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentAboutToBeChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- if (oldInput != null && fLocalLastEditPosition != null) {
- oldInput.removePosition(fLocalLastEditPosition);
- fLocalLastEditPosition= null;
- }
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument, org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- }
- }
-
- /**
- * Internal property change listener for handling changes in the editor's preferences.
- */
- class PropertyChangeListener implements IPropertyChangeListener {
- /*
- * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- handlePreferenceStoreChanged(event);
- }
- }
-
- /**
- * Internal property change listener for handling workbench font changes.
- * @since 2.1
- */
- class FontPropertyChangeListener implements IPropertyChangeListener {
- /*
- * @see IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (fSourceViewer == null)
- return;
-
- String property= event.getProperty();
-
- if (getFontPropertyPreferenceKey().equals(property)) {
- initializeViewerFont(fSourceViewer);
- updateCaret();
- }
- }
- }
-
- /**
- * Internal key verify listener for triggering action activation codes.
- */
- class ActivationCodeTrigger implements VerifyKeyListener {
-
- /** Indicates whether this trigger has been installed. */
- private boolean fIsInstalled= false;
- /**
- * The key binding service to use.
- * @since 2.0
- */
- private IKeyBindingService fKeyBindingService;
-
- /*
- * @see VerifyKeyListener#verifyKey(org.eclipse.swt.events.VerifyEvent)
- */
- public void verifyKey(VerifyEvent event) {
-
- ActionActivationCode code= null;
- int size= fActivationCodes.size();
- for (int i= 0; i < size; i++) {
- code= (ActionActivationCode) fActivationCodes.get(i);
- if (code.matches(event)) {
- IAction action= getAction(code.fActionId);
- if (action != null) {
-
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
-
- if (!action.isEnabled() && action instanceof IReadOnlyDependent) {
- IReadOnlyDependent dependent= (IReadOnlyDependent) action;
- boolean writable= dependent.isEnabled(true);
- if (writable) {
- event.doit= false;
- return;
- }
- } else if (action.isEnabled()) {
- event.doit= false;
- action.run();
- return;
- }
- }
- }
- }
- }
-
- /**
- * Installs this trigger on the editor's text widget.
- * @since 2.0
- */
- public void install() {
- if (!fIsInstalled) {
-
- if (fSourceViewer instanceof ITextViewerExtension) {
- ITextViewerExtension e= (ITextViewerExtension) fSourceViewer;
- e.prependVerifyKeyListener(this);
- } else {
- StyledText text= fSourceViewer.getTextWidget();
- text.addVerifyKeyListener(this);
- }
-
- fKeyBindingService= getEditorSite().getKeyBindingService();
- fIsInstalled= true;
- }
- }
-
- /**
- * Uninstalls this trigger from the editor's text widget.
- * @since 2.0
- */
- public void uninstall() {
- if (fIsInstalled) {
-
- if (fSourceViewer instanceof ITextViewerExtension) {
- ITextViewerExtension e= (ITextViewerExtension) fSourceViewer;
- e.removeVerifyKeyListener(this);
- } else if (fSourceViewer != null) {
- StyledText text= fSourceViewer.getTextWidget();
- if (text != null && !text.isDisposed())
- text.removeVerifyKeyListener(fActivationCodeTrigger);
- }
-
- fIsInstalled= false;
- fKeyBindingService= null;
- }
- }
-
- /**
- * Registers the given action for key activation.
- * @param action the action to be registered
- * @since 2.0
- */
- public void registerActionForKeyActivation(IAction action) {
- if (action.getActionDefinitionId() != null)
- fKeyBindingService.registerAction(action);
- }
-
- /**
- * The given action is no longer available for key activation
- * @param action the action to be unregistered
- * @since 2.0
- */
- public void unregisterActionFromKeyActivation(IAction action) {
- if (action.getActionDefinitionId() != null)
- fKeyBindingService.unregisterAction(action);
- }
-
- /**
- * Sets the keybindings scopes for this editor.
- * @param keyBindingScopes the keybinding scopes
- * @since 2.1
- */
- public void setScopes(String[] keyBindingScopes) {
- if (keyBindingScopes != null && keyBindingScopes.length > 0)
- fKeyBindingService.setScopes(keyBindingScopes);
- }
- }
-
- /**
- * Representation of action activation codes.
- */
- static class ActionActivationCode {
-
- /** The action id. */
- public String fActionId;
- /** The character. */
- public char fCharacter;
- /** The key code. */
- public int fKeyCode= -1;
- /** The state mask. */
- public int fStateMask= SWT.DEFAULT;
-
- /**
- * Creates a new action activation code for the given action id.
- * @param actionId the action id
- */
- public ActionActivationCode(String actionId) {
- fActionId= actionId;
- }
-
- /**
- * Returns <code>true</code> if this activation code matches the given verify event.
- * @param event the event to test for matching
- * @return whether this activation code matches <code>event</code>
- */
- public boolean matches(VerifyEvent event) {
- return (event.character == fCharacter &&
- (fKeyCode == -1 || event.keyCode == fKeyCode) &&
- (fStateMask == SWT.DEFAULT || event.stateMask == fStateMask));
- }
- }
-
- /**
- * Internal part and shell activation listener for triggering state validation.
- * @since 2.0
- */
- class ActivationListener extends ShellAdapter implements IPartListener {
-
- /** Cache of the active workbench part. */
- private IWorkbenchPart fActivePart;
- /** Indicates whether activation handling is currently be done. */
- private boolean fIsHandlingActivation= false;
-
- /*
- * @see IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
- */
- public void partActivated(IWorkbenchPart part) {
- fActivePart= part;
- handleActivation();
- }
-
- /*
- * @see IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
- */
- public void partBroughtToTop(IWorkbenchPart part) {
- }
-
- /*
- * @see IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
- */
- public void partClosed(IWorkbenchPart part) {
- }
-
- /*
- * @see IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart)
- */
- public void partDeactivated(IWorkbenchPart part) {
- fActivePart= null;
- }
-
- /*
- * @see IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
- */
- public void partOpened(IWorkbenchPart part) {
- }
-
- /*
- * @see ShellListener#shellActivated(org.eclipse.swt.events.ShellEvent)
- */
- public void shellActivated(ShellEvent e) {
- /*
- * Workaround for problem described in
- * http://dev.eclipse.org/bugs/show_bug.cgi?id=11731
- * Will be removed when SWT has solved the problem.
- */
- e.widget.getDisplay().asyncExec(new Runnable() {
- public void run() {
- handleActivation();
- }
- });
- }
-
- /**
- * Handles the activation triggering a element state check in the editor.
- */
- private void handleActivation() {
- if (fIsHandlingActivation)
- return;
-
- if (fActivePart == AbstractTextEditor.this) {
- fIsHandlingActivation= true;
- try {
- safelySanityCheckState(getEditorInput());
- } finally {
- fIsHandlingActivation= false;
- }
- }
- }
- }
-
- /**
- * Internal interface for a cursor listener. I.e. aggregation
- * of mouse and key listener.
- * @since 2.0
- */
- interface ICursorListener extends MouseListener, KeyListener {
- }
-
- /**
- * Maps an action definition id to an StyledText action.
- * @since 2.0
- */
- static class IdMapEntry {
-
- /** The action id. */
- private String fActionId;
- /** The StyledText action. */
- private int fAction;
-
- /**
- * Creates a new mapping.
- * @param actionId the action id
- * @param action the StyledText action
- */
- public IdMapEntry(String actionId, int action) {
- fActionId= actionId;
- fAction= action;
- }
-
- /**
- * Returns the action id.
- * @return the action id
- */
- public String getActionId() {
- return fActionId;
- }
-
- /**
- * Returns the action.
- * @return the action
- */
- public int getAction() {
- return fAction;
- }
- }
-
- /**
- * Internal action to scroll the editor's viewer by a specified number of lines.
- * @since 2.0
- */
- class ScrollLinesAction extends Action {
-
- /** Number of lines to scroll. */
- private int fScrollIncrement;
-
- /**
- * Creates a new scroll action that scroll the given number of lines. If the
- * increment is &lt 0, it's scrolling up, if &gt 0 it's scrolling down.
- * @param scrollIncrement the number of lines to scroll
- */
- public ScrollLinesAction(int scrollIncrement) {
- fScrollIncrement= scrollIncrement;
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
- ISourceViewer viewer= getSourceViewer();
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- StyledText textWidget= viewer.getTextWidget();
- int topIndex= textWidget.getTopIndex();
- int newTopIndex= Math.max(0, topIndex + fScrollIncrement);
- viewer.setTopIndex(extension.widgetLine2ModelLine(newTopIndex));
- } else {
- int topIndex= viewer.getTopIndex();
- int newTopIndex= Math.max(0, topIndex + fScrollIncrement);
- viewer.setTopIndex(newTopIndex);
- }
- }
- }
-
- /**
- * Action to toggle the insert mode. The action is checked if smart mode is
- * turned on.
- *
- * @since 2.1
- */
- class ToggleInsertModeAction extends ResourceAction {
-
- public ToggleInsertModeAction(ResourceBundle bundle, String prefix) {
- super(bundle, prefix, IAction.AS_CHECK_BOX);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- switchToNextInsertMode();
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#isChecked()
- * @since 3.0
- */
- public boolean isChecked() {
- return fInsertMode == SMART_INSERT;
- }
- }
-
- /**
- * Action to toggle the overwrite mode.
- *
- * @since 3.0
- */
- class ToggleOverwriteModeAction extends ResourceAction {
-
- public ToggleOverwriteModeAction(ResourceBundle bundle, String prefix) {
- super(bundle, prefix);
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- toggleOverwriteMode();
- }
- }
-
- /**
- * This action implements smart end.
- * Instead of going to the end of a line it does the following:
- * - if smart home/end is enabled and the caret is before the line's last non-whitespace and then the caret is moved directly after it
- * - if the caret is after last non-whitespace the caret is moved at the end of the line
- * - if the caret is at the end of the line the caret is moved directly after the line's last non-whitespace character
- * @since 2.1
- */
- class LineEndAction extends TextNavigationAction {
-
- /** boolean flag which tells if the text up to the line end should be selected. */
- private boolean fDoSelect;
-
- /**
- * Create a new line end action.
- *
- * @param textWidget the styled text widget
- * @param doSelect a boolean flag which tells if the text up to the line end should be selected
- */
- public LineEndAction(StyledText textWidget, boolean doSelect) {
- super(textWidget, ST.LINE_END);
- fDoSelect= doSelect;
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- boolean isSmartHomeEndEnabled= false;
- IPreferenceStore store= getPreferenceStore();
- if (store != null)
- isSmartHomeEndEnabled= store.getBoolean(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END);
-
- StyledText st= getSourceViewer().getTextWidget();
- if (st == null || st.isDisposed())
- return;
- int caretOffset= st.getCaretOffset();
- int lineNumber= st.getLineAtOffset(caretOffset);
- int lineOffset= st.getOffsetAtLine(lineNumber);
-
- int lineLength;
- try {
- int caretOffsetInDocument= widgetOffset2ModelOffset(getSourceViewer(), caretOffset);
- lineLength= getSourceViewer().getDocument().getLineInformationOfOffset(caretOffsetInDocument).getLength();
- } catch (BadLocationException ex) {
- return;
- }
- int lineEndOffset= lineOffset + lineLength;
-
- int delta= lineEndOffset - st.getCharCount();
- if (delta > 0) {
- lineEndOffset -= delta;
- lineLength -= delta;
- }
-
- String line= ""; //$NON-NLS-1$
- if (lineLength > 0)
- line= st.getText(lineOffset, lineEndOffset - 1);
- int i= lineLength - 1;
- while (i > -1 && Character.isWhitespace(line.charAt(i))) {
- i--;
- }
- i++;
-
- // Remember current selection
- Point oldSelection= st.getSelection();
-
- // Compute new caret position
- int newCaretOffset= -1;
-
- if (isSmartHomeEndEnabled) {
-
- if (caretOffset - lineOffset == i)
- // to end of line
- newCaretOffset= lineEndOffset;
- else
- // to end of text
- newCaretOffset= lineOffset + i;
-
- } else {
-
- if (caretOffset < lineEndOffset)
- // to end of line
- newCaretOffset= lineEndOffset;
-
- }
-
- if (newCaretOffset == -1)
- newCaretOffset= caretOffset;
- else
- st.setCaretOffset(newCaretOffset);
-
- st.setCaretOffset(newCaretOffset);
- if (fDoSelect) {
- if (caretOffset < oldSelection.y)
- st.setSelection(oldSelection.y, newCaretOffset);
- else
- st.setSelection(oldSelection.x, newCaretOffset);
- } else
- st.setSelection(newCaretOffset);
-
- fireSelectionChanged(oldSelection);
- }
- }
-
- /**
- * This action implements smart home.
- * Instead of going to the start of a line it does the following:
- * - if smart home/end is enabled and the caret is after the line's first non-whitespace then the caret is moved directly before it
- * - if the caret is before the line's first non-whitespace the caret is moved to the beginning of the line
- * - if the caret is at the beginning of the line the caret is moved directly before the line's first non-whitespace character
- * @since 2.1
- */
- protected class LineStartAction extends TextNavigationAction {
-
- /** boolean flag which tells if the text up to the beginning of the line should be selected. */
- private final boolean fDoSelect;
-
- /**
- * Creates a new line start action.
- *
- * @param textWidget the styled text widget
- * @param doSelect a boolean flag which tells if the text up to the beginning of the line should be selected
- */
- public LineStartAction(final StyledText textWidget, final boolean doSelect) {
- super(textWidget, ST.LINE_START);
- fDoSelect= doSelect;
- }
-
- /**
- * Computes the offset of the line start position.
- *
- * @param document The document where to compute the line start position
- * @param line The line to determine the start position of
- * @param length The length of the line
- * @param offset The caret position in the document
- * @return The offset of the line start
- * @since 3.0
- */
- protected int getLineStartPosition(final IDocument document, final String line, final int length, final int offset) {
- int index= 0;
- while (index < length && Character.isWhitespace(line.charAt(index)))
- index++;
- return index;
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- boolean isSmartHomeEndEnabled= false;
- IPreferenceStore store= getPreferenceStore();
- if (store != null)
- isSmartHomeEndEnabled= store.getBoolean(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END);
-
- StyledText st= getSourceViewer().getTextWidget();
- if (st == null || st.isDisposed())
- return;
-
- int caretOffset= st.getCaretOffset();
- int lineNumber= st.getLineAtOffset(caretOffset);
- int lineOffset= st.getOffsetAtLine(lineNumber);
-
- int lineLength;
- int caretOffsetInDocument;
- final IDocument document= getSourceViewer().getDocument();
-
- try {
- caretOffsetInDocument= widgetOffset2ModelOffset(getSourceViewer(), caretOffset);
- lineLength= document.getLineInformationOfOffset(caretOffsetInDocument).getLength();
- } catch (BadLocationException ex) {
- return;
- }
-
- String line= ""; //$NON-NLS-1$
- if (lineLength > 0) {
- int end= lineOffset + lineLength - 1;
- end= Math.min(end, st.getCharCount() -1);
- line= st.getText(lineOffset, end);
- }
-
- // Compute the line start offset
- int index= getLineStartPosition(document, line, lineLength, caretOffsetInDocument);
-
- // Remember current selection
- Point oldSelection= st.getSelection();
-
- // Compute new caret position
- int newCaretOffset= -1;
- if (isSmartHomeEndEnabled) {
-
- if (caretOffset - lineOffset == index)
- // to beginning of line
- newCaretOffset= lineOffset;
- else
- // to beginning of text
- newCaretOffset= lineOffset + index;
-
- } else {
-
- if (caretOffset > lineOffset)
- // to beginning of line
- newCaretOffset= lineOffset;
- }
-
- if (newCaretOffset == -1)
- newCaretOffset= caretOffset;
- else
- st.setCaretOffset(newCaretOffset);
-
- if (fDoSelect) {
- if (caretOffset < oldSelection.y)
- st.setSelection(oldSelection.y, newCaretOffset);
- else
- st.setSelection(oldSelection.x, newCaretOffset);
- } else
- st.setSelection(newCaretOffset);
-
- fireSelectionChanged(oldSelection);
- }
-
- }
-
- /**
- * Internal action to show the editor's ruler context menu (accessibility).
- * @since 2.0
- */
- class ShowRulerContextMenuAction extends Action {
- /*
- * @see IAction#run()
- */
- public void run() {
- if (fSourceViewer == null)
- return;
-
- StyledText text= fSourceViewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
- Point location= text.getLocationAtOffset(text.getCaretOffset());
- location.x= 0;
-
- if (fVerticalRuler instanceof IVerticalRulerExtension)
- ((IVerticalRulerExtension) fVerticalRuler).setLocationOfLastMouseButtonActivity(location.x, location.y);
-
- location= text.toDisplay(location);
- fRulerContextMenu.setLocation(location.x, location.y);
- fRulerContextMenu.setVisible(true);
- }
- }
-
-
- /**
- * Editor specific selection provider which wraps the source viewer's selection provider.
- * @since 2.1
- */
- class SelectionProvider implements IPostSelectionProvider, ISelectionValidator {
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(ISelectionChangedListener)
- */
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- if (fSourceViewer != null)
- fSourceViewer.getSelectionProvider().addSelectionChangedListener(listener);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
- */
- public ISelection getSelection() {
- return doGetSelection();
- }
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(ISelectionChangedListener)
- */
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- if (fSourceViewer != null)
- fSourceViewer.getSelectionProvider().removeSelectionChangedListener(listener);
- }
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(ISelection)
- */
- public void setSelection(ISelection selection) {
- doSetSelection(selection);
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#addPostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- * @since 3.0
- */
- public void addPostSelectionChangedListener(ISelectionChangedListener listener) {
- if (fSourceViewer != null) {
- if (fSourceViewer.getSelectionProvider() instanceof IPostSelectionProvider) {
- IPostSelectionProvider provider= (IPostSelectionProvider) fSourceViewer.getSelectionProvider();
- provider.addPostSelectionChangedListener(listener);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionProvider#removePostSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
- * @since 3.0
- */
- public void removePostSelectionChangedListener(ISelectionChangedListener listener) {
- if (fSourceViewer != null) {
- if (fSourceViewer.getSelectionProvider() instanceof IPostSelectionProvider) {
- IPostSelectionProvider provider= (IPostSelectionProvider) fSourceViewer.getSelectionProvider();
- provider.removePostSelectionChangedListener(listener);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IPostSelectionValidator#isValid()
- * @since 3.0
- */
- public boolean isValid(ISelection postSelection) {
- return fSelectionListener != null && fSelectionListener.isValid(postSelection);
- }
- }
-
- /**
- * Internal implementation class for a change listener.
- * @since 3.0
- */
- protected abstract class AbstractSelectionChangedListener implements ISelectionChangedListener {
-
- /**
- * Installs this selection changed listener with the given selection provider. If
- * the selection provider is a post selection provider, post selection changed
- * events are the preferred choice, otherwise normal selection changed events
- * are requested.
- *
- * @param selectionProvider
- */
- public void install(ISelectionProvider selectionProvider) {
- if (selectionProvider == null)
- return;
-
- if (selectionProvider instanceof IPostSelectionProvider) {
- IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider;
- provider.addPostSelectionChangedListener(this);
- } else {
- selectionProvider.addSelectionChangedListener(this);
- }
- }
-
- /**
- * Removes this selection changed listener from the given selection provider.
- *
- * @param selectionProvider the selection provider
- */
- public void uninstall(ISelectionProvider selectionProvider) {
- if (selectionProvider == null)
- return;
-
- if (selectionProvider instanceof IPostSelectionProvider) {
- IPostSelectionProvider provider= (IPostSelectionProvider) selectionProvider;
- provider.removePostSelectionChangedListener(this);
- } else {
- selectionProvider.removeSelectionChangedListener(this);
- }
- }
- }
-
- /**
- * This selection listener allows the SelectionProvider to implement {@link ISelectionValidator}.
- *
- * @since 3.0
- */
- private class SelectionListener extends AbstractSelectionChangedListener implements IDocumentListener {
-
- private IDocument fDocument;
- private final Object INVALID_SELECTION= new Object();
- private Object fPostSelection= INVALID_SELECTION;
-
- /*
- * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public synchronized void selectionChanged(SelectionChangedEvent event) {
- fPostSelection= event.getSelection();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- * @since 3.0
- */
- public synchronized void documentAboutToBeChanged(DocumentEvent event) {
- fPostSelection= INVALID_SELECTION;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- * @since 3.0
- */
- public void documentChanged(DocumentEvent event) {
- }
-
- public synchronized boolean isValid(ISelection selection) {
- return fPostSelection != INVALID_SELECTION && fPostSelection == selection;
- }
-
- public void setDocument(IDocument document) {
- if (fDocument != null)
- fDocument.removeDocumentListener(this);
-
- fDocument= document;
- if (fDocument != null)
- fDocument.addDocumentListener(this);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor.AbstractSelectionChangedListener#install(org.eclipse.jface.viewers.ISelectionProvider)
- * @since 3.0
- */
- public void install(ISelectionProvider selectionProvider) {
- super.install(selectionProvider);
-
- if (selectionProvider != null)
- selectionProvider.addSelectionChangedListener(this);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.AbstractTextEditor.AbstractSelectionChangedListener#uninstall(org.eclipse.jface.viewers.ISelectionProvider)
- * @since 3.0
- */
- public void uninstall(ISelectionProvider selectionProvider) {
- if (selectionProvider != null)
- selectionProvider.removeSelectionChangedListener(this);
-
- if (fDocument != null) {
- fDocument.removeDocumentListener(this);
- fDocument= null;
- }
- super.uninstall(selectionProvider);
- }
- }
-
-
- /**
- * Key used to look up font preference.
- * Value: <code>"org.eclipse.jface.textfont"</code>
- *
- * @deprecated As of 2.1, replaced by {@link JFaceResources#TEXT_FONT}
- */
- public final static String PREFERENCE_FONT= JFaceResources.TEXT_FONT;
- /**
- * Key used to look up foreground color preference.
- * Value: <code>AbstractTextEditor.Color.Foreground</code>
- * @since 2.0
- */
- public final static String PREFERENCE_COLOR_FOREGROUND= "AbstractTextEditor.Color.Foreground"; //$NON-NLS-1$
- /**
- * Key used to look up background color preference.
- * Value: <code>AbstractTextEditor.Color.Background</code>
- * @since 2.0
- */
- public final static String PREFERENCE_COLOR_BACKGROUND= "AbstractTextEditor.Color.Background"; //$NON-NLS-1$
- /**
- * Key used to look up foreground color system default preference.
- * Value: <code>AbstractTextEditor.Color.Foreground.SystemDefault</code>
- * @since 2.0
- */
- public final static String PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.Foreground.SystemDefault"; //$NON-NLS-1$
- /**
- * Key used to look up background color system default preference.
- * Value: <code>AbstractTextEditor.Color.Background.SystemDefault</code>
- * @since 2.0
- */
- public final static String PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.Background.SystemDefault"; //$NON-NLS-1$
- /**
- * Key used to look up selection foreground color preference.
- * Value: <code>AbstractTextEditor.Color.SelectionForeground</code>
- * @since 3.0
- */
- public final static String PREFERENCE_COLOR_SELECTION_FOREGROUND= "AbstractTextEditor.Color.SelectionForeground"; //$NON-NLS-1$
- /**
- * Key used to look up selection background color preference.
- * Value: <code>AbstractTextEditor.Color.SelectionBackground</code>
- * @since 3.0
- */
- public final static String PREFERENCE_COLOR_SELECTION_BACKGROUND= "AbstractTextEditor.Color.SelectionBackground"; //$NON-NLS-1$
- /**
- * Key used to look up selection foreground color system default preference.
- * Value: <code>AbstractTextEditor.Color.SelectionForeground.SystemDefault</code>
- * @since 3.0
- */
- public final static String PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.SelectionForeground.SystemDefault"; //$NON-NLS-1$
- /**
- * Key used to look up selection background color system default preference.
- * Value: <code>AbstractTextEditor.Color.SelectionBackground.SystemDefault</code>
- * @since 3.0
- */
- public final static String PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT= "AbstractTextEditor.Color.SelectionBackground.SystemDefault"; //$NON-NLS-1$
- /**
- * Key used to look up find scope background color preference.
- * Value: <code>AbstractTextEditor.Color.FindScope</code>
- * @since 2.0
- */
- public final static String PREFERENCE_COLOR_FIND_SCOPE= "AbstractTextEditor.Color.FindScope"; //$NON-NLS-1$
- /**
- * Key used to look up smart home/end preference.
- * Value: <code>AbstractTextEditor.Navigation.SmartHomeEnd</code>
- * @since 2.1
- */
- public final static String PREFERENCE_NAVIGATION_SMART_HOME_END= "AbstractTextEditor.Navigation.SmartHomeEnd"; //$NON-NLS-1$
- /**
- * Key used to look up the custom caret preference.
- * Value: {@value}
- * @since 3.0
- */
- public final static String PREFERENCE_USE_CUSTOM_CARETS= "AbstractTextEditor.Accessibility.UseCustomCarets"; //$NON-NLS-1$
- /**
- * Key used to look up the caret width preference.
- * Value: {@value}
- * @since 3.0
- */
- public final static String PREFERENCE_WIDE_CARET= "AbstractTextEditor.Accessibility.WideCaret"; //$NON-NLS-1$
-
-
- /** Menu id for the editor context menu. */
- public final static String DEFAULT_EDITOR_CONTEXT_MENU_ID= "#EditorContext"; //$NON-NLS-1$
- /** Menu id for the ruler context menu. */
- public final static String DEFAULT_RULER_CONTEXT_MENU_ID= "#RulerContext"; //$NON-NLS-1$
-
- /** The width of the vertical ruler. */
- protected final static int VERTICAL_RULER_WIDTH= 12;
-
- /**
- * The complete mapping between action definition IDs used by eclipse and StyledText actions.
- *
- * @since 2.0
- */
- protected final static IdMapEntry[] ACTION_MAP= new IdMapEntry[] {
- // navigation
- new IdMapEntry(ITextEditorActionDefinitionIds.LINE_UP, ST.LINE_UP),
- new IdMapEntry(ITextEditorActionDefinitionIds.LINE_DOWN, ST.LINE_DOWN),
- new IdMapEntry(ITextEditorActionDefinitionIds.LINE_START, ST.LINE_START),
- new IdMapEntry(ITextEditorActionDefinitionIds.LINE_END, ST.LINE_END),
- new IdMapEntry(ITextEditorActionDefinitionIds.COLUMN_PREVIOUS, ST.COLUMN_PREVIOUS),
- new IdMapEntry(ITextEditorActionDefinitionIds.COLUMN_NEXT, ST.COLUMN_NEXT),
- new IdMapEntry(ITextEditorActionDefinitionIds.PAGE_UP, ST.PAGE_UP),
- new IdMapEntry(ITextEditorActionDefinitionIds.PAGE_DOWN, ST.PAGE_DOWN),
- new IdMapEntry(ITextEditorActionDefinitionIds.WORD_PREVIOUS, ST.WORD_PREVIOUS),
- new IdMapEntry(ITextEditorActionDefinitionIds.WORD_NEXT, ST.WORD_NEXT),
- new IdMapEntry(ITextEditorActionDefinitionIds.TEXT_START, ST.TEXT_START),
- new IdMapEntry(ITextEditorActionDefinitionIds.TEXT_END, ST.TEXT_END),
- new IdMapEntry(ITextEditorActionDefinitionIds.WINDOW_START, ST.WINDOW_START),
- new IdMapEntry(ITextEditorActionDefinitionIds.WINDOW_END, ST.WINDOW_END),
- // selection
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_UP, ST.SELECT_LINE_UP),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_DOWN, ST.SELECT_LINE_DOWN),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_START, ST.SELECT_LINE_START),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_LINE_END, ST.SELECT_LINE_END),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_COLUMN_PREVIOUS, ST.SELECT_COLUMN_PREVIOUS),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_COLUMN_NEXT, ST.SELECT_COLUMN_NEXT),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_PAGE_UP, ST.SELECT_PAGE_UP),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_PAGE_DOWN, ST.SELECT_PAGE_DOWN),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WORD_PREVIOUS, ST.SELECT_WORD_PREVIOUS),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WORD_NEXT, ST.SELECT_WORD_NEXT),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_TEXT_START, ST.SELECT_TEXT_START),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_TEXT_END, ST.SELECT_TEXT_END),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WINDOW_START, ST.SELECT_WINDOW_START),
- new IdMapEntry(ITextEditorActionDefinitionIds.SELECT_WINDOW_END, ST.SELECT_WINDOW_END),
- // modification
- new IdMapEntry(ITextEditorActionDefinitionIds.CUT, ST.CUT),
- new IdMapEntry(ITextEditorActionDefinitionIds.COPY, ST.COPY),
- new IdMapEntry(ITextEditorActionDefinitionIds.PASTE, ST.PASTE),
- new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_PREVIOUS, ST.DELETE_PREVIOUS),
- new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_NEXT, ST.DELETE_NEXT),
- new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_PREVIOUS_WORD, ST.DELETE_WORD_PREVIOUS),
- new IdMapEntry(ITextEditorActionDefinitionIds.DELETE_NEXT_WORD, ST.DELETE_WORD_NEXT),
- // miscellaneous
- new IdMapEntry(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, ST.TOGGLE_OVERWRITE)
- };
-
- private final String fReadOnlyLabel = EditorMessages.getString("Editor.statusline.state.readonly.label"); //$NON-NLS-1$
- private final String fWritableLabel = EditorMessages.getString("Editor.statusline.state.writable.label"); //$NON-NLS-1$
- private final String fInsertModeLabel = EditorMessages.getString("Editor.statusline.mode.insert.label"); //$NON-NLS-1$
- private final String fOverwriteModeLabel = EditorMessages.getString("Editor.statusline.mode.overwrite.label"); //$NON-NLS-1$
- private final String fSmartInsertModeLabel= EditorMessages.getString("Editor.statusline.mode.smartinsert.label"); //$NON-NLS-1$
-
- /** The error message shown in the status line in case of failed information look up. */
- protected final String fErrorLabel= EditorMessages.getString("Editor.statusline.error.label"); //$NON-NLS-1$
-
- /**
- * Data structure for the position label value.
- */
- private static class PositionLabelValue {
-
- public int fValue;
-
- public String toString() {
- return String.valueOf(fValue);
- }
- }
- /** The pattern used to show the position label in the status line. */
- private final String fPositionLabelPattern= EditorMessages.getString("Editor.statusline.position.pattern"); //$NON-NLS-1$
- /** The position label value of the current line. */
- private final PositionLabelValue fLineLabel= new PositionLabelValue();
- /** The position label value of the current column. */
- private final PositionLabelValue fColumnLabel= new PositionLabelValue();
- /** The arguments for the position label pattern. */
- private final Object[] fPositionLabelPatternArguments= new Object[] { fLineLabel, fColumnLabel };
-
-
-
-
-
- /** The editor's explicit document provider. */
- private IDocumentProvider fExplicitDocumentProvider;
- /** The editor's preference store. */
- private IPreferenceStore fPreferenceStore;
- /** The editor's range indicator. */
- private Annotation fRangeIndicator;
- /** The editor's source viewer configuration. */
- private SourceViewerConfiguration fConfiguration;
- /** The editor's source viewer. */
- private ISourceViewer fSourceViewer;
- /**
- * The editor's selection provider.
- * @since 2.1
- */
- private SelectionProvider fSelectionProvider= new SelectionProvider();
- /**
- * The editor's selection listener.
- * @since 3.0
- */
- private SelectionListener fSelectionListener;
- /** The editor's font. */
- private Font fFont; /**
- * The editor's foreground color.
- * @since 2.0
- */
- private Color fForegroundColor;
- /**
- * The editor's background color.
- * @since 2.0
- */
- private Color fBackgroundColor;
- /**
- * The editor's selection foreground color.
- * @since 3.0
- */
- private Color fSelectionForegroundColor;
- /**
- * The editor's selection background color.
- * @since 3.0
- */
- private Color fSelectionBackgroundColor;
- /**
- * The find scope's highlight color.
- * @since 2.0
- */
- private Color fFindScopeHighlightColor;
-
- /**
- * The editor's status line.
- * @since 2.1
- */
- private IEditorStatusLine fEditorStatusLine;
- /** The editor's vertical ruler. */
- private IVerticalRuler fVerticalRuler;
- /** The editor's context menu id. */
- private String fEditorContextMenuId;
- /** The ruler's context menu id. */
- private String fRulerContextMenuId;
- /** The editor's help context id. */
- private String fHelpContextId;
- /** The editor's presentation mode. */
- private boolean fShowHighlightRangeOnly;
- /** The actions registered with the editor. */
- private Map fActions= new HashMap(10);
- /** The actions marked as selection dependent. */
- private List fSelectionActions= new ArrayList(5);
- /** The actions marked as content dependent. */
- private List fContentActions= new ArrayList(5);
- /**
- * The actions marked as property dependent.
- * @since 2.0
- */
- private List fPropertyActions= new ArrayList(5);
- /**
- * The actions marked as state dependent.
- * @since 2.0
- */
- private List fStateActions= new ArrayList(5);
- /** The editor's action activation codes. */
- private List fActivationCodes= new ArrayList(2);
- /** The verify key listener for activation code triggering. */
- private ActivationCodeTrigger fActivationCodeTrigger= new ActivationCodeTrigger();
- /** Context menu listener. */
- private IMenuListener fMenuListener;
- /** Vertical ruler mouse listener. */
- private MouseListener fMouseListener;
- /** Selection changed listener. */
- private ISelectionChangedListener fSelectionChangedListener;
- /** Title image to be disposed. */
- private Image fTitleImage;
- /** The text context menu to be disposed. */
- private Menu fTextContextMenu;
- /** The ruler context menu to be disposed. */
- private Menu fRulerContextMenu;
- /** The editor's element state listener. */
- private IElementStateListener fElementStateListener= new ElementStateListener();
- /**
- * The editor's text input listener.
- * @since 2.1
- */
- private TextInputListener fTextInputListener= new TextInputListener();
- /** The editor's text listener. */
- private TextListener fTextListener= new TextListener();
- /** The editor's property change listener. */
- private IPropertyChangeListener fPropertyChangeListener= new PropertyChangeListener();
- /**
- * The editor's font properties change listener.
- * @since 2.1
- */
- private IPropertyChangeListener fFontPropertyChangeListener= new FontPropertyChangeListener();
-
- /**
- * The editor's activation listener.
- * @since 2.0
- */
- private ActivationListener fActivationListener= new ActivationListener();
- /**
- * The map of the editor's status fields.
- * @since 2.0
- */
- private Map fStatusFields;
- /**
- * The editor's cursor listener.
- * @since 2.0
- */
- private ICursorListener fCursorListener;
- /**
- * The editor's remembered text selection.
- * @since 2.0
- */
- private ISelection fRememberedSelection;
- /**
- * Indicates whether the editor runs in 1.0 context menu registration compatibility mode.
- * @since 2.0
- */
- private boolean fCompatibilityMode= true;
- /**
- * The number of reentrances into error correction code while saving.
- * @since 2.0
- */
- private int fErrorCorrectionOnSave;
- /**
- * The delete line target.
- * @since 2.1
- */
- private DeleteLineTarget fDeleteLineTarget;
- /**
- * The incremental find target.
- * @since 2.0
- */
- private IncrementalFindTarget fIncrementalFindTarget;
- /**
- * The mark region target.
- * @since 2.0
- */
- private IMarkRegionTarget fMarkRegionTarget;
- /**
- * Cached modification stamp of the editor's input.
- * @since 2.0
- */
- private long fModificationStamp= -1;
- /**
- * Ruler context menu listeners.
- * @since 2.0
- */
- private List fRulerContextMenuListeners= new ArrayList();
- /**
- * Indicates whether sanity checking in enabled.
- * @since 2.0
- */
- private boolean fIsSanityCheckEnabled= true;
- /**
- * The find replace target.
- * @since 2.1
- */
- private FindReplaceTarget fFindReplaceTarget;
- /**
- * Indicates whether state validation is enabled.
- * @since 2.1
- */
- private boolean fIsStateValidationEnabled= true;
- /**
- * The key binding scopes of this editor.
- * @since 2.1
- */
- private String[] fKeyBindingScopes;
- /**
- * Whether the overwrite mode can be turned on.
- * @since 3.0
- */
- private boolean fIsOverwriteModeEnabled= true;
- /**
- * Whether the overwrite mode is currently on.
- * @since 3.0
- */
- private boolean fIsOverwriting= false;
- /**
- * The editor's insert mode.
- * @since 3.0
- */
- private InsertMode fInsertMode= SMART_INSERT;
- /**
- * The sequence of legal editor insert modes.
- * @since 3.0
- */
- private List fLegalInsertModes= null;
- /**
- * The non-default caret.
- * @since 3.0
- */
- private Caret fNonDefaultCaret;
- /**
- * The image used in non-default caret.
- * @since 3.0
- */
- private Image fNonDefaultCaretImage;
- /**
- * The styled text's initial caret.
- * @since 3.0
- */
- private Caret fInitialCaret;
-
- /**
- * Creates a new text editor. If not explicitly set, this editor uses
- * a <code>SourceViewerConfiguration</code> to configure its
- * source viewer. This viewer does not have a range indicator installed,
- * nor any menu id set. By default, the created editor runs in 1.0 context
- * menu registration compatibility mode.
- */
- protected AbstractTextEditor() {
- super();
- fEditorContextMenuId= null;
- fRulerContextMenuId= null;
- fHelpContextId= null;
- }
-
- /*
- * @see ITextEditor#getDocumentProvider()
- */
- public IDocumentProvider getDocumentProvider() {
- return fExplicitDocumentProvider;
- }
-
- /**
- * Returns the editor's range indicator. May return <code>null</code> if no
- * range indicator is installed.
- *
- * @return the editor's range indicator which may be <code>null</code>
- */
- protected final Annotation getRangeIndicator() {
- return fRangeIndicator;
- }
-
- /**
- * Returns the editor's source viewer configuration. May return <code>null</code>
- * before the editor's part has been created and after disposal.
- *
- * @return the editor's source viewer configuration which may be <code>null</code>
- */
- protected final SourceViewerConfiguration getSourceViewerConfiguration() {
- return fConfiguration;
- }
-
- /**
- * Returns the editor's source viewer. May return <code>null</code> before
- * the editor's part has been created and after disposal.
- *
- * @return the editor's source viewer which may be <code>null</code>
- */
- protected final ISourceViewer getSourceViewer() {
- return fSourceViewer;
- }
-
- /**
- * Returns the editor's vertical ruler. May return <code>null</code> before
- * the editor's part has been created and after disposal.
- *
- * @return the editor's vertical ruler which may be <code>null</code>
- */
- protected final IVerticalRuler getVerticalRuler() {
- return fVerticalRuler;
- }
-
- /**
- * Returns the editor's context menu id. May return <code>null</code> before
- * the editor's part has been created.
- *
- * @return the editor's context menu id which may be <code>null</code>
- */
- protected final String getEditorContextMenuId() {
- return fEditorContextMenuId;
- }
-
- /**
- * Returns the ruler's context menu id. May return <code>null</code> before
- * the editor's part has been created.
- *
- * @return the ruler's context menu id which may be <code>null</code>
- */
- protected final String getRulerContextMenuId() {
- return fRulerContextMenuId;
- }
-
- /**
- * Returns the editor's help context id or <code>null</code> if none has
- * been set.
- *
- * @return the editor's help context id which may be <code>null</code>
- */
- protected final String getHelpContextId() {
- return fHelpContextId;
- }
-
- /**
- * Returns this editor's preference store or <code>null</code> if none has
- * been set.
- *
- * @return this editor's preference store which may be <code>null</code>
- */
- protected final IPreferenceStore getPreferenceStore() {
- return fPreferenceStore;
- }
-
- /**
- * Sets this editor's document provider. This method must be
- * called before the editor's control is created.
- *
- * @param provider the document provider
- */
- protected void setDocumentProvider(IDocumentProvider provider) {
- Assert.isNotNull(provider);
- fExplicitDocumentProvider= provider;
- }
-
- /**
- * Sets this editor's source viewer configuration used to configure its
- * internal source viewer. This method must be called before the editor's
- * control is created. If not, this editor uses a <code>SourceViewerConfiguration</code>.
- *
- * @param configuration the source viewer configuration object
- */
- protected void setSourceViewerConfiguration(SourceViewerConfiguration configuration) {
- Assert.isNotNull(configuration);
- fConfiguration= configuration;
- }
-
- /**
- * Sets the annotation which this editor uses to represent the highlight
- * range if the editor is configured to show the entire document. If the
- * range indicator is not set, this editor will not show a range indication.
- *
- * @param rangeIndicator the annotation
- */
- protected void setRangeIndicator(Annotation rangeIndicator) {
- Assert.isNotNull(rangeIndicator);
- fRangeIndicator= rangeIndicator;
- }
-
- /**
- * Sets this editor's context menu id.
- *
- * @param contextMenuId the context menu id
- */
- protected void setEditorContextMenuId(String contextMenuId) {
- Assert.isNotNull(contextMenuId);
- fEditorContextMenuId= contextMenuId;
- }
-
- /**
- * Sets the ruler's context menu id.
- *
- * @param contextMenuId the context menu id
- */
- protected void setRulerContextMenuId(String contextMenuId) {
- Assert.isNotNull(contextMenuId);
- fRulerContextMenuId= contextMenuId;
- }
-
- /**
- * Sets the context menu registration 1.0 compatibility mode. (See class
- * description for more details.)
- *
- * @param compatible <code>true</code> if compatibility mode is enabled
- * @since 2.0
- */
- protected final void setCompatibilityMode(boolean compatible) {
- fCompatibilityMode= compatible;
- }
-
- /**
- * Sets the editor's help context id.
- *
- * @param helpContextId the help context id
- */
- protected void setHelpContextId(String helpContextId) {
- Assert.isNotNull(helpContextId);
- fHelpContextId= helpContextId;
- }
-
- /**
- * Sets the keybinding scopes for this editor.
- *
- * @param scopes a non-empty array of keybinding scope identifiers
- * @since 2.1
- */
- protected void setKeyBindingScopes(String[] scopes) {
- Assert.isTrue(scopes != null && scopes.length > 0);
- fKeyBindingScopes= scopes;
- }
-
- /**
- * Sets this editor's preference store. This method must be
- * called before the editor's control is created.
- *
- * @param store the preference store or <code>null</code> to unset the
- * preference store
- */
- protected void setPreferenceStore(IPreferenceStore store) {
- if (fPreferenceStore != null)
- fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener);
-
- fPreferenceStore= store;
-
- if (fPreferenceStore != null)
- fPreferenceStore.addPropertyChangeListener(fPropertyChangeListener);
- }
-
- /*
- * @see ITextEditor#isEditable()
- */
- public boolean isEditable() {
- IDocumentProvider provider= getDocumentProvider();
- if (provider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
- return extension.isModifiable(getEditorInput());
- }
- return false;
- }
-
- /**
- * {@inheritDoc}
- * <p>
- * Returns <code>null</code> after disposal.
- * </p>
- *
- * @return the selection provider or <code>null</code> if the editor has
- * been disposed
- */
- public ISelectionProvider getSelectionProvider() {
- return fSelectionProvider;
- }
-
- /**
- * Remembers the current selection of this editor. This method is called when, e.g.,
- * the content of the editor is about to be reverted to the saved state. This method
- * remembers the selection in a semantic format, i.e., in a format which allows to
- * restore the selection even if the originally selected text is no longer part of the
- * editor's content.
- * <p>
- * Subclasses should implement this method including all necessary state. This
- * default implementation remembers the textual range only and is thus purely
- * syntactic.</p>
- *
- * @see #restoreSelection()
- * @since 2.0
- */
- protected void rememberSelection() {
- fRememberedSelection= doGetSelection();
- }
-
- /**
- * Returns the current selection.
- * @return ISelection
- * @since 2.1
- */
- protected ISelection doGetSelection() {
- ISelectionProvider sp= null;
- if (fSourceViewer != null)
- sp= fSourceViewer.getSelectionProvider();
- return (sp == null ? null : sp.getSelection());
- }
-
- /**
- * Restores a selection previously remembered by <code>rememberSelection</code>.
- * Subclasses may reimplement this method and thereby semantically adapt the
- * remembered selection. This default implementation just selects the
- * remembered textual range.
- *
- * @see #rememberSelection()
- * @since 2.0
- */
- protected void restoreSelection() {
- if (fRememberedSelection instanceof ITextSelection) {
- ITextSelection textSelection= (ITextSelection)fRememberedSelection;
- if (isValidSelection(textSelection.getOffset(), textSelection.getLength()))
- doSetSelection(fRememberedSelection);
- }
- fRememberedSelection= null;
- }
-
- /**
- * Tells whether the given selection is valid.
- *
- * @param offset the offset of the selection
- * @param length the length of the selection
- * @return <code>true</code> if the selection is valid
- * @since 2.1
- */
- private boolean isValidSelection(int offset, int length) {
- IDocumentProvider provider= getDocumentProvider();
- if (provider != null) {
- IDocument document= provider.getDocument(getEditorInput());
- if (document != null) {
- int end= offset + length;
- int documentLength= document.getLength();
- return 0 <= offset && offset <= documentLength && 0 <= end && end <= documentLength;
- }
- }
- return false;
- }
-
- /**
- * Sets the given selection.
- * @param selection
- * @since 2.1
- */
- protected void doSetSelection(ISelection selection) {
- if (selection instanceof ITextSelection) {
- ITextSelection textSelection= (ITextSelection) selection;
- selectAndReveal(textSelection.getOffset(), textSelection.getLength());
- }
- }
-
- /**
- * Creates and returns the listener on this editor's context menus.
- *
- * @return the menu listener
- */
- protected final IMenuListener getContextMenuListener() {
- if (fMenuListener == null) {
- fMenuListener= new IMenuListener() {
-
- public void menuAboutToShow(IMenuManager menu) {
- String id= menu.getId();
- if (getRulerContextMenuId().equals(id)) {
- setFocus();
- rulerContextMenuAboutToShow(menu);
- } else if (getEditorContextMenuId().equals(id)) {
- setFocus();
- editorContextMenuAboutToShow(menu);
- }
- }
- };
- }
- return fMenuListener;
- }
-
- /**
- * Creates and returns the listener on this editor's vertical ruler.
- *
- * @return the mouse listener
- */
- protected final MouseListener getRulerMouseListener() {
- if (fMouseListener == null) {
- fMouseListener= new MouseListener() {
-
- private boolean fDoubleClicked= false;
-
- private void triggerAction(String actionID) {
- IAction action= getAction(actionID);
- if (action != null) {
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
- if (action.isEnabled())
- action.run();
- }
- }
-
- public void mouseUp(MouseEvent e) {
- setFocus();
- if (1 == e.button && !fDoubleClicked)
- triggerAction(ITextEditorActionConstants.RULER_CLICK);
- fDoubleClicked= false;
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- if (1 == e.button) {
- fDoubleClicked= true;
- triggerAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK);
- }
- }
-
- public void mouseDown(MouseEvent e) {
- StyledText text= fSourceViewer.getTextWidget();
- if (text != null && !text.isDisposed()) {
- Display display= text.getDisplay();
- Point location= display.getCursorLocation();
- fRulerContextMenu.setLocation(location.x, location.y);
- }
- }
- };
- }
- return fMouseListener;
- }
-
- /**
- * Returns this editor's selection changed listener to be installed
- * on the editor's source viewer.
- *
- * @return the listener
- */
- protected final ISelectionChangedListener getSelectionChangedListener() {
- if (fSelectionChangedListener == null) {
- fSelectionChangedListener= new ISelectionChangedListener() {
-
- private Runnable fRunnable= new Runnable() {
- public void run() {
- // check whether editor has not been disposed yet
- if (fSourceViewer != null && fSourceViewer.getDocument() != null) {
- updateSelectionDependentActions();
- }
- }
- };
-
- private Display fDisplay;
-
- public void selectionChanged(SelectionChangedEvent event) {
- if (fDisplay == null)
- fDisplay= getSite().getShell().getDisplay();
- fDisplay.asyncExec(fRunnable);
- handleCursorPositionChanged();
- }
- };
- }
-
- return fSelectionChangedListener;
- }
-
- /**
- * Returns this editor's "cursor" listener to be installed on the editor's
- * source viewer. This listener is listening to key and mouse button events.
- * It triggers the updating of the status line by calling
- * <code>handleCursorPositionChanged()</code>.
- *
- * @return the listener
- * @since 2.0
- */
- protected final ICursorListener getCursorListener() {
- if (fCursorListener == null) {
- fCursorListener= new ICursorListener() {
-
- public void keyPressed(KeyEvent e) {
- handleCursorPositionChanged();
- }
-
- public void keyReleased(KeyEvent e) {
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- handleCursorPositionChanged();
- }
- };
- }
- return fCursorListener;
- }
-
- /**
- * Implements the <code>init</code> method of <code>IEditorPart</code>.
- * Subclasses replacing <code>init</code> may choose to call this method in
- * their implementation.
- *
- * @param window the site's workbench window
- * @param site the editor's site
- * @param input the editor input for the editor being created
- * @throws PartInitException if {@link #doSetInput(IEditorInput)} fails or gets canceled
- *
- * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
- * @since 2.1
- */
- protected final void internalInit(IWorkbenchWindow window, final IEditorSite site, final IEditorInput input) throws PartInitException {
-
- IRunnableWithProgress runnable= new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
- try {
-
- if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) getDocumentProvider();
- extension.setProgressMonitor(monitor);
- }
-
- doSetInput(input);
-
- } catch (CoreException x) {
- throw new InvocationTargetException(x);
- } finally {
- if (getDocumentProvider() instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) getDocumentProvider();
- extension.setProgressMonitor(null);
- }
- }
- }
- };
-
- try {
- window.run(false, true, runnable);
- } catch (InterruptedException x) {
- } catch (InvocationTargetException x) {
- Throwable t= x.getTargetException();
- if (t instanceof CoreException)
- throw new PartInitException(((CoreException) t).getStatus());
- throw new PartInitException(new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, EditorMessages.getString("Editor.error.init"), t)); //$NON-NLS-1$
- }
- }
-
- /*
- * @see IEditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
- */
- public void init(final IEditorSite site, final IEditorInput input) throws PartInitException {
-
- setSite(site);
-
- IWorkbenchWindow window= getSite().getWorkbenchWindow();
- internalInit(window, site, input);
-
- window.getPartService().addPartListener(fActivationListener);
- window.getShell().addShellListener(fActivationListener);
- }
-
- /**
- * Creates the vertical ruler to be used by this editor.
- * Subclasses may re-implement this method.
- *
- * @return the vertical ruler
- */
- protected IVerticalRuler createVerticalRuler() {
- return new VerticalRuler(VERTICAL_RULER_WIDTH);
- }
-
- /**
- * Creates the source viewer to be used by this editor.
- * Subclasses may re-implement this method.
- *
- * @param parent the parent control
- * @param ruler the vertical ruler
- * @param styles style bits, <code>SWT.WRAP</code> is currently not supported
- * @return the source viewer
- */
- protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) {
- return new SourceViewer(parent, ruler, styles);
- }
-
- /**
- * Initializes the drag and drop support for the given viewer based on
- * provided editor adapter for drop target listeners.
- *
- * @param viewer the viewer
- * @since 3.0
- */
- protected void initializeDragAndDrop(ISourceViewer viewer) {
- ITextEditorDropTargetListener listener= (ITextEditorDropTargetListener) getAdapter(ITextEditorDropTargetListener.class);
-
- if (listener == null) {
- Object object= Platform.getAdapterManager().loadAdapter(this, "org.eclipse.ui.texteditor.ITextEditorDropTargetListener"); //$NON-NLS-1$
- if (object instanceof ITextEditorDropTargetListener)
- listener= (ITextEditorDropTargetListener)object;
- }
-
- if (listener != null) {
- DropTarget dropTarget = new DropTarget(viewer.getTextWidget(), DND.DROP_COPY | DND.DROP_MOVE);
- dropTarget.setTransfer(listener.getTransfers());
- dropTarget.addDropListener(listener);
- }
- }
-
- /**
- * The <code>AbstractTextEditor</code> implementation of this
- * <code>IWorkbenchPart</code> method creates the vertical ruler and
- * source viewer.
- * <p>
- * Subclasses may extend this method. Besides extending this method, the
- * behavior of <code>createPartControl</code> may be customized by
- * calling, extending or replacing the following methods: <br>
- * Subclasses may supply customized implementations for some members using
- * the following methods before <code>createPartControl</code> is invoked:
- * <ul>
- * <li>
- * {@linkplain #setSourceViewerConfiguration(SourceViewerConfiguration) setSourceViewerConfiguration}
- * to supply a custom source viewer configuration,</li>
- * <li>{@linkplain #setRangeIndicator(Annotation) setRangeIndicator} to
- * provide a range indicator,</li>
- * <li>{@linkplain #setHelpContextId(String) setHelpContextId} to provide a
- * help context id,</li>
- * <li>{@linkplain #setEditorContextMenuId(String) setEditorContextMenuId}
- * to set a custom context menu id,</li>
- * <li>{@linkplain #setRulerContextMenuId(String) setRulerContextMenuId} to
- * set a custom ruler context menu id.</li>
- * </ul>
- * <br>
- * Subclasses may replace the following methods called from within
- * <code>createPartControl</code>:
- * <ul>
- * <li>{@linkplain #createVerticalRuler() createVerticalRuler} to supply a
- * custom vertical ruler,</li>
- * <li>{@linkplain #createSourceViewer(Composite, IVerticalRuler, int) createSourceViewer}
- * to supply a custom source viewer,</li>
- * <li>{@linkplain #getSelectionProvider() getSelectionProvider} to supply
- * a custom selection provider.</li>
- * </ul>
- * <br>
- * Subclasses may extend the following methods called from within
- * <code>createPartControl</code>:
- * <ul>
- * <li>
- * {@linkplain #initializeViewerColors(ISourceViewer) initializeViewerColors}
- * to customize the viewer color scheme (may also be replaced),</li>
- * <li>
- * {@linkplain #initializeDragAndDrop(ISourceViewer) initializeDragAndDrop}
- * to customize drag and drop (may also be replaced),</li>
- * <li>{@linkplain #createNavigationActions() createNavigationActions} to
- * add navigation actions,</li>
- * <li>{@linkplain #createActions() createActions} to add text editor
- * actions.</li>
- * </ul>
- * </p>
- *
- * @param parent the parent composite
- */
- public void createPartControl(Composite parent) {
-
- fVerticalRuler= createVerticalRuler();
-
- int styles= SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION;
- fSourceViewer= createSourceViewer(parent, fVerticalRuler, styles);
-
- if (fConfiguration == null)
- fConfiguration= new SourceViewerConfiguration();
- fSourceViewer.configure(fConfiguration);
-
- if (fRangeIndicator != null)
- fSourceViewer.setRangeIndicator(fRangeIndicator);
-
- fSourceViewer.addTextListener(fTextListener);
- fSourceViewer.addTextInputListener(fTextListener);
- getSelectionProvider().addSelectionChangedListener(getSelectionChangedListener());
-
- initializeViewerFont(fSourceViewer);
- initializeViewerColors(fSourceViewer);
- initializeFindScopeColor(fSourceViewer);
- initializeDragAndDrop(fSourceViewer);
-
- StyledText styledText= fSourceViewer.getTextWidget();
-
- /* gestures commented out until proper solution (i.e. preference page) can be found
- * for bug # 28417:
- *
- final Map gestureMap = new HashMap();
-
- gestureMap.put("E", "org.eclipse.ui.navigate.forwardHistory");
- gestureMap.put("N", "org.eclipse.ui.file.save");
- gestureMap.put("NW", "org.eclipse.ui.file.saveAll");
- gestureMap.put("S", "org.eclipse.ui.file.close");
- gestureMap.put("SW", "org.eclipse.ui.file.closeAll");
- gestureMap.put("W", "org.eclipse.ui.navigate.backwardHistory");
- gestureMap.put("EN", "org.eclipse.ui.edit.copy");
- gestureMap.put("ES", "org.eclipse.ui.edit.paste");
- gestureMap.put("EW", "org.eclipse.ui.edit.cut");
-
- Capture capture = Capture.create();
- capture.setControl(styledText);
-
- capture.addCaptureListener(new CaptureListener() {
- public void gesture(Gesture gesture) {
- if (gesture.getPen() == 3) {
- String actionId = (String) gestureMap.get(Util.recognize(gesture.getPoints(), 20));
-
- if (actionId != null) {
- IKeyBindingService keyBindingService = getEditorSite().getKeyBindingService();
-
- if (keyBindingService instanceof KeyBindingService) {
- IAction action = ((KeyBindingService) keyBindingService).getAction(actionId);
-
- if (action != null) {
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
-
- if (action.isEnabled())
- action.run();
- }
- }
-
- return;
- }
-
- fTextContextMenu.setVisible(true);
- }
- };
- });
- */
-
- styledText.addMouseListener(getCursorListener());
- styledText.addKeyListener(getCursorListener());
-
- if (getHelpContextId() != null)
- WorkbenchHelp.setHelp(styledText, getHelpContextId());
-
-
- String id= fEditorContextMenuId != null ? fEditorContextMenuId : DEFAULT_EDITOR_CONTEXT_MENU_ID;
-
- MenuManager manager= new MenuManager(id, id);
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(getContextMenuListener());
- fTextContextMenu= manager.createContextMenu(styledText);
-
- // comment this line if using gestures, above.
- styledText.setMenu(fTextContextMenu);
-
- if (fEditorContextMenuId != null)
- getSite().registerContextMenu(fEditorContextMenuId, manager, getSelectionProvider());
- else if (fCompatibilityMode)
- getSite().registerContextMenu(DEFAULT_EDITOR_CONTEXT_MENU_ID, manager, getSelectionProvider());
-
- if ((fEditorContextMenuId != null && fCompatibilityMode) || fEditorContextMenuId == null) {
- String partId= getSite().getId();
- if (partId != null)
- getSite().registerContextMenu(partId + ".EditorContext", manager, getSelectionProvider()); //$NON-NLS-1$
- }
-
- if (fEditorContextMenuId == null)
- fEditorContextMenuId= DEFAULT_EDITOR_CONTEXT_MENU_ID;
-
-
- id= fRulerContextMenuId != null ? fRulerContextMenuId : DEFAULT_RULER_CONTEXT_MENU_ID;
- manager= new MenuManager(id, id);
- manager.setRemoveAllWhenShown(true);
- manager.addMenuListener(getContextMenuListener());
-
- Control rulerControl= fVerticalRuler.getControl();
- fRulerContextMenu= manager.createContextMenu(rulerControl);
- rulerControl.setMenu(fRulerContextMenu);
- rulerControl.addMouseListener(getRulerMouseListener());
-
- if (fRulerContextMenuId != null)
- getSite().registerContextMenu(fRulerContextMenuId, manager, getSelectionProvider());
- else if (fCompatibilityMode)
- getSite().registerContextMenu(DEFAULT_RULER_CONTEXT_MENU_ID, manager, getSelectionProvider());
-
- if ((fRulerContextMenuId != null && fCompatibilityMode) || fRulerContextMenuId == null) {
- String partId= getSite().getId();
- if (partId != null)
- getSite().registerContextMenu(partId + ".RulerContext", manager, getSelectionProvider()); //$NON-NLS-1$
- }
-
- if (fRulerContextMenuId == null)
- fRulerContextMenuId= DEFAULT_RULER_CONTEXT_MENU_ID;
-
- getSite().setSelectionProvider(getSelectionProvider());
-
- fSelectionListener= new SelectionListener();
- fSelectionListener.install(getSelectionProvider());
- fSelectionListener.setDocument(getDocumentProvider().getDocument(getEditorInput()));
-
- initializeActivationCodeTrigger();
-
- createNavigationActions();
- createAccessibilityActions();
- createActions();
-
- initializeSourceViewer(getEditorInput());
-
- JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener);
- }
-
- /**
- * Initializes the activation code trigger.
- *
- * @since 2.1
- */
- private void initializeActivationCodeTrigger() {
- fActivationCodeTrigger.install();
- fActivationCodeTrigger.setScopes(fKeyBindingScopes);
- }
-
- /**
- * Initializes the given viewer's font.
- *
- * @param viewer the viewer
- * @since 2.0
- */
- private void initializeViewerFont(ISourceViewer viewer) {
-
- boolean isSharedFont= true;
- Font font= null;
- String symbolicFontName= getSymbolicFontName();
-
- if (symbolicFontName != null)
- font= JFaceResources.getFont(symbolicFontName);
- else if (fPreferenceStore != null) {
- // Backward compatibility
- if (fPreferenceStore.contains(JFaceResources.TEXT_FONT) && !fPreferenceStore.isDefault(JFaceResources.TEXT_FONT)) {
- FontData data= PreferenceConverter.getFontData(fPreferenceStore, JFaceResources.TEXT_FONT);
-
- if (data != null) {
- isSharedFont= false;
- font= new Font(viewer.getTextWidget().getDisplay(), data);
- }
- }
- }
- if (font == null)
- font= JFaceResources.getTextFont();
-
- setFont(viewer, font);
-
- if (fFont != null) {
- fFont.dispose();
- fFont= null;
- }
-
- if (!isSharedFont)
- fFont= font;
- }
-
- /**
- * Sets the font for the given viewer sustaining selection and scroll position.
- *
- * @param sourceViewer the source viewer
- * @param font the font
- * @since 2.0
- */
- private void setFont(ISourceViewer sourceViewer, Font font) {
- if (sourceViewer.getDocument() != null) {
-
- Point selection= sourceViewer.getSelectedRange();
- int topIndex= sourceViewer.getTopIndex();
-
- StyledText styledText= sourceViewer.getTextWidget();
- Control parent= styledText;
- if (sourceViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) sourceViewer;
- parent= extension.getControl();
- }
-
- parent.setRedraw(false);
-
- styledText.setFont(font);
-
- if (fVerticalRuler instanceof IVerticalRulerExtension) {
- IVerticalRulerExtension e= (IVerticalRulerExtension) fVerticalRuler;
- e.setFont(font);
- }
-
- sourceViewer.setSelectedRange(selection.x , selection.y);
- sourceViewer.setTopIndex(topIndex);
-
- if (parent instanceof Composite) {
- Composite composite= (Composite) parent;
- composite.layout(true);
- }
-
- parent.setRedraw(true);
-
-
- } else {
-
- StyledText styledText= sourceViewer.getTextWidget();
- styledText.setFont(font);
-
- if (fVerticalRuler instanceof IVerticalRulerExtension) {
- IVerticalRulerExtension e= (IVerticalRulerExtension) fVerticalRuler;
- e.setFont(font);
- }
- }
- }
-
- /**
- * Creates a color from the information stored in the given preference store.
- * Returns <code>null</code> if there is no such information available.
- *
- * @param store the store to read from
- * @param key the key used for the lookup in the preference store
- * @param display the display used create the color
- * @return the created color according to the specification in the preference store
- * @since 2.0
- */
- private Color createColor(IPreferenceStore store, String key, Display display) {
-
- RGB rgb= null;
-
- if (store.contains(key)) {
-
- if (store.isDefault(key))
- rgb= PreferenceConverter.getDefaultColor(store, key);
- else
- rgb= PreferenceConverter.getColor(store, key);
-
- if (rgb != null)
- return new Color(display, rgb);
- }
-
- return null;
- }
-
- /**
- * Initializes the fore- and background colors of the given viewer for both
- * normal and selected text.
- *
- * @param viewer the viewer to be initialized
- * @since 2.0
- */
- protected void initializeViewerColors(ISourceViewer viewer) {
-
- IPreferenceStore store= getPreferenceStore();
- if (store != null) {
-
- StyledText styledText= viewer.getTextWidget();
-
- // ----------- foreground color --------------------
- Color color= store.getBoolean(PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(store, PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay());
- styledText.setForeground(color);
-
- if (fForegroundColor != null)
- fForegroundColor.dispose();
-
- fForegroundColor= color;
-
- // ---------- background color ----------------------
- color= store.getBoolean(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(store, PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay());
- styledText.setBackground(color);
-
- if (fBackgroundColor != null)
- fBackgroundColor.dispose();
-
- fBackgroundColor= color;
-
- // ----------- selection foreground color --------------------
- color= store.getBoolean(PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(store, PREFERENCE_COLOR_SELECTION_FOREGROUND, styledText.getDisplay());
- styledText.setSelectionForeground(color);
-
- if (fSelectionForegroundColor != null)
- fSelectionForegroundColor.dispose();
-
- fSelectionForegroundColor= color;
-
- // ---------- selection background color ----------------------
- color= store.getBoolean(PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT)
- ? null
- : createColor(store, PREFERENCE_COLOR_SELECTION_BACKGROUND, styledText.getDisplay());
- styledText.setSelectionBackground(color);
-
- if (fSelectionBackgroundColor != null)
- fSelectionBackgroundColor.dispose();
-
- fSelectionBackgroundColor= color;
- }
- }
-
- /**
- * Initializes the background color used for highlighting the document ranges
- * defining search scopes.
- *
- * @param viewer the viewer to initialize
- * @since 2.0
- */
- private void initializeFindScopeColor(ISourceViewer viewer) {
-
- IPreferenceStore store= getPreferenceStore();
- if (store != null) {
-
- StyledText styledText= viewer.getTextWidget();
-
- Color color= createColor(store, PREFERENCE_COLOR_FIND_SCOPE, styledText.getDisplay());
-
- IFindReplaceTarget target= viewer.getFindReplaceTarget();
- if (target != null && target instanceof IFindReplaceTargetExtension)
- ((IFindReplaceTargetExtension) target).setScopeHighlightColor(color);
-
- if (fFindScopeHighlightColor != null)
- fFindScopeHighlightColor.dispose();
-
- fFindScopeHighlightColor= color;
- }
- }
-
-
- /**
- * Initializes the editor's source viewer based on the given editor input.
- *
- * @param input the editor input to be used to initialize the source viewer
- */
- private void initializeSourceViewer(IEditorInput input) {
-
- IAnnotationModel model= getDocumentProvider().getAnnotationModel(input);
- IDocument document= getDocumentProvider().getDocument(input);
-
- if (document != null) {
- fSourceViewer.setDocument(document, model);
- fSourceViewer.setEditable(isEditable());
- fSourceViewer.showAnnotations(model != null);
- }
-
- if (fElementStateListener instanceof IElementStateListenerExtension) {
- IElementStateListenerExtension extension= (IElementStateListenerExtension) fElementStateListener;
- extension.elementStateValidationChanged(input, false);
- }
-
- if (fInitialCaret == null)
- fInitialCaret= getSourceViewer().getTextWidget().getCaret();
-
- if (fIsOverwriting)
- fSourceViewer.getTextWidget().invokeAction(ST.TOGGLE_OVERWRITE);
- handleInsertModeChanged();
- }
-
- /**
- * Initializes the editor's title based on the given editor input.
- *
- * @param input the editor input to be used
- */
- private void initializeTitle(IEditorInput input) {
-
- Image oldImage= fTitleImage;
- fTitleImage= null;
- String title= ""; //$NON-NLS-1$
-
- if (input != null) {
- IEditorRegistry editorRegistry = getEditorSite().getPage().getWorkbenchWindow().getWorkbench().getEditorRegistry();
- IEditorDescriptor editorDesc= editorRegistry.findEditor(getSite().getId());
- ImageDescriptor imageDesc= editorDesc != null ? editorDesc.getImageDescriptor() : null;
-
- fTitleImage= imageDesc != null ? imageDesc.createImage() : null;
- title= input.getName();
- }
-
- setTitleImage(fTitleImage);
- setTitle(title);
-
- firePropertyChange(PROP_DIRTY);
-
- if (oldImage != null && !oldImage.isDisposed())
- oldImage.dispose();
- }
-
- /**
- * Hook method for setting the document provider for the given input.
- * This default implementation does nothing. Clients may
- * reimplement.
- *
- * @param input the input of this editor.
- * @since 3.0
- */
- protected void setDocumentProvider(IEditorInput input) {
- }
-
- /**
- * If there is no explicit document provider set, the implicit one is
- * re-initialized based on the given editor input.
- *
- * @param input the editor input.
- */
- private void updateDocumentProvider(IEditorInput input) {
-
- IProgressMonitor rememberedProgressMonitor= null;
-
- IDocumentProvider provider= getDocumentProvider();
- if (provider != null) {
- provider.removeElementStateListener(fElementStateListener);
- if (provider instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) provider;
- rememberedProgressMonitor= extension.getProgressMonitor();
- extension.setProgressMonitor(null);
- }
- }
-
- setDocumentProvider(input);
-
- provider= getDocumentProvider();
- if (provider != null) {
- provider.addElementStateListener(fElementStateListener);
- if (provider instanceof IDocumentProviderExtension2) {
- IDocumentProviderExtension2 extension= (IDocumentProviderExtension2) provider;
- extension.setProgressMonitor(rememberedProgressMonitor);
- }
- }
- }
-
- /**
- * Called directly from <code>setInput</code> and from within a workspace
- * runnable from <code>init</code>, this method does the actual setting
- * of the editor input. Closes the editor if <code>input</code> is
- * <code>null</code>. Disconnects from any previous editor input and its
- * document provider and connects to the new one.
- * <p>
- * Subclasses may extend.
- * </p>
- *
- * @param input the input to be set
- * @exception CoreException if input cannot be connected to the document
- * provider
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
-
- if (input == null)
-
- close(isSaveOnCloseNeeded());
-
- else {
-
- IEditorInput oldInput= getEditorInput();
- if (oldInput != null)
- getDocumentProvider().disconnect(oldInput);
-
- super.setInput(input);
-
- updateDocumentProvider(input);
-
- IDocumentProvider provider= getDocumentProvider();
- if (provider == null) {
- IStatus s= new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, EditorMessages.getString("Editor.error.no_provider"), null); //$NON-NLS-1$
- throw new CoreException(s);
- }
-
- provider.connect(input);
-
- initializeTitle(input);
-
- if (fSourceViewer != null)
- initializeSourceViewer(input);
-
- if (fIsOverwriting)
- toggleOverwriteMode();
- setInsertMode((InsertMode) getLegalInsertModes().get(0));
- updateCaret();
-
- updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
-
- if (fSelectionListener != null)
- fSelectionListener.setDocument(getDocumentProvider().getDocument(input));
- }
- }
-
- /*
- * @see EditorPart#setInput(org.eclipse.ui.IEditorInput)
- */
- public final void setInput(IEditorInput input) {
-
- try {
-
- doSetInput(input);
-
- } catch (CoreException x) {
- String title= EditorMessages.getString("Editor.error.setinput.title"); //$NON-NLS-1$
- String msg= EditorMessages.getString("Editor.error.setinput.message"); //$NON-NLS-1$
- Shell shell= getSite().getShell();
- ErrorDialog.openError(shell, title, msg, x.getStatus());
- }
- }
-
- /*
- * @see ITextEditor#close
- */
- public void close(final boolean save) {
-
- enableSanityChecking(false);
-
- Display display= getSite().getShell().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- if (fSourceViewer != null) {
- // check whether editor has not been disposed yet
- getSite().getPage().closeEditor(AbstractTextEditor.this, save);
- }
- }
- });
- }
-
- /**
- * The <code>AbstractTextEditor</code> implementation of this
- * <code>IWorkbenchPart</code> method may be extended by subclasses.
- * Subclasses must call <code>super.dispose()</code>.
- * <p>
- * Note that many methods may return <code>null</code> after the editor is
- * disposed.
- * </p>
- */
- public void dispose() {
-
- if (fActivationListener != null) {
- IWorkbenchWindow window= getSite().getWorkbenchWindow();
- window.getPartService().removePartListener(fActivationListener);
- Shell shell= window.getShell();
- if (shell != null && !shell.isDisposed())
- shell.removeShellListener(fActivationListener);
- fActivationListener= null;
- }
-
- if (fTitleImage != null) {
- fTitleImage.dispose();
- fTitleImage= null;
- }
-
- if (fFont != null) {
- fFont.dispose();
- fFont= null;
- }
-
- disposeNonDefaultCaret();
- fInitialCaret= null;
-
- if (fForegroundColor != null) {
- fForegroundColor.dispose();
- fForegroundColor= null;
- }
-
- if (fBackgroundColor != null) {
- fBackgroundColor.dispose();
- fBackgroundColor= null;
- }
-
- if (fSelectionForegroundColor != null) {
- fSelectionForegroundColor.dispose();
- fSelectionForegroundColor= null;
- }
-
- if (fSelectionBackgroundColor != null) {
- fSelectionBackgroundColor.dispose();
- fSelectionBackgroundColor= null;
- }
-
- if (fFindScopeHighlightColor != null) {
- fFindScopeHighlightColor.dispose();
- fFindScopeHighlightColor= null;
- }
-
- if (fFontPropertyChangeListener != null) {
- JFaceResources.getFontRegistry().removeListener(fFontPropertyChangeListener);
- fFontPropertyChangeListener= null;
- }
-
- if (fPropertyChangeListener != null) {
- if (fPreferenceStore != null) {
- fPreferenceStore.removePropertyChangeListener(fPropertyChangeListener);
- fPreferenceStore= null;
- }
- fPropertyChangeListener= null;
- }
-
- if (fActivationCodeTrigger != null) {
- fActivationCodeTrigger.uninstall();
- fActivationCodeTrigger= null;
- }
-
- if (fSelectionListener != null) {
- fSelectionListener.uninstall(getSelectionProvider());
- fSelectionListener= null;
- }
-
- disposeDocumentProvider();
-
- if (fSourceViewer != null) {
-
- if (fTextListener != null) {
- fSourceViewer.removeTextListener(fTextListener);
- fSourceViewer.removeTextInputListener(fTextListener);
- fTextListener= null;
- }
-
- fTextInputListener= null;
- fSelectionProvider= null;
- fSourceViewer= null;
- }
-
- if (fTextContextMenu != null) {
- fTextContextMenu.dispose();
- fTextContextMenu= null;
- }
-
- if (fRulerContextMenu != null) {
- fRulerContextMenu.dispose();
- fRulerContextMenu= null;
- }
-
- if (fActions != null) {
- fActions.clear();
- fActions= null;
- }
-
- if (fSelectionActions != null) {
- fSelectionActions.clear();
- fSelectionActions= null;
- }
-
- if (fContentActions != null) {
- fContentActions.clear();
- fContentActions= null;
- }
-
- if (fPropertyActions != null) {
- fPropertyActions.clear();
- fPropertyActions= null;
- }
-
- if (fStateActions != null) {
- fStateActions.clear();
- fStateActions= null;
- }
-
- if (fActivationCodes != null) {
- fActivationCodes.clear();
- fActivationCodes= null;
- }
-
- if (fEditorStatusLine != null)
- fEditorStatusLine= null;
-
- if (fConfiguration != null)
- fConfiguration= null;
-
- super.setInput(null);
-
- super.dispose();
- }
-
- /**
- * Disposes of the connection with the document provider. Subclasses
- * may extend.
- *
- * @since 3.0
- */
- protected void disposeDocumentProvider() {
- IDocumentProvider provider= getDocumentProvider();
- if (provider != null) {
-
- IEditorInput input= getEditorInput();
- if (input != null)
- provider.disconnect(input);
-
- if (fElementStateListener != null) {
- provider.removeElementStateListener(fElementStateListener);
- fElementStateListener= null;
- }
-
- fExplicitDocumentProvider= null;
- }
- }
-
- /**
- * Determines whether the given preference change affects the editor's
- * presentation. This implementation always returns <code>false</code>.
- * May be reimplemented by subclasses.
- *
- * @param event the event which should be investigated
- * @return <code>true</code> if the event describes a preference change affecting the editor's presentation
- * @since 2.0
- */
- protected boolean affectsTextPresentation(PropertyChangeEvent event) {
- return false;
- }
-
- /**
- * Returns the symbolic font name for this editor as defined in XML.
- *
- * @return a String with the symbolic font name or <code>null</code> if
- * none is defined
- * @since 2.1
- */
- private String getSymbolicFontName() {
- if (getConfigurationElement() != null)
- return getConfigurationElement().getAttribute("symbolicFontName"); //$NON-NLS-1$
- else
- return null;
- }
-
- /**
- * Returns the property preference key for the editor font. Subclasses may
- * replace this method.
- *
- * @return a String with the key
- * @since 2.1
- */
- protected final String getFontPropertyPreferenceKey() {
- String symbolicFontName= getSymbolicFontName();
-
- if (symbolicFontName != null)
- return symbolicFontName;
- else
- return JFaceResources.TEXT_FONT;
- }
-
- /**
- * Handles a property change event describing a change of the editor's
- * preference store and updates the preference related editor properties.
- * <p>
- * Subclasses may extend.
- * </p>
- *
- * @param event the property change event
- */
- protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
-
- if (fSourceViewer == null)
- return;
-
- String property= event.getProperty();
-
- if (getFontPropertyPreferenceKey().equals(property)) {
- // There is a separate handler for font preference changes
- return;
- } else if (PREFERENCE_COLOR_FOREGROUND.equals(property) || PREFERENCE_COLOR_FOREGROUND_SYSTEM_DEFAULT.equals(property) ||
- PREFERENCE_COLOR_BACKGROUND.equals(property) || PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT.equals(property) ||
- PREFERENCE_COLOR_SELECTION_FOREGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_FOREGROUND_SYSTEM_DEFAULT.equals(property) ||
- PREFERENCE_COLOR_SELECTION_BACKGROUND.equals(property) || PREFERENCE_COLOR_SELECTION_BACKGROUND_SYSTEM_DEFAULT.equals(property))
- {
- initializeViewerColors(fSourceViewer);
- } else if (PREFERENCE_COLOR_FIND_SCOPE.equals(property)) {
- initializeFindScopeColor(fSourceViewer);
- } else if (PREFERENCE_USE_CUSTOM_CARETS.equals(property)) {
- updateCaret();
- } else if (PREFERENCE_WIDE_CARET.equals(property)) {
- updateCaret();
- }
-
- if (affectsTextPresentation(event))
- fSourceViewer.invalidateTextPresentation();
- }
-
- /**
- * Returns the progress monitor related to this editor. It should not be
- * necessary to extend this method.
- *
- * @return the progress monitor related to this editor
- * @since 2.1
- */
- protected IProgressMonitor getProgressMonitor() {
-
- IProgressMonitor pm= null;
-
- IStatusLineManager manager= getStatusLineManager();
- if (manager != null)
- pm= manager.getProgressMonitor();
-
- return pm != null ? pm : new NullProgressMonitor();
- }
-
- /**
- * Handles an external change of the editor's input element. Subclasses may
- * extend.
- */
- protected void handleEditorInputChanged() {
-
- String title;
- String msg;
- Shell shell= getSite().getShell();
-
- final IDocumentProvider provider= getDocumentProvider();
- if (provider == null) {
- // fix for http://dev.eclipse.org/bugs/show_bug.cgi?id=15066
- close(false);
- return;
- }
-
- final IEditorInput input= getEditorInput();
- if (provider.isDeleted(input)) {
-
- if (isSaveAsAllowed()) {
-
- title= EditorMessages.getString("Editor.error.activated.deleted.save.title"); //$NON-NLS-1$
- msg= EditorMessages.getString("Editor.error.activated.deleted.save.message"); //$NON-NLS-1$
-
- String[] buttons= {
- EditorMessages.getString("Editor.error.activated.deleted.save.button.save"), //$NON-NLS-1$
- EditorMessages.getString("Editor.error.activated.deleted.save.button.close"), //$NON-NLS-1$
- };
-
- MessageDialog dialog= new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, buttons, 0);
-
- if (dialog.open() == 0) {
- IProgressMonitor pm= getProgressMonitor();
- performSaveAs(pm);
- if (pm.isCanceled())
- handleEditorInputChanged();
- } else {
- close(false);
- }
-
- } else {
-
- title= EditorMessages.getString("Editor.error.activated.deleted.close.title"); //$NON-NLS-1$
- msg= EditorMessages.getString("Editor.error.activated.deleted.close.message"); //$NON-NLS-1$
- if (MessageDialog.openConfirm(shell, title, msg))
- close(false);
- }
-
- } else {
-
- title= EditorMessages.getString("Editor.error.activated.outofsync.title"); //$NON-NLS-1$
- msg= EditorMessages.getString("Editor.error.activated.outofsync.message"); //$NON-NLS-1$
-
- if (MessageDialog.openQuestion(shell, title, msg)) {
-
-
- try {
- if (provider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
- extension.synchronize(input);
- } else {
- doSetInput(input);
- }
- } catch (CoreException x) {
- IStatus status= x.getStatus();
- if (status == null || status.getSeverity() != IStatus.CANCEL) {
- title= EditorMessages.getString("Editor.error.refresh.outofsync.title"); //$NON-NLS-1$
- msg= EditorMessages.getString("Editor.error.refresh.outofsync.message"); //$NON-NLS-1$
- ErrorDialog.openError(shell, title, msg, x.getStatus());
- }
- }
- }
- }
- }
-
- /**
- * The <code>AbstractTextEditor</code> implementation of this
- * <code>IEditorPart</code> method calls <code>performSaveAs</code>.
- * Subclasses may reimplement.
- */
- public void doSaveAs() {
- /*
- * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
- * Changed Behavior to make sure that if called inside a regular save (because
- * of deletion of input element) there is a way to report back to the caller.
- */
- performSaveAs(getProgressMonitor());
- }
-
- /**
- * Performs a save as and reports the result state back to the
- * given progress monitor. This default implementation does nothing.
- * Subclasses may reimplement.
- *
- * @param progressMonitor the progress monitor for communicating result state or <code>null</code>
- */
- protected void performSaveAs(IProgressMonitor progressMonitor) {
- }
-
- /**
- * The <code>AbstractTextEditor</code> implementation of this
- * <code>IEditorPart</code> method may be extended by subclasses.
- *
- * @param progressMonitor the progress monitor for communicating result state or <code>null</code>
- */
- public void doSave(IProgressMonitor progressMonitor) {
-
- IDocumentProvider p= getDocumentProvider();
- if (p == null)
- return;
-
- if (p.isDeleted(getEditorInput())) {
-
- if (isSaveAsAllowed()) {
-
- /*
- * 1GEUSSR: ITPUI:ALL - User should never loose changes made in the editors.
- * Changed Behavior to make sure that if called inside a regular save (because
- * of deletion of input element) there is a way to report back to the caller.
- */
- performSaveAs(progressMonitor);
-
- } else {
-
- Shell shell= getSite().getShell();
- String title= EditorMessages.getString("Editor.error.save.deleted.title"); //$NON-NLS-1$
- String msg= EditorMessages.getString("Editor.error.save.deleted.message"); //$NON-NLS-1$
- MessageDialog.openError(shell, title, msg);
- }
-
- } else {
- updateState(getEditorInput());
- validateState(getEditorInput());
- performSave(false, progressMonitor);
- }
- }
-
- /**
- * Enables/disables sanity checking.
- * @param enable <code>true</code> if sanity checking should be enabled, <code>false</code> otherwise
- * @since 2.0
- */
- protected void enableSanityChecking(boolean enable) {
- synchronized (this) {
- fIsSanityCheckEnabled= enable;
- }
- }
-
- /**
- * Checks the state of the given editor input if sanity checking is enabled.
- * @param input the editor input whose state is to be checked
- * @since 2.0
- */
- protected void safelySanityCheckState(IEditorInput input) {
- boolean enabled= false;
-
- synchronized (this) {
- enabled= fIsSanityCheckEnabled;
- }
-
- if (enabled)
- sanityCheckState(input);
- }
-
- /**
- * Checks the state of the given editor input.
- * @param input the editor input whose state is to be checked
- * @since 2.0
- */
- protected void sanityCheckState(IEditorInput input) {
-
- IDocumentProvider p= getDocumentProvider();
- if (p == null)
- return;
-
- if (p instanceof IDocumentProviderExtension3) {
-
- IDocumentProviderExtension3 p3= (IDocumentProviderExtension3) p;
-
- long stamp= p.getModificationStamp(input);
- if (stamp != fModificationStamp) {
- fModificationStamp= stamp;
- if (!p3.isSynchronized(input))
- handleEditorInputChanged();
- }
-
- } else {
-
- if (fModificationStamp == -1)
- fModificationStamp= p.getSynchronizationStamp(input);
-
- long stamp= p.getModificationStamp(input);
- if (stamp != fModificationStamp) {
- fModificationStamp= stamp;
- if (stamp != p.getSynchronizationStamp(input))
- handleEditorInputChanged();
- }
- }
-
- updateState(getEditorInput());
- updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE);
- }
-
- /**
- * Enables/disables state validation.
- * @param enable <code>true</code> if state validation should be enabled, <code>false</code> otherwise
- * @since 2.1
- */
- protected void enableStateValidation(boolean enable) {
- synchronized (this) {
- fIsStateValidationEnabled= enable;
- }
- }
-
- /**
- * Validates the state of the given editor input. The predominate intent
- * of this method is to take any action probably necessary to ensure that
- * the input can persistently be changed.
- *
- * @param input the input to be validated
- * @since 2.0
- */
- protected void validateState(IEditorInput input) {
-
- IDocumentProvider provider= getDocumentProvider();
- if (! (provider instanceof IDocumentProviderExtension))
- return;
-
- IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
-
- try {
-
- extension.validateState(input, getSite().getShell());
-
- } catch (CoreException x) {
- IStatus status= x.getStatus();
- if (status == null || status.getSeverity() != IStatus.CANCEL) {
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log= Platform.getLog(bundle);
- log.log(x.getStatus());
-
- Shell shell= getSite().getShell();
- String title= EditorMessages.getString("Editor.error.validateEdit.title"); //$NON-NLS-1$
- String msg= EditorMessages.getString("Editor.error.validateEdit.message"); //$NON-NLS-1$
- ErrorDialog.openError(shell, title, msg, x.getStatus());
- }
- return;
- }
-
- if (fSourceViewer != null)
- fSourceViewer.setEditable(isEditable());
-
- updateStateDependentActions();
- }
-
- /*
- * @see org.eclipse.ui.texteditor.ITextEditorExtension2#validateEditorInputState()
- * @since 2.1
- */
- public boolean validateEditorInputState() {
-
- boolean enabled= false;
-
- synchronized (this) {
- enabled= fIsStateValidationEnabled;
- }
-
- if (enabled) {
-
- ISourceViewer viewer= getSourceViewer();
- if (viewer == null)
- return false;
-
- fTextInputListener.inputChanged= false;
- viewer.addTextInputListener(fTextInputListener);
-
- try {
- final IEditorInput input= getEditorInput();
- BusyIndicator.showWhile(getSite().getShell().getDisplay(), new Runnable() {
- /*
- * @see java.lang.Runnable#run()
- */
- public void run() {
- validateState(input);
- }
- });
- sanityCheckState(input);
- return !isEditorInputReadOnly() && !fTextInputListener.inputChanged;
-
- } finally {
- viewer.removeTextInputListener(fTextInputListener);
- }
-
- }
-
- return !isEditorInputReadOnly();
- }
-
- /**
- * Updates the state of the given editor input such as read-only flag.
- *
- * @param input the input to be validated
- * @since 2.0
- */
- protected void updateState(IEditorInput input) {
- IDocumentProvider provider= getDocumentProvider();
- if (provider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
- try {
-
- boolean wasReadOnly= isEditorInputReadOnly();
- extension.updateStateCache(input);
-
- if (fSourceViewer != null)
- fSourceViewer.setEditable(isEditable());
-
- if (wasReadOnly != isEditorInputReadOnly())
- updateStateDependentActions();
-
- } catch (CoreException x) {
- Bundle bundle = Platform.getBundle(PlatformUI.PLUGIN_ID);
- ILog log= Platform.getLog(bundle);
- log.log(x.getStatus());
- }
- }
- }
-
- /**
- * Performs the save and handles errors appropriately.
- *
- * @param overwrite indicates whether or not overwriting is allowed
- * @param progressMonitor the monitor in which to run the operation
- * @since 3.0
- */
- protected void performSave(boolean overwrite, IProgressMonitor progressMonitor) {
-
- IDocumentProvider provider= getDocumentProvider();
- if (provider == null)
- return;
-
- try {
-
- provider.aboutToChange(getEditorInput());
- IEditorInput input= getEditorInput();
- provider.saveDocument(progressMonitor, input, getDocumentProvider().getDocument(input), overwrite);
- editorSaved();
-
- } catch (CoreException x) {
- IStatus status= x.getStatus();
- if (status == null || status.getSeverity() != IStatus.CANCEL)
- handleExceptionOnSave(x, progressMonitor);
- } finally {
- provider.changed(getEditorInput());
- }
- }
-
- /**
- * Handles the given exception. If the exception reports an out-of-sync
- * situation, this is reported to the user. Otherwise, the exception
- * is generically reported.
- *
- * @param exception the exception to handle
- * @param progressMonitor the progress monitor
- */
- protected void handleExceptionOnSave(CoreException exception, IProgressMonitor progressMonitor) {
-
- try {
- ++ fErrorCorrectionOnSave;
-
- Shell shell= getSite().getShell();
-
- boolean isSynchronized= false;
- IDocumentProvider p= getDocumentProvider();
-
- if (p instanceof IDocumentProviderExtension3) {
- IDocumentProviderExtension3 p3= (IDocumentProviderExtension3) p;
- isSynchronized= p3.isSynchronized(getEditorInput());
- } else {
- long modifiedStamp= p.getModificationStamp(getEditorInput());
- long synchStamp= p.getSynchronizationStamp(getEditorInput());
- isSynchronized= (modifiedStamp == synchStamp);
- }
-
- if (fErrorCorrectionOnSave == 1 && !isSynchronized) {
-
- String title= EditorMessages.getString("Editor.error.save.outofsync.title"); //$NON-NLS-1$
- String msg= EditorMessages.getString("Editor.error.save.outofsync.message"); //$NON-NLS-1$
-
- if (MessageDialog.openQuestion(shell, title, msg))
- performSave(true, progressMonitor);
- else {
- /*
- * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits
- * Set progress monitor to canceled in order to report back
- * to enclosing operations.
- */
- if (progressMonitor != null)
- progressMonitor.setCanceled(true);
- }
- } else {
-
- String title= EditorMessages.getString("Editor.error.save.title"); //$NON-NLS-1$
- String msg= EditorMessages.getString("Editor.error.save.message"); //$NON-NLS-1$
- ErrorDialog.openError(shell, title, msg, exception.getStatus());
-
- /*
- * 1GEUPKR: ITPJUI:ALL - Loosing work with simultaneous edits
- * Set progress monitor to canceled in order to report back
- * to enclosing operations.
- */
- if (progressMonitor != null)
- progressMonitor.setCanceled(true);
- }
-
- } finally {
- -- fErrorCorrectionOnSave;
- }
- }
-
- /**
- * The <code>AbstractTextEditor</code> implementation of this
- * <code>IEditorPart</code> method returns <code>false</code>.
- * Subclasses may override.
- *
- * @return <code>false</code>
- */
- public boolean isSaveAsAllowed() {
- return false;
- }
-
- /*
- * @see EditorPart#isSaveOnCloseNeeded()
- */
- public boolean isSaveOnCloseNeeded() {
- IDocumentProvider p= getDocumentProvider();
- return p == null ? false : p.mustSaveDocument(getEditorInput());
- }
-
- /*
- * @see EditorPart#isDirty()
- */
- public boolean isDirty() {
- IDocumentProvider p= getDocumentProvider();
- return p == null ? false : p.canSaveDocument(getEditorInput());
- }
-
- /**
- * The <code>AbstractTextEditor</code> implementation of this
- * <code>ITextEditor</code> method may be extended by subclasses.
- */
- public void doRevertToSaved() {
- IDocumentProvider p= getDocumentProvider();
- if (p == null)
- return;
-
- performRevert();
- }
-
- /**
- * Performs revert and handles errors appropriately.
- * <p>
- * Subclasses may extend.
- * </p>
- *
- * @since 3.0
- */
- protected void performRevert() {
-
- IDocumentProvider provider= getDocumentProvider();
- if (provider == null)
- return;
-
- try {
-
- provider.aboutToChange(getEditorInput());
- provider.resetDocument(getEditorInput());
- editorSaved();
-
- } catch (CoreException x) {
- IStatus status= x.getStatus();
- if (status == null || status.getSeverity() != IStatus.CANCEL ) {
- Shell shell= getSite().getShell();
- String title= EditorMessages.getString("Editor.error.revert.title"); //$NON-NLS-1$
- String msg= EditorMessages.getString("Editor.error.revert.message"); //$NON-NLS-1$
- ErrorDialog.openError(shell, title, msg, x.getStatus());
- }
- } finally {
- provider.changed(getEditorInput());
- }
- }
-
- /**
- * Performs any additional action necessary to perform after the input
- * document's content has been replaced.
- * <p>
- * Clients may extended this method.
- *
- * @since 3.0
- */
- protected void handleElementContentReplaced() {
- }
-
- /*
- * @see ITextEditor#setAction(String, IAction)
- */
- public void setAction(String actionID, IAction action) {
- Assert.isNotNull(actionID);
- if (action == null) {
- action= (IAction) fActions.remove(actionID);
- if (action != null)
- fActivationCodeTrigger.unregisterActionFromKeyActivation(action);
- } else {
- fActions.put(actionID, action);
- fActivationCodeTrigger.registerActionForKeyActivation(action);
- }
- }
-
- /*
- * @see ITextEditor#setActionActivationCode(String, char, int, int)
- */
- public void setActionActivationCode(String actionID, char activationCharacter, int activationKeyCode, int activationStateMask) {
-
- Assert.isNotNull(actionID);
-
- ActionActivationCode found= findActionActivationCode(actionID);
- if (found == null) {
- found= new ActionActivationCode(actionID);
- fActivationCodes.add(found);
- }
-
- found.fCharacter= activationCharacter;
- found.fKeyCode= activationKeyCode;
- found.fStateMask= activationStateMask;
- }
-
- /**
- * Returns the activation code registered for the specified action.
- *
- * @param actionID the action id
- * @return the registered activation code or <code>null</code> if no code has been installed
- */
- private ActionActivationCode findActionActivationCode(String actionID) {
- int size= fActivationCodes.size();
- for (int i= 0; i < size; i++) {
- ActionActivationCode code= (ActionActivationCode) fActivationCodes.get(i);
- if (actionID.equals(code.fActionId))
- return code;
- }
- return null;
- }
-
- /*
- * @see ITextEditor#removeActionActivationCode(String)
- */
- public void removeActionActivationCode(String actionID) {
- Assert.isNotNull(actionID);
- ActionActivationCode code= findActionActivationCode(actionID);
- if (code != null)
- fActivationCodes.remove(code);
- }
-
- /*
- * @see ITextEditor#getAction(String)
- */
- public IAction getAction(String actionID) {
- Assert.isNotNull(actionID);
- IAction action= (IAction) fActions.get(actionID);
-
- if (action == null) {
- action= findContributedAction(actionID);
- if (action != null)
- setAction(actionID, action);
- }
-
- return action;
- }
-
- /**
- * Returns the action with the given action id that has been contributed via XML to this editor.
- * The lookup honors the dependencies of plug-ins.
- *
- * @param actionID the action id to look up
- * @return the action that has been contributed
- * @since 2.0
- */
- private IAction findContributedAction(String actionID) {
- List actions= new ArrayList();
- IConfigurationElement[] elements= Platform.getExtensionRegistry().getConfigurationElementsFor(PlatformUI.PLUGIN_ID, "editorActions"); //$NON-NLS-1$
- for (int i= 0; i < elements.length; i++) {
- IConfigurationElement element= elements[i];
- if (TAG_CONTRIBUTION_TYPE.equals(element.getName())) {
- if (!getSite().getId().equals(element.getAttribute("targetID"))) //$NON-NLS-1$
- continue;
-
- IConfigurationElement[] children= element.getChildren("action"); //$NON-NLS-1$
- for (int j= 0; j < children.length; j++) {
- IConfigurationElement child= children[j];
- if (actionID.equals(child.getAttribute("actionID"))) //$NON-NLS-1$
- actions.add(child);
- }
- }
- }
- int actionSize= actions.size();
- if (actionSize > 0) {
- IConfigurationElement element;
- if (actionSize > 1) {
- IConfigurationElement[] actionArray= (IConfigurationElement[])actions.toArray(new IConfigurationElement[actionSize]);
- ConfigurationElementSorter sorter= new ConfigurationElementSorter() {
- /**
- * {@inheritDoc}
- */
- public IConfigurationElement getConfigurationElement(Object object) {
- return (IConfigurationElement)object;
- }
- };
- sorter.sort(actionArray);
- element= actionArray[0];
- } else
- element= (IConfigurationElement)actions.get(0);
-
- String defId = element.getAttribute(ActionDescriptor.ATT_DEFINITION_ID);
- return new EditorPluginAction(element, this, defId, IAction.AS_UNSPECIFIED); //$NON-NLS-1$
- }
-
- return null;
- }
-
- /**
- * Updates the specified action by calling <code>IUpdate.update</code>
- * if applicable.
- *
- * @param actionId the action id
- */
- private void updateAction(String actionId) {
- Assert.isNotNull(actionId);
- if (fActions != null) {
- IAction action= (IAction) fActions.get(actionId);
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
- }
- }
-
- /**
- * Marks or unmarks the given action to be updated on text selection changes.
- *
- * @param actionId the action id
- * @param mark <code>true</code> if the action is selection dependent
- */
- public void markAsSelectionDependentAction(String actionId, boolean mark) {
- Assert.isNotNull(actionId);
- if (mark) {
- if (!fSelectionActions.contains(actionId))
- fSelectionActions.add(actionId);
- } else
- fSelectionActions.remove(actionId);
- }
-
- /**
- * Marks or unmarks the given action to be updated on content changes.
- *
- * @param actionId the action id
- * @param mark <code>true</code> if the action is content dependent
- */
- public void markAsContentDependentAction(String actionId, boolean mark) {
- Assert.isNotNull(actionId);
- if (mark) {
- if (!fContentActions.contains(actionId))
- fContentActions.add(actionId);
- } else
- fContentActions.remove(actionId);
- }
-
- /**
- * Marks or unmarks the given action to be updated on property changes.
- *
- * @param actionId the action id
- * @param mark <code>true</code> if the action is property dependent
- * @since 2.0
- */
- public void markAsPropertyDependentAction(String actionId, boolean mark) {
- Assert.isNotNull(actionId);
- if (mark) {
- if (!fPropertyActions.contains(actionId))
- fPropertyActions.add(actionId);
- } else
- fPropertyActions.remove(actionId);
- }
-
- /**
- * Marks or unmarks the given action to be updated on state changes.
- *
- * @param actionId the action id
- * @param mark <code>true</code> if the action is state dependent
- * @since 2.0
- */
- public void markAsStateDependentAction(String actionId, boolean mark) {
- Assert.isNotNull(actionId);
- if (mark) {
- if (!fStateActions.contains(actionId))
- fStateActions.add(actionId);
- } else
- fStateActions.remove(actionId);
- }
-
- /**
- * Updates all selection dependent actions.
- */
- protected void updateSelectionDependentActions() {
- if (fSelectionActions != null) {
- Iterator e= fSelectionActions.iterator();
- while (e.hasNext())
- updateAction((String) e.next());
- }
- }
-
- /**
- * Updates all content dependent actions.
- */
- protected void updateContentDependentActions() {
- if (fContentActions != null) {
- Iterator e= fContentActions.iterator();
- while (e.hasNext())
- updateAction((String) e.next());
- }
- }
-
- /**
- * Updates all property dependent actions.
- * @since 2.0
- */
- protected void updatePropertyDependentActions() {
- if (fPropertyActions != null) {
- Iterator e= fPropertyActions.iterator();
- while (e.hasNext())
- updateAction((String) e.next());
- }
- }
-
- /**
- * Updates all state dependent actions.
- * @since 2.0
- */
- protected void updateStateDependentActions() {
- if (fStateActions != null) {
- Iterator e= fStateActions.iterator();
- while (e.hasNext())
- updateAction((String) e.next());
- }
- }
-
- /**
- * Creates action entries for all SWT StyledText actions as defined in
- * <code>org.eclipse.swt.custom.ST</code>. Overwrites and
- * extends the list of these actions afterwards.
- * <p>
- * Subclasses may extend.
- * </p>
- * @since 2.0
- */
- protected void createNavigationActions() {
-
- IAction action;
-
- StyledText textWidget= getSourceViewer().getTextWidget();
- for (int i= 0; i < ACTION_MAP.length; i++) {
- IdMapEntry entry= ACTION_MAP[i];
- action= new TextNavigationAction(textWidget, entry.getAction());
- action.setActionDefinitionId(entry.getActionId());
- setAction(entry.getActionId(), action);
- }
-
- action= new ToggleOverwriteModeAction(EditorMessages.getResourceBundle(), "Editor.ToggleOverwriteMode."); //$NON-NLS-1$
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE);
- setAction(ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, action);
- textWidget.setKeyBinding(SWT.INSERT, SWT.NULL);
-
- action= new ScrollLinesAction(-1);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SCROLL_LINE_UP);
- setAction(ITextEditorActionDefinitionIds.SCROLL_LINE_UP, action);
-
- action= new ScrollLinesAction(1);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SCROLL_LINE_DOWN);
- setAction(ITextEditorActionDefinitionIds.SCROLL_LINE_DOWN, action);
-
- action= new LineEndAction(textWidget, false);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_END);
- setAction(ITextEditorActionDefinitionIds.LINE_END, action);
-
- action= new LineStartAction(textWidget, false);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_START);
- setAction(ITextEditorActionDefinitionIds.LINE_START, action);
-
- action= new LineEndAction(textWidget, true);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_END);
- setAction(ITextEditorActionDefinitionIds.SELECT_LINE_END, action);
-
- action= new LineStartAction(textWidget, true);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_LINE_START);
- setAction(ITextEditorActionDefinitionIds.SELECT_LINE_START, action);
-
- setActionActivationCode(ITextEditorActionDefinitionIds.LINE_END, (char) 0, SWT.END, SWT.NONE);
- setActionActivationCode(ITextEditorActionDefinitionIds.LINE_START, (char) 0, SWT.HOME, SWT.NONE);
- setActionActivationCode(ITextEditorActionDefinitionIds.SELECT_LINE_END, (char) 0, SWT.END, SWT.SHIFT);
- setActionActivationCode(ITextEditorActionDefinitionIds.SELECT_LINE_START, (char) 0, SWT.HOME, SWT.SHIFT);
-
- // to accommodate https://bugs.eclipse.org/bugs/show_bug.cgi?id=51516
- // nullify handling of DELETE key by StyledText
- textWidget.setKeyBinding(SWT.DEL, SWT.NULL);
- }
-
- /**
- * Creates this editor's accessibility actions.
- * @since 2.0
- */
- private void createAccessibilityActions() {
- IAction action= new ShowRulerContextMenuAction();
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_RULER_CONTEXT_MENU);
- setAction(ITextEditorActionDefinitionIds.SHOW_RULER_CONTEXT_MENU, action);
- }
-
- /**
- * Creates this editor's standard actions and connects them with the global
- * workbench actions.
- * <p>
- * Subclasses may extend.</p>
- */
- protected void createActions() {
-
- ResourceAction action;
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Undo.", this, ITextOperationTarget.UNDO); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.UNDO_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.UNDO);
- setAction(ITextEditorActionConstants.UNDO, action);
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Redo.", this, ITextOperationTarget.REDO); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.REDO_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.REDO);
- setAction(ITextEditorActionConstants.REDO, action);
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Cut.", this, ITextOperationTarget.CUT); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT);
- setAction(ITextEditorActionConstants.CUT, action);
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Copy.", this, ITextOperationTarget.COPY, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY);
- setAction(ITextEditorActionConstants.COPY, action);
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Paste.", this, ITextOperationTarget.PASTE); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.PASTE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.PASTE);
- setAction(ITextEditorActionConstants.PASTE, action);
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Delete.", this, ITextOperationTarget.DELETE); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE);
- setAction(ITextEditorActionConstants.DELETE, action);
-
- action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.DeleteLine.", this, DeleteLineAction.WHOLE, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE);
- setAction(ITextEditorActionConstants.DELETE_LINE, action);
-
- action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.CutLine.", this, DeleteLineAction.WHOLE, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE);
- setAction(ITextEditorActionConstants.CUT_LINE, action);
-
- action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.DeleteLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_BEGINNING_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_BEGINNING);
- setAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, action);
-
- action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.CutLineToBeginning.", this, DeleteLineAction.TO_BEGINNING, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_BEGINNING_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_BEGINNING);
- setAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, action);
-
- action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.DeleteLineToEnd.", this, DeleteLineAction.TO_END, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.DELETE_LINE_TO_END_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.DELETE_LINE_TO_END);
- setAction(ITextEditorActionConstants.DELETE_LINE_TO_END, action);
-
- action= new DeleteLineAction(EditorMessages.getResourceBundle(), "Editor.CutLineToEnd.", this, DeleteLineAction.TO_END, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.CUT_LINE_TO_END_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CUT_LINE_TO_END);
- setAction(ITextEditorActionConstants.CUT_LINE_TO_END, action);
-
- action= new MarkAction(EditorMessages.getResourceBundle(), "Editor.SetMark.", this, MarkAction.SET_MARK); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SET_MARK_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SET_MARK);
- setAction(ITextEditorActionConstants.SET_MARK, action);
-
- action= new MarkAction(EditorMessages.getResourceBundle(), "Editor.ClearMark.", this, MarkAction.CLEAR_MARK); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.CLEAR_MARK_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CLEAR_MARK);
- setAction(ITextEditorActionConstants.CLEAR_MARK, action);
-
- action= new MarkAction(EditorMessages.getResourceBundle(), "Editor.SwapMark.", this, MarkAction.SWAP_MARK); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SWAP_MARK_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SWAP_MARK);
- setAction(ITextEditorActionConstants.SWAP_MARK, action);
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.SelectAll.", this, ITextOperationTarget.SELECT_ALL, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SELECT_ALL_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SELECT_ALL);
- setAction(ITextEditorActionConstants.SELECT_ALL, action);
-
- action= new ShiftAction(EditorMessages.getResourceBundle(), "Editor.ShiftRight.", this, ITextOperationTarget.SHIFT_RIGHT); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_RIGHT_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT);
- setAction(ITextEditorActionConstants.SHIFT_RIGHT, action);
-
- action= new ShiftAction(EditorMessages.getResourceBundle(), "Editor.ShiftRight.", this, ITextOperationTarget.SHIFT_RIGHT) { //$NON-NLS-1$
- public void update() {
- updateForTab();
- }
- };
- setAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, action);
-
- action= new ShiftAction(EditorMessages.getResourceBundle(), "Editor.ShiftLeft.", this, ITextOperationTarget.SHIFT_LEFT); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHIFT_LEFT_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT);
- setAction(ITextEditorActionConstants.SHIFT_LEFT, action);
-
- action= new TextOperationAction(EditorMessages.getResourceBundle(), "Editor.Print.", this, ITextOperationTarget.PRINT, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.PRINT_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.PRINT);
- setAction(ITextEditorActionConstants.PRINT, action);
-
- action= new FindReplaceAction(EditorMessages.getResourceBundle(), "Editor.FindReplace.", this); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_REPLACE);
- setAction(ITextEditorActionConstants.FIND, action);
-
- action= new FindNextAction(EditorMessages.getResourceBundle(), "Editor.FindNext.", this, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_NEXT_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_NEXT);
- setAction(ITextEditorActionConstants.FIND_NEXT, action);
-
- action= new FindNextAction(EditorMessages.getResourceBundle(), "Editor.FindPrevious.", this, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_PREVIOUS_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_PREVIOUS);
- setAction(ITextEditorActionConstants.FIND_PREVIOUS, action);
-
- action= new IncrementalFindAction(EditorMessages.getResourceBundle(), "Editor.FindIncremental.", this, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL);
- setAction(ITextEditorActionConstants.FIND_INCREMENTAL, action);
-
- action= new IncrementalFindAction(EditorMessages.getResourceBundle(), "Editor.FindIncrementalReverse.", this, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.FIND_INCREMENTAL_REVERSE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL_REVERSE);
- setAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, action);
-
- action= new SaveAction(EditorMessages.getResourceBundle(), "Editor.Save.", this); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SAVE_ACTION);
- /*
- * if the line below is uncommented then the key binding does not work any more
- * see https://bugs.eclipse.org/bugs/show_bug.cgi?id=53417
- */
-// action.setActionDefinitionId(ITextEditorActionDefinitionIds.SAVE);
- setAction(ITextEditorActionConstants.SAVE, action);
-
- action= new RevertToSavedAction(EditorMessages.getResourceBundle(), "Editor.Revert.", this); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.REVERT_TO_SAVED_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.REVERT_TO_SAVED);
- setAction(ITextEditorActionConstants.REVERT_TO_SAVED, action);
-
- action= new GotoLineAction(EditorMessages.getResourceBundle(), "Editor.GotoLine.", this); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.GOTO_LINE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO);
- setAction(ITextEditorActionConstants.GOTO_LINE, action);
-
- action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.MoveLinesUp.", this, true, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_UP);
- setAction(ITextEditorActionConstants.MOVE_LINE_UP, action);
-
- action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.MoveLinesDown.", this, false, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.MOVE_LINES_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.MOVE_LINES_DOWN);
- setAction(ITextEditorActionConstants.MOVE_LINE_DOWN, action);
-
- action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.CopyLineUp.", this, true, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_UP);
- setAction(ITextEditorActionConstants.COPY_LINE_UP, action);
-
- action = new MoveLinesAction(EditorMessages.getResourceBundle(), "Editor.CopyLineDown.", this, false, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.COPY_LINES_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.COPY_LINES_DOWN);
- setAction(ITextEditorActionConstants.COPY_LINE_DOWN, action);
-
- action = new CaseAction(EditorMessages.getResourceBundle(), "Editor.UpperCase.", this, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.UPPER_CASE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.UPPER_CASE);
- setAction(ITextEditorActionConstants.UPPER_CASE, action);
-
- action = new CaseAction(EditorMessages.getResourceBundle(), "Editor.LowerCase.", this, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.LOWER_CASE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.LOWER_CASE);
- setAction(ITextEditorActionConstants.LOWER_CASE, action);
-
- action = new InsertLineAction(EditorMessages.getResourceBundle(), "Editor.SmartEnter.", this, false); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER);
- setAction(ITextEditorActionConstants.SMART_ENTER, action);
-
- action = new InsertLineAction(EditorMessages.getResourceBundle(), "Editor.SmartEnterInverse.", this, true); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.SMART_ENTER_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.SMART_ENTER_INVERSE);
- setAction(ITextEditorActionConstants.SMART_ENTER_INVERSE, action);
-
- action = new ToggleInsertModeAction(EditorMessages.getResourceBundle(), "Editor.ToggleInsertMode."); //$NON-NLS-1$
- action.setHelpContextId(IAbstractTextEditorHelpContextIds.TOGGLE_INSERT_MODE_ACTION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
- setAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE, action);
-
- markAsContentDependentAction(ITextEditorActionConstants.UNDO, true);
- markAsContentDependentAction(ITextEditorActionConstants.REDO, true);
- markAsContentDependentAction(ITextEditorActionConstants.FIND, true);
- markAsContentDependentAction(ITextEditorActionConstants.FIND_NEXT, true);
- markAsContentDependentAction(ITextEditorActionConstants.FIND_PREVIOUS, true);
- markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL, true);
- markAsContentDependentAction(ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE, true);
-
- markAsSelectionDependentAction(ITextEditorActionConstants.CUT, true);
- markAsSelectionDependentAction(ITextEditorActionConstants.COPY, true);
- markAsSelectionDependentAction(ITextEditorActionConstants.PASTE, true);
- markAsSelectionDependentAction(ITextEditorActionConstants.DELETE, true);
- markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true);
- markAsSelectionDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true);
- markAsSelectionDependentAction(ITextEditorActionConstants.UPPER_CASE, true);
- markAsSelectionDependentAction(ITextEditorActionConstants.LOWER_CASE, true);
-
- markAsPropertyDependentAction(ITextEditorActionConstants.UNDO, true);
- markAsPropertyDependentAction(ITextEditorActionConstants.REDO, true);
- markAsPropertyDependentAction(ITextEditorActionConstants.REVERT_TO_SAVED, true);
-
- markAsStateDependentAction(ITextEditorActionConstants.UNDO, true);
- markAsStateDependentAction(ITextEditorActionConstants.REDO, true);
- markAsStateDependentAction(ITextEditorActionConstants.CUT, true);
- markAsStateDependentAction(ITextEditorActionConstants.PASTE, true);
- markAsStateDependentAction(ITextEditorActionConstants.DELETE, true);
- markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT, true);
- markAsStateDependentAction(ITextEditorActionConstants.SHIFT_RIGHT_TAB, true);
- markAsStateDependentAction(ITextEditorActionConstants.SHIFT_LEFT, true);
- markAsStateDependentAction(ITextEditorActionConstants.FIND, true);
- markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE, true);
- markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_BEGINNING, true);
- markAsStateDependentAction(ITextEditorActionConstants.DELETE_LINE_TO_END, true);
- markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_UP, true);
- markAsStateDependentAction(ITextEditorActionConstants.MOVE_LINE_DOWN, true);
- markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE, true);
- markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_BEGINNING, true);
- markAsStateDependentAction(ITextEditorActionConstants.CUT_LINE_TO_END, true);
-
- setActionActivationCode(ITextEditorActionConstants.SHIFT_RIGHT_TAB,'\t', -1, SWT.NONE);
- setActionActivationCode(ITextEditorActionConstants.SHIFT_LEFT, '\t', -1, SWT.SHIFT);
- }
-
- /**
- * Convenience method to add the action installed under the given action id to the given menu.
- * @param menu the menu to add the action to
- * @param actionId the id of the action to be added
- */
- protected final void addAction(IMenuManager menu, String actionId) {
- IAction action= getAction(actionId);
- if (action != null) {
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
- menu.add(action);
- }
- }
-
- /**
- * Convenience method to add the action installed under the given action id to the specified group of the menu.
- * @param menu the menu to add the action to
- * @param group the group in the menu
- * @param actionId the id of the action to add
- */
- protected final void addAction(IMenuManager menu, String group, String actionId) {
- IAction action= getAction(actionId);
- if (action != null) {
- if (action instanceof IUpdate)
- ((IUpdate) action).update();
-
- IMenuManager subMenu= menu.findMenuUsingPath(group);
- if (subMenu != null)
- subMenu.add(action);
- else
- menu.appendToGroup(group, action);
- }
- }
-
- /**
- * Convenience method to add a new group after the specified group.
- * @param menu the menu to add the new group to
- * @param existingGroup the group after which to insert the new group
- * @param newGroup the new group
- */
- protected final void addGroup(IMenuManager menu, String existingGroup, String newGroup) {
- IMenuManager subMenu= menu.findMenuUsingPath(existingGroup);
- if (subMenu != null)
- subMenu.add(new Separator(newGroup));
- else
- menu.appendToGroup(existingGroup, new Separator(newGroup));
- }
-
- /**
- * Sets up the ruler context menu before it is made visible.
- * <p>
- * Subclasses may extend to add other actions.</p>
- *
- * @param menu the menu
- */
- protected void rulerContextMenuAboutToShow(IMenuManager menu) {
-
- menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
- menu.add(new Separator(ITextEditorActionConstants.MB_ADDITIONS));
-
- for (Iterator i = fRulerContextMenuListeners.iterator(); i.hasNext();)
- ((IMenuListener) i.next()).menuAboutToShow(menu);
-
- addAction(menu, ITextEditorActionConstants.RULER_MANAGE_BOOKMARKS);
- addAction(menu, ITextEditorActionConstants.RULER_MANAGE_TASKS);
- }
-
- /**
- * Sets up this editor's context menu before it is made visible.
- * <p>
- * Subclasses may extend to add other actions.</p>
- *
- * @param menu the menu
- */
- protected void editorContextMenuAboutToShow(IMenuManager menu) {
-
- menu.add(new Separator(ITextEditorActionConstants.GROUP_UNDO));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_COPY));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_PRINT));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_EDIT));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_FIND));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_ADD));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
- menu.add(new Separator(ITextEditorActionConstants.MB_ADDITIONS));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_SAVE));
-
- if (isEditable()) {
- addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.UNDO);
- addAction(menu, ITextEditorActionConstants.GROUP_UNDO, ITextEditorActionConstants.REVERT_TO_SAVED);
- addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.CUT);
- addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
- addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.PASTE);
- addAction(menu, ITextEditorActionConstants.GROUP_SAVE, ITextEditorActionConstants.SAVE);
- } else {
- addAction(menu, ITextEditorActionConstants.GROUP_COPY, ITextEditorActionConstants.COPY);
- }
- }
-
- /**
- * Returns the status line manager of this editor.
- * @return the status line manager of this editor
- * @since 2.0
- */
- private IStatusLineManager getStatusLineManager() {
-
- IEditorActionBarContributor contributor= getEditorSite().getActionBarContributor();
- if (!(contributor instanceof EditorActionBarContributor))
- return null;
-
- IActionBars actionBars= ((EditorActionBarContributor) contributor).getActionBars();
- if (actionBars == null)
- return null;
-
- return actionBars.getStatusLineManager();
- }
-
- /*
- * @see IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class required) {
-
- if (IEditorStatusLine.class.equals(required)) {
- if (fEditorStatusLine == null) {
- IStatusLineManager statusLineManager= getStatusLineManager();
- ISelectionProvider selectionProvider= getSelectionProvider();
- if (statusLineManager != null && selectionProvider != null)
- fEditorStatusLine= new EditorStatusLine(statusLineManager, selectionProvider);
- }
- return fEditorStatusLine;
- }
-
- if (IVerticalRulerInfo.class.equals(required)) {
- if (fVerticalRuler != null)
- return fVerticalRuler;
- }
-
- if (IMarkRegionTarget.class.equals(required)) {
- if (fMarkRegionTarget == null) {
- IStatusLineManager manager= getStatusLineManager();
- if (manager != null)
- fMarkRegionTarget= (fSourceViewer == null ? null : new MarkRegionTarget(fSourceViewer, manager));
- }
- return fMarkRegionTarget;
- }
-
- if (DeleteLineTarget.class.equals(required)){
- if (fDeleteLineTarget == null) {
- fDeleteLineTarget = new DeleteLineTarget(fSourceViewer);
- }
- return fDeleteLineTarget;
- }
-
- if (IncrementalFindTarget.class.equals(required)) {
- if (fIncrementalFindTarget == null) {
- IStatusLineManager manager= getStatusLineManager();
- if (manager != null)
- fIncrementalFindTarget= (fSourceViewer == null ? null : new IncrementalFindTarget(fSourceViewer, manager));
- }
- return fIncrementalFindTarget;
- }
-
- if (IFindReplaceTarget.class.equals(required)) {
- if (fFindReplaceTarget == null) {
- IFindReplaceTarget target= (fSourceViewer == null ? null : fSourceViewer.getFindReplaceTarget());
- if (target != null) {
- fFindReplaceTarget= new FindReplaceTarget(this, target);
- if (fFindScopeHighlightColor != null)
- fFindReplaceTarget.setScopeHighlightColor(fFindScopeHighlightColor);
- }
- }
- return fFindReplaceTarget;
- }
-
- if (ITextOperationTarget.class.equals(required))
- return (fSourceViewer == null ? null : fSourceViewer.getTextOperationTarget());
-
- if (IRewriteTarget.class.equals(required)) {
- if (fSourceViewer instanceof ITextViewerExtension) {
- ITextViewerExtension extension= (ITextViewerExtension) fSourceViewer;
- return extension.getRewriteTarget();
- }
- return null;
- }
-
- if (Control.class.equals(required))
- return fSourceViewer != null ? fSourceViewer.getTextWidget() : null;
-
- return super.getAdapter(required);
- }
-
- /*
- * @see IWorkbenchPart#setFocus()
- */
- public void setFocus() {
- if (fSourceViewer != null && fSourceViewer.getTextWidget() != null)
- fSourceViewer.getTextWidget().setFocus();
- }
-
- /*
- * @see ITextEditor#showsHighlightRangeOnly()
- */
- public boolean showsHighlightRangeOnly() {
- return fShowHighlightRangeOnly;
- }
-
- /*
- * @see ITextEditor#showHighlightRangeOnly(boolean)
- */
- public void showHighlightRangeOnly(boolean showHighlightRangeOnly) {
- fShowHighlightRangeOnly= showHighlightRangeOnly;
- }
-
- /*
- * @see ITextEditor#setHighlightRange(int, int, boolean)
- */
- public void setHighlightRange(int offset, int length, boolean moveCursor) {
- if (fSourceViewer == null)
- return;
-
- if (fShowHighlightRangeOnly) {
- if (moveCursor)
- fSourceViewer.setVisibleRegion(offset, length);
- } else {
- IRegion rangeIndication= fSourceViewer.getRangeIndication();
- if (rangeIndication == null || offset != rangeIndication.getOffset() || length != rangeIndication.getLength())
- fSourceViewer.setRangeIndication(offset, length, moveCursor);
- }
- }
-
- /*
- * @see ITextEditor#getHighlightRange()
- */
- public IRegion getHighlightRange() {
- if (fSourceViewer == null)
- return null;
-
- if (fShowHighlightRangeOnly)
- return getCoverage(fSourceViewer);
-
- return fSourceViewer.getRangeIndication();
- }
-
- /*
- * @see ITextEditor#resetHighlightRange
- */
- public void resetHighlightRange() {
- if (fSourceViewer == null)
- return;
-
- if (fShowHighlightRangeOnly)
- fSourceViewer.resetVisibleRegion();
- else
- fSourceViewer.removeRangeIndication();
- }
-
- /**
- * Adjusts the highlight range so that at least the specified range
- * is highlighted.
- * <p>
- * Subclasses may re-implement this method.</p>
- *
- * @param offset the offset of the range which at least should be highlighted
- * @param length the length of the range which at least should be highlighted
- */
- protected void adjustHighlightRange(int offset, int length) {
- if (fSourceViewer == null)
- return;
-
- if (fSourceViewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) fSourceViewer;
- extension.exposeModelRange(new Region(offset, length));
- } else if (!isVisible(fSourceViewer, offset, length)) {
- fSourceViewer.resetVisibleRegion();
- }
- }
-
- /*
- * @see ITextEditor#selectAndReveal(int, int)
- */
- public void selectAndReveal(int start, int length) {
- selectAndReveal(start, length, start, length);
- }
-
- /**
- * Selects and reveals the specified ranges in this text editor.
- *
- * @param selectionStart the offset of the selection
- * @param selectionLength the length of the selection
- * @param revealStart the offset of the revealed range
- * @param revealLength the length of the revealed range
- * @since 3.0
- */
- protected void selectAndReveal(int selectionStart, int selectionLength, int revealStart, int revealLength) {
- if (fSourceViewer == null)
- return;
-
- ISelection selection= getSelectionProvider().getSelection();
- if (selection instanceof TextSelection) {
- TextSelection textSelection= (TextSelection) selection;
- if (textSelection.getOffset() != 0 || textSelection.getLength() != 0)
- markInNavigationHistory();
- }
-
- StyledText widget= fSourceViewer.getTextWidget();
- widget.setRedraw(false);
- {
- adjustHighlightRange(revealStart, revealLength);
- fSourceViewer.revealRange(revealStart, revealLength);
-
- fSourceViewer.setSelectedRange(selectionStart, selectionLength);
-
- markInNavigationHistory();
- }
- widget.setRedraw(true);
- }
-
- /*
- * @see org.eclipse.ui.INavigationLocationProvider#createNavigationLocation()
- * @since 2.1
- */
- public INavigationLocation createEmptyNavigationLocation() {
- return new TextSelectionNavigationLocation(this, false);
- }
-
- /*
- * @see org.eclipse.ui.INavigationLocationProvider#createNavigationLocation()
- */
- public INavigationLocation createNavigationLocation() {
- return new TextSelectionNavigationLocation(this, true);
- }
-
- /**
- * Writes a check mark of the given situation into the navigation history.
- * @since 2.1
- */
- protected void markInNavigationHistory() {
- IWorkbenchPage page= getEditorSite().getPage();
- page.getNavigationHistory().markLocation(this);
- }
-
- /**
- * Hook which gets called when the editor has been saved.
- * Subclasses may extend.
- * @since 2.1
- */
- protected void editorSaved() {
- IWorkbenchPage page= getEditorSite().getPage();
- INavigationLocation[] locations= page.getNavigationHistory().getLocations();
- IEditorInput input= getEditorInput();
- for (int i= 0; i < locations.length; i++) {
- if (locations[i] instanceof TextSelectionNavigationLocation) {
- if(input.equals(locations[i].getInput())) {
- TextSelectionNavigationLocation location= (TextSelectionNavigationLocation) locations[i];
- location.partSaved(this);
- }
- }
- }
- }
-
- /*
- * @see WorkbenchPart#firePropertyChange(int)
- */
- protected void firePropertyChange(int property) {
- super.firePropertyChange(property);
- updatePropertyDependentActions();
- }
-
- /*
- * @see ITextEditorExtension#setStatusField(IStatusField, String)
- * @since 2.0
- */
- public void setStatusField(IStatusField field, String category) {
- Assert.isNotNull(category);
- if (field != null) {
-
- if (fStatusFields == null)
- fStatusFields= new HashMap(3);
-
- fStatusFields.put(category, field);
- updateStatusField(category);
-
- } else if (fStatusFields != null)
- fStatusFields.remove(category);
-
- if (fIncrementalFindTarget != null && ITextEditorActionConstants.STATUS_CATEGORY_FIND_FIELD.equals(category))
- fIncrementalFindTarget.setStatusField(field);
- }
-
- /**
- * Returns the current status field for the given status category.
- *
- * @param category the status category
- * @return the current status field for the given status category
- * @since 2.0
- */
- protected IStatusField getStatusField(String category) {
- if (category != null && fStatusFields != null)
- return (IStatusField) fStatusFields.get(category);
- return null;
- }
-
- /**
- * Returns whether this editor is in overwrite or insert mode.
- *
- * @return <code>true</code> if in insert mode, <code>false</code> for overwrite mode
- * @since 2.0
- */
- protected boolean isInInsertMode() {
- return !fIsOverwriting;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.ITextEditorExtension3#getInsertMode()
- * @since 3.0
- */
- public InsertMode getInsertMode() {
- return fInsertMode;
- }
-
- /*
- * @see org.eclipse.ui.texteditor.ITextEditorExtension3#setInsertMode(org.eclipse.ui.texteditor.ITextEditorExtension3.InsertMode)
- * @since 3.0
- */
- public void setInsertMode(InsertMode newMode) {
- List legalModes= getLegalInsertModes();
- if (!legalModes.contains(newMode))
- throw new IllegalArgumentException();
-
- fInsertMode= newMode;
-
- handleInsertModeChanged();
- }
-
- /**
- * Returns the set of legal insert modes. If insert modes are configured all defined insert modes
- * are legal.
- *
- * @return the set of legal insert modes
- * @since 3.0
- */
- protected List getLegalInsertModes() {
- if (fLegalInsertModes == null) {
- fLegalInsertModes= new ArrayList();
- fLegalInsertModes.add(SMART_INSERT);
- fLegalInsertModes.add(INSERT);
- }
- return fLegalInsertModes;
- }
-
- private void switchToNextInsertMode() {
-
- InsertMode mode= getInsertMode();
- List legalModes= getLegalInsertModes();
-
- int i= 0;
- while (i < legalModes.size()) {
- if (legalModes.get(i) == mode) break;
- ++ i;
- }
-
- i= (i + 1) % legalModes.size();
- InsertMode newMode= (InsertMode) legalModes.get(i);
- setInsertMode(newMode);
- }
-
- private void toggleOverwriteMode() {
- if (fIsOverwriteModeEnabled) {
- fIsOverwriting= !fIsOverwriting;
- fSourceViewer.getTextWidget().invokeAction(ST.TOGGLE_OVERWRITE);
- handleInsertModeChanged();
- }
- }
-
- /**
- * Configures the given insert mode as legal or illegal. This call is ignored if the set of legal
- * input modes would be empty after the call.
- *
- * @param mode the insert mode to be configured
- * @param legal <code>true</code> if the given mode is legal, <code>false</code> otherwise
- * @since 3.0
- */
- protected void configureInsertMode(InsertMode mode, boolean legal) {
- List legalModes= getLegalInsertModes();
- if (legal) {
- if (!legalModes.contains(mode))
- legalModes.add(mode);
- } else if (legalModes.size() > 1) {
- if (getInsertMode() == mode)
- switchToNextInsertMode();
- legalModes.remove(mode);
- }
- }
-
- /**
- * Sets the overwrite mode enablement.
- *
- * @param enable <code>true</code> to enable new overwrite mode,
- * <code>false</code> to disable
- * @since 3.0
- */
- protected void enableOverwriteMode(boolean enable) {
- if (fIsOverwriting && !enable)
- toggleOverwriteMode();
- fIsOverwriteModeEnabled= enable;
- }
-
- private Caret createOverwriteCaret(StyledText styledText) {
- Caret caret= new Caret(styledText, SWT.NULL);
- GC gc= new GC(styledText);
- // XXX this overwrite box is not proportional-font aware
- // take 'a' as a medium sized character
- Point charSize= gc.stringExtent("a"); //$NON-NLS-1$
- caret.setSize(charSize.x, styledText.getLineHeight());
- gc.dispose();
-
- return caret;
- }
-
- private Caret createInsertCaret(StyledText styledText) {
- Caret caret= new Caret(styledText, SWT.NULL);
- caret.setSize(getCaretWidthPreference(), styledText.getLineHeight());
- return caret;
- }
-
- private Image createRawInsertModeCaretImage(StyledText styledText) {
-
- PaletteData caretPalette= new PaletteData(new RGB[] {new RGB (0,0,0), new RGB (255,255,255)});
- int width= getCaretWidthPreference();
- int widthOffset= width - 1;
- ImageData imageData = new ImageData(4 + widthOffset, styledText.getLineHeight(), 1, caretPalette);
- Display display = styledText.getDisplay();
- Image bracketImage= new Image(display, imageData);
- GC gc = new GC (bracketImage);
- gc.setForeground(display.getSystemColor(SWT.COLOR_WHITE));
- gc.setLineWidth(1);
- int height= imageData.height / 3;
- // gap between two bars of one third of the height
- // draw boxes using lines as drawing a line of a certain width produces
- // rounded corners.
- for (int i= 0; i < width ; i++) {
- gc.drawLine(i, 0, i, height - 1);
- gc.drawLine(i, imageData.height - height, i, imageData.height - 1);
- }
-
- gc.dispose();
-
- return bracketImage;
- }
-
- private Caret createRawInsertModeCaret(StyledText styledText) {
- // don't draw special raw caret if no smart mode is enabled
- if (!getLegalInsertModes().contains(SMART_INSERT))
- return createInsertCaret(styledText);
-
- Caret caret= new Caret(styledText, SWT.NULL);
- Image image= createRawInsertModeCaretImage(styledText);
- if (image != null)
- caret.setImage(image);
- else
- caret.setSize(getCaretWidthPreference(), styledText.getLineHeight());
-
- return caret;
- }
-
- private int getCaretWidthPreference() {
- if (getPreferenceStore() != null && getPreferenceStore().getBoolean(PREFERENCE_WIDE_CARET))
- return WIDE_CARET_WIDTH;
-
- return SINGLE_CARET_WIDTH;
- }
-
- private void updateCaret() {
-
- if (getSourceViewer() == null)
- return;
-
- StyledText styledText= getSourceViewer().getTextWidget();
-
- InsertMode mode= getInsertMode();
-
- styledText.setCaret(null);
- disposeNonDefaultCaret();
-
- if (getPreferenceStore() == null || !getPreferenceStore().getBoolean(PREFERENCE_USE_CUSTOM_CARETS))
- Assert.isTrue(fNonDefaultCaret == null);
- else if (fIsOverwriting)
- fNonDefaultCaret= createOverwriteCaret(styledText);
- else if (SMART_INSERT == mode)
- fNonDefaultCaret= createInsertCaret(styledText);
- else if (INSERT == mode)
- fNonDefaultCaret= createRawInsertModeCaret(styledText);
-
- if (fNonDefaultCaret != null) {
- styledText.setCaret(fNonDefaultCaret);
- fNonDefaultCaretImage= fNonDefaultCaret.getImage();
- } else if (fInitialCaret != styledText.getCaret())
- styledText.setCaret(fInitialCaret);
- }
-
- private void disposeNonDefaultCaret() {
- if (fNonDefaultCaretImage != null) {
- fNonDefaultCaretImage.dispose();
- fNonDefaultCaretImage= null;
- }
-
- if (fNonDefaultCaret != null) {
- fNonDefaultCaret.dispose();
- fNonDefaultCaret= null;
- }
- }
-
- /**
- * Handles a change of the editor's insert mode.
- * Subclasses may extend.
- *
- * @since 2.0
- */
- protected void handleInsertModeChanged() {
- updateInsertModeAction();
- updateCaret();
- updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE);
- }
-
- private void updateInsertModeAction() {
-
- // this may be called before the part is fully initialized (see configureInsertMode)
- // drop out in this case.
- if (getSite() == null)
- return;
-
- IAction action= getAction(ITextEditorActionConstants.TOGGLE_INSERT_MODE);
- if (action != null) {
- action.setEnabled(!fIsOverwriting);
- action.setChecked(fInsertMode == SMART_INSERT);
- }
- }
-
- /**
- * Handles a potential change of the cursor position.
- * Subclasses may extend.
- *
- * @since 2.0
- */
- protected void handleCursorPositionChanged() {
- updateStatusField(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION);
- }
-
- /**
- * Updates the status fields for the given category.
- *
- * @param category
- * @since 2.0
- */
- protected void updateStatusField(String category) {
-
- if (category == null)
- return;
-
- IStatusField field= getStatusField(category);
- if (field != null) {
-
- String text= null;
-
- if (ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION.equals(category))
- text= getCursorPosition();
- else if (ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE.equals(category))
- text= isEditorInputReadOnly() ? fReadOnlyLabel : fWritableLabel;
- else if (ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE.equals(category)) {
- InsertMode mode= getInsertMode();
- if (fIsOverwriting)
- text= fOverwriteModeLabel;
- else if (INSERT == mode)
- text= fInsertModeLabel;
- else if (SMART_INSERT == mode)
- text= fSmartInsertModeLabel;
- }
-
- field.setText(text == null ? fErrorLabel : text);
- }
- }
-
- /**
- * Updates all status fields.
- *
- * @since 2.0
- */
- protected void updateStatusFields() {
- if (fStatusFields != null) {
- Iterator e= fStatusFields.keySet().iterator();
- while (e.hasNext())
- updateStatusField((String) e.next());
- }
- }
-
- /**
- * Returns a description of the cursor position.
- *
- * @return a description of the cursor position
- * @since 2.0
- */
- protected String getCursorPosition() {
-
- if (fSourceViewer == null)
- return fErrorLabel;
-
- StyledText styledText= fSourceViewer.getTextWidget();
- int caret= widgetOffset2ModelOffset(fSourceViewer, styledText.getCaretOffset());
- IDocument document= fSourceViewer.getDocument();
-
- if (document == null)
- return fErrorLabel;
-
- try {
-
- int line= document.getLineOfOffset(caret);
-
- int lineOffset= document.getLineOffset(line);
- int tabWidth= styledText.getTabs();
- int column= 0;
- for (int i= lineOffset; i < caret; i++)
- if ('\t' == document.getChar(i))
- column += tabWidth - (tabWidth == 0 ? 0 : column % tabWidth);
- else
- column++;
-
- fLineLabel.fValue= line + 1;
- fColumnLabel.fValue= column + 1;
- return MessageFormat.format(fPositionLabelPattern, fPositionLabelPatternArguments);
-
- } catch (BadLocationException x) {
- return fErrorLabel;
- }
- }
-
- /*
- * @see ITextEditorExtension#isEditorInputReadOnly()
- * @since 2.0
- */
- public boolean isEditorInputReadOnly() {
- IDocumentProvider provider= getDocumentProvider();
- if (provider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
- return extension.isReadOnly(getEditorInput());
- }
- return true;
- }
-
- /*
- * @see ITextEditorExtension2#isEditorInputModifiable()
- * @since 2.1
- */
- public boolean isEditorInputModifiable() {
- IDocumentProvider provider= getDocumentProvider();
- if (provider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension= (IDocumentProviderExtension) provider;
- return extension.isModifiable(getEditorInput());
- }
- return true;
- }
-
- /*
- * @see ITextEditorExtension#addRulerContextMenuListener(IMenuListener)
- * @since 2.0
- */
- public void addRulerContextMenuListener(IMenuListener listener) {
- fRulerContextMenuListeners.add(listener);
- }
-
- /*
- * @see ITextEditorExtension#removeRulerContextMenuListener(IMenuListener)
- * @since 2.0
- */
- public void removeRulerContextMenuListener(IMenuListener listener) {
- fRulerContextMenuListeners.remove(listener);
- }
-
- /**
- * Returns whether this editor can handle the move of the original element
- * so that it ends up being the moved element. By default this method
- * returns <code>true</code>. Subclasses may reimplement.
- *
- * @param originalElement the original element
- * @param movedElement the moved element
- * @return whether this editor can handle the move of the original element
- * so that it ends up being the moved element
- * @since 2.0
- */
- protected boolean canHandleMove(IEditorInput originalElement, IEditorInput movedElement) {
- return true;
- }
-
- /**
- * Returns the offset of the given source viewer's document that corresponds
- * to the given widget offset or <code>-1</code> if there is no such offset.
- *
- * @param viewer the source viewer
- * @param widgetOffset the widget offset
- * @return the corresponding offset in the source viewer's document or <code>-1</code>
- * @since 2.1
- */
- protected final static int widgetOffset2ModelOffset(ISourceViewer viewer, int widgetOffset) {
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- return extension.widgetOffset2ModelOffset(widgetOffset);
- }
- return widgetOffset + viewer.getVisibleRegion().getOffset();
- }
-
- /**
- * Returns the offset of the given source viewer's text widget that corresponds
- * to the given model offset or <code>-1</code> if there is no such offset.
- *
- * @param viewer the source viewer
- * @param modelOffset the model offset
- * @return the corresponding offset in the source viewer's text widget or <code>-1</code>
- * @since 3.0
- */
- protected final static int modelOffset2WidgetOffset(ISourceViewer viewer, int modelOffset) {
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- return extension.modelOffset2WidgetOffset(modelOffset);
- }
- return modelOffset - viewer.getVisibleRegion().getOffset();
- }
-
- /**
- * Returns the minimal region of the given source viewer's document that completely
- * comprises everything that is visible in the viewer's widget.
- *
- * @param viewer the viewer go return the coverage for
- * @return the minimal region of the source viewer's document comprising the contents of the viewer's widget
- * @since 2.1
- */
- protected final static IRegion getCoverage(ISourceViewer viewer) {
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- return extension.getModelCoverage();
- }
- return viewer.getVisibleRegion();
- }
-
- /**
- * Tells whether the given region is visible in the given source viewer.
- *
- * @param viewer the source viewer
- * @param offset the offset of the region
- * @param length the length of the region
- * @return <code>true</code> if visible
- * @since 2.1
- */
- protected final static boolean isVisible(ISourceViewer viewer, int offset, int length) {
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer;
- IRegion overlap= extension.modelRange2WidgetRange(new Region(offset, length));
- return overlap != null;
- }
- return viewer.overlapsWithVisibleRegion(offset, length);
- }
-
- /*
- * @see org.eclipse.ui.texteditor.ITextEditorExtension3#showChangeInformation(boolean)
- * @since 3.0
- */
- public void showChangeInformation(boolean show) {
- // do nothing
- }
-
- /*
- * @see org.eclipse.ui.texteditor.ITextEditorExtension3#isChangeInformationShowing()
- * @since 3.0
- */
- public boolean isChangeInformationShowing() {
- return false;
- }
-} \ No newline at end of file
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
deleted file mode 100644
index 2f9339919..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/AnnotationPreference.java
+++ /dev/null
@@ -1,1058 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.texteditor;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.osgi.framework.Bundle;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-
-import org.eclipse.swt.graphics.RGB;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-
-import org.eclipse.ui.internal.texteditor.TextEditorPlugin;
-
-
-/**
- * An annotation preference provides all the information required for handing
- * the preferences for the presentation of annotations of a specified type. The
- * type can be changed and retrieved using the <code>getAnnotationType</code>
- * and <code>setAnnotationType</code> methods. For each preference, getter and
- * setter methods are provided.
- * <p>
- * Preferences that may be changed by the user also have a corresponding key
- * that can be used to obtain the currently set value from an
- * <code>IPreferenceStore</code>.
- * </p>
- * <h3>The following annotation preferences are covered:</h4>
- * <h4>Display Preferences controlling how and where annotations are shown</h4>
- * <ul>
- * <li>as text background highlighting (and respective preference key),</li>
- * <li>as text decorations (and respective preference key),</li>
- * <li>on the overview ruler (and respective preference key),</li>
- * <li>on the overview ruler header,</li>
- * <li>on the vertical ruler (and respective preference key),</li>
- * </li>
- * </ul>
- * <h4>Additional Display Preferences</h4>
- * <ul>
- * <li>the base color for annotations of this type (and respective preference key),
- * <li>the style of text decorations that are drawn (and respective preference
- * key),</li>
- * <li>the annotation image provider,</li>
- * <li>the image descriptor,</li>
- * <li>the symbolic image name,</li>
- * <li>the presentation layer.</li>
- * </ul>
- * <h4>Navigation Preferences</h4>
- * <ul>
- * <li>whether included in the "Go to Next Annotation" navigation action (and
- * respective preference key),</li>
- * <li>whether included in the "Go to Previous Annotation" navigation action
- * (and respective preference key),</li>
- * <li>whether to be shown in the "Go to Next/Previous Annotation" navigation
- * toolbar dropdown (and respective preference key).</li>
- * </ul>
- * <h4>Preference Page Preferences</h4>
- * <ul>
- * <li>whether the annotation type should be included on the generic annotation
- * preference page,</li>
- * <li>preference label.</li>
- * </ul>
- *
- * @since 2.1
- */
-public class AnnotationPreference {
-
- /* String constants for style enumeration */
-
- /**
- * Constant defining no decoration for the show in text style preference.
- * @since 3.0
- */
- public static final String STYLE_NONE= "NONE"; //$NON-NLS-1$
- /**
- * Constant defining squiggly decoration for the show in text style preference.
- * @since 3.0
- */
- public static final String STYLE_SQUIGGLES= "SQUIGGLES"; //$NON-NLS-1$
- /**
- * Constant defining box decoration for the show in text style preference.
- * @since 3.0
- */
- public static final String STYLE_BOX= "BOX"; //$NON-NLS-1$
- /**
- * Constant defining underline decoration for the show in text style preference.
- * @since 3.0
- */
- public static final String STYLE_UNDERLINE= "UNDERLINE"; //$NON-NLS-1$
- /**
- * Constant defining i-beam decoration for the show in text style preference.
- * @since 3.0
- */
- public static final String STYLE_IBEAM= "IBEAM"; //$NON-NLS-1$
-
- /* IDs for presentation preference attributes */
-
- /**
- * The image to be used for drawing in the vertical ruler.
- * @since 3.0
- */
- protected final static Object IMAGE_DESCRIPTOR= new Object();
- /**
- * The preference label.
- * @since 3.0
- */
- protected final static Object PREFERENCE_LABEL= new Object();
- /**
- * The presentation layer.
- * @since 3.0
- */
- protected final static Object PRESENTATION_LAYER= new Object();
- /**
- * The symbolic name of the image to be drawn in the vertical ruler.
- * @since 3.0
- */
- protected final static Object SYMBOLIC_IMAGE_NAME= new Object();
- /**
- * Indicates whether the annotation type contributed to the overview ruler's header.
- * @since 3.0
- */
- protected final static Object HEADER_VALUE= new Object();
- /**
- * The annotation image provider.
- * @since 3.0
- */
- protected final static Object IMAGE_PROVIDER= new Object();
- /**
- * The value for the includeOnPreferencePage property.
- * @since 3.0
- */
- protected final static Object INCLUDE_ON_PREFERENCE_PAGE= new Object();
-
- /* IDs for preference store access and initialization */
-
- /**
- * The preference key for the visibility inside text.
- * @since 3.0
- */
- protected final static Object TEXT_PREFERENCE_KEY= new Object();
- /**
- * The visibility inside text.
- * @since 3.0
- */
- protected final static Object TEXT_PREFERENCE_VALUE= new Object();
- /**
- * The preference key for the presentation color.
- * @since 3.0
- */
- protected final static Object COLOR_PREFERENCE_KEY= new Object();
- /** The presentation color.
- * @since 3.0
- */
- protected final static Object COLOR_PREFERENCE_VALUE= new Object();
- /**
- * The preference key for highlighting inside text.
- * @since 3.0
- */
- protected final static Object HIGHLIGHT_PREFERENCE_KEY= new Object();
- /**
- * The value for highlighting inside text.
- * @since 3.0
- */
- protected final static Object HIGHLIGHT_PREFERENCE_VALUE= new Object();
- /**
- * The preference key for go to next navigation enablement.
- * @since 3.0
- */
- protected final static Object IS_GO_TO_NEXT_TARGET_KEY= new Object();
- /**
- * The value for go to next navigation enablement.
- * @since 3.0
- */
- protected final static Object IS_GO_TO_NEXT_TARGET_VALUE= new Object();
- /**
- * The preference key for go to previous navigation enablement.
- * @since 3.0
- */
- protected final static Object IS_GO_TO_PREVIOUS_TARGET_KEY= new Object();
- /**
- * The value for go to previous navigation enablement.
- * @since 3.0
- */
- protected final static Object IS_GO_TO_PREVIOUS_TARGET_VALUE= new Object();
- /**
- * The preference key for the visibility in the vertical ruler.
- * @since 3.0
- */
- protected final static Object VERTICAL_RULER_PREFERENCE_KEY= new Object();
- /**
- * The visibility in the vertical ruler.
- * @since 3.0
- */
- protected final static Object VERTICAL_RULER_PREFERENCE_VALUE= new Object();
- /**
- * The preference key for the visibility in the overview ruler.
- * @since 3.0
- */
- protected final static Object OVERVIEW_RULER_PREFERENCE_KEY= new Object();
- /**
- * The visibility in the overview ruler.
- * @since 3.0
- */
- protected final static Object OVERVIEW_RULER_PREFERENCE_VALUE= new Object();
- /**
- * The preference key for the visibility in the next/previous drop down toolbar action.
- * @since 3.0
- */
- protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_KEY= new Object();
- /**
- * The value for the visibility in the next/previous drop down toolbar action.
- * @since 3.0
- */
- protected final static Object SHOW_IN_NAVIGATION_DROPDOWN_VALUE= new Object();
- /**
- * The preference key for the decoration style.
- * @since 3.0
- */
- protected final static Object TEXT_STYLE_PREFERENCE_KEY= new Object();
- /**
- * The value for the text decoration style.
- * @since 3.0
- */
- protected final static Object TEXT_STYLE_PREFERENCE_VALUE= new Object();
-
- /**
- * Array of all supported attributes.
- * @since 3.0
- */
- protected final static Object[] ATTRIBUTES= new Object[] {
- IMAGE_DESCRIPTOR,
- PREFERENCE_LABEL,
- PRESENTATION_LAYER,
- SYMBOLIC_IMAGE_NAME,
- HEADER_VALUE,
- IMAGE_PROVIDER,
- TEXT_PREFERENCE_KEY,
- TEXT_PREFERENCE_VALUE,
- COLOR_PREFERENCE_KEY,
- COLOR_PREFERENCE_VALUE,
- HIGHLIGHT_PREFERENCE_KEY,
- HIGHLIGHT_PREFERENCE_VALUE,
- IS_GO_TO_NEXT_TARGET_KEY,
- IS_GO_TO_NEXT_TARGET_VALUE,
- IS_GO_TO_PREVIOUS_TARGET_KEY,
- IS_GO_TO_PREVIOUS_TARGET_VALUE,
- VERTICAL_RULER_PREFERENCE_KEY,
- VERTICAL_RULER_PREFERENCE_VALUE,
- OVERVIEW_RULER_PREFERENCE_KEY,
- OVERVIEW_RULER_PREFERENCE_VALUE,
- SHOW_IN_NAVIGATION_DROPDOWN_KEY,
- SHOW_IN_NAVIGATION_DROPDOWN_VALUE,
- TEXT_STYLE_PREFERENCE_KEY,
- TEXT_STYLE_PREFERENCE_VALUE,
- INCLUDE_ON_PREFERENCE_PAGE
- };
-
- /** The annotation type */
- private Object fAnnotationType;
- /** The marker type */
- private String fMarkerType;
- /** The marker severity */
- private int fSeverity;
- /**
- * The annotation image provider.
- * @since 3.0
- */
- public IAnnotationImageProvider fAnnotationImageProvider;
- /**
- * The configuration element from which to create the annotation image provider.
- * @since 3.0
- */
- public IConfigurationElement fConfigurationElement;
- /**
- * The name of the attribute used to load the annotation image provider
- * from the configuration element.
- * @since 3.0
- */
- public String fAnnotationImageProviderAttribute;
- /**
- * The map of attributes.
- * @since 3.0
- */
- private Map fAttributes= new HashMap();
-
-
-
- /**
- * Creates a new uninitialized annotation preference. Note that instances
- * with a <code>null</code> annotation type are invalid and should not be
- * used.
- */
- public AnnotationPreference() {
- }
-
- /**
- * Creates a new annotation preference for the given annotation type.
- *
- * @param annotationType the annotation type
- * @param colorKey the preference key for the presentation color
- * @param textKey the preference key for the visibility inside text
- * @param overviewRulerKey the preference key for the visibility in the
- * overview ruler
- * @param presentationLayer the presentation layer
- */
- public AnnotationPreference(Object annotationType, String colorKey, String textKey, String overviewRulerKey, int presentationLayer) {
- fAnnotationType= annotationType;
- setValue(COLOR_PREFERENCE_KEY, colorKey);
- setValue(TEXT_PREFERENCE_KEY, textKey);
- setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey);
- setValue(PRESENTATION_LAYER, presentationLayer);
- }
-
- /**
- * Sets the given value for the given attribute.
- *
- * @param attribute the attribute
- * @param value the attribute value
- * @since 3.0
- */
- protected void setValue(Object attribute, Object value) {
- fAttributes.put(attribute, value);
- }
-
- /**
- * Sets the given value for the given attribute.
- *
- * @param attribute the attribute
- * @param value the attribute value
- * @since 3.0
- */
- protected void setValue(Object attribute, int value) {
- fAttributes.put(attribute, new Integer(value));
- }
-
- /**
- * Sets the given value for the given attribute.
- *
- * @param attribute the attribute
- * @param value the attribute value
- * @since 3.0
- */
- protected void setValue(Object attribute, boolean value) {
- fAttributes.put(attribute, value ? Boolean.TRUE : Boolean.FALSE);
- }
-
- /**
- * Returns the value of the given attribute as string.
- *
- * @param attribute the attribute
- * @return the attribute value
- * @since 3.0
- */
- protected String getStringValue(Object attribute) {
- Object value= fAttributes.get(attribute);
- if (value instanceof String)
- return (String) value;
- return null;
- }
-
- /**
- * Returns the value of the given attribute as boolean.
- *
- * @param attribute the attribute
- * @return the attribute value
- * @since 3.0
- */
- protected boolean getBooleanValue(Object attribute) {
- Object value= fAttributes.get(attribute);
- if (value instanceof Boolean)
- return ((Boolean) value).booleanValue();
- return false;
- }
-
- /**
- * Returns the value of the given attribute as integer.
- *
- * @param attribute the attribute
- * @return the attribute value
- * @since 3.0
- */
- protected int getIntegerValue(Object attribute) {
- Object value= fAttributes.get(attribute);
- if (value instanceof Integer)
- return ((Integer) value).intValue();
- return 0;
- }
-
- /**
- * Returns the value of the given attribute.
- *
- * @param attribute the attribute
- * @return the attribute value
- * @since 3.0
- */
- public Object getValue(Object attribute) {
- return fAttributes.get(attribute);
- }
-
- /**
- * Returns whether the given attribute is defined.
- *
- * @param attribute the attribute
- * @return <code>true</code> if the attribute has a value <code>false</code> otherwise
- * @since 3.0
- */
- public boolean hasValue(Object attribute) {
- return fAttributes.get(attribute) != null;
- }
-
- /**
- * Returns whether the given string is a preference key.
- *
- * @param key the string to test
- * @return <code>true</code> if the string is a preference key
- */
- public boolean isPreferenceKey(String key) {
- if (key == null)
- return false;
-
- return key.equals(getStringValue(COLOR_PREFERENCE_KEY)) ||
- key.equals(getStringValue(OVERVIEW_RULER_PREFERENCE_KEY)) ||
- key.equals(getStringValue(TEXT_PREFERENCE_KEY)) ||
- key.equals(getStringValue(HIGHLIGHT_PREFERENCE_KEY)) ||
- key.equals(getStringValue(TEXT_STYLE_PREFERENCE_KEY)) ||
- key.equals(getStringValue(VERTICAL_RULER_PREFERENCE_KEY));
- }
-
- /**
- * Returns the annotation type. Should not be null in a completely set up
- * instance.
- *
- * @return the annotation type, <code>null</code> if the receiver has not
- * been initialized yet
- */
- public Object getAnnotationType() {
- return fAnnotationType;
- }
-
- /**
- * Returns the marker type.
- *
- * @return the marker type, or <code>null</code> if none is set
- * @deprecated since 3.0
- */
- public String getMarkerType() {
- return fMarkerType;
- }
-
- /**
- * Returns the marker severity.
- *
- * @return the marker severity
- * @deprecated since 3.0
- */
- public int getSeverity() {
- return fSeverity;
- }
-
- /**
- * Sets the annotation type. Note that instances with a <code>null</code>
- * annotation type are considered invalid and should not be used with the
- * framework.
- *
- * @param annotationType the annotation type
- */
- public void setAnnotationType(Object annotationType) {
- fAnnotationType= annotationType;
- }
-
- /**
- * Sets the marker type.
- *
- * @param markerType the marker type
- */
- public void setMarkerType(String markerType) {
- fMarkerType= markerType;
- }
-
- /**
- * Sets the marker severity.
- *
- * @param severity the marker severity
- */
- public void setSeverity(int severity) {
- fSeverity= severity;
- }
-
- /**
- * Returns the preference key for the presentation color.
- *
- * @return the preference key for the presentation color or <code>null</code>
- * if none is set
- */
- public String getColorPreferenceKey() {
- return getStringValue(COLOR_PREFERENCE_KEY);
- }
-
- /**
- * Returns the default presentation color.
- *
- * @return the default presentation color or <code>null</code> if none is
- * set
- */
- public RGB getColorPreferenceValue() {
- return (RGB) getValue(COLOR_PREFERENCE_VALUE);
- }
-
- /**
- * Returns the presentation string for this annotation type.
- *
- * @return the presentation string for this annotation type or <code>null</code>
- * if none is set
- */
- public String getPreferenceLabel() {
- return getStringValue(PREFERENCE_LABEL);
- }
-
- /**
- * Returns the preference key for the visibility in the overview ruler.
- *
- * @return the preference key for the visibility in the overview ruler or
- * <code>null</code> if none is set
- */
- public String getOverviewRulerPreferenceKey() {
- return getStringValue(OVERVIEW_RULER_PREFERENCE_KEY);
- }
-
- /**
- * Returns the default visibility in the overview ruler.
- *
- * @return the default visibility in the overview ruler
- */
- public boolean getOverviewRulerPreferenceValue() {
- return getBooleanValue(OVERVIEW_RULER_PREFERENCE_VALUE);
- }
-
- /**
- * Returns the preference key for the visibility in the vertical ruler.
- *
- * @return the preference key for the visibility in the vertical ruler or
- * <code>null</code> if none is set
- * @since 3.0
- */
- public String getVerticalRulerPreferenceKey() {
- return getStringValue(VERTICAL_RULER_PREFERENCE_KEY);
- }
-
- /**
- * Returns the default visibility in the vertical ruler.
- *
- * @return the default visibility in the vertical ruler
- * @since 3.0
- */
- public boolean getVerticalRulerPreferenceValue() {
- return getBooleanValue(VERTICAL_RULER_PREFERENCE_VALUE);
- }
-
- /**
- * Returns the presentation layer.
- *
- * @return the presentation layer
- */
- public int getPresentationLayer() {
- return getIntegerValue(PRESENTATION_LAYER);
- }
-
- /**
- * Returns the preference key for the visibility inside text.
- *
- * @return the preference key for the visibility inside text or <code>null</code>
- * if none is set
- */
- public String getTextPreferenceKey() {
- return getStringValue(TEXT_PREFERENCE_KEY);
- }
-
- /**
- * Returns the default visibility inside text.
- *
- * @return the default visibility inside text
- */
- public boolean getTextPreferenceValue() {
- return getBooleanValue(TEXT_PREFERENCE_VALUE);
- }
-
- /**
- * Returns the preference key for highlighting inside text.
- *
- * @return the preference key for highlighting inside text or <code>null</code>
- * if none is set
- * @since 3.0
- */
- public String getHighlightPreferenceKey() {
- return getStringValue(HIGHLIGHT_PREFERENCE_KEY);
- }
-
- /**
- * Returns the default value for highlighting inside text.
- *
- * @return the default value for highlighting inside text
- * @since 3.0
- */
- public boolean getHighlightPreferenceValue() {
- return getBooleanValue(HIGHLIGHT_PREFERENCE_VALUE);
- }
-
- /**
- * Returns whether the annotation type contributes to the header of the overview ruler.
- *
- * @return <code>true</code> if the annotation type contributes to the header of the overview ruler
- */
- public boolean contributesToHeader() {
- return getBooleanValue(HEADER_VALUE);
- }
-
- /**
- * Sets the preference key for the presentation color.
- *
- * @param colorKey the preference key
- */
- public void setColorPreferenceKey(String colorKey) {
- setValue(COLOR_PREFERENCE_KEY, colorKey);
- }
-
- /**
- * Sets the default presentation color.
- *
- * @param colorValue the default color
- */
- public void setColorPreferenceValue(RGB colorValue) {
- setValue(COLOR_PREFERENCE_VALUE, colorValue);
- }
-
- /**
- * Sets the presentation label of this annotation type.
- *
- * @param label the presentation label
- */
- public void setPreferenceLabel(String label) {
- setValue(PREFERENCE_LABEL, label);
- }
-
- /**
- * Sets the preference key for the visibility in the overview ruler.
- *
- * @param overviewRulerKey the preference key
- */
- public void setOverviewRulerPreferenceKey(String overviewRulerKey) {
- setValue(OVERVIEW_RULER_PREFERENCE_KEY, overviewRulerKey);
- }
-
- /**
- * Sets the default visibility in the overview ruler.
- *
- * @param overviewRulerValue <code>true</code> if visible by default, <code>false</code> otherwise
- */
- public void setOverviewRulerPreferenceValue(boolean overviewRulerValue) {
- setValue(OVERVIEW_RULER_PREFERENCE_VALUE, overviewRulerValue);
- }
-
- /**
- * Sets the preference key for the visibility in the vertical ruler.
- *
- * @param verticalRulerKey the preference key
- * @since 3.0
- */
- public void setVerticalRulerPreferenceKey(String verticalRulerKey) {
- setValue(VERTICAL_RULER_PREFERENCE_KEY, verticalRulerKey);
- }
-
- /**
- * Sets the default visibility in the vertical ruler.
- *
- * @param verticalRulerValue <code>true</code> if visible by default, <code>false</code> otherwise
- * @since 3.0
- */
- public void setVerticalRulerPreferenceValue(boolean verticalRulerValue) {
- setValue(VERTICAL_RULER_PREFERENCE_VALUE, verticalRulerValue);
- }
-
- /**
- * Sets the presentation layer.
- *
- * @param presentationLayer the presentation layer
- */
- public void setPresentationLayer(int presentationLayer) {
- setValue(PRESENTATION_LAYER, presentationLayer);
- }
-
- /**
- * Sets the preference key for the visibility of squiggles inside text.
- *
- * @param textKey the preference key
- */
- public void setTextPreferenceKey(String textKey) {
- setValue(TEXT_PREFERENCE_KEY, textKey);
- }
-
- /**
- * Sets the default visibility inside text.
- *
- * @param textValue <code>true</code> if visible by default, <code>false</code> otherwise
- */
- public void setTextPreferenceValue(boolean textValue) {
- setValue(TEXT_PREFERENCE_VALUE, textValue);
- }
-
- /**
- * Sets the preference key for highlighting inside text.
- *
- * @param highlightKey the preference key
- * @since 3.0
- */
- public void setHighlightPreferenceKey(String highlightKey) {
- setValue(HIGHLIGHT_PREFERENCE_KEY, highlightKey);
- }
-
- /**
- * Sets the default value for highlighting inside text.
- *
- * @param highlightValue <code>true</code> if highlighted in text by default, <code>false</code> otherwise
- * @since 3.0
- */
- public void setHighlightPreferenceValue(boolean highlightValue) {
- setValue(HIGHLIGHT_PREFERENCE_VALUE, highlightValue);
- }
-
- /**
- * Sets whether the annotation type contributes to the overview ruler's header.
- *
- * @param contributesToHeader <code>true</code> if in header, <code>false</code> otherwise
- */
- public void setContributesToHeader(boolean contributesToHeader) {
- setValue(HEADER_VALUE, contributesToHeader);
- }
-
- /**
- * Returns the default value for go to next navigation enablement.
- *
- * @return <code>true</code> if enabled by default
- * @since 3.0
- */
- public boolean isGoToNextNavigationTarget() {
- return getBooleanValue(IS_GO_TO_NEXT_TARGET_VALUE);
- }
-
- /**
- * Sets the default value for go to next navigation enablement.
- *
- * @param isGoToNextNavigationTarget <code>true</code> if enabled by default
- * @since 3.0
- */
- public void setIsGoToNextNavigationTarget(boolean isGoToNextNavigationTarget) {
- setValue(IS_GO_TO_NEXT_TARGET_VALUE, isGoToNextNavigationTarget);
- }
-
- /**
- * Returns the preference key for go to next navigation enablement.
- *
- * @return the preference key or <code>null</code> if the key is undefined
- * @since 3.0
- */
- public String getIsGoToNextNavigationTargetKey() {
- return getStringValue(IS_GO_TO_NEXT_TARGET_KEY);
- }
-
- /**
- * Sets the preference key for go to next navigation enablement.
- *
- * @param isGoToNextNavigationTargetKey <code>true</code> if enabled by default
- * @since 3.0
- */
- public void setIsGoToNextNavigationTargetKey(String isGoToNextNavigationTargetKey) {
- setValue(IS_GO_TO_NEXT_TARGET_KEY, isGoToNextNavigationTargetKey);
- }
-
- /**
- * Returns the default value for go to previous navigation enablement.
- *
- * @return <code>true</code> if enabled by default
- * @since 3.0
- */
- public boolean isGoToPreviousNavigationTarget() {
- return getBooleanValue(IS_GO_TO_PREVIOUS_TARGET_VALUE);
- }
-
- /**
- * Sets the default value for go to previous navigation enablement.
- *
- * @param isGoToPreviousNavigationTarget <code>true</code> if enabled by default
- * @since 3.0
- */
- public void setIsGoToPreviousNavigationTarget(boolean isGoToPreviousNavigationTarget) {
- setValue(IS_GO_TO_PREVIOUS_TARGET_VALUE, isGoToPreviousNavigationTarget);
- }
-
- /**
- * Returns the preference key for go to previous navigation enablement.
- *
- * @return the preference key or <code>null</code> if the key is undefined
- * @since 3.0
- */
- public String getIsGoToPreviousNavigationTargetKey() {
- return getStringValue(IS_GO_TO_PREVIOUS_TARGET_KEY);
- }
-
- /**
- * Sets the preference key for go to previous navigation enablement.
- *
- * @param isGoToPreviousNavigationTargetKey the preference key
- * @since 3.0
- */
- public void setIsGoToPreviousNavigationTargetKey(String isGoToPreviousNavigationTargetKey) {
- setValue(IS_GO_TO_PREVIOUS_TARGET_KEY, isGoToPreviousNavigationTargetKey);
- }
-
- /**
- * Returns the preference key for the visibility in the next/previous drop down toolbar action.
- *
- * @return the preference key or <code>null</code> if the key is undefined
- * @since 3.0
- */
- public String getShowInNextPrevDropdownToolbarActionKey() {
- return getStringValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY);
- }
-
- /**
- * Sets the preference key for the visibility in the next/previous drop down toolbar action.
- *
- * @param showInNextPrevDropdownToolbarActionKey the preference key
- * @since 3.0
- */
- public void setShowInNextPrevDropdownToolbarActionKey(String showInNextPrevDropdownToolbarActionKey) {
- setValue(SHOW_IN_NAVIGATION_DROPDOWN_KEY, showInNextPrevDropdownToolbarActionKey);
- }
-
- /**
- * Returns the default value for the visibility in the next/previous drop down toolbar action.
- *
- * @return <code>true</code> if enabled by default
- * @since 3.0
- */
- public boolean isShowInNextPrevDropdownToolbarAction() {
- return getBooleanValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE);
- }
-
- /**
- * Sets the default value for the visibility in the next/previous drop down toolbar action.
- *
- * @param showInNextPrevDropdownToolbarAction <code>true</code> if enabled by default
- * @since 3.0
- */
- public void setShowInNextPrevDropdownToolbarAction(boolean showInNextPrevDropdownToolbarAction) {
- setValue(SHOW_IN_NAVIGATION_DROPDOWN_VALUE, showInNextPrevDropdownToolbarAction);
- }
-
- /**
- * Sets the preference key for the text style property.
- *
- * @param key the new key
- * @since 3.0
- */
- public void setTextStylePreferenceKey(String key) {
- setValue(TEXT_STYLE_PREFERENCE_KEY, key);
- }
-
- /**
- * Returns the preference key for the decoration style used when the annotation is shown in text.
- *
- * @return the preference key for the decoration style or <code>null</code> if the key is undefined
- * @since 3.0
- */
- public String getTextStylePreferenceKey() {
- return getStringValue(TEXT_STYLE_PREFERENCE_KEY);
- }
-
- /**
- * Returns the value for the decoration style used when the annotation is shown in text.
- *
- * @return the value for the decoration style or <code>null</code> if the key is undefined
- * @since 3.0
- */
- public String getTextStyleValue() {
- return getStringValue(TEXT_STYLE_PREFERENCE_VALUE);
- }
-
- /**
- * Sets the value for the text style property.
- *
- * @param value the new text decoration style
- * @since 3.0
- */
- public void setTextStyleValue(String value) {
- if (!STYLE_NONE.equals(value) && !STYLE_BOX.equals(value)
- && !STYLE_IBEAM.equals(value) && !STYLE_SQUIGGLES.equals(value)
- && !STYLE_UNDERLINE.equals(value))
- throw new IllegalArgumentException();
-
- setValue(TEXT_STYLE_PREFERENCE_VALUE, value);
- }
-
- /**
- * Returns the image descriptor for the image to be drawn in the vertical ruler. The provided
- * image is only used, if <code>getAnnotationImageProvider</code> returns <code>null</code>.
- *
- * @return the image descriptor or <code>null</code>
- * @since 3.0
- */
- public ImageDescriptor getImageDescriptor() {
- return (ImageDescriptor) getValue(IMAGE_DESCRIPTOR);
- }
-
- /**
- * Sets the image descriptor for the image to be drawn in the vertical ruler.
- *
- * @param descriptor the image descriptor
- * @since 3.0
- */
- public void setImageDescriptor(ImageDescriptor descriptor) {
- setValue(IMAGE_DESCRIPTOR, descriptor);
- }
-
- /**
- * Returns the symbolic name of the image to be drawn in the vertical ruler.
- * The image is only used if <code>getImageDescriptor</code> returns <code>null</code>.
- *
- * @return the symbolic name of the image or <code>null</code>
- * @since 3.0
- */
- public String getSymbolicImageName() {
- return getStringValue(SYMBOLIC_IMAGE_NAME);
- }
-
- /**
- * Sets the symbolic name of the image to be drawn in the vertical ruler.
- *
- * @param symbolicImageName the symbolic image name
- * @since 3.0
- */
- public void setSymbolicImageName(String symbolicImageName) {
- setValue(SYMBOLIC_IMAGE_NAME, symbolicImageName);
- }
-
- /**
- * Returns the annotation image provider. If no default annotation image
- * provider has been set, this method checks whether the annotation image
- * provider data has been set. If so, an annotation image provider is
- * created if the configuration element's plug-in is loaded. When an
- * annotation image provider has been created successfully, it is set as
- * the default annotation image provider.
- *
- * @return the annotation image provider
- * @since 3.0
- */
- public IAnnotationImageProvider getAnnotationImageProvider() {
- if (fAnnotationImageProvider == null) {
- if (fConfigurationElement != null && fAnnotationImageProviderAttribute != null) {
- Bundle bundle= Platform.getBundle( fConfigurationElement.getDeclaringExtension().getNamespace());
- if (bundle != null && bundle.getState() == Bundle.ACTIVE) {
- try {
- fAnnotationImageProvider= (IAnnotationImageProvider) fConfigurationElement.createExecutableExtension(fAnnotationImageProviderAttribute);
- } catch (CoreException x) {
- TextEditorPlugin.getDefault().getLog().log(x.getStatus());
- }
- }
- }
- }
- return fAnnotationImageProvider;
- }
-
- /**
- * Sets the annotation image provider who provides images for annotations
- * of the specified annotation type.
- *
- * @param provider the annotation image provider
- * @since 3.0
- */
- public void setAnnotationImageProvider(IAnnotationImageProvider provider) {
- fAnnotationImageProvider= provider;
- setValue(IMAGE_PROVIDER, provider != null);
- }
-
- /**
- * Sets the data needed to create the annotation image provider.
- *
- * @param configurationElement the configuration element
- * @param annotationImageProviderAttribute the attribute of the
- * configuration element
- * @since 3.0
- */
- public void setAnnotationImageProviderData(IConfigurationElement configurationElement, String annotationImageProviderAttribute) {
- fConfigurationElement= configurationElement;
- fAnnotationImageProviderAttribute= annotationImageProviderAttribute;
- setValue(IMAGE_PROVIDER, annotationImageProviderAttribute != null);
- }
-
- /**
- * Sets the property of this annotation preference whether it should be included
- * on the default annotation preference page.
- *
- * @param includeOnPreferencePage the new value
- * @since 3.0
- */
- public void setIncludeOnPreferencePage(boolean includeOnPreferencePage) {
- setValue(INCLUDE_ON_PREFERENCE_PAGE, includeOnPreferencePage);
- }
-
- /**
- * Returns the property of the receiver of whether it should be included on
- * the default annotation preference page.
- *
- * @return the includeOnPreferencePage property
- * @since 3.0
- */
- public boolean isIncludeOnPreferencePage() {
- Object value= fAttributes.get(INCLUDE_ON_PREFERENCE_PAGE);
- if (value instanceof Boolean)
- return ((Boolean) value).booleanValue();
- return true;
- }
-
- /**
- * Merges the values of the given preference into this preference. Existing
- * values will not be overwritten. Subclasses may extend.
- *
- * @param preference the preference to merge into this preference
- * @since 3.0
- */
- public void merge(AnnotationPreference preference) {
- if (!getAnnotationType().equals(preference.getAnnotationType()))
- return;
-
- for (int i= 0; i < ATTRIBUTES.length; i++) {
- if (!hasValue(ATTRIBUTES[i]))
- setValue(ATTRIBUTES[i], preference.getValue(ATTRIBUTES[i]));
- }
-
- if (fAnnotationImageProvider == null)
- fAnnotationImageProvider= preference.fAnnotationImageProvider;
- if (fConfigurationElement == null)
- fConfigurationElement= preference.fConfigurationElement;
- if (fAnnotationImageProviderAttribute == null)
- fAnnotationImageProviderAttribute= preference.fAnnotationImageProviderAttribute;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
deleted file mode 100644
index 75e08446a..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/BasicTextEditorActionContributor.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-
-import org.eclipse.jface.text.Assert;
-
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.part.EditorActionBarContributor;
-
-
-
-/**
- * Manages the installation and uninstallation of global actions for
- * the same type of editors.
- * <p>
- * If instantiated and used as-is, this contributor connects to all of the workbench defined
- * global editor actions the corresponding actions of the current editor. It also adds addition
- * actions for searching and navigation (go to line) as well as a set of status fields.</p>
- * <p>
- * Subclasses may override the following methods:
- * <ul>
- * <li><code>contributeToMenu</code> - extend to contribute to menu</li>
- * <li><code>contributeToToolBar</code> - reimplement to contribute to toolbar</li>
- * <li><code>contributeToStatusLine</code> - reimplement to contribute to status line</li>
- * <li><code>setActiveEditor</code> - extend to react to editor changes</li>
- * </ul>
- * </p>
- * @see org.eclipse.ui.texteditor.ITextEditorActionConstants
- */
-public class BasicTextEditorActionContributor extends EditorActionBarContributor {
-
- /** The global actions to be connected with editor actions */
- private final static String[] ACTIONS= {
- ITextEditorActionConstants.UNDO,
- ITextEditorActionConstants.REDO,
- ITextEditorActionConstants.CUT,
- ITextEditorActionConstants.COPY,
- ITextEditorActionConstants.PASTE,
- ITextEditorActionConstants.DELETE,
- ITextEditorActionConstants.SELECT_ALL,
- ITextEditorActionConstants.FIND,
- ITextEditorActionConstants.PRINT,
- ITextEditorActionConstants.REVERT
- };
-
- /**
- * Status field definition.
- * @since 3.0
- */
- private static class StatusFieldDef {
-
- private String category;
- private String actionId;
- private boolean visible;
- private int widthInChars;
-
- private StatusFieldDef(String category, String actionId, boolean visible, int widthInChars) {
- Assert.isNotNull(category);
- this.category= category;
- this.actionId= actionId;
- this.visible= visible;
- this.widthInChars= widthInChars;
- }
- }
-
- /**
- * The status fields to be set to the editor
- * @since 3.0
- */
- private final static StatusFieldDef[] STATUS_FIELD_DEFS= {
- new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_FIND_FIELD, null, false, EditorMessages.getString("Editor.FindIncremental.reverse.name").length() + 15), //$NON-NLS-1$
- new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_ELEMENT_STATE, null, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS),
- new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_MODE, ITextEditorActionDefinitionIds.TOGGLE_OVERWRITE, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS),
- new StatusFieldDef(ITextEditorActionConstants.STATUS_CATEGORY_INPUT_POSITION, ITextEditorActionConstants.GOTO_LINE, true, StatusLineContributionItem.DEFAULT_WIDTH_IN_CHARS)
- };
-
- /**
- * The active editor part.
- */
- private IEditorPart fActiveEditorPart;
- /**
- * The find next action.
- * @since 2.0
- */
- private RetargetTextEditorAction fFindNext;
- /**
- * The find previous action.
- * @since 2.0
- */
- private RetargetTextEditorAction fFindPrevious;
- /**
- * The incremental find action.
- * @since 2.0
- */
- private RetargetTextEditorAction fIncrementalFind;
- /**
- * The reverse incremental find action.
- * @since 2.1
- */
- private RetargetTextEditorAction fIncrementalFindReverse;
- /**
- * The go to line action.
- */
- private RetargetTextEditorAction fGotoLine;
- /**
- * The map of status fields.
- * @since 2.0
- */
- private Map fStatusFields;
-
-
- /**
- * Creates an empty editor action bar contributor. The action bars are
- * furnished later via the <code>init</code> method.
- *
- * @see org.eclipse.ui.IEditorActionBarContributor#init(org.eclipse.ui.IActionBars, org.eclipse.ui.IWorkbenchPage)
- */
- public BasicTextEditorActionContributor() {
-
- fFindNext= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindNext."); //$NON-NLS-1$
- fFindNext.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_NEXT);
- fFindPrevious= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindPrevious."); //$NON-NLS-1$
- fFindPrevious.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_PREVIOUS);
- fIncrementalFind= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindIncremental."); //$NON-NLS-1$
- fIncrementalFind.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL);
- fIncrementalFindReverse= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.FindIncrementalReverse."); //$NON-NLS-1$
- fIncrementalFindReverse.setActionDefinitionId(ITextEditorActionDefinitionIds.FIND_INCREMENTAL_REVERSE);
- fGotoLine= new RetargetTextEditorAction(EditorMessages.getResourceBundle(), "Editor.GotoLine."); //$NON-NLS-1$
- fGotoLine.setActionDefinitionId(ITextEditorActionDefinitionIds.LINE_GOTO);
-
- fStatusFields= new HashMap(3);
- for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
- StatusFieldDef fieldDef= STATUS_FIELD_DEFS[i];
- fStatusFields.put(fieldDef, new StatusLineContributionItem(fieldDef.category, fieldDef.visible, fieldDef.widthInChars));
- }
- }
-
- /**
- * Returns the active editor part.
- *
- * @return the active editor part
- */
- protected final IEditorPart getActiveEditorPart() {
- return fActiveEditorPart;
- }
-
- /**
- * Returns the action registered with the given text editor.
- *
- * @param editor the editor, or <code>null</code>
- * @param actionId the action id
- * @return the action, or <code>null</code> if none
- */
- protected final IAction getAction(ITextEditor editor, String actionId) {
- return (editor == null || actionId == null ? null : editor.getAction(actionId));
- }
-
- /**
- * The method installs the global action handlers for the given text editor.
- * <p>
- * This method cannot be overridden by subclasses.</p>
- *
- * @param part the active editor part
- * @since 2.0
- */
- private void doSetActiveEditor(IEditorPart part) {
-
- if (fActiveEditorPart == part)
- return;
-
- if (fActiveEditorPart instanceof ITextEditorExtension) {
- ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart;
- for (int i= 0; i < STATUS_FIELD_DEFS.length; i++)
- extension.setStatusField(null, STATUS_FIELD_DEFS[i].category);
- }
-
- fActiveEditorPart= part;
- ITextEditor editor= (part instanceof ITextEditor) ? (ITextEditor) part : null;
-
- IActionBars actionBars= getActionBars();
- if (actionBars != null) {
- for (int i= 0; i < ACTIONS.length; i++)
- actionBars.setGlobalActionHandler(ACTIONS[i], getAction(editor, ACTIONS[i]));
- }
-
- fFindNext.setAction(getAction(editor, ITextEditorActionConstants.FIND_NEXT));
- fFindPrevious.setAction(getAction(editor, ITextEditorActionConstants.FIND_PREVIOUS));
- fIncrementalFind.setAction(getAction(editor, ITextEditorActionConstants.FIND_INCREMENTAL));
- fIncrementalFindReverse.setAction(getAction(editor, ITextEditorActionConstants.FIND_INCREMENTAL_REVERSE));
- fGotoLine.setAction(getAction(editor, ITextEditorActionConstants.GOTO_LINE));
-
- for (int i= 0; i < STATUS_FIELD_DEFS.length; i++) {
- if (fActiveEditorPart instanceof ITextEditorExtension) {
- StatusLineContributionItem statusField= (StatusLineContributionItem) fStatusFields.get(STATUS_FIELD_DEFS[i]);
- statusField.setActionHandler(getAction(editor, STATUS_FIELD_DEFS[i].actionId));
- ITextEditorExtension extension= (ITextEditorExtension) fActiveEditorPart;
- extension.setStatusField(statusField, STATUS_FIELD_DEFS[i].category);
- }
- }
- }
-
- /**
- * The <code>BasicTextEditorActionContributor</code> implementation of this
- * <code>IEditorActionBarContributor</code> method installs the global
- * action handler for the given text editor by calling a private helper
- * method.
- * <p>
- * Subclasses may extend.</p>
- *
- * @param part {@inheritDoc}
- */
- public void setActiveEditor(IEditorPart part) {
- doSetActiveEditor(part);
- }
-
- /*
- * @see EditorActionBarContributor#contributeToMenu(IMenuManager)
- */
- public void contributeToMenu(IMenuManager menu) {
-
- IMenuManager editMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fIncrementalFindReverse);
- editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fIncrementalFind);
- editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindPrevious);
- editMenu.prependToGroup(IWorkbenchActionConstants.FIND_EXT, fFindNext);
- }
-
- IMenuManager navigateMenu= menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
- if (navigateMenu != null) {
- navigateMenu.appendToGroup(IWorkbenchActionConstants.MB_ADDITIONS, fGotoLine);
- }
- }
-
- /*
- * @see EditorActionBarContributor#contributeToStatusLine(org.eclipse.jface.action.IStatusLineManager)
- * @since 2.0
- */
- public void contributeToStatusLine(IStatusLineManager statusLineManager) {
- super.contributeToStatusLine(statusLineManager);
- for (int i= 0; i < STATUS_FIELD_DEFS.length; i++)
- statusLineManager.add((IContributionItem)fStatusFields.get(STATUS_FIELD_DEFS[i]));
- }
-
- /*
- * @see org.eclipse.ui.IEditorActionBarContributor#dispose()
- * @since 2.0
- */
- public void dispose() {
- doSetActiveEditor(null);
- super.dispose();
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java
deleted file mode 100644
index 15915bd19..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/CaseAction.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.ui.texteditor;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Point;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-/**
- * Action that converts the current selection to lower case or upper case.
- * @since 3.0
- */
-public class CaseAction extends TextEditorAction implements IUpdate {
-
- /** <code>true</code> if this action converts to upper case, <code>false</code> otherwise. */
- private boolean fToUpper;
-
- /**
- * Creates and initializes the action for the given text editor.
- * The action configures its visual representation from the given resource
- * bundle.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or <code>null</code> if none
- * @param editor the text editor
- * @param toUpper <code>true</code> if this is an uppercase action, <code>false</code> otherwise.
- *
- * @see ResourceAction#ResourceAction(ResourceBundle, String)
- */
- public CaseAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor, boolean toUpper) {
- super(bundle, prefix, editor);
- fToUpper= toUpper;
- update();
- }
-
- /*
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- if (!validateEditorInputState())
- return;
-
- ISourceViewer viewer= ((AbstractTextEditor) editor).getSourceViewer();
- if (viewer == null)
- return;
-
- IDocument document= viewer.getDocument();
- if (document == null)
- return;
-
- StyledText st= viewer.getTextWidget();
- if (st == null)
- return;
-
- Point sel= viewer.getSelectedRange();
- if (sel == null)
- return;
-
- try {
- // if the selection is empty, we select the word / string using the viewer's
- // double-click strategy
- if (sel.y == 0) {
-
- // TODO find a better way to do this although there are multiple partitionings on a single document
-
-// String partition= getContentType(viewer, document, sel.x);
-// SourceViewerConfiguration svc= fEditor.getSourceViewerConfiguration(); // never null when viewer instantiated
-// ITextDoubleClickStrategy dcs= svc.getDoubleClickStrategy(viewer, partition);
-// if (dcs != null) {
-// dcs.doubleClicked(viewer);
-// sel= viewer.getSelectedRange();
-// }
-
- if (sel.y == 0)
- return; // if the selection is still empty, we're done
- }
-
- String target= document.get(sel.x, sel.y);
- String replacement= (fToUpper ? target.toUpperCase() : target.toLowerCase());
- if (!target.equals(replacement)) {
- document.replace(sel.x, target.length(), replacement);
- }
- } catch (BadLocationException x) {
- // ignore and return
- return;
- }
-
- // reinstall selection and move it into view
- viewer.setSelectedRange(sel.x, sel.y);
- // don't use the viewer's reveal feature in order to avoid jumping around
- st.showSelection();
- }
-
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java
deleted file mode 100644
index a6d986f2d..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConfigurationElementSorter.java
+++ /dev/null
@@ -1,167 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.osgi.util.ManifestElement;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.Constants;
-
-/**
- * Allows to sort an array based on their elements' configuration elements
- * according to the prerequisite relation of their defining plug-ins.
- * <p>
- * This class may be subclassed.
- * </p>
- *
- * @since 3.0
- */
-public abstract class ConfigurationElementSorter {
-
- /**
- * Sorts the given array based on its elements' configuration elements
- * according to the prerequisite relation of their defining plug-ins.
- *
- * @param elements the array to be sorted
- */
- public final void sort(Object[] elements) {
- Arrays.sort(elements, new ConfigurationElementComparator(elements));
- }
-
- /**
- * Returns the configuration element for the given object.
- *
- * @param object the object
- * @return the object's configuration element, must not be <code>null</code>
- */
- public abstract IConfigurationElement getConfigurationElement(Object object);
-
- /**
- * Compare configuration elements according to the prerequisite relation
- * of their defining plug-ins.
- */
- private class ConfigurationElementComparator implements Comparator {
-
- private Map fDescriptorMapping;
- private Map fPrereqsMapping;
-
- public ConfigurationElementComparator(Object[] elements) {
- Assert.isNotNull(elements);
- initialize(elements);
- }
-
- /*
- * @see Comparator#compare(java.lang.Object, java.lang.Object)
- * @since 2.0
- */
- public int compare(Object object0, Object object1) {
-
- if (dependsOn(object0, object1))
- return -1;
-
- if (dependsOn(object1, object0))
- return +1;
-
- return 0;
- }
-
- /**
- * Returns whether one configuration element depends on the other element.
- * This is done by checking the dependency chain of the defining plug-ins.
- *
- * @param element0 the first element
- * @param element1 the second element
- * @return <code>true</code> if <code>element0</code> depends on <code>element1</code>.
- * @since 2.0
- */
- private boolean dependsOn(Object element0, Object element1) {
- if (element0 == null || element1 == null)
- return false;
-
- String pluginDesc0= (String)fDescriptorMapping.get(element0);
- String pluginDesc1= (String)fDescriptorMapping.get(element1);
-
- // performance tuning - code below would give same result
- if (pluginDesc0.equals(pluginDesc1))
- return false;
-
- Set prereqUIds0= (Set)fPrereqsMapping.get(pluginDesc0);
-
- return prereqUIds0.contains(pluginDesc1);
- }
-
- /**
- * Initialize this comparator.
- *
- * @param elements an array of Java editor hover descriptors
- */
- private void initialize(Object[] elements) {
- int length= elements.length;
- fDescriptorMapping= new HashMap(length);
- fPrereqsMapping= new HashMap(length);
- Set fBundleSet= new HashSet(length);
-
- for (int i= 0; i < length; i++) {
- IExtension extension = getConfigurationElement(elements[i]).getDeclaringExtension();
- Bundle bundle = Platform.getBundle(extension.getNamespace());
- fDescriptorMapping.put(elements[i], bundle.getSymbolicName());
- fBundleSet.add(bundle);
- }
-
- Iterator iter= fBundleSet.iterator();
- while (iter.hasNext()) {
- Bundle bundle= (Bundle)iter.next();
- List toTest= new ArrayList(fBundleSet);
- toTest.remove(bundle);
- Set prereqUIds= new HashSet(Math.max(0, toTest.size() - 1));
- fPrereqsMapping.put(bundle.getSymbolicName(), prereqUIds);
-
- String requires = (String)bundle.getHeaders().get(Constants.REQUIRE_BUNDLE);
- ManifestElement[] manifestElements;
- try {
- manifestElements = ManifestElement.parseHeader(Constants.REQUIRE_BUNDLE, requires);
- } catch (BundleException e) {
- continue;
- }
-
- int i= 0;
- while (i < manifestElements.length && !toTest.isEmpty()) {
- String prereqUId= manifestElements[i].getValue();
- for (int j= 0; j < toTest.size();) {
- Bundle toTest_j= (Bundle)toTest.get(j);
- if (toTest_j.getSymbolicName().equals(prereqUId)) {
- toTest.remove(toTest_j);
- prereqUIds.add(toTest_j.getSymbolicName());
- } else
- j++;
- }
- i++;
- }
- }
- }
-
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java
deleted file mode 100644
index 1b59c5e2b..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ContentAssistAction.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-
-import java.util.ResourceBundle;
-
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextOperationTargetExtension;
-import org.eclipse.jface.text.source.ISourceViewer;
-
-import org.eclipse.ui.IWorkbenchPartSite;
-
-
-/**
- * A content assist action which gets its target from its text editor.
- * <p>
- * The action is initially associated with a text editor via the constructor,
- * but can subsequently be changed using <code>setEditor</code>.</p>
- * <p>
- * If this class is used as is, it works by asking the text editor for its text operation target
- * (using <code>getAdapter(ITextOperationTarget.class)</code> and runs the content assist
- * operation on this target.
- * </p>
- * @since 2.0
- */
-public final class ContentAssistAction extends TextEditorAction {
-
- /** The text operation target */
- private ITextOperationTarget fOperationTarget;
-
- /**
- * Creates and initializes the action for the given text editor.
- * The action configures its visual representation from the given resource
- * bundle. The action works by asking the text editor at the time for its
- * text operation target adapter (using
- * <code>getAdapter(ITextOperationTarget.class)</code>. The action runs the
- * content assist operation on this target.
- *
- * @param bundle the resource bundle
- * @param prefix a prefix to be prepended to the various resource keys
- * (described in <code>ResourceAction</code> constructor), or
- * <code>null</code> if none
- * @param editor the text editor
- * @see ResourceAction#ResourceAction(ResourceBundle, String)
- */
- public ContentAssistAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /**
- * Runs the content assist operation on the editor's text operation target.
- */
- public void run() {
- if (fOperationTarget != null) {
-
- ITextEditor editor= getTextEditor();
- if (editor != null && validateEditorInputState()) {
-
- Display display= null;
-
- IWorkbenchPartSite site= editor.getSite();
- Shell shell= site.getShell();
- if (shell != null && !shell.isDisposed())
- display= shell.getDisplay();
-
- BusyIndicator.showWhile(display, new Runnable() {
- public void run() {
- fOperationTarget.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
- }
- });
- }
- }
- }
-
- /**
- * The <code>ContentAssistAction</code> implementation of this
- * <code>IUpdate</code> method discovers the operation through the current
- * editor's <code>ITextOperationTarget</code> adapter, and sets the
- * enabled state accordingly.
- */
- public void update() {
-
- ITextEditor editor= getTextEditor();
-
- if (fOperationTarget == null && editor!= null)
- fOperationTarget= (ITextOperationTarget) editor.getAdapter(ITextOperationTarget.class);
-
- if (fOperationTarget == null) {
- setEnabled(false);
- return;
- }
-
- if (fOperationTarget instanceof ITextOperationTargetExtension) {
- ITextOperationTargetExtension targetExtension= (ITextOperationTargetExtension) fOperationTarget;
- targetExtension.enableOperation(ISourceViewer.CONTENTASSIST_PROPOSALS, canModifyEditor());
- }
-
- setEnabled(fOperationTarget.canDoOperation(ISourceViewer.CONTENTASSIST_PROPOSALS));
- }
-
- /**
- * @see TextEditorAction#setEditor(ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- super.setEditor(editor);
- fOperationTarget= null;
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
deleted file mode 100644
index e612e2928..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/ConvertLineDelimitersAction.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Shell;
-
-import org.eclipse.jface.dialogs.ProgressMonitorDialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.IRewriteTarget;
-import org.eclipse.jface.text.TextUtilities;
-
-
-/**
- * An action to convert line delimiters of a text editor document to a
- * particular line delimiter.
- *
- * @since 2.0
- */
-public class ConvertLineDelimitersAction extends TextEditorAction {
-
- /** The target line delimiter. */
- private final String fLineDelimiter;
-
- /**
- * Creates a line delimiter conversion action.
- *
- * @param editor the editor
- * @param lineDelimiter the target line delimiter to convert the editor's document to
- */
- public ConvertLineDelimitersAction(ITextEditor editor, String lineDelimiter) {
- this(EditorMessages.getResourceBundle(), "dummy", editor, lineDelimiter); //$NON-NLS-1$
- }
-
- /**
- * Creates a line delimiter conversion action.
- *
- * @param bundle the resource bundle
- * @param prefix the prefix for the resource bundle lookup
- * @param editor the editor
- * @param lineDelimiter the target line delimiter to convert the editor's document to
- */
- public ConvertLineDelimitersAction(ResourceBundle bundle, String prefix, ITextEditor editor, String lineDelimiter) {
- super(bundle, prefix, editor);
- fLineDelimiter= lineDelimiter;
-
- String platformLineDelimiter= System.getProperty("line.separator"); //$NON-NLS-1$
- setText(EditorMessages.getString(getLabelKey(fLineDelimiter, platformLineDelimiter)));
-
- update();
- }
-
- /*
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
-
- try {
-
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- if (!validateEditorInputState())
- return;
-
- Object adapter= editor.getAdapter(IRewriteTarget.class);
- if (adapter instanceof IRewriteTarget) {
-
- IRewriteTarget target= (IRewriteTarget) adapter;
- IDocument document= target.getDocument();
- if (document != null) {
- Shell shell= getTextEditor().getSite().getShell();
- ConvertRunnable runnable= new ConvertRunnable(target, fLineDelimiter);
-
- if (document.getNumberOfLines() < 40) {
- BusyIndicator.showWhile(shell.getDisplay(), runnable);
-
- } else {
- ProgressMonitorDialog dialog= new ProgressMonitorDialog(shell);
- dialog.run(false, true, runnable);
- }
- }
- }
-
- } catch (InterruptedException e) {
- // action cancelled
-
- } catch (InvocationTargetException e) {
- // should not happen
- }
- }
-
- /**
- * A runnable that converts all line delimiters of a document to <code>lineDelimiter</code>.
- */
- private static class ConvertRunnable implements IRunnableWithProgress, Runnable {
-
- /** The rewrite target */
- private final IRewriteTarget fRewriteTarget;
- /** The line delimiter to which to convert to */
- private final String fLineDelimiter;
-
- /**
- * Returns a new runnable for converting all line delimiters in
- * the <code>rewriteTarget</code> to <code>lineDelimter</code>.
- * @param rewriteTarget
- * @param lineDelimiter
- */
- public ConvertRunnable(IRewriteTarget rewriteTarget, String lineDelimiter) {
- fRewriteTarget= rewriteTarget;
- fLineDelimiter= lineDelimiter;
- }
-
- /*
- * @see IRunnableWithProgress#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
-
- IDocument document= fRewriteTarget.getDocument();
- final int lineCount= document.getNumberOfLines();
- monitor.beginTask(EditorMessages.getString("Editor.ConvertLineDelimiter.title"), lineCount); //$NON-NLS-1$
-
- fRewriteTarget.setRedraw(false);
- fRewriteTarget.beginCompoundChange();
-
- if (document instanceof IDocumentExtension)
- ((IDocumentExtension) document).startSequentialRewrite(true);
-
- Map partitioners= TextUtilities.removeDocumentPartitioners(document);
-
- try {
- for (int i= 0; i < lineCount; i++) {
- if (monitor.isCanceled())
- throw new InterruptedException();
-
- final String delimiter= document.getLineDelimiter(i);
- if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(fLineDelimiter)) {
- IRegion region= document.getLineInformation(i);
- document.replace(region.getOffset() + region.getLength(), delimiter.length(), fLineDelimiter);
- }
-
- monitor.worked(1);
- }
-
- } catch (BadLocationException e) {
- throw new InvocationTargetException(e);
-
- } finally {
-
- if (partitioners != null)
- TextUtilities.addDocumentPartitioners(document, partitioners);
-
- if (document instanceof IDocumentExtension)
- ((IDocumentExtension) document).stopSequentialRewrite();
-
- fRewriteTarget.endCompoundChange();
- fRewriteTarget.setRedraw(true);
-
- monitor.done();
- }
- }
-
- /*
- * @see Runnable#run()
- */
- public void run() {
- try {
- run(new NullProgressMonitor());
-
- } catch (InterruptedException e) {
- // should not happen
-
- } catch (InvocationTargetException e) {
- // should not happen
- }
- }
- }
-
-// /**
-// * Returns whether the given document uses only the given line delimiter.
-// * @param document the document to check
-// * @param lineDelimiter the line delimiter to check for
-// */
-// private static boolean usesLineDelimiterExclusively(IDocument document, String lineDelimiter) {
-//
-// try {
-// final int lineCount= document.getNumberOfLines();
-// for (int i= 0; i < lineCount; i++) {
-// final String delimiter= document.getLineDelimiter(i);
-// if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(lineDelimiter))
-// return false;
-// }
-//
-// } catch (BadLocationException e) {
-// return false;
-// }
-//
-// return true;
-// }
-
- /**
- * Computes and returns the key to be used to lookup the action's label in
- * its resource bundle.
- *
- * @param lineDelimiter the line delimiter
- * @param platformLineDelimiter the platform line delimiter
- * @return the key used to lookup the action's label
- */
- private static String getLabelKey(String lineDelimiter, String platformLineDelimiter) {
- if (lineDelimiter.equals(platformLineDelimiter)) {
-
- if (lineDelimiter.equals("\r\n")) //$NON-NLS-1$
- return "Editor.ConvertLineDelimiter.toWindows.default.label"; //$NON-NLS-1$
-
- if (lineDelimiter.equals("\n")) //$NON-NLS-1$
- return "Editor.ConvertLineDelimiter.toUNIX.default.label"; //$NON-NLS-1$
-
- if (lineDelimiter.equals("\r")) //$NON-NLS-1$
- return "Editor.ConvertLineDelimiter.toMac.default.label"; //$NON-NLS-1$
-
- } else {
-
- if (lineDelimiter.equals("\r\n")) //$NON-NLS-1$
- return "Editor.ConvertLineDelimiter.toWindows.label"; //$NON-NLS-1$
-
- if (lineDelimiter.equals("\n")) //$NON-NLS-1$
- return "Editor.ConvertLineDelimiter.toUNIX.label"; //$NON-NLS-1$
-
- if (lineDelimiter.equals("\r")) //$NON-NLS-1$
- return "Editor.ConvertLineDelimiter.toMac.label"; //$NON-NLS-1$
- }
-
- return null;
- }
-
- /**
- * Internally sets the enable state of this action.
- */
- private boolean doEnable() {
- return canModifyEditor();
- }
-
- /*
- * @see IUpdate#update()
- */
- public void update() {
- super.update();
- setEnabled(doEnable());
- }
-
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
deleted file mode 100644
index c42d70d6b..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DefaultRangeIndicator.java
+++ /dev/null
@@ -1,175 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationPresentation;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Canvas;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-
-/**
- * Specialized annotation to indicate a particular range of text lines.
- * <p>
- * This class may be instantiated; it is not intended to be subclassed.
- * This class is instantiated automatically by <code>AbstractTextEditor</code>.
- * </p>
- */
-public class DefaultRangeIndicator extends Annotation implements IAnnotationPresentation {
-
- /** The color palette data of this range indicator */
- private static PaletteData fgPaletteData;
- /** The image of this range indicator */
- private Image fImage;
-
- /**
- * Creates a new range indicator.
- */
- public DefaultRangeIndicator() {
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationPresentation#paint(org.eclipse.swt.graphics.GC, org.eclipse.swt.widgets.Canvas, org.eclipse.swt.graphics.Rectangle)
- */
- public void paint(GC gc, Canvas canvas, Rectangle bounds) {
-
- Point canvasSize= canvas.getSize();
-
- int x= 0;
- int y= bounds.y;
- int w= canvasSize.x;
- int h= bounds.height;
- int b= 1;
-
- if (y + h > canvasSize.y)
- h= canvasSize.y - y;
-
- if (y < 0) {
- h= h + y;
- y= 0;
- }
-
- if (h <= 0)
- return;
-
- Image image = getImage(canvas);
- gc.drawImage(image, 0, 0, w, h, x, y, w, h);
-
- gc.setBackground(canvas.getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION));
- gc.fillRectangle(x, bounds.y, w, b);
- gc.fillRectangle(x, bounds.y + bounds.height - b, w, b);
- }
-
- /*
- * @see org.eclipse.jface.text.source.IAnnotationPresentation#getLayer()
- */
- public int getLayer() {
- return IAnnotationPresentation.DEFAULT_LAYER;
- }
-
- /**
- * Returns the image of this range indicator.
- *
- * @param control the control
- * @return an image
- */
- private Image getImage(Control control) {
- if (fImage == null) {
- fImage= createImage(control.getDisplay(), control.getSize());
-
- control.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- if (fImage != null && !fImage.isDisposed()) {
- fImage.dispose();
- fImage= null;
- }
- }
- });
- } else {
- Rectangle imageRectangle= fImage.getBounds();
- Point controlSize= control.getSize();
-
- if (imageRectangle.width < controlSize.x || imageRectangle.height < controlSize.y) {
- fImage.dispose();
- fImage= createImage(control.getDisplay(), controlSize);
- }
- }
-
- return fImage;
- }
-
- /**
- * Creates and returns a new SWT image with the given size on
- * the given display which is used as this range indicator's image.
- *
- * @param display the display on which to create the image
- * @param size the image size
- * @return a new image
- */
- private static Image createImage(Display display, Point size) {
-
- int width= size.x;
- int height= size.y;
-
- if (fgPaletteData == null)
- fgPaletteData= createPalette(display);
-
- ImageData imageData= new ImageData(width, height, 1, fgPaletteData);
-
- for (int y= 0; y < height; y++)
- for (int x= 0; x < width; x++)
- imageData.setPixel(x, y, (x + y) % 2);
-
- return new Image(display, imageData);
- }
-
- /**
- * Creates and returns a new color palette data.
- *
- * @param display
- * @return the new color palette data
- */
- private static PaletteData createPalette(Display display) {
- Color c1;
- Color c2;
-
- if (false) {
- // range lighter
- c1= display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
- c2= display.getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- } else {
- // range darker
- c1= display.getSystemColor(SWT.COLOR_LIST_SELECTION);
- c2= display.getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
- }
-
- RGB rgbs[]= new RGB[] {
- new RGB(c1.getRed(), c1.getGreen(), c1.getBlue()),
- new RGB(c2.getRed(), c2.getGreen(), c2.getBlue())};
-
- return new PaletteData(rgbs);
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java
deleted file mode 100644
index 1323af7e1..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineAction.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-/**
- * An action to delete a whole line, the fraction of the line that is left from the cursor
- * or the fraction that is right from the cursor.
- *
- * @since 2.0
- */
-public class DeleteLineAction extends TextEditorAction {
-
- /**
- * Delete the whole line.
- */
- public static final int WHOLE= 0;
- /**
- * Delete to the beginning of line.
- */
- public static final int TO_BEGINNING= 1;
- /**
- * Delete to the end of line.
- */
- public static final int TO_END= 2;
-
- /**
- * The type of deletion.
- */
- private final int fType;
- /**
- * Should the deleted line be copied to the clipboard.
- * @since 2.1
- */
- private final boolean fCopyToClipboard;
- /** The deletion target.
- * @since 2.1
- */
- private DeleteLineTarget fTarget;
-
- /**
- * Creates a line delimiter conversion action.
- *
- * @param bundle the resource bundle for UI strings
- * @param prefix the prefix for the property keys into <code>bundle</code>
- * @param editor the editor
- * @param type the line deletion type, must be one of
- * <code>WHOLE_LINE</code>, <code>TO_BEGINNING</code> or <code>TO_END</code>
- */
- public DeleteLineAction(ResourceBundle bundle, String prefix, ITextEditor editor, int type) {
- this(bundle, prefix, editor, type, true);
- }
-
- /**
- * Creates a line deletion action.
- *
- * @param bundle the resource bundle for UI strings
- * @param prefix the prefix for the property keys into <code>bundle</code>
- * @param editor the editor
- * @param type the line deletion type, must be one of
- * <code>WHOLE_LINE</code>, <code>TO_BEGINNING</code> or <code>TO_END</code>
- * @param copyToClipboard if <code>true</code>, the contents of the deleted line are copied to the clipboard
- * @since 2.1
- */
- public DeleteLineAction(ResourceBundle bundle, String prefix, ITextEditor editor, int type, boolean copyToClipboard) {
- super(bundle, prefix, editor);
- fType= type;
- fCopyToClipboard= copyToClipboard;
- update();
- }
-
- /**
- * Returns the editor's document.
- *
- * @param editor the editor
- * @return the editor's document
- */
- private static IDocument getDocument(ITextEditor editor) {
-
- IDocumentProvider documentProvider= editor.getDocumentProvider();
- if (documentProvider == null)
- return null;
-
- IDocument document= documentProvider.getDocument(editor.getEditorInput());
- if (document == null)
- return null;
-
- return document;
- }
-
- /**
- * Returns the editor's selection.
- *
- * @param editor the editor
- * @return the editor's selection
- */
- private static ITextSelection getSelection(ITextEditor editor) {
-
- ISelectionProvider selectionProvider= editor.getSelectionProvider();
- if (selectionProvider == null)
- return null;
-
- ISelection selection= selectionProvider.getSelection();
- if (!(selection instanceof ITextSelection))
- return null;
-
- return (ITextSelection) selection;
- }
-
- /*
- * @see IAction#run()
- */
- public void run() {
-
- if (fTarget == null)
- return;
-
- ITextEditor editor= getTextEditor();
- if (editor == null)
- return;
-
- if (!validateEditorInputState())
- return;
-
- IDocument document= getDocument(editor);
- if (document == null)
- return;
-
- ITextSelection selection= getSelection(editor);
- if (selection == null)
- return;
-
- try {
- fTarget.deleteLine(document, selection.getOffset(), fType, fCopyToClipboard);
- } catch (BadLocationException e) {
- // should not happen
- }
- }
-
- /*
- * @see IUpdate#update()
- */
- public void update() {
-
- super.update();
- if (!isEnabled())
- return;
-
- if (!canModifyEditor()) {
- setEnabled(false);
- return;
- }
-
- ITextEditor editor= getTextEditor();
- if (editor != null)
- fTarget= (DeleteLineTarget) editor.getAdapter(DeleteLineTarget.class);
- else
- fTarget= null;
-
- setEnabled(fTarget != null);
- }
-}
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java
deleted file mode 100644
index 1a76e1f44..000000000
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/DeleteLineTarget.java
+++ /dev/null
@@ -1,353 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2000, 2004 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.ui.texteditor;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-
-import org.eclipse.swt.SWTError;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.dnd.Clipboard;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.TextTransfer;
-import org.eclipse.swt.dnd.Transfer;