Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordavid_williams2004-11-11 08:20:43 +0000
committerdavid_williams2004-11-11 08:20:43 +0000
commit6fdcc7185a155ce3b8eccaed32db98524c3c29f9 (patch)
tree819ce0d048142af5b48795bbe8e044794268e8e2 /bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse
parent13c034178ca8ffe88d7f877113f84e9c78d54c0e (diff)
downloadwebtools.sourceediting-6fdcc7185a155ce3b8eccaed32db98524c3c29f9.tar.gz
webtools.sourceediting-6fdcc7185a155ce3b8eccaed32db98524c3c29f9.tar.xz
webtools.sourceediting-6fdcc7185a155ce3b8eccaed32db98524c3c29f9.zip
removing previous, in prep for refresh
Diffstat (limited to 'bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse')
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractContentSettingsHandler.java83
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractSubject.java50
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentPropertiesPlugin.java121
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettings.java697
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsChangeSubject.java59
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsCreator.java23
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsFileHandler.java144
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSelfHandler.java90
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSynchronizer.java176
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsUtil.java102
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettings.java91
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsHandler.java22
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsListener.java20
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/INotify.java20
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ISubject.java23
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/Logger.java143
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/SimpleNodeOperator.java347
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/CaretMediator.java427
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/EditorPlugin.java156
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/FileModelProvider.java984
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/GotoAnnotationAction.java350
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IHelpContextIds.java155
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IModelProvider.java20
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IReleasable.java20
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ISourceViewerActionBarContributor.java27
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ITemporaryAnnotation.java17
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/Logger.java145
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/NullModelProvider.java112
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ReadOnlyAwareDropTargetAdapter.java43
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckActionWrapper.java197
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckTargetImpl.java256
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StorageModelProvider.java421
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredAnnotationType.java60
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentCommand.java476
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentToTextAdapter.java1083
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredLineChangeHover.java53
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredMarkerAnnotation.java129
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredResourceMarkerAnnotationModel.java91
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredSharedTextColors.java77
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextAnnotationHover.java350
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextColors.java196
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java2637
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextLineBreakingReader.java110
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextReconciler.java742
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextSelectionChangedEvent.java29
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextUndoManagerImpl.java607
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java1129
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewerConfiguration.java412
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/TextFileModelProvider.java466
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManager.java52
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManagerImpl.java708
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IRelevanceCompletionProposal.java28
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IResourceDependentProcessor.java24
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboList.java285
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboListOnPropertyPage.java37
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ContentSettingsPropertyPage.java292
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/AbstractDropAction.java67
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedConfigurationBuilder.java204
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorActionBuilder.java670
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorDropTargetAdapter.java301
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FileDropAction.java52
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FormatProcessorsExtensionReader.java104
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IActionValidator.java17
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IDropAction.java35
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedConfiguration.java17
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedContributor.java30
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedEditorAction.java37
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditor.java33
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditorExtension.java30
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedSimpleEditor.java35
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IPopupMenuContributor.java22
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/SpellCheckProviderBuilder.java239
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TextDropAction.java32
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TransferBuilder.java425
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ConfigurationPointCalculator.java138
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ExtensionsPlugin.java80
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ISelfValidateEditAction.java29
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/Logger.java143
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointConstants.java21
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointProvider.java69
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IExtendedStorageEditorInput.java35
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NodeLocation.java40
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NullSourceEditingTextTools.java60
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/SourceEditingTextTools.java61
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/openon/IOpenOn.java49
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckAction.java23
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckElement.java24
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckException.java32
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckOptionDialog.java24
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckProvider.java21
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionListener.java22
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionManager.java24
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckTarget.java57
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellChecker.java35
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/ContentAssistUtils.java88
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CustomCompletionProposal.java296
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/IRelevanceConstants.java17
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/ContributedProcessorDescriptor.java35
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickAssistProcessor.java31
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickFixProcessor.java30
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/NoModificationCompletionProposal.java66
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/StructuredCorrectionProcessor.java164
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/BreakpointRulerAction.java344
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/EditBreakpointAction.java67
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java96
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ToggleBreakpointAction.java170
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImageHelper.java154
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImages.java33
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTML2TextReader.java308
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTMLTextPresenter.java199
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/IHelpContextIds.java58
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/LineBreakingReader.java124
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SingleCharReader.java70
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SubstitutionTextReader.java161
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/StructuredTextEditorViewer.java512
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/TextStorageEditorInput.java99
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ActionDescriptor.java383
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/BreakpointProviderBuilder.java399
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java165
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ExtendedEditorActionProxy.java155
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ImageUtil.java84
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/RegistryReader.java171
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/ExternalFileEditorInput.java113
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenFileHyperlinkTracker.java682
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnAction.java65
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnBuilder.java255
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnDefinition.java157
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/OverlayPreferenceStore.java487
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/TabFolderLayout.java60
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java488
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentAdapter.java44
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileAnnotationKey.java32
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileStepAdapter.java49
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcileStep.java60
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcilingStrategy.java40
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/ReconcileAnnotationKey.java60
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java285
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/TemporaryAnnotation.java132
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalHelper.java61
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalReporter.java85
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java235
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorBuilder.java143
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java182
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java173
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java159
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchLabelProvider.java76
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchQuery.java214
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java145
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesContentProvider.java69
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchQuery.java156
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchResult.java116
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchViewPage.java109
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java86
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java101
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java46
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java58
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java63
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java58
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/taginfo/DebugInfoHoverProcessor.java123
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/ui/StructuredTextAnnotationImageProvider.java50
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCommandImpl.java107
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCompoundCommandImpl.java221
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/nls/ResourceHandler.java75
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/AbstractOpenOn.java279
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/OpenOnProvider.java132
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/CommonEditorPreferenceNames.java154
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceKeyGenerator.java28
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceManager.java362
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractColorPage.java309
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferencePage.java281
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferenceTab.java260
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorEditor.java142
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorHelper.java69
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorNames.java27
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/EditStructuredTextEditorPreferencesAction.java238
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/FilePreferencePage.java131
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/IPreferenceTab.java27
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/NavigationPreferenceTab.java207
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StatusInfo.java194
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StructuredTextEditorPreferencePage.java538
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StyledTextColorPicker.java1035
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TaskTagPreferenceTab.java484
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TextHoverPreferenceTab.java411
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TranslucencyPreferenceTab.java64
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryProvider.java32
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistry.java28
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryImpl.java43
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryReader.java78
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryProvider.java23
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryImpl.java46
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryReader.java83
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/AbstractLineStyleProvider.java317
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/Highlighter.java518
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/IHighlighter.java40
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProvider.java46
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProviderForNoOp.java46
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/YUV_RGBConverter.java203
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AbstractBestMatchHoverProcessor.java125
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AnnotationHoverProcessor.java202
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/ProblemAnnotationHoverProcessor.java42
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/TextHoverManager.java199
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionContributor.java363
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionDefinitionIds.java41
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActiveEditorActionHandler.java273
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/BasicAutoEditStrategy.java49
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/CleanupAction.java79
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRActionDelegate.java21
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRLFActionDelegate.java202
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToLFActionDelegate.java21
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/FormatActionDelegate.java149
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionDelegate.java98
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionProgressDialog.java564
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/SharedEditorPluginImageHelper.java54
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/StructuredTextEditorActionConstants.java43
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/text/DocumentRegionEdgeMatcher.java114
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/AccessibleInputDialog.java244
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Assert.java140
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/EditorUtility.java134
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ImageRegistry.java179
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/PlatformStatusLineUtil.java171
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/RegistryReader.java170
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ShowViewAction.java103
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Sorter.java80
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/SourceEditorImageHelper.java97
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/CaretEvent.java47
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ICaretListener.java20
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/INodeSelectionListener.java20
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ITextSelectionListener.java20
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/NodeSelectionChangedEvent.java37
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/TextSelectionChangedEvent.java35
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/ContentOutlineConfiguration.java226
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapter.java44
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapterFactory.java27
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateAction.java77
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateActionContributionItem.java69
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/SourceEditorTreeViewer.java238
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredContentOutlineConfiguration.java260
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredTextEditorContentOutlinePage.java455
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySheetEntryLabelProvider.java50
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySourceProvider.java33
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ConfigurablePropertySheetPage.java275
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/CustomPropertyDescriptor.java91
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/EnumeratedStringPropertyDescriptor.java75
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/IPropertySourceExtension.java19
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/PropertySheetConfiguration.java168
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/RemoveAction.java46
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ShowPropertiesAction.java36
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StringComboBoxCellEditor.java111
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StructuredPropertySheetConfiguration.java116
249 files changed, 0 insertions, 42777 deletions
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractContentSettingsHandler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractContentSettingsHandler.java
deleted file mode 100644
index 1c79f6ae59..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractContentSettingsHandler.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-import org.eclipse.core.resources.IResourceDelta;
-
-abstract class AbstractContentSettingsHandler implements IContentSettingsHandler {
-
-
- private IContentSettings contentSettings = ContentSettingsCreator.create();
- private IResourceDelta fDelta;
-
-
- /*
- * @see IContentSettingsHandler#handle(IResourceDelta)
- */
- public void handle(final IResourceDelta delta) {
- this.fDelta = delta;
- // get Resource delta kind
- final int kind = delta.getKind();
- // never used!?
- //IResource resource = delta.getResource();
-
-
- switch (kind) {
- case IResourceDelta.CHANGED :
- {
- handleChanged();
- }
- break;
- case IResourceDelta.REMOVED :
- {
- handleRemoved();
- }
- break;
- case IResourceDelta.ADDED :
- {
- handleAdded();
- }
- break;
-
-
- }
-
-
-
- }
-
- private void commonWithRespectToKind() {
- getContentSettings().releaseCache();
- }
-
- protected void handleChanged() {
- commonWithRespectToKind();
- }
-
- protected void handleRemoved() {
- commonWithRespectToKind();
- }
-
- protected void handleAdded() {
- commonWithRespectToKind();
- }
-
- protected final IResourceDelta getDelta() {
- return fDelta;
- }
-
- protected final IContentSettings getContentSettings() {
- return contentSettings;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractSubject.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractSubject.java
deleted file mode 100644
index 2a996414c7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/AbstractSubject.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-public abstract class AbstractSubject implements INotify, ISubject {
-
-
-
- private static Map listenerList = new Hashtable();
-
- /*
- * @see IContentSettingsEventSubject#notifyContentSettingsListeners(Object)
- */
- public synchronized void notifyListeners(org.eclipse.core.resources.IResource changedResource) {
-
- Set keys = listenerList.keySet();
- Iterator iter = keys.iterator();
-
- while (iter.hasNext()) {
- IContentSettingsListener csl = (IContentSettingsListener) iter.next();
- csl.contentSettingsChanged(changedResource);
- }
- }
-
- public synchronized void addListener(IContentSettingsListener listener) {
- listenerList.put(listener, listener);
- }
-
- public synchronized void removeListener(IContentSettingsListener listener) {
- listenerList.remove(listener);
- }
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentPropertiesPlugin.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentPropertiesPlugin.java
deleted file mode 100644
index a9316d51a4..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentPropertiesPlugin.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.ui.IStartup;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class ContentPropertiesPlugin extends Plugin implements IStartup {
- //The shared instance.
- private static ContentPropertiesPlugin plugin;
-
- /**
- * Returns the shared instance.
- */
- public static ContentPropertiesPlugin getDefault() {
- if (plugin == null) {
- plugin = new ContentPropertiesPlugin();
- }
- return plugin;
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = ContentPropertiesPlugin.getDefault().getResourceBundle();
- try {
- return bundle.getString(key);
- }
- catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- //Resource bundle.
- private ResourceBundle resourceBundle;
-
- /**
- * The constructor.
- */
- private ContentPropertiesPlugin() {
- plugin = this;
- try {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.sse.contentproperties.ContentPropertiesPluginResources"); //$NON-NLS-1$
- }
- catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- public static void disableSynchronizer() {
- ContentSettingsSynchronizer listener = ContentSettingsSynchronizer.getInstance();
- if (listener != null && listener.isListening())
- listener.unInstall();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IStartup#earlyStartup()
- */
- public void earlyStartup() {
- enableSynchronizer();
- }
-
- public static void enableSynchronizer() {
- ContentSettingsSynchronizer listener = ContentSettingsSynchronizer.getInstance();
- if (listener != null && !listener.isListening())
- listener.install();
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#shutdown()
- */
- public void shutdown() throws CoreException {
- super.shutdown();
- disableSynchronizer();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#startup()
- */
- public void startup() throws CoreException {
- super.startup();
- enableSynchronizer();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettings.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettings.java
deleted file mode 100644
index c5a72f024b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettings.java
+++ /dev/null
@@ -1,697 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class ContentSettings implements IContentSettings {
-
- private static final IContentSettings singleton = new ContentSettings();
-
- private static SimpleNodeOperator domOperator;
- private static final String contentSettingsName = ".contentsettings";//$NON-NLS-1$
- private String contentSettingsPath;
-
- private static IProject preProject;
- private IProject currProject;
-
-
-
- private final String rootElementName = "contentsettings";//$NON-NLS-1$
- private final String projectElementName = "project";//$NON-NLS-1$
- private final String fileElementName = "file";//$NON-NLS-1$
- private final String PATHATTR = "path"; //$NON-NLS-1$
-
-
-
- private ContentSettings() {
- currProject = null;
- contentSettingsPath = null;
- }
-
- public final String getPathAttr() {
- return PATHATTR;
- }
-
- public static final String getContentSettingsName() {
- return contentSettingsName;
- }
-
- public synchronized static IContentSettings getInstance() {
- return singleton;
- }
-
-
- private String getProjectOf(IResource resource) {
- //if (resource==null) return null;
- currProject = resource.getProject();
- //String projectPath=null;
-
- IPath path = currProject.getLocation();
- if (path == null) {
- path = ResourcesPlugin.getWorkspace().getRoot().getLocation();
- if (path != null) {
- path = path.addTrailingSeparator();
- path = path.append(currProject.getName());
- }
- }
- return (path != null) ? path.toString() : null;
-
- }
-
- private String getRelativePathFromProject(IResource resource) {
- if (resource == null)
- return null;
-
- IPath path = resource.getProjectRelativePath();
- if (path == null)
- return null; // if resource is project or workspace root
- String resourcePath = path.toString();
-
- return resourcePath;
-
- }
-
-
- private boolean existsContentSettings() {
- if (contentSettingsPath == null)
- return false;
-
- IResource file = currProject.getFile(contentSettingsName);
- if (file == null)
- return false;
- if (file.isAccessible())
- return true;
- else
- return false;
-
- }
-
-
- private void createDOMTree() throws SimpleNodeOperator.ReadContentSettingsFailureException {
- if (domOperator == null || (currProject != null && (!currProject.equals(preProject)) && contentSettingsPath != null))
- domOperator = new SimpleNodeOperator(contentSettingsPath);
-
-
- }
-
- /*
- * private void createNewDOMTree() throws
- * SimpleNodeOperator.CreateContentSettingsFailureException{ // create New
- * document when no file exists. DOMImplementation impl =
- * DOMImplementationImpl.getDOMImplementation(); Document document =
- * impl.createDocument(null,rootElementName,null); domOperator = new
- * SimpleNodeOperator(document); }
- */
- private void createNewDOMTree() throws SimpleNodeOperator.CreateContentSettingsFailureException {
- Document document = null;
- try {
- document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
- }
- catch (ParserConfigurationException e) {
- Logger.logException("exception creating document", e); //$NON-NLS-1$
- }
- catch (FactoryConfigurationError e) {
- Logger.logException("exception creating document", e); //$NON-NLS-1$
- }
- document.appendChild(document.createElement(rootElementName));
- domOperator = new SimpleNodeOperator(document);
- }
-
- private void writeDOMDocument() throws SimpleNodeOperator.WriteContentSettingsFailureException {
- try {
-
- ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
- domOperator.writeDocument(outputStream);
- outputStream.flush();
- outputStream.close();
-
- ByteArrayInputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
-
- IFile outputFile = currProject.getFile(contentSettingsName);
- if (outputFile.exists())
- outputFile.setContents(inputStream, true, true, null);
- else
- outputFile.create(inputStream, true, null);
-
- inputStream.close();
- }
- catch (CoreException e) {
- Logger.logException(e);
- throw new SimpleNodeOperator.WriteContentSettingsFailureException("invalid outputFile in writeDOMDocument()");//$NON-NLS-1$
- }
- catch (IOException e) {
- Logger.logException(e);
- throw new SimpleNodeOperator.WriteContentSettingsFailureException("invalid outputStream or inputStream in writeDOMDocument()");//$NON-NLS-1$
- }
- }
-
- private String getContentSettingsPath(IResource resource) {
- String projectPath = getProjectOf(resource);
- StringBuffer strbuf = new StringBuffer(""); //$NON-NLS-1$
- if (projectPath != null) {
- strbuf.append(projectPath);
- strbuf.append(IPath.SEPARATOR);
- strbuf.append(contentSettingsName);
- }
- else
- return null;
-
- String str = strbuf.toString();
- strbuf.delete(0, strbuf.length());
- return str;
- }
-
- public synchronized String getProperty(final IResource resource, final String propertyName) {
- if (resource == null)
- return null;
-
- if (!(resource.getType() == IResource.PROJECT || resource.getType() == IResource.FILE))
- return null;
-
- contentSettingsPath = getContentSettingsPath(resource);
- if (contentSettingsPath == null)
- return null;
-
- if (!existsContentSettings()) {
- return null; // when .contentsettings.xml is NOT exist.
- }
-
-
- try {
- createDOMTree();
- }
- catch (SimpleNodeOperator.ReadContentSettingsFailureException e1) {
- Logger.logException(e1);
- // create DOM tree for new XML Document
- try {
- createNewDOMTree();
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.CreateContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return null;
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return null;
- }
-
- }
-
-
- Element e = null;
- if (resource.getType() == IResource.PROJECT)
- // select project element and get attribute
- e = (Element) domOperator.getElementWithNodeName(this.projectElementName);
- else if (resource.getType() == IResource.FILE)
- e = (Element) domOperator.getElementWithAttribute(getPathAttr(), getRelativePathFromProject(resource));
-
-
- if (e != null) {
- String result = e.getAttribute(propertyName);
- preProject = currProject;
- return result;
- }
- else {
- preProject = currProject;
- return null;// when project or file element is NOT exist.
- }
- }
-
-
- private void _setProperty(final IResource resource, final String propertyName, final String propertyValue) {
- if (resource == null || propertyName == null)
- return;
- if (!(resource.getType() == IResource.PROJECT || resource.getType() == IResource.FILE))
- return;
-
- contentSettingsPath = getContentSettingsPath(resource);
- if (contentSettingsPath == null)
- return;
-
- try {
-
- if (!existsContentSettings()) {
- // create DOM tree for new XML Document
- createNewDOMTree();
- }
- else {
- // create DOM tree from existing contentsettings.
- createDOMTree();
- }
-
- }
- catch (SimpleNodeOperator.ReadContentSettingsFailureException e) {
- Logger.logException(e);
- try {
- createNewDOMTree();
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.CreateContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return;
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return;
- }
-
- }
- catch (SimpleNodeOperator.CreateContentSettingsFailureException e) {
- Logger.logException(e);
- preProject = currProject;
- return;
- }
-
- Element e = null;
- if (resource.getType() == IResource.PROJECT) {
- e = (Element) domOperator.getElementWithNodeName(this.projectElementName);
- if (e == null) {
- // create project Element and add it into tree
- e = (Element) domOperator.addElementUnderRoot(this.projectElementName);
- }
- }
- else if (resource.getType() == IResource.FILE) {
- // check exists file Element
- e = (Element) domOperator.getElementWithAttribute(getPathAttr(), getRelativePathFromProject(resource));
- if (e == null) {
- // create file Element and add path into it.
- e = (Element) domOperator.addElementUnderRoot(this.fileElementName);
- domOperator.addAttributeAt(e, getPathAttr(), getRelativePathFromProject(resource));
- }
- }
-
- // check exists propertyName attribute
-
- Map attrList = domOperator.getAttributesOf(e);
- if (attrList == null || attrList.isEmpty() || (String) attrList.get(propertyName) == null)
- // create propertyName attribute and add
- domOperator.addAttributeAt(e, propertyName, propertyValue);
- else
- // set attribute value
- domOperator.updateAttributeAt(e, propertyName, propertyValue);
-
-
- // write dom tree into .contentsettings
- try {
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException ex) {
- Logger.logException(ex);
- preProject = currProject;
- return;
- }
-
- preProject = currProject;
-
-
- }
-
- public synchronized void setProperty(final IResource resource, final String propertyName, final String propertyValue) {
- // deny to set "path" attribute value.
- if (this.getPathAttr().equals(propertyName))
- return;
- this._setProperty(resource, propertyName, propertyValue);
- }
-
- public synchronized void deleteProperty(final IResource resource, final String propertyName) {
- if (resource == null)
- return;
- if (!(resource.getType() == IResource.PROJECT || resource.getType() == IResource.FILE))
- return;
- contentSettingsPath = getContentSettingsPath(resource);
- if (contentSettingsPath == null)
- return;
-
- if (!existsContentSettings()) {
- return; // when .contentsettings.xml is NOT exist.
- }
- try {
- createDOMTree();
- }
- catch (SimpleNodeOperator.ReadContentSettingsFailureException e) {
- Logger.logException(e);
- try {
- createNewDOMTree();
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.CreateContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return;
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return;
- }
- }
-
- Element e = null;
- if (resource.getType() == IResource.PROJECT)
- // select project element and get attribute
- e = (Element) domOperator.getElementWithNodeName(this.projectElementName);
- else if (resource.getType() == IResource.FILE)
- e = (Element) domOperator.getElementWithAttribute(getPathAttr(), getRelativePathFromProject(resource));
-
-
- if (e != null) {
- domOperator.removeAttributeAt(e, propertyName);
- // write dom tree into .contentsettings
- try {
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException ex) {
- Logger.logException(ex);
- preProject = currProject;
- return;
- }
- }
-
- preProject = currProject;
-
- }
-
- public synchronized void releaseCache() {
- domOperator = null;
- }
-
-
- /**
- *
- */
- public synchronized void deleteAllProperties(final IResource deletedFile) {
- if (deletedFile == null)
- return;
- // if (deletedFile.exists()) return;
- if ((deletedFile).getType() != IResource.FILE && (deletedFile).getType() != IResource.PROJECT)
- return;
-
-
- contentSettingsPath = getContentSettingsPath(deletedFile);//getProjectOf((IResource)deletedFile)
- // +
- // IPath.SEPARATOR
- // +
- // contentSettingsName;
- if (contentSettingsPath == null)
- return;
- if (!existsContentSettings())
- return;
-
- try {
- createDOMTree();
- }
- catch (SimpleNodeOperator.ReadContentSettingsFailureException e) {
- Logger.logException(e);
- return;
- }
-
- Element e = null;
- if (deletedFile.getType() == IResource.PROJECT)
- // select project element and get attribute
- e = (Element) domOperator.getElementWithNodeName(this.projectElementName);
- else if (deletedFile.getType() == IResource.FILE)
- e = (Element) domOperator.getElementWithAttribute(getPathAttr(), getRelativePathFromProject(deletedFile));
- if (e == null) {
- preProject = currProject;
- return;
- }
-
-
- // when deletedFile entry exists.
- if (deletedFile.getType() == IResource.PROJECT)
- domOperator.removeElementWith(this.projectElementName);
- else if (deletedFile.getType() == IResource.FILE)
- domOperator.removeElementWith(getPathAttr(), getRelativePathFromProject(deletedFile));
-
-
- // write dom tree into .contentsettings
- try {
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException ex) {
- Logger.logException(ex);
- preProject = currProject;
- return;
- }
-
- preProject = currProject;
-
-
- }
-
-
- private void _setProperties(final IResource resource, final Map properties) {
- if (resource == null || properties == null || properties.isEmpty())
- return;
- if (!(resource.getType() == IResource.PROJECT || resource.getType() == IResource.FILE))
- return;
-
- contentSettingsPath = getContentSettingsPath(resource);
- if (contentSettingsPath == null)
- return;
-
- try {
-
- if (!existsContentSettings()) {
- // create DOM tree for new XML Document
- createNewDOMTree();
- }
- else {
- // create DOM tree from existing contentsettings.
- createDOMTree();
- }
-
- }
- catch (SimpleNodeOperator.ReadContentSettingsFailureException e) {
- Logger.logException(e);
- try {
- createNewDOMTree();
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.CreateContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return;
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return;
- }
-
- }
- catch (SimpleNodeOperator.CreateContentSettingsFailureException e) {
- Logger.logException(e);
- preProject = currProject;
- return;
- }
-
- Element e = null;
- if (resource.getType() == IResource.PROJECT) {
- e = (Element) domOperator.getElementWithNodeName(this.projectElementName);
- if (e == null) {
- // create project Element and add it into tree
- e = (Element) domOperator.addElementUnderRoot(this.projectElementName);
- }
- }
- else if (resource.getType() == IResource.FILE) {
- // check exists file Element
- e = (Element) domOperator.getElementWithAttribute(getPathAttr(), getRelativePathFromProject(resource));
- if (e == null) {
- // create file Element and add path into it.
- e = (Element) domOperator.addElementUnderRoot(this.fileElementName);
- domOperator.addAttributeAt(e, getPathAttr(), getRelativePathFromProject(resource));
- }
- }
-
- // check exists propertyName attribute
- Map attrList = domOperator.getAttributesOf(e);
- boolean hasAttr = true;
- if (attrList == null || attrList.isEmpty())
- hasAttr = false;
- Set keys = properties.keySet();
- Iterator ii = keys.iterator();
- while (ii.hasNext()) {
- String propertyName = (String) ii.next();
- String propertyValue = (String) properties.get(propertyName);
-
-
- if (!hasAttr || (String) attrList.get(propertyName) == null)
- // create propertyName attribute and add
- domOperator.addAttributeAt(e, propertyName, propertyValue);
- else
- // set attribute value
- domOperator.updateAttributeAt(e, propertyName, propertyValue);
- }
-
- // write dom tree into .contentsettings
- try {
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException ex) {
- Logger.logException(ex);
- preProject = currProject;
- return;
- }
-
- preProject = currProject;
-
-
- }
-
- public synchronized void setProperties(final IResource resource, final Map properties) {
- // deny to set "path" attribute value.
- Set keys = properties.keySet();
- Iterator ii = keys.iterator();
- while (ii.hasNext()) {
- if (this.getPathAttr().equals(ii.next()))
- return;
- }
- this._setProperties(resource, properties);
- }
-
-
- public synchronized Map getProperties(final IResource resource) {
- if (resource == null)
- return null;
-
- if (!(resource.getType() == IResource.PROJECT || resource.getType() == IResource.FILE))
- return null;
-
- contentSettingsPath = getContentSettingsPath(resource);
- if (contentSettingsPath == null)
- return null;
-
- if (!existsContentSettings()) {
- return null; // when .contentsettings.xml is NOT exist.
- }
-
-
- try {
- createDOMTree();
- }
- catch (SimpleNodeOperator.ReadContentSettingsFailureException e1) {
- Logger.logException(e1);
- // create DOM tree for new XML Document
- try {
- createNewDOMTree();
- writeDOMDocument();
- }
- catch (SimpleNodeOperator.CreateContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return null;
- }
- catch (SimpleNodeOperator.WriteContentSettingsFailureException e2) {
- Logger.logException(e2);
- preProject = currProject;
- return null;
- }
-
- }
-
-
- Element e = null;
- if (resource.getType() == IResource.PROJECT)
- // select project element and get attribute
- e = (Element) domOperator.getElementWithNodeName(this.projectElementName);
- else if (resource.getType() == IResource.FILE)
- e = (Element) domOperator.getElementWithAttribute(getPathAttr(), getRelativePathFromProject(resource));
-
-
- if (e != null) {
-
- Map properties = domOperator.getAttributesOf(e);
- preProject = currProject;
- if (properties == null)
- return null;
- if (properties.isEmpty())
- return null;
- properties.remove(getPathAttr());
- return properties;
- }
- else {
- preProject = currProject;
- return null;// when project or file element is NOT exist.
- }
- }
-
- public boolean existsProperties(IResource resource) {
- if (resource == null)
- return false;
-
- if (!(resource.getType() == IResource.PROJECT || resource.getType() == IResource.FILE))
- return false;
-
- contentSettingsPath = getContentSettingsPath(resource);
- if (contentSettingsPath == null)
- return false;
-
- if (!existsContentSettings())
- return false; // when .contentsettings.xml is NOT exist.
-
- try {
- createDOMTree();
- }
- catch (SimpleNodeOperator.ReadContentSettingsFailureException e1) {
- return false;
- }
-
- Element e = null;
- if (resource.getType() == IResource.PROJECT)
- // select project element and get attribute
- e = (Element) domOperator.getElementWithNodeName(this.projectElementName);
- else if (resource.getType() == IResource.FILE)
- e = (Element) domOperator.getElementWithAttribute(getPathAttr(), getRelativePathFromProject(resource));
-
- preProject = currProject;
- if (e == null)
- return false;
-
- Map properties = domOperator.getAttributesOf(e);
- if (properties == null)
- return false;
- properties.remove(getPathAttr());// if IFile,removed
- if (properties.isEmpty())
- return false;
- return true;
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsChangeSubject.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsChangeSubject.java
deleted file mode 100644
index 80880b518f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsChangeSubject.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-public class ContentSettingsChangeSubject extends AbstractSubject {
-
-
- private static INotify notify;
- private static ISubject subject;
-
- protected static INotify getNotify() {
- if (notify == null && subject == null) {
- synchronized (ContentSettingsChangeSubject.class) {
- if (notify == null && subject == null) {
- notify = new ContentSettingsChangeSubject();
- subject = (ISubject) notify;
- }
- }
- }
-
- return notify;
- }
-
- public static ISubject getSubject() {
- if (subject == null && notify == null) {
- synchronized (ContentSettingsChangeSubject.class) {
- if (subject == null && notify == null) {
- subject = new ContentSettingsChangeSubject();
- notify = (INotify) subject;
- }
- }
- }
- return subject;
- }
-
- public synchronized void notifyListeners(org.eclipse.core.resources.IResource changedResource) {
- super.notifyListeners(changedResource);
- }
-
- public synchronized void addListener(IContentSettingsListener listener) {
- super.addListener(listener);
- }
-
- public synchronized void removeListener(IContentSettingsListener listener) {
- super.removeListener(listener);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsCreator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsCreator.java
deleted file mode 100644
index ffa992f21b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsCreator.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-public class ContentSettingsCreator {
-
- public final static IContentSettings create() {
- return ContentSettings.getInstance();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsFileHandler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsFileHandler.java
deleted file mode 100644
index d78b7ff5dc..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsFileHandler.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-
-class ContentSettingsFileHandler extends AbstractContentSettingsHandler {
-
-
-
- private Map properties;
-
-
- private void getProperties(IResource file) {
- properties = getContentSettings().getProperties(file);
- }
-
- private void setProperties(IResource file) {
- if (file.getFileExtension() == null)
- return;
- if (!(file.getFileExtension().equalsIgnoreCase("shtml")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("htm")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("html")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("jhtml")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("xhtml")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("jsp")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("css")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("jsf")//$NON-NLS-1$
- || file.getFileExtension().equalsIgnoreCase("jspf")))//$NON-NLS-1$
- return;
- if (properties == null || properties.isEmpty())
- return;
- getContentSettings().setProperties(file, properties);
- }
-
-
- /*
- * @see AbstractContentSettingsHandler#handleChanged()
- */
- protected void handleChanged() {
- // edit
- if (getDelta().getFlags() == IResourceDelta.CONTENT && (getDelta().getFlags() & IResourceDelta.REPLACED) == 0) {
- super.handleChanged();
-
- }
- else if (getDelta().getFlags() == IResourceDelta.CONTENT && (getDelta().getFlags() & IResourceDelta.REPLACED) != 0) {
- // override as a result of copy or import
- // in Web project, copy with override doesn't happen
-
- // override as move or rename
- // handleRemoved() works for this delta
- super.handleChanged();
-
- }
-
-
- }
-
- /*
- * @see AbstractContentSettingsHandler#handleRemoved()
- */
- protected void handleRemoved() {
- super.handleRemoved();
- IFile deletedFile = null;
-
- // if entry exists then remove it.
- if (getDelta().getFlags() == 0) {
- // pulldown menu->delete
- deletedFile = (IFile) getDelta().getResource();
-
- if (deletedFile == null)
- return;
- getContentSettings().deleteAllProperties(deletedFile);
-
- getContentSettings().releaseCache();
- }
-
- else if ((getDelta().getFlags() & IResourceDelta.MOVED_TO) != 0) {
-
- // pulldown menu-> rename, pulldown menu->move
- deletedFile = (IFile) getDelta().getResource();
- getProperties(deletedFile);
-
- // get destination IResource
- IPath targetPath = getDelta().getMovedToPath();
- IWorkspaceRoot iwr = ResourcesPlugin.getWorkspace().getRoot();
- IResource targetFile = iwr.getFile(targetPath);//iwr.findMember(targetPath);
-
- // set property of destination file
- getContentSettings().deleteAllProperties(targetFile);
- setProperties(targetFile);
- if (properties != null)
- properties.clear();
- properties = null;
- }
-
- if (deletedFile == null)
- return;
- getContentSettings().deleteAllProperties(deletedFile);
-
- getContentSettings().releaseCache();
-
- }
-
- /*
- * @see AbstractContentSettingsHandler#handleAdded()
- */
- protected void handleAdded() {
- super.handleAdded();
-
- if (super.getDelta().getFlags() == 0) {
- // pulldown memu->copy->create file without override, new file, import without override
- // copy,new,import has same kind(=1) and flag(=0).
-
- }
- else if ((getDelta().getFlags() & IResourceDelta.MOVED_FROM) != 0) {
- // pulldown menu-> rename without override,pulldown menu->move without override
- // instead of this method,handleRemoved() works for this delta
-
- }
-
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSelfHandler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSelfHandler.java
deleted file mode 100644
index 7d2e579250..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSelfHandler.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-import org.eclipse.core.resources.IResourceDelta;
-
-final class ContentSettingsSelfHandler extends AbstractContentSettingsHandler {
-
- private static INotify notify;// = new ContentSettingsChangedSubject();
-
-
- private final void getSubject() {
- notify = ContentSettingsChangeSubject.getNotify();
- }
-
-
- /*
- * @see AbstractContentSettingsHandler#handleChanged()
- */
- protected void handleChanged() {
- getSubject();
- if ((getDelta().getFlags() & IResourceDelta.CONTENT) != 0 && (getDelta().getFlags() & IResourceDelta.REPLACED) == 0) {
- // result of edit, property page operate setProperty(apply or ok button) in .contentsettings
- super.handleChanged();
-
- notify.notifyListeners(getDelta().getResource());
-
- }
- else if ((getDelta().getFlags() & IResourceDelta.CONTENT) != 0 && (getDelta().getFlags() & IResourceDelta.REPLACED) != 0) {
- super.handleChanged();
- notify.notifyListeners(getDelta().getResource());
-
- }
-
-
- }
-
- /*
- * @see AbstractContentSettingsHandler#handleRemoved()
- */
- protected void handleRemoved() {
- getSubject();
- if (getDelta().getFlags() == 0) {
- // pulldown menu->delete
- super.handleRemoved();
- notify.notifyListeners(getDelta().getResource());
-
- }
- else if ((getDelta().getFlags() & IResourceDelta.MOVED_TO) != 0) {
- // pulldown menu-> rename, pulldown menu->move
- super.handleRemoved();
- notify.notifyListeners(getDelta().getResource());
-
- }
-
- }
-
- /*
- * @see AbstractContentSettingsHandler#handleAdded()
- */
- protected void handleAdded() {
- getSubject();
- if (super.getDelta().getFlags() == 0) {
- // pulldown memu->copy->create file without override, new file, property page create .contentsettings
- super.handleAdded();
- notify.notifyListeners(getDelta().getResource());
-
- }
- else if ((getDelta().getFlags() & IResourceDelta.MOVED_FROM) != 0) {
- // pulldown menu-> rename without override,pulldown menu->move without override
- super.handleAdded();
- notify.notifyListeners(getDelta().getResource());
-
- }
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSynchronizer.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSynchronizer.java
deleted file mode 100644
index 08b2084926..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsSynchronizer.java
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceChangeEvent;
-import org.eclipse.core.resources.IResourceChangeListener;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.PlatformUI;
-
-public class ContentSettingsSynchronizer implements IResourceChangeListener {
- class ContentSettingsVisitor implements IResourceDeltaVisitor {
- // redefinition in ContentSettings.java
- private String contentSettingsName = ContentSettings.getContentSettingsName(); //$NON-NLS-1$
- private IResourceChangeEvent fEvent;
- private IContentSettingsHandler handler;
-
- public ContentSettingsVisitor(IResourceChangeEvent event) {
- this.fEvent = event;
- }
-
- /**
- * @see IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) {
- if (delta == null)
- return false;
- IResource resource = delta.getResource();
- if (resource == null)
- return false;
- // parent folder or project
- if (delta.getKind() == IResourceDelta.CHANGED && delta.getFlags() == 0)
- return true;
- final int resourceType = resource.getType();
- switch (resourceType) {
- case IResource.PROJECT :
- return false;
- case IResource.FILE :
- // whether resource is .contentsettings file or not
- IProject project = delta.getResource().getProject();
- if (this.fEvent.getType() == IResourceChangeEvent.POST_CHANGE && resource.equals(project.getFile(this.contentSettingsName))) {
- // new object for .contentsettings
- handler = new ContentSettingsSelfHandler();
- }
- else if (this.fEvent.getType() == IResourceChangeEvent.PRE_BUILD && resource.getFileExtension() != null) {
- //TODO change to content type!
- if (resource.getFileExtension().equalsIgnoreCase("shtml") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("htm") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("html") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("jhtml") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("xhtml") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("jsp") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("css") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("jsf") //$NON-NLS-1$
- || resource.getFileExtension().equalsIgnoreCase("jspf")) { //$NON-NLS-1$
- // new object for IFile
- handler = new ContentSettingsFileHandler();
- handler.handle(delta);
- handler = null;
- return true;
- }
- }
- else
- return false; // true or false;motomoto true;
- break;
- case IResource.FOLDER :
- return true;
- default :
- return true;
- }
- final IResourceDelta fDelta = delta;
- final IContentSettingsHandler deltaHandler = this.handler;
- Display display = getDisplay();
- if (display != null && !display.isDisposed()) {
- display.asyncExec(new Runnable() {
- public void run() {
- if (deltaHandler != null) {
- deltaHandler.handle(fDelta);
- }
- }
- });
- }
- else if (deltaHandler != null) {
- deltaHandler.handle(fDelta);
- }
- handler = null;
- return true; // true or false;motomoto true;
- }
- }
-
- Display getDisplay() {
- IWorkbench workbench = null;
- if (PlatformUI.isWorkbenchRunning()) {
- workbench = PlatformUI.getWorkbench();
- }
- if (workbench != null)
- return workbench.getDisplay();
- return null;
- }
-
- private static ContentSettingsSynchronizer instance = null;
-
- public synchronized static ContentSettingsSynchronizer getInstance() {
- if (instance == null)
- instance = new ContentSettingsSynchronizer();
- return instance;
- }
-
- private ContentSettingsVisitor csVisitor;
- private boolean fListening = false;
- private IProject fProject;
-
- private final IProject getProject() {
- return fProject;
- }
-
- private final IWorkspace getWorkspace() {
- if (getProject() == null)
- return ResourcesPlugin.getWorkspace();
- return getProject().getWorkspace();
- }
-
- public synchronized void install() {
- if (!fListening) {
- getWorkspace().addResourceChangeListener(this, IResourceChangeEvent.PRE_BUILD | IResourceChangeEvent.POST_CHANGE);
- fListening = true;
- }
- }
-
- /**
- * @return
- */
- public boolean isListening() {
- return fListening;
- }
-
- /*
- * @see IResourceChangeListener#resourceChanged(IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- if (delta != null) {
- try {
- if (csVisitor == null)
- csVisitor = new ContentSettingsVisitor(event);
- delta.accept(csVisitor);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- csVisitor = null;
- }
-
- public synchronized void unInstall() {
- getWorkspace().removeResourceChangeListener(this);
- fListening = false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsUtil.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsUtil.java
deleted file mode 100644
index a3a834586a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ContentSettingsUtil.java
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-
-/**
- */
-public class ContentSettingsUtil {
-
-
- /**
- * Not meant to be instantiated. All static utility methods.
- */
- protected ContentSettingsUtil() {
- super();
- }
-
- public static String getEncodingFromSettings(IFile file) {
- if (file == null)
- return null;
- IProject project = file.getProject();
- if (project == null)
- return null;
- IContentSettings settings = ContentSettings.getInstance();
- if (settings == null)
- return null;
-
- String value = settings.getProperty(file, IContentSettings.JSP_PAGE_ENCODING);
- if (value == null || value.length() == 0) {
- value = settings.getProperty(project, IContentSettings.JSP_PAGE_ENCODING);
- }
- // for empty String, return null
- if (value != null && value.length() == 0) {
- value = null;
- }
-
- return value;
-
- }
-
-
-
- public static String getContentTypeFromSettings(IFile file) {
- if (file == null)
- return null;
- IProject project = file.getProject();
- if (project == null)
- return null;
- IContentSettings settings = ContentSettings.getInstance();
- if (settings == null)
- return null;
-
- String value = settings.getProperty(file, IContentSettings.JSP_CONTENT_TYPE);
- if (value == null || value.length() == 0) {
- value = settings.getProperty(project, IContentSettings.JSP_CONTENT_TYPE);
- }
- // for empty String, return null
- if (value != null && value.length() == 0) {
- value = null;
- }
- return value;
-
- }
-
-
- public static String getLanguageFromSettings(IFile file) {
- if (file == null)
- return null;
- IProject project = file.getProject();
- if (project == null)
- return null;
- IContentSettings settings = ContentSettings.getInstance();
- if (settings == null)
- return null;
-
- String value = settings.getProperty(file, IContentSettings.JSP_LANGUAGE);
- if (value == null || value.length() == 0) {
- value = settings.getProperty(project, IContentSettings.JSP_LANGUAGE);
- }
- // for empty String, return null
- if (value != null && value.length() == 0) {
- value = null;
- }
- return value;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettings.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettings.java
deleted file mode 100644
index db003ebc24..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettings.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-
-public interface IContentSettings {
-
- /**
- *
- */
- public final String DOCUMENT_TYPE = "document-type"; //$NON-NLS-1$
- /**
- *
- */
- public final String HTML_DOCUMENT_TYPE = "html-document-type"; //$NON-NLS-1$
- /**
- *
- */
- public final String CSS_PROFILE = "css-profile"; //$NON-NLS-1$
- /**
- *
- */
- public final String DEVICE_PROFILE = "target-device"; //$NON-NLS-1$
- /**
- *
- */
- public final String JSP_PAGE_ENCODING = "jsp-page-encoding"; //$NON-NLS-1$
- /**
- *
- */
- public final String JSP_LANGUAGE = "jsp-language"; //$NON-NLS-1$
- /**
- *
- */
- public final String JSP_CONTENT_TYPE = "jsp-content-type"; //$NON-NLS-1$
-
- /**
- *
- */
- public String getProperty(final IResource resource, final String propertyName);
-
- /**
- *
- */
- public void setProperty(final IResource resource, final String propertyName, final String propertyValue);
-
- /**
- *
- */
- public void deleteProperty(final IResource resource, final String propertyName);
-
- /**
- * release cache of DOM tree in .contentsettings
- */
- public void releaseCache();
-
- /**
- *
- */
- public void deleteAllProperties(final IResource deletedFile);
-
- /**
- *
- */
- public void setProperties(final IResource resource, final Map properties);
-
- /**
- *
- */
- public Map getProperties(final IResource resource);
-
- /**
- *
- */
- public boolean existsProperties(IResource resource);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsHandler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsHandler.java
deleted file mode 100644
index aa1266b48e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsHandler.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-import org.eclipse.core.resources.IResourceDelta;
-
-interface IContentSettingsHandler {
-
- public void handle(final IResourceDelta delta);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsListener.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsListener.java
deleted file mode 100644
index 47b5bbaacb..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/IContentSettingsListener.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-public interface IContentSettingsListener {
-
- void contentSettingsChanged(org.eclipse.core.resources.IResource e);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/INotify.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/INotify.java
deleted file mode 100644
index 74f343f027..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/INotify.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-interface INotify {
-
- void notifyListeners(org.eclipse.core.resources.IResource resource);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ISubject.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ISubject.java
deleted file mode 100644
index 418f40488a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/ISubject.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-public interface ISubject {
-
- void addListener(IContentSettingsListener listener);
-
- void removeListener(IContentSettingsListener listener);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/Logger.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/Logger.java
deleted file mode 100644
index f38dacf9f2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/Logger.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if desired,
- * the console. This class should only be used by classes in this plugin. Other
- * plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static Plugin fPlugin = ContentPropertiesPlugin.getDefault();
- private static final String fPluginId = fPlugin.getDescriptor().getUniqueIdentifier();
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
-
- public static final int OK = IStatus.OK; // 0
- public static final int INFO = IStatus.INFO; // 1
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int ERROR = IStatus.ERROR; // 4
-
- public static final int OK_DEBUG = 200 + OK;
- public static final int INFO_DEBUG = 200 + INFO;
- public static final int WARNING_DEBUG = 200 + WARNING;
- public static final int ERROR_DEBUG = 200 + ERROR;
-
- /**
- * Adds message to log.
- * @param level severity level of the message (OK, INFO, WARNING, ERROR, OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message text to add to the log
- * @param exception exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, fPluginId, severity, message, exception);
- fPlugin.getLog().log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- * @param message text to print
- * @param category category of the message, to be compared with /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, fPluginId, IStatus.OK, message, exception);
- fPlugin.getLog().log(statusObj);
- }
- }
-
- /**
- * @return true if the plugin for this logger is debugging
- */
- public static boolean isDebugging() {
- return fPlugin.isDebugging();
- }
-
- /**
- * Determines if currently tracing a category
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(fPluginId + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/SimpleNodeOperator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/SimpleNodeOperator.java
deleted file mode 100644
index 322377ece7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/contentproperties/SimpleNodeOperator.java
+++ /dev/null
@@ -1,347 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.contentproperties;
-
-
-
-import java.io.File;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.FactoryConfigurationError;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.traversal.NodeIterator;
-import org.xml.sax.SAXException;
-
-class SimpleNodeOperator {
-
- private String settingsFileName;
-
- //never used
- //private DOMParser parser;
- private Document fDocument;
- private Node root;
-
- public SimpleNodeOperator(String fullPath) throws ReadContentSettingsFailureException {
- this.settingsFileName = fullPath;
- createObjectOfDocument();
- }
-
-
- public SimpleNodeOperator(Document doc) throws CreateContentSettingsFailureException {
-
- if (doc == null)
- throw new CreateContentSettingsFailureException("Document doc==null");//$NON-NLS-1$
- fDocument = doc;
- root = fDocument.getLastChild();
- if (root == null)
- throw new CreateContentSettingsFailureException("Node root==null");//$NON-NLS-1$
- }
-
- private void createObjectOfDocument() throws ReadContentSettingsFailureException {
- try {
- fDocument = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(new File(settingsFileName));
- }
- catch (SAXException e) {
- Logger.logException("exception parsing" + settingsFileName, e); //$NON-NLS-1$
- }
- catch (IOException e) {
- Logger.logException("I/O exception parsing" + settingsFileName, e); //$NON-NLS-1$
- }
- catch (ParserConfigurationException e) {
- Logger.logException("exception accessing DOMImplementation", e); //$NON-NLS-1$
- }
- catch (FactoryConfigurationError e) {
- Logger.logException("exception accessing DOMImplementation", e); //$NON-NLS-1$
- }
- //get the root of the XML fDocument
- root = fDocument.getLastChild();
- if (root == null) {
- throw new ReadContentSettingsFailureException("Error: Node root==null");//$NON-NLS-1$
- }
- }
-
-
- // return a (first) Element with attr(attName=attValue) it if exists,
- // otherwise return null
- protected Node getElementWithAttribute(String attName, String attValue) {
- if (attName == null || attValue == null || !fDocument.hasChildNodes())
- return null;
- return getElementWithAttribute(fDocument.getFirstChild(), attName, attValue);
- }
-
- private Node getElementWithAttribute(Node first, String attName, String attValue) {
- Node navpoint = first;
- while (navpoint != null) {
- if (navpoint.getNodeType() == Node.ELEMENT_NODE) {
- NamedNodeMap m = navpoint.getAttributes();
- if (m == null)
- continue;
- if (m.getNamedItem(attName) != null) {
- if (attValue.equals(((Attr) m.getNamedItem(attName)).getNodeValue()))
- return navpoint;
- }
- NodeList childNodes = navpoint.getChildNodes();
- if (childNodes != null && childNodes.getLength() > 0) {
- Node holdNode = getElementWithAttribute(navpoint.getFirstChild(), attName, attValue);
- if (holdNode != null) {
- return holdNode;
- }
- }
- }
- navpoint = navpoint.getNextSibling();
- }
- return null;
- }
-
- // retrun Element which has nodeName as Node Name
- protected Node getElementWithNodeName(String nodeName) {
- if (nodeName == null)
- return null;
- NodeList nodes = fDocument.getElementsByTagName(nodeName);
- if (nodes.getLength() > 0) {
- return nodes.item(0);
- }
- return null;
- }
-
- protected Node addElementUnder(Node parent, String tagName, Map attMap) {
- if (parent == null || tagName == null)
- return null;
- Element e = fDocument.createElement(tagName);
- if (attMap != null) {
- if (!attMap.isEmpty()) {
- Set attKeys = attMap.keySet();
- Iterator iter = attKeys.iterator();
- while (iter.hasNext()) {
- String key = (String) iter.next();
- e.setAttribute(key, (String) attMap.get(key));
- }
- }
- }
- parent.appendChild(e);
- return e;
- }
-
- // add element with attMap as attribute without checking overlapping.
- protected final Node addElementUnderRoot(String tagName, Map attMap) {
- return addElementUnder(root, tagName, attMap);
- }
-
- protected final Node addElementUnderRoot(String tagName) {
- return addElementUnder(root, tagName, null);
- }
-
- // add attribute(attName=attValue) of ele without checking overlapping of
- // another attributes of ele.
- // if overlapping ,override
- protected Node addAttributeAt(Element ele, String attName, String attValue) {
- Attr att = fDocument.createAttribute(attName);
- att.setValue(attValue);
- if (ele != null)
- ele.setAttributeNode(att);
- return ele;
- }
-
- // update attribute(attName=newValue) at ele if both ele and attribute of
- // ele exist
- protected void updateAttributeAt(Element ele, String attName, String newValue) {
- Attr att = null;
- if (ele != null)
- if ((att = ele.getAttributeNode(attName)) != null)
- att.setValue(newValue);
- }
-
- // remove a (first) Element with attr(attName=attValue) and return it if
- // exists, otherwise return null
- protected Element removeElementWith(String attName, String attValue) {
- if (fDocument.hasChildNodes()) {
- Node element = getElementWithAttribute(attName, attValue);
- if (element != null && element.getNodeType() == Node.ELEMENT_NODE) {
- element.getParentNode().removeChild(element);
- return (Element) element;
- }
- }
- return null;
-
- }
-
- protected Element removeElementWith(String nodeName) {
- NodeList nodes = fDocument.getElementsByTagName(nodeName);
- for (int i = 0; i < nodes.getLength(); i++) {
- nodes.item(i).getParentNode().removeChild(nodes.item(i));
- }
- return null;
- }
-
-
- // remove attribute(attName) at ele.
- protected Attr removeAttributeAt(Element ele, String attName) {
- if (ele == null || attName == null)
- return null;
- Attr att = ele.getAttributeNode(attName);
- ele.removeAttribute(attName);
- return att;
- }
-
- protected void writeDocument(OutputStream out) throws WriteContentSettingsFailureException {
- XMLDocumentWriter writer = new XMLDocumentWriter(out);
- try {
- writer.serialize(fDocument);
- }
- finally {
- writer.close();
- }
- }
-
- public void printTree(NodeIterator iter) {
- Node n;
- while ((n = iter.nextNode()) != null) {
- System.out.println(n.getNodeName() + ":");//$NON-NLS-1$
- NamedNodeMap m = n.getAttributes();
- if (m == null)
- continue;
- for (int i = 0; i < m.getLength(); i++) {
- String attName = m.item(i).getNodeName();
- System.out.print(" " + attName + "=" + m.item(i).getNodeValue());//$NON-NLS-1$ //$NON-NLS-2$
- }
- System.out.println("");//$NON-NLS-1$
- }
- }
-
- // writer class for .contentSettings.
- class XMLDocumentWriter {
- OutputStream fOut;
-
- protected XMLDocumentWriter(OutputStream out) {
- this.fOut = out;
- }
-
- protected final void close() {
- try {
- fOut.close();
- }
- catch (IOException e) {
- // do nothing, shouldn't matter
- }
- }
-
- protected void serialize(Document sourceDocument) throws WriteContentSettingsFailureException {
- // JAXP transformation
- Source domSource = new DOMSource(sourceDocument);
- try {
- Transformer serializer = TransformerFactory.newInstance().newTransformer();
- try {
- serializer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- catch (IllegalArgumentException e) {
- // unsupported properties
- }
- serializer.transform(domSource, new StreamResult(fOut));
- }
- catch (TransformerConfigurationException e) {
- throw new WriteContentSettingsFailureException(e.getMessage());
- }
- catch (TransformerFactoryConfigurationError e) {
- throw new WriteContentSettingsFailureException(e.getMessage());
- }
- catch (TransformerException e) {
- throw new WriteContentSettingsFailureException(e.getMessage());
- }
- }
- }
-
-
- class ReadContentSettingsFailureException extends Exception {
- public ReadContentSettingsFailureException(String reason) {
- super(reason);
- }
- }
-
- class CreateContentSettingsFailureException extends Exception {
- public CreateContentSettingsFailureException(String reason) {
- super(reason);
- }
- }
-
- static class WriteContentSettingsFailureException extends Exception {
- public WriteContentSettingsFailureException(String reason) {
- super(reason);
- }
- }
-
- public static void main(String[] args) {
- SimpleNodeOperator a = null;
- try {
- a = new SimpleNodeOperator("workspace/org.eclipse.examples.contentsettings/.contentsettings.xml");//$NON-NLS-1$
- }
- catch (Exception e) {
- System.exit(0);
- }
-
- // print all Elements
- //a.printTree(iter);
-
- // add Element
- Map attMap = new Hashtable();
- attMap.put("path", "hogepath");//$NON-NLS-1$ //$NON-NLS-2$
- attMap.put("fDocument-type", "documenthogehoge");//$NON-NLS-1$ //$NON-NLS-2$
- a.addElementUnderRoot("file", attMap);//$NON-NLS-1$
-
- try {
- a.writeDocument(System.out);
- }
- catch (Exception e) {
- System.err.println(e.toString());
- }
-
- }
-
- protected Map getAttributesOf(Node node) {
- if (!node.hasAttributes())
- return null;
- Map map = new HashMap();
- NamedNodeMap attrs = node.getAttributes();
- int size = attrs.getLength();
- for (int i = 0; i < size; i++) {
- Attr attr = (Attr) attrs.item(i);
- map.put(attr.getName(), attr.getValue());
- }
- return (map);
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/CaretMediator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/CaretMediator.java
deleted file mode 100644
index b8d3aab397..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/CaretMediator.java
+++ /dev/null
@@ -1,427 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-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.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TypedEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.swt.widgets.Listener;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.Utilities;
-import org.eclipse.wst.sse.ui.util.Assert;
-import org.eclipse.wst.sse.ui.view.events.CaretEvent;
-import org.eclipse.wst.sse.ui.view.events.ICaretListener;
-
-
-/**
- * Has the responsibility of listening for key events, and mouse events, deciding if the
- * caret has moved (without a text change), and if so, will notify CaretListeners that the
- * caret has moved. Objects which are interested in ALL caret postion changes will also
- * have to listen for textChanged events.
- */
-public class CaretMediator implements org.eclipse.swt.widgets.Listener {
-
-
- public class DelayTimer {
-
- /**
- * A DelayTimer notifies a listener when a specific amount
- * of time has passed. Based upon
- * org.eclipse.jdt.internal.debug.core.Timer
- */
-
- protected Listener fListener;
- protected int fTimeout;
- protected boolean fAlive = true;
- protected boolean fStarted = false;
-
- /**
- */
- private Thread fDelayThread;
-
- /**
- * Constructs a new timer
- */
- public DelayTimer() {
- fTimeout = Integer.MAX_VALUE;
- Runnable r = new Runnable() {
- public void run() {
- while (fAlive) {
- boolean interrupted = false;
- try {
- Thread.sleep(fTimeout);
- }
- catch (InterruptedException e) {
- interrupted = true;
- }
- if (!interrupted) {
- if (fListener != null) {
- fStarted = false;
- fTimeout = Integer.MAX_VALUE;
- fListener.handleEvent(null);
- }
- }
- }
- }
- };
- fDelayThread = new Thread(r, "Caret Delay Timer");//$NON-NLS-1$
- fDelayThread.setDaemon(true);
- fDelayThread.start();
- }
-
- /**
- * Disposes this timer
- */
- public void dispose() {
- fAlive = false;
- fDelayThread.interrupt();
- fDelayThread = null;
- }
-
- /**
- * Immediately cancels any pending requests, and start over,
- * with the previous value, fTimeout, passed into start.
- * Note: 'restarting' a stopped timer basically has no effect.
- */
- public synchronized void restart() {
- stop();
- start(fListener, fTimeout);
- }
-
- /**
- * Starts this timer, and notifies the given listener when
- * the time has passed. A call to <code>stop</code>, before the
- * time expires, will cancel the the timer and timeout callback.
- * This method can only be called if this timer is idle (i.e.
- * stopped, or expired).
- */
- public synchronized void start(Listener listener, int ms) {
- // if we are already started, we'll ignore the previous request,
- // and "start over" with this new request.
- //if (fStarted) {
- //restart();
- ////throw new IllegalStateException();
- //}
- fListener = listener;
- fTimeout = ms;
- fStarted = true;
- fDelayThread.interrupt();
- }
-
- /**
- * Stops this timer
- */
- public synchronized void stop() {
- fTimeout = Integer.MAX_VALUE;
- fStarted = false;
- fDelayThread.interrupt();
- }
- }
-
- class CaretMediatorListener implements KeyListener, MouseListener, SelectionListener {
-
-
- public void widgetSelected(SelectionEvent e) {
- internalWidgetSelected(e);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- internalWidgetDefaultSelected(e);
- }
-
- public void mouseDoubleClick(MouseEvent e) {
- // ignore completely since mouseUp is always sent too
- }
-
- public void mouseDown(MouseEvent e) {
- // ignore ... even during a swipe select, we're only interested after the select
- // in which case the "caret" postion returned by the widget's getCaretPostion is
- // at the beginning of the selection -- which is what we want.
- internalMouseDown(e);
- }
-
- public void mouseUp(MouseEvent e) {
- internalMouseUp(e);
- }
-
- public void keyPressed(KeyEvent e) {
- internalKeyPressed(e);
- }
-
- public void keyReleased(KeyEvent e) {
- internalKeyReleased(e);
- }
- }
-
- protected ICaretListener[] fCaretListeners;
- protected DelayTimer timer;
- protected StyledText textWidget;
- protected int delayMSecs = 300;
- protected CaretMediatorListener internalListener;
- /** used just for debug print outs */
- private long startTime;
- /** used just for debug print outs */
- private long endTime;
-
- /**
- * CaretMediator constructor comment.
- */
- public CaretMediator() {
- super();
- }
-
- /**
- * CaretMediator constructor comment. Must always provide the widget its supposed to
- * listen to.
- */
- public CaretMediator(StyledText textWidget) {
- this();
- setTextWidget(textWidget);
- }
-
- public synchronized void addCaretListener(ICaretListener listener) {
-
- if (Debug.debugStructuredDocument) {
- System.out.println("CaretMediator::addCaretListener. Request to add an instance of " + listener.getClass() + " as a listener on caretlistner.");//$NON-NLS-2$//$NON-NLS-1$
- }
- // make sure listener is not already in listening array
- // (and if it is, print a warning to aid debugging, if needed)
-
- if (Utilities.contains(fCaretListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("CaretMediator::addCaretListener. listener " + listener + " was added more than once. ");//$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("CaretMediator::addCaretListener. Adding an instance of " + listener.getClass() + " as a listener on caret mediator.");//$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fCaretListeners != null) {
- // normally won't be null, but we need to be sure, for first time through
- oldSize = fCaretListeners.length;
- }
- int newSize = oldSize + 1;
- ICaretListener[] newListeners = new ICaretListener[newSize];
- if (fCaretListeners != null) {
- System.arraycopy(fCaretListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fCaretListeners = newListeners;
-
- }
- }
-
- protected void fireCaretEvent(CaretEvent event) {
- if (fCaretListeners != null) {
- // we must assign listeners to local variable to be thread safe,
- // since the add and remove listner methods
- // can change this object's actual instance of the listener array from another thread
- // (and since object assignment is atomic, we don't need to synchronize
- ICaretListener[] holdListeners = fCaretListeners;
- //
- for (int i = 0; i < holdListeners.length; i++) {
- holdListeners[i].caretMoved(event);
-
- }
- }
- }
-
- public void handleEvent(Event e) {
- Display display = null;
- // timer should never be null when this fires,
- // since the handleEvent should be called from the other thread.
- Assert.isNotNull(timer);
-
- if (Debug.debugCaretMediator) {
- endTime = System.currentTimeMillis();
- System.out.println("Timer fired: " + (endTime - startTime)); //$NON-NLS-1$
- }
-
- // check if 'okToUse'
- if (textWidget != null && !textWidget.isDisposed()) {
- display = textWidget.getDisplay();
- if ((display != null) && (!display.isDisposed())) {
- display.asyncExec(new Runnable() {
- public void run() {
- if (textWidget != null && !textWidget.isDisposed()) {
- fireCaretEvent(new CaretEvent(textWidget, textWidget.getCaretOffset()));
- }
- }
- });
- }
- }
- }
-
- protected void internalKeyPressed(KeyEvent e) {
- // stopTimer(e);
- }
-
- protected void internalKeyReleased(KeyEvent e) {
- switch (e.keyCode) {
- case SWT.ARROW_DOWN :
- case SWT.ARROW_UP :
- case SWT.ARROW_LEFT :
- case SWT.ARROW_RIGHT :
- case SWT.HOME :
- case SWT.END :
- case SWT.PAGE_DOWN :
- case SWT.PAGE_UP :
- {
- startTimer(e);
- break;
- }
- default :
- {
- // always update cursor postion, even during normal typing
- // (the logic may look funny, since we always to the same
- // thing, but we haven't always done the same thing, so I
- // wanted to leave that fact documented via code.)
- startTimer(e);
- }
- }
- }
-
- protected void internalMouseDown(MouseEvent e) {
- stopTimer(e);
- }
-
- protected void internalMouseUp(MouseEvent e) {
- // Note, even during a swipe select, when the mouse button goes up, and the widget is
- // queried for the current caret postion, it always returns the beginning of the selection,
- // which is desirable (at least for the known use of this feature, which is to signal
- // that the property sheet can update itself.
- startTimer(e);
- }
-
- protected void internalWidgetDefaultSelected(SelectionEvent event) {
- // What to do here?
- //System.out.println("Double: " + event.x + " " + event.y + " " + event.width + " " + event.item);
- }
-
- protected void internalWidgetSelected(SelectionEvent event) {
- // TODO: be sure "current caret postion is updated with event.x (beginnging of selection)
- // and that your 'end' is set to event.y
- //System.out.println("Single: " + event.x + " " + event.y + " " + event.width + " " + event.item);
- }
-
- public void release() {
- if (timer != null) {
- timer.dispose();
- timer = null;
- }
- if (textWidget != null && !textWidget.isDisposed()) {
- textWidget.removeKeyListener(internalListener);
- textWidget.removeMouseListener(internalListener);
- textWidget.removeSelectionListener(internalListener);
- textWidget = null;
- }
-
- }
-
- public synchronized void removeCaretListener(ICaretListener listener) {
-
- if ((fCaretListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fCaretListeners, listener)) {
- int oldSize = fCaretListeners.length;
- int newSize = oldSize - 1;
- ICaretListener[] newListeners = new ICaretListener[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fCaretListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fCaretListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old one
- fCaretListeners = newListeners;
- }
- }
- }
-
- public void setTextWidget(StyledText textWidget) {
- // unhook from previous, if any
- if (this.textWidget != null) {
- stopTimer(null);
- this.textWidget.removeKeyListener(internalListener);
- this.textWidget.removeMouseListener(internalListener);
- this.textWidget.removeSelectionListener(internalListener);
- }
- //
- //
- this.textWidget = textWidget;
- internalListener = new CaretMediatorListener();
- if (textWidget != null) {
- textWidget.addKeyListener(internalListener);
- textWidget.addMouseListener(internalListener);
- textWidget.addSelectionListener(internalListener);
- }
- else {
- Logger.log(Logger.WARNING, "CaretMediator constructor. textWidget was null, so keys and mouse events won't be listened to");//$NON-NLS-1$
- }
- }
-
- /**
- * The TypedEvent is expected to be of type KeyEvent or MouseEvent.
- */
- protected void startTimer(TypedEvent e) {
- if (timer == null) {
- timer = new DelayTimer();
- if (Debug.debugCaretMediator) {
- startTime = System.currentTimeMillis();
- System.out.println("Timer created: " + startTime); //$NON-NLS-1$
- }
- }
- if (Debug.debugCaretMediator) {
-
- endTime = System.currentTimeMillis();
- System.out.println("Timer started/restarted: after " + (endTime - startTime)); //$NON-NLS-1$
- startTime = System.currentTimeMillis();
- }
- timer.start(this, delayMSecs);
- }
-
- /**
- * The TypedEvent is expected to be of type KeyEvent or MouseEvent.
- */
- protected void stopTimer(TypedEvent e) {
- if (timer != null) {
- timer.stop();
- if (Debug.debugCaretMediator) {
- endTime = System.currentTimeMillis();
- System.out.println("Timer stopped: " + (endTime - startTime)); //$NON-NLS-1$
- startTime = System.currentTimeMillis();
- }
- }
- else if (Debug.debugCaretMediator) {
- System.out.println("No Timer to stop: " + System.currentTimeMillis()); //$NON-NLS-1$
- }
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/EditorPlugin.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/EditorPlugin.java
deleted file mode 100644
index b602f50e86..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/EditorPlugin.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.ui.IStartup;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.sse.contentproperties.ContentPropertiesPlugin;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.ui.preferences.CommonEditorPreferenceNames;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistry;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistryImpl;
-import org.eclipse.wst.sse.ui.registry.embedded.EmbeddedAdapterFactoryRegistryImpl;
-import org.eclipse.wst.sse.ui.taginfo.TextHoverManager;
-
-
-public class EditorPlugin extends AbstractUIPlugin implements IStartup {
-
- public final static String ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$
-
- protected static EditorPlugin instance = null;
- private TextHoverManager fTextHoverManager;
-
- public EditorPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- instance = this;
- }
-
- public static EditorPlugin getDefault() {
- return instance;
- }
-
- public synchronized static EditorPlugin getInstance() {
- return instance;
- }
-
- public AdapterFactoryRegistry getAdapterFactoryRegistry() {
- return AdapterFactoryRegistryImpl.getInstance();
-
- }
-
- public AdapterFactoryRegistry getEmbeddedAdapterFactoryRegistry() {
- return EmbeddedAdapterFactoryRegistryImpl.getInstance();
-
- }
-
- /**
- * @see AbstractUIPlugin#initializeDefaultPreferences
- */
- protected void initializeDefaultPreferences(IPreferenceStore store) {
- initializeDefaultEditorPreferences(store);
- }
-
- /**
- * This method is here so that other editor plugins can set Editor defaults in their
- * initialzeDefaultPreferences(...) methods.
- * @param store
- */
- public static void initializeDefaultEditorPreferences(IPreferenceStore store) {
- // use the base annotation & quick diff preference page
- EditorsUI.useAnnotationsPreferencePage(store);
- EditorsUI.useQuickDiffPreferencePage(store);
-
- // preferences relative to all sse editors are initialized
- AbstractDecoratedTextEditorPreferenceConstants.initializeDefaultValues(store);
-
- // these annotation preferences have a different default value than the one the base provides
- store.setDefault("errorIndicationInVerticalRuler", false); //$NON-NLS-1$
- store.setDefault("warningIndicationInVerticalRuler", false); //$NON-NLS-1$
-
- // these annotation preferences are not part of base text editor preference
- store.setDefault(CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS, true);
- store.setDefault(CommonEditorPreferenceNames.SHOW_QUICK_FIXABLES, true);
-
- // matching brackets is not part of base text editor preference
- store.setDefault(CommonEditorPreferenceNames.MATCHING_BRACKETS, true);
- PreferenceConverter.setDefault(store, CommonEditorPreferenceNames.MATCHING_BRACKETS_COLOR, new RGB(192, 192, 192));
-
- // open file hyperlink navigation is not part of base text editor preference
- String mod1Name = Action.findModifierString(SWT.MOD1); // SWT.COMMAND on Mac; SWT.CONTROL elsewhere
- store.setDefault(CommonEditorPreferenceNames.BROWSER_LIKE_LINKS, true);
- store.setDefault(CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER, mod1Name);
- store.setDefault(CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK, SWT.MOD1);
- PreferenceConverter.setDefault(store, CommonEditorPreferenceNames.LINK_COLOR, new RGB(0, 0, 255));
-
- // hover help preferences are not part of base text editor preference
- store.setDefault(CommonEditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS, "combinationHover|true|0;problemHover|false|0;documentationHover|false|0;annotationHover|true|"+mod1Name); //$NON-NLS-1$
- store.setDefault(CommonEditorPreferenceNames.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, true);
- store.setDefault(CommonEditorPreferenceNames.EDITOR_ANNOTATION_ROLL_OVER, false);
-
- // tab width is also a model-side preference so need to load default from there
- store.setDefault(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, CommonModelPreferenceNames.DEFAULT_TAB_WIDTH);
- }
-
- private static IModelManagerPlugin getModelManagerPlugin() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- /**
- * Return text hover manager
- * @return TextHoverManager
- */
- public TextHoverManager getTextHoverManager() {
- if (fTextHoverManager == null) {
- fTextHoverManager = new TextHoverManager();
- }
- return fTextHoverManager;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IStartup#earlyStartup()
- */
- public void earlyStartup() {
- ContentPropertiesPlugin.enableSynchronizer();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#shutdown()
- */
- public void shutdown() throws CoreException {
- super.shutdown();
- ContentPropertiesPlugin.disableSynchronizer();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.Plugin#startup()
- */
- public void startup() throws CoreException {
- super.startup();
- ContentPropertiesPlugin.enableSynchronizer();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/FileModelProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/FileModelProvider.java
deleted file mode 100644
index 8f75cd0118..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/FileModelProvider.java
+++ /dev/null
@@ -1,984 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.UnsupportedCharsetException;
-import java.text.MessageFormat;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-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.SubProgressMonitor;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.ContainerGenerator;
-import org.eclipse.ui.editors.text.FileDocumentProvider;
-import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.encoding.EncodingRule;
-import org.eclipse.wst.encoding.exceptions.CharConversionErrorWithDetail;
-import org.eclipse.wst.encoding.exceptions.MalformedInputExceptionWithDetail;
-import org.eclipse.wst.encoding.exceptions.MalformedOutputExceptionWithDetail;
-import org.eclipse.wst.sse.core.FactoryRegistry;
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IModelStateListenerExtended;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryProvider;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistry;
-import org.eclipse.wst.sse.ui.util.Assert;
-
-
-/**
- * This version of an IDocumentProvider is the editor side counter part to
- * IModelManager. It is responsible for providing the structuredModel, which
- * is actually deferred to the IModelManager. But other, non-deffered
- * responsibilities include providing editing related models, such as
- * annotation models, undo command stack, etc.
- */
-public class FileModelProvider extends FileDocumentProvider implements IModelProvider {
- /**
- * @deprecated - termporary flag to change the behavior of createDocument
- * during revert/reset
- */
- private boolean fReuseModelDocument = true;
-
- // workaround for save-as in C4
- private Vector fChangingElements = new Vector(1);
-
- protected class InternalModelStateListener implements IModelStateListenerExtended {
- public void modelAboutToBeChanged(IStructuredModel model) {
- // do nothing
- }
-
- public void modelAboutToBeReinitialized(IStructuredModel model) {
- // do nothing
- }
-
- public void modelChanged(IStructuredModel model) {
- // do nothing
- }
-
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
- fireModelDirtyStateChanged(model, isDirty);
- }
-
- public void modelReinitialized(IStructuredModel model) {
- reinitializeFactories(model);
- }
-
- public void modelResourceDeleted(IStructuredModel model) {
- fireModelDeleted(model);
- }
-
- public void modelResourceMoved(IStructuredModel originalmodel, IStructuredModel movedmodel) {
- fireModelMoved(originalmodel, movedmodel);
- }
- }
-
- /**
- * Collection of info that goes with a model.
- */
- protected class ModelInfo {
- public IAnnotationModel fAnnotationModel;
- public IEditorInput fElement;
- public FileSynchronizer fFileSynchronizer;
- public boolean fShouldReleaseOnInfoDispose;
- public IStructuredModel fStructuredModel;
-
- public ModelInfo(IStructuredModel structuredModel, IEditorInput element, IAnnotationModel model, boolean selfCreated) {
- fElement = element;
- fStructuredModel = structuredModel;
- fAnnotationModel = model;
- fShouldReleaseOnInfoDispose = selfCreated;
- fFileSynchronizer = createModelSynchronizer(element, structuredModel);
- }
- }
-
- private static FileModelProvider fInstance = null;
- private static IModelManager fModelManager;
-
- /** NLS strings */
- // private static final String UNSUPPORTED_ENCODING_WARNING =
- // ResourceHandler.getString("1This_encoding({0})_is_not__WARN_");
- // //$NON-NLS-1$
- //$NON-NLS-1$ = "This encoding({0}) is not supported. The default encoding will be used instead."
- // CSSFileModelProvider will use this.
- protected static final String UNSUPPORTED_ENCODING_WARNING_TITLE = ResourceHandler.getString("Encoding_warning_UI_"); //$NON-NLS-1$ = "Encoding warning"
-
- public synchronized static FileModelProvider getInstance() {
- if (fInstance == null)
- fInstance = new FileModelProvider();
- return fInstance;
- }
-
- /**
- * Utility method also used in subclasses
- */
- protected static IModelManager getModelManager() {
- if (fModelManager == null) {
- // get the model manager from the plugin
- // note: we can use the static "ID" variable, since we pre-req
- // that plugin
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- fModelManager = plugin.getModelManager();
- }
- return fModelManager;
- }
-
- private InternalModelStateListener fInternalModelStateListener;
- /** IStructuredModel information of all connected elements */
- private Map fModelInfoMap = new HashMap();
-
- protected FileModelProvider() {
- fInternalModelStateListener = new InternalModelStateListener();
- }
-
- /**
- * Register additional (viewer related) factories Note: this can be called
- * twice, one for when model first created and loaded to editor. And
- * possible later, if a model "reinit" takes place.
- */
- protected void addProviderFactories(IStructuredModel structuredModel) {
- // its an error to call with null argument
- if (structuredModel == null)
- return;
- EditorPlugin plugin = ((EditorPlugin) Platform.getPlugin(EditorPlugin.ID));
- AdapterFactoryRegistry adapterRegistry = plugin.getAdapterFactoryRegistry();
- Iterator adapterFactoryList = adapterRegistry.getAdapterFactories();
- IFactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
- if (factoryRegistry == null) {
- factoryRegistry = new FactoryRegistry();
- structuredModel.setFactoryRegistry(factoryRegistry);
- }
- // And all those appropriate for this particular type of content
- while (adapterFactoryList.hasNext()) {
- try {
- AdapterFactoryProvider provider = (AdapterFactoryProvider) adapterFactoryList.next();
- if (provider.isFor(structuredModel.getModelHandler())) {
- provider.addAdapterFactories(structuredModel);
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- }
-
- /**
- * Overridden to properly use the annotation model stored within the
- * ModelInfo
- *
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createAnnotationModel(Object)
- */
- protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
- IAnnotationModel model = null;
- if (element instanceof IEditorInput) {
- IFile file = (IFile) ((IEditorInput) element).getAdapter(IFile.class);
- if (file != null) {
- model = getAnnotationModel(element);
- if (model == null)
- model = new StructuredResourceMarkerAnnotationModel(file);
- }
- }
- if (model == null)
- model = super.createAnnotationModel(element);
- return model;
- }
-
- /**
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createDocument(java.lang.Object)
- */
- protected IDocument createDocument(Object element) {
- IDocument document = null;
- if (element instanceof IEditorInput) {
- // create a new IDocument for the element; should always reflect
- // the contents of the resource
- ModelInfo info = getModelInfoFor((IEditorInput) element);
- if (info == null) {
- throw new SourceEditingRuntimeException(new IllegalArgumentException("no corresponding model info found")); //$NON-NLS-1$
- }
- IStructuredModel model = info.fStructuredModel;
- if (model != null) {
- // // Nitin, Do you recall why this 'model.isDirty' clause was
- // here?
- // if (model.isDirty() && element instanceof IFileEditorInput)
- // {
- // document = createNewStructuredDocument(((IFileEditorInput)
- // element));
- // }
- if (!fReuseModelDocument && element instanceof IFileEditorInput) {
- //document =
- // createNewStructuredDocument(((IFileEditorInput)
- // element));
- try {
- // update document from file contents
- InputStream is = ((IFileEditorInput) element).getFile().getContents();
- BufferedReader reader = new BufferedReader(new InputStreamReader(is));
-
- StringBuffer text = new StringBuffer();
- String current = null;
- // read first line
- current = reader.readLine();
- while (current != null) {
- text.append(current);
- current = reader.readLine();
- if (current != null) {
- // possibly get line separator preferences?
- // for now use use system line separator
- text.append(System.getProperty("line.separator")); //$NON-NLS-1$
- }
- }
- is.close();
- reader.close();
-
- int currentLength = model.getStructuredDocument().getLength();
- model.getStructuredDocument().replace(0, currentLength, text.toString());
- model.setDirtyState(false);
- document = model.getStructuredDocument();
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- catch (IOException e) {
- Logger.logException(e);
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
-
- }
- if (document == null) {
- document = model.getStructuredDocument();
- }
- }
- }
- return document;
- }
-
- /**
- * Create a new IStructuredDocument for the file
- *
- * @param element
- * @return
- */
- private IStructuredDocument createNewStructuredDocument(IFileEditorInput element) {
- IStructuredDocument document = null;
- try {
- document = getModelManager().createStructuredDocumentFor(element.getFile());
- }
- catch (IOException e) {
- throw new SourceEditingRuntimeException(new IllegalArgumentException("Invalid input type for creating Structured Document (I/O)")); //$NON-NLS-1$
- }
- catch (CoreException e) {
- throw new SourceEditingRuntimeException(new IllegalArgumentException("Invalid input type for creating Structured Document " + e.getStatus().getMessage())); //$NON-NLS-1$
- }
- return document;
- }
-
- /**
- * Also create ModelInfo - extra resource synchronization classes should
- * be stored within the ModelInfo
- */
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- // create the corresponding ModelInfo if necessary
- if (getModelInfoFor((IEditorInput) element) == null) {
- createModelInfo((IEditorInput) element);
- }
- ElementInfo info = super.createElementInfo(element);
- return info;
- }
-
- public void createModelInfo(IEditorInput input) {
- if (!(input instanceof IFileEditorInput)) {
- throw new SourceEditingRuntimeException(new IllegalArgumentException("This model provider only supports IFileEditorInputs")); //$NON-NLS-1$
- }
- if (getModelInfoFor(input) == null) {
- IStructuredModel structuredModel = selfCreateModel((IFileEditorInput) input);
- createModelInfo(input, structuredModel, true);
- }
- }
-
- /**
- * To be used when model is provided to us, ensures that when setInput is
- * used on this input, the given model will be used.
- */
- public void createModelInfo(IEditorInput input, IStructuredModel structuredModel, boolean releaseModelOnDisconnect) {
- if (!(input instanceof IFileEditorInput)) {
- throw new SourceEditingRuntimeException(new IllegalArgumentException("This model provider only supports IFileEditorInputs")); //$NON-NLS-1$
- }
- else if (structuredModel == null) {
- throw new SourceEditingRuntimeException(new IllegalArgumentException("No model loaded for input: " + input.getName())); //$NON-NLS-1$
- }
- // we have to make sure factories are added, whether we created or
- // not.
- if (getModelInfoFor(input) != null || getModelInfoFor(structuredModel) != null)
- return;
- addProviderFactories(structuredModel);
- IAnnotationModel annotationModel = null;
- try {
- annotationModel = createAnnotationModel(input);
- }
- catch (CoreException e) {
- // just continue without one
- }
- ModelInfo modelInfo = new ModelInfo(structuredModel, input, annotationModel, releaseModelOnDisconnect);
- fModelInfoMap.put(input, modelInfo);
- if (modelInfo.fFileSynchronizer != null) {
- modelInfo.fFileSynchronizer.install();
- }
- modelInfo.fStructuredModel.addModelStateListener(fInternalModelStateListener);
- // fix once approved
- // we only resetSynchronizationStamp on model if its not set already
- if (input.getAdapter(IFile.class) != null && modelInfo.fStructuredModel.getSynchronizationStamp() == IResource.NULL_STAMP) {
- modelInfo.fStructuredModel.resetSynchronizationStamp((IResource) input.getAdapter(IFile.class));
- }
- }
-
- protected FileSynchronizer createModelSynchronizer(IEditorInput input, IStructuredModel model) {
- return null;
- }
-
- protected void disposeElementInfo(Object element, ElementInfo info) {
- super.disposeElementInfo(element, info);
- if (element instanceof IEditorInput) {
- IEditorInput input = (IEditorInput) element;
- ModelInfo modelInfo = getModelInfoFor(input);
- if (modelInfo.fFileSynchronizer != null) {
- modelInfo.fFileSynchronizer.uninstall();
- }
- disposeModelInfo(modelInfo);
- }
- }
-
- /**
- * disconnect from this model info
- *
- * @param info
- */
- public void disposeModelInfo(ModelInfo info) {
- info.fStructuredModel.removeModelStateListener(fInternalModelStateListener);
- if (info.fShouldReleaseOnInfoDispose) {
- info.fStructuredModel.releaseFromEdit();
- }
- if (info.fFileSynchronizer != null) {
- info.fFileSynchronizer.uninstall();
- }
- fModelInfoMap.remove(info.fElement);
- }
-
-public void doSaveDocument(IProgressMonitor progressMonitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- //TODO: still need to "transfer" much of this logic to model level
- boolean success = false;
- Assert.isTrue(element instanceof IFileEditorInput);
- IFileEditorInput input = (IFileEditorInput) element;
- IStructuredModel model = getModel(getInputFor(document));
- Assert.isNotNull(model);
- boolean localDirtyState = model.isDirty();
- IFile resource = input.getFile();
- try {
- if (!overwrite) {
- checkSynchronizationState(((FileInfo) getElementInfo(element)).fModificationStamp, resource);
- }
- // inform about the upcoming content change
- fireElementStateChanging(element);
- try {
- model.save(resource); //, encodingname, null);
- }
- catch (UnsupportedCharsetException exception) {
- Shell shell = getActiveShell();
- // FYI: made this indirect chain of calls to help get rid of
- // our specific Exception, need to test
- // that all is updated in right order, even when error.
- EncodingMemento encodingMemento = model.getStructuredDocument().getEncodingMemento();
- String foundEncoding = encodingMemento.getDetectedCharsetName();
- String defaultToUse = encodingMemento.getAppropriateDefault();
- boolean tryDefault = openUnsupportEncodingForSave(foundEncoding, defaultToUse, resource.getName(), shell);
- if (tryDefault) {
- model.save(resource, EncodingRule.FORCE_DEFAULT);
- }
- else {
- // User has canceled Save. Keep view opened
- progressMonitor.setCanceled(true);
- return;
- }
- }
- catch (MalformedOutputExceptionWithDetail exception) {
- Shell shell = getActiveShell();
- boolean userOK = openUnconvertableCharactersWarningForSave(exception, shell); //resource.getName()
- if (userOK) {
- model.save(resource, EncodingRule.IGNORE_CONVERSION_ERROR);
- }
- else {
- // User has canceled Save. Keep view opened
- progressMonitor.setCanceled(true);
- return;
- }
- }
- catch (CharConversionErrorWithDetail exception) {
- Shell shell = getActiveShell();
- boolean userOK = openUnconvertableCharactersWarningForSave(exception, shell); //resource.getName()
- if (userOK) {
- model.save(resource, EncodingRule.IGNORE_CONVERSION_ERROR);
- }
- else {
- // User has canceled Save. Keep view opened
- progressMonitor.setCanceled(true);
- //outStream.close();
- //outStream = null;
- return;
- }
- }
- if (!resource.exists()) {
- progressMonitor.beginTask(ResourceHandler.getString("FileDocumentProvider.task.saving"), 2000); //$NON-NLS-1$
- ContainerGenerator generator = new ContainerGenerator(resource.getParent().getFullPath());
- generator.generateContainer(new SubProgressMonitor(progressMonitor, 1000));
- }
- // if we get to here without an exception... success!
- success = true;
- model.setDirtyState(false);
- model.resetSynchronizationStamp(resource);
-
- // update markers
- if (getAnnotationModel(element) instanceof AbstractMarkerAnnotationModel) {
- ((AbstractMarkerAnnotationModel) getAnnotationModel(element)).updateMarkers(document);
- }
- // reset the modification stamp record so we know we don't try to
- // reload on following resource change notifications
- FileInfo info = (FileInfo) getElementInfo(element);
- if (info != null) {
- info.fModificationStamp = computeModificationStamp(resource);
- }
-
- //For error handling test only!!!==========
- //
- //Uncomment the following line of code to simulate a
- // FileNotFoundException.
- //throw new FileNotFoundException();
- //
- //Uncomment the following line of code to simulate a
- // UnsupportedEncodingException.
- //throw new UnsupportedEncodingException();
- //
- //Uncomment the following line of code to simulate a IOException.
- //throw new IOException();
- //For error handling test only!!!==========
- }
- catch (java.io.FileNotFoundException exception) {
- /*
- * The FileNotFoundException's message may not be very meaningful
- * to user. Since the SourceEditingRuntimeException(exception,
- * message) form will use just the detail message in the passed-in
- * exception (instead of concatenating the detail message with the
- * additional message), we are converting this exception into a
- * more informative message. Same idea applies to the following
- * catch blocks.
- */
- progressMonitor.setCanceled(true);
- // inform about failure
- fireElementStateChangeFailed(element);
- throw new SourceEditingRuntimeException(ResourceHandler.getString("Unable_to_save_the_documen_ERROR_")); //$NON-NLS-1$ = "Unable to save the document. Output file not found."
- }
- catch (UnsupportedEncodingException exception) {
- progressMonitor.setCanceled(true);
- // inform about failure
- fireElementStateChangeFailed(element);
- throw new SourceEditingRuntimeException(ResourceHandler.getString("Unable_to_save_the_documen1_ERROR_")); //$NON-NLS-1$ = "Unable to save the document. Unsupported encoding."
- }
- catch (java.io.IOException exception) {
- progressMonitor.setCanceled(true);
- // inform about failure
- fireElementStateChangeFailed(element);
- throw new SourceEditingRuntimeException(ResourceHandler.getString("Unable_to_save_the_documen2_ERROR_")); //$NON-NLS-1$
- //$NON-NLS-1$ = "Unable to save the document. An I/O error occurred while saving the document."
- }
- catch (OperationCanceledException exception) {
- Logger.log(Logger.INFO, "Save Operation Canceled at user's request"); //$NON-NLS-1$
- }
- finally {
- if (!success) {
- model.setDirtyState(localDirtyState);
- }
- }
- } protected void fireModelContentAboutToBeReplaced(IStructuredModel model) {
- }
-
- protected void fireModelContentReplaced(IStructuredModel model) {
- }
-
- protected void fireModelDeleted(IStructuredModel model) {
- }
-
- protected void fireModelDirtyStateChanged(IStructuredModel model, final boolean isDirty) {
- }
-
- protected void fireModelMoved(IStructuredModel originalModel, IStructuredModel movedModel) {
- }
-
- protected Shell getActiveShell() {
- // Looks like Display tells me what is the current active Shell
- // so that it seems not to ask EditorPart to give me a Shell.
- // Same technique in used by
- // Infopop(org.eclipse.help.internal.ui.ContextHelpDialog(Object [],
- // int, int))
- Display dsp = getDisplay();
- Shell shell = dsp.getActiveShell();
- return shell;
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- * Overridden to use ModelInfo's annotation model
- *
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object)
- */
- public IAnnotationModel getAnnotationModel(Object element) {
- // override behavior an retrieve the annotation model from the model
- // info
- ModelInfo info = getModelInfoFor((IEditorInput) element);
- if (info != null)
- return info.fAnnotationModel;
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.editors.text.IStorageDocumentProvider#getEncoding(java.lang.Object)
- */
- public String getEncoding(Object element) {
- EncodingMemento em = null;
- IStructuredModel model = getModel((IEditorInput) element);
- // model can be null if opened on non-expected file
- if (model != null) {
- em = model.getStructuredDocument().getEncodingMemento();
- }
- // DefaultEncodingSupport uses IANA names
- if (em != null)
- return em.getDetectedCharsetName();
- return super.getEncoding(element);
- }
-
- protected IEditorInput getInputFor(IDocument document) {
- IStructuredModel model = getModelManager().getExistingModelForRead(document);
- IEditorInput input = getInputFor(model);
- model.releaseFromRead();
- return input;
- }
-
- protected IEditorInput getInputFor(IStructuredModel structuredModel) {
- IEditorInput result = null;
- ModelInfo info = getModelInfoFor(structuredModel);
- if (info != null)
- result = info.fElement;
- return result;
- }
-
- public IStructuredModel getModel(IEditorInput element) {
- IStructuredModel result = null;
- ModelInfo info = getModelInfoFor(element);
- if (info != null) {
- result = info.fStructuredModel;
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IStructuredModel getModel(Object element) {
- Assert.isTrue(element instanceof IFileEditorInput);
- return getModel((IFileEditorInput) element);
- }
-
- protected ModelInfo getModelInfoFor(IEditorInput element) {
- ModelInfo result = (ModelInfo) fModelInfoMap.get(element);
- return result;
- }
-
- protected ModelInfo getModelInfoFor(IStructuredModel structuredModel) {
- ModelInfo result = null;
- if (structuredModel != null) {
- ModelInfo[] modelInfos = (ModelInfo[]) fModelInfoMap.values().toArray(new ModelInfo[0]);
- for (int i = 0; i < modelInfos.length; i++) {
- ModelInfo info = modelInfos[i];
- if (structuredModel.equals(info.fStructuredModel)) {
- result = info;
- break;
- }
- }
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.editors.text.FileDocumentProvider#getPersistedEncoding(java.lang.Object)
- */
- protected String getPersistedEncoding(Object element) {
- EncodingMemento em = null;
- IStructuredModel model = getModel((IEditorInput) element);
- if (model != null) {
- em = model.getStructuredDocument().getEncodingMemento();
- }
- // DefaultEncodingSupport uses IANA names
- if (em != null) {
- return em.getDetectedCharsetName();
- }
- else {
- // error condition
- return ""; //$NON-NLS-1$
- }
- }
-
- /**
- * Defines the standard procedure to handle CoreExceptions.
- *
- * @param exception
- * the exception to be logged
- * @param message
- * the message to be logged
- */
- protected void handleCoreException(CoreException exception, String message) {
- Logger.logException(message, exception);
- }
-
- /**
- * Updates the element info and Document contents to a change of the file
- * content and sends out appropriate notifications.
- *
- * @param fileEditorInput
- * the input of a text editor
- */
- protected void handleElementContentChanged(IFileEditorInput fileEditorInput) {
- FileInfo info = (FileInfo) getElementInfo(fileEditorInput);
- if (info == null)
- return;
-
- String oldContents = getModel(fileEditorInput).getStructuredDocument().get();
-
- try {
- refreshFile(fileEditorInput.getFile());
- }
- catch (CoreException x) {
- handleCoreException(x, "FileDocumentProvider.handleElementContentChanged"); //$NON-NLS-1$
- }
-
- // set the new content and fire content related events
- fireElementContentAboutToBeReplaced(fileEditorInput);
- removeUnchangedElementListeners(fileEditorInput, info);
-
- // direct superclass also removes but never adds?
- info.fDocument.removeDocumentListener(info);
-
- boolean reloaded = false;
- try {
- InputStream inStream = fileEditorInput.getFile().getContents(true);
- getModel(fileEditorInput).reload(inStream);
- reloaded = true;
- }
- catch (IOException e) {
- info.fStatus = new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.ERROR, "error reloading " + fileEditorInput.getName(), e);
- }
- catch (CoreException e) {
- info.fStatus = e.getStatus();
- }
- info.fDocument = getModel(fileEditorInput).getStructuredDocument();
-
- info.fCanBeSaved = false;
- info.fModificationStamp = computeModificationStamp(fileEditorInput.getFile());
- if (reloaded) {
- info.fStatus = null;
- }
-
- addUnchangedElementListeners(fileEditorInput, info);
- fireElementContentReplaced(fileEditorInput);
- if (!reloaded) {
- info.fDocument.set(oldContents);
- }
- }
-
- /**
- * @see org.eclipse.ui.editors.text.FileDocumentProvider#isModifiable(java.lang.Object)
- */
- public boolean isModifiable(Object element) {
- return super.isModifiable(element); //!isReadOnly(element);
- }
-
- /**
- * @see org.eclipse.ui.texteditor.IDocumentProvider#mustSaveDocument(java.lang.Object)
- * <br>
- *
- * The rule is that if it is sharedForEdit, then it never "must be saved",
- * but if its not sharedForEdit, then it depends on its dirty state.
- */
- public boolean mustSaveDocument(Object element) {
- boolean result = false;
- if (getModel((IEditorInput) element) != null) {
- if (!getModel((IEditorInput) element).isSharedForEdit()) {
- result = getModel((IEditorInput) element).isDirty();
- }
- }
- return result;
- }
-
- protected boolean openUnconvertableCharactersWarningForSave(MalformedOutputExceptionWithDetail outputException, Shell topshell) {
- // open message dialog
- final String title = UNSUPPORTED_ENCODING_WARNING_TITLE;
- String userMessage = ResourceHandler.getString("cannot_convert_some_characters"); //$NON-NLS-1$
- MessageFormat form = new MessageFormat(userMessage);
- Object[] args = {outputException.getAttemptedIANAEncoding(), Integer.toString(outputException.getCharPosition())};
- final String msg = form.format(args);
- Shell shell = getActiveShell();
- MessageDialog warning = new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, new String[]{IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
- if (warning.open() == 0)
- return true;
- return false;
- }
-
- private boolean openUnconvertableCharactersWarningForSave(CharConversionErrorWithDetail outputException, Shell topshell) {
- // open message dialog
- final String title = UNSUPPORTED_ENCODING_WARNING_TITLE;
- String userMessage = ResourceHandler.getString("cannot_convert_some_characters2"); //$NON-NLS-1$
- MessageFormat form = new MessageFormat(userMessage);
- Object[] args = {outputException.getCharsetName()};
- final String msg = form.format(args);
- Shell shell = getActiveShell();
- MessageDialog warning = new MessageDialog(shell, title, null, msg, MessageDialog.QUESTION, new String[]{IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
- if (warning.open() == 0)
- return true;
- return false;
- }
-
- protected void openUndecodableCharacterError(MalformedInputExceptionWithDetail e) {
- // checked and coordinated among all editors.
- String title = ResourceHandler.getString("Error_opening_file_UI_"); //$NON-NLS-1$ = "Error opening file"
- String msg = e.toString();
- // if the exception char position < 0, perhaps we exceeded the max
- // buffer when detecting pos of error
- // if that is the case, display a different error message
- IStatus status;
- if ((e.getCharPosition() < 0) && (e.isExceededMax()))
- status = new Status(IStatus.ERROR, EditorPlugin.ID, 0, ResourceHandler.getString("8concat_ERROR_", (new Object[]{Integer.toString(e.getMaxBuffer()), e.getAttemptedIANAEncoding()})), e); //$NON-NLS-1$
- else
- status = new Status(IStatus.ERROR, EditorPlugin.ID, 0, ResourceHandler.getString("7concat_ERROR_", (new Object[]{(Integer.toString(e.getCharPosition())), e.getAttemptedIANAEncoding()})), e); //$NON-NLS-1$
- //$NON-NLS-1$ = "Could not be decoded character (at position {0}) according to the encoding parameter {1}"
- ErrorDialog.openError(getActiveShell(), title, msg, status);
- }
-
- protected void openUnsupportedEncodingWarningForLoad(String encoding, String defaultToUse) {
- // open message dialog
- final String title = UNSUPPORTED_ENCODING_WARNING_TITLE;
- MessageFormat form = new MessageFormat(ResourceHandler.getString("This_encoding_({0})_is_not_supported._The_default_encoding_({1})_will_be_used_instead._1")); //$NON-NLS-1$
- Object[] args = {encoding, defaultToUse};
- final String msg = form.format(args);
- Shell shell = getActiveShell();
- MessageDialog warning = new MessageDialog(shell, title, null, msg, MessageDialog.WARNING, new String[]{IDialogConstants.OK_LABEL}, 0);
- warning.open();
- }
-
- protected boolean openUnsupportEncodingForSave(String foundEncoding, String defaultEncodingToUse, String dialogTitle, Shell topshell) {
- if (topshell == null)
- return true; // if no topshell, return true;
- // open message dialog
- // MessageFormat form = new
- // MessageFormat(ResourceHandler.getString("This_encoding({0})_is_not__WARN_"));
- // //$NON-NLS-1$ = "This encoding({0}) is not supported. Continue ?"
- MessageFormat form = new MessageFormat(ResourceHandler.getString("This_encoding_({0})_is_not_supported._Continue_the_save_using_the_default_({1})__2")); //$NON-NLS-1$
- Object[] args = {foundEncoding, defaultEncodingToUse};
- final String msg = form.format(args);
- MessageDialog warning = new MessageDialog(topshell, dialogTitle, null, msg, MessageDialog.QUESTION, new String[]{IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
- if (warning.open() == 0)
- return true;
- return false;
- }
-
- /**
- * Register additional (viewer related) factories Note: this can be called
- * twice, one for when model first created and loaded to editor. And
- * possible later, if a model "reinit" takes place.
- */
- protected void reinitializeFactories(IStructuredModel structuredModel) {
- // its an error to call with null argument
- if (structuredModel == null)
- return;
- EditorPlugin plugin = ((EditorPlugin) Platform.getPlugin(EditorPlugin.ID));
- AdapterFactoryRegistry adapterRegistry = plugin.getAdapterFactoryRegistry();
- Iterator adapterList = adapterRegistry.getAdapterFactories();
- // And all those appropriate for this particular type of content
- while (adapterList.hasNext()) {
- try {
- AdapterFactoryProvider provider = (AdapterFactoryProvider) adapterList.next();
- if (provider.isFor(structuredModel.getModelHandler())) {
- provider.reinitializeFactories(structuredModel);
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- }
-
- protected IStructuredModel selfCreateModel(IFileEditorInput input) {
- // this method should be called only after is established the
- // desired model is not in the active items list.
- IStructuredModel structuredModel = getModelManager().getExistingModelForEdit(input.getFile());
- if (structuredModel == null) {
- try {
- try {
- structuredModel = getModelManager().getModelForEdit(input.getFile()); //
- }
- catch (UnsupportedCharsetException exception) {
- // TODO-future: user should be given a choice here to try
- // other encodings other than 'default'
- EncodingMemento encodingMemento = null;
- if (exception instanceof org.eclipse.wst.encoding.exceptions.UnsupportedCharsetExceptionWithDetail) {
- org.eclipse.wst.encoding.exceptions.UnsupportedCharsetExceptionWithDetail detailedException = (org.eclipse.wst.encoding.exceptions.UnsupportedCharsetExceptionWithDetail) exception;
- encodingMemento = detailedException.getEncodingMemento();
- }
-
- String foundEncoding = encodingMemento.getDetectedCharsetName();
- String defaultToUse = encodingMemento.getAppropriateDefault();
- openUnsupportedEncodingWarningForLoad(foundEncoding, defaultToUse);
- try {
- structuredModel = getModelManager().getModelForEdit(input.getFile(), EncodingRule.FORCE_DEFAULT); //$NON-NLS-1$ //$NON-NLS-2$
- }
- catch (MalformedInputExceptionWithDetail ex) { // this
- openUndecodableCharacterError(ex);
- structuredModel = null;
- }
- }
- catch (MalformedInputExceptionWithDetail e) {
- openUndecodableCharacterError(e);
-
- structuredModel = getModelManager().getModelForEdit(input.getFile(), EncodingRule.IGNORE_CONVERSION_ERROR);
- }
- }
- catch (CoreException e) {
- throw new SourceEditingRuntimeException(e);
- }
- catch (IOException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
- return structuredModel;
- }
-
- /**
- * This method is intended for those uses where the model has already been
- * obtained and provided by the client (with its own id, not necessarily
- * the one we would create by default). We require the input not to create
- * a model, but to retrieve the annotation data that goes with this
- * resouce.
- */
- public void setModel(IStructuredModel model, IEditorInput input) {
- createModelInfo(input, model, false);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IDocumentProviderExtension#synchronize(java.lang.Object)
- */
- public void doSynchronize(Object element, IProgressMonitor monitor) throws CoreException {
- super.doSynchronize(element, monitor);
- if (element instanceof IFileEditorInput) {
- IFileEditorInput input = (IFileEditorInput) element;
- getModel(input).resetSynchronizationStamp(input.getFile());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doResetDocument(java.lang.Object,
- * org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void doResetDocument(Object element, IProgressMonitor monitor) throws CoreException {
- fReuseModelDocument = false;
- super.doResetDocument(element, monitor);
- fReuseModelDocument = true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IDocumentProvider#aboutToChange(java.lang.Object)
- */
- public void aboutToChange(Object element) {
-
- super.aboutToChange(element);
-
- // start recording for revert
- IStructuredModel model = getModel(element);
- if (model != null) {
- fChangingElements.add(element);
- StructuredTextUndoManager undoMgr = model.getUndoManager();
- int offset = undoMgr.getTextViewer().getTextWidget().getCaretOffset();
- undoMgr.beginRecording(this, offset, 0);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IDocumentProvider#changed(java.lang.Object)
- */
- public void changed(Object element) {
-
- super.changed(element);
-
- // end recording for revert
- if (fChangingElements.contains(element)) {
- fChangingElements.remove(element);
- StructuredTextUndoManager undoMgr = getModel(element).getUndoManager();
- undoMgr.endRecording(this, 0, 0);
- undoMgr.getTextViewer().getTextWidget().setCaretOffset(0);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/GotoAnnotationAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/GotoAnnotationAction.java
deleted file mode 100644
index 12c1b4d966..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/GotoAnnotationAction.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Iterator;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.part.EditorActionBarContributor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * Based on org.eclipse.jdt.internal.ui.javaeditor.GotoAnnotationAction and the org.eclipse.jdt.internal.ui.JavaEditor's gotoError() method. Rewritten based on 3.0M7 version to operate generically.
- *
- */
-public class GotoAnnotationAction extends TextEditorAction {
-
- /**
- * Clears the status line on selection changed.
- */
- protected class StatusLineClearer implements ISelectionChangedListener {
- IStatusLineManager fStatusLineManager = null;
-
- protected StatusLineClearer(IStatusLineManager mgr) {
- super();
- fStatusLineManager = mgr;
- }
-
- /*
- * @see ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- getTextEditor().getSelectionProvider().removeSelectionChangedListener(StatusLineClearer.this);
-
- fStatusLineManager.setErrorMessage(null, null);
- fStatusLineManager.setMessage(null, null);
- }
- }
-
- private boolean fForward;
- private String fLabel;
- /**
- * The marker that served as last target for a goto marker request.
- *
- * @since 3.0
- */
- private IMarker fLastMarkerTarget = null;
- private String fPrefix;
-
- /**
- * @param prefix
- * @param editor
- */
- public GotoAnnotationAction(String prefix, boolean forward) {
- super(ResourceHandler.getResourceBundle(), prefix, null);
- fForward = forward;
- fPrefix = prefix;
- fLabel = ResourceHandler.getResourceBundle().getString(fPrefix);
- }
-
- /*
- * This is the default label used for description
- */
- public String getDefaultLabel() {
- return fLabel;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#getDescription()
- */
- public String getDescription() {
- return getDefaultLabel();
- }
-
- /**
- * Returns the annotation closest to the given range respecting the given direction. If an annotation is found, the annotations current position is copied into the provided annotation position.
- *
- * @param offset
- * the region offset
- * @param length
- * the region length
- * @param forward
- * <code>true</code> for forwards, <code>false</code> for backward
- * @param annotationPosition
- * the position of the found annotation
- * @return the found annotation
- */
- protected Annotation getNextAnnotation(final int offset, final int length, boolean forward, Position annotationPosition) {
-
- Annotation nextAnnotation = null;
- Position nextAnnotationPosition = null;
- Annotation containingAnnotation = null;
- Position containingAnnotationPosition = null;
- boolean currentAnnotation = false;
-
- IDocument document = getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
- int endOfDocument = document.getLength();
- int distance = Integer.MAX_VALUE;
-
- IAnnotationModel model = getTextEditor().getDocumentProvider().getAnnotationModel(getTextEditor().getEditorInput());
- // external files may not have an annotation model
- if (model != null) {
- Iterator e = model.getAnnotationIterator();
- while (e.hasNext()) {
- Annotation a = (Annotation) e.next();
- if (!isNavigationTarget(a))
- continue;
-
- Position p = model.getPosition(a);
- if (p == null)
- continue;
-
- if (forward && p.offset == offset || !forward && p.offset + p.getLength() == offset + length) {// || p.includes(offset)) {
- if (containingAnnotation == null || (forward && p.length >= containingAnnotationPosition.length || !forward && p.length >= containingAnnotationPosition.length)) {
- containingAnnotation = a;
- containingAnnotationPosition = p;
- currentAnnotation = p.length == length;
- }
- }
- else {
- int currentDistance = 0;
-
- if (forward) {
- currentDistance = p.getOffset() - offset;
- if (currentDistance < 0)
- currentDistance = endOfDocument + currentDistance;
-
- if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
- distance = currentDistance;
- nextAnnotation = a;
- nextAnnotationPosition = p;
- }
- }
- else {
- currentDistance = offset + length - (p.getOffset() + p.length);
- if (currentDistance < 0)
- currentDistance = endOfDocument + currentDistance;
-
- if (currentDistance < distance || currentDistance == distance && p.length < nextAnnotationPosition.length) {
- distance = currentDistance;
- nextAnnotation = a;
- nextAnnotationPosition = p;
- }
- }
- }
- }
- }
- if (containingAnnotationPosition != null && (!currentAnnotation || nextAnnotation == null)) {
- annotationPosition.setOffset(containingAnnotationPosition.getOffset());
- annotationPosition.setLength(containingAnnotationPosition.getLength());
- return containingAnnotation;
- }
- if (nextAnnotationPosition != null) {
- annotationPosition.setOffset(nextAnnotationPosition.getOffset());
- annotationPosition.setLength(nextAnnotationPosition.getLength());
- }
-
- return nextAnnotation;
- }
-
- private IStatusLineManager getStatusLineManager() {
- // The original JavaEditor M7 implementation made use of an adapter, but that approach
- // failed with a MultiPageEditorSite
- AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
- IWorkbenchWindow window = plugin.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return null;
- IWorkbenchPage page = window.getActivePage();
- if (page == null)
- return null;
- IEditorPart editor = page.getActiveEditor();
- if (editor == null)
- return null;
- IEditorActionBarContributor contributor = editor.getEditorSite().getActionBarContributor();
- if (contributor instanceof EditorActionBarContributor) {
- return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
- }
- return null;
- }
-
- public String getText() {
- return getDefaultLabel();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#getToolTipText()
- */
- public String getToolTipText() {
- return getDefaultLabel();
- }
-
- /**
- * Jumps to the error next according to the given direction based off JavaEditor#gotoAnnotation()
- *
- * @param forward
- * is the direction
- */
- public void gotoAnnotation(boolean forward) {
- ITextSelection selection = (ITextSelection) getTextEditor().getSelectionProvider().getSelection();
- Position position = new Position(0, 0);
- if (false /* delayed - see bug 18316 */) {
- getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
- getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
- }
- else /* no delay - see bug 18316 */{
- Annotation annotation = getNextAnnotation(selection.getOffset(), selection.getLength(), forward, position);
- IEditorStatusLine editorStatusLine = (IEditorStatusLine) getTextEditor().getAdapter(IEditorStatusLine.class);
- if (editorStatusLine != null) {
- editorStatusLine.setMessage(true, null, null);
- editorStatusLine.setMessage(false, null, null);
- }
- else {
- IStatusLineManager mgr = getStatusLineManager();
- mgr.setErrorMessage(null);
- mgr.setMessage(null, null);
- }
- if (annotation != null) {
- updateAnnotationViews(annotation);
- getTextEditor().selectAndReveal(position.getOffset(), position.getLength());
- if (editorStatusLine != null) {
- editorStatusLine.setMessage(true, null, null);
- editorStatusLine.setMessage(false, annotation.getText(), null);
- }
- else {
- IStatusLineManager mgr = getStatusLineManager();
- mgr.setErrorMessage(null);
- mgr.setMessage(null, annotation.getText());
- getTextEditor().getSelectionProvider().addSelectionChangedListener(new StatusLineClearer(mgr));
- }
- }
- }
- }
-
- /**
- * Returns whether the given annotation is configured as a target for the "Go to Next/Previous Annotation" actions
- *
- * @param annotation
- * the annotation
- * @return <code>true</code> if this is a target, <code>false</code> otherwise
- * @since 3.0
- */
- protected boolean isNavigationTarget(Annotation annotation) {
- Preferences preferences = Platform.getPlugin(EditorsUI.PLUGIN_ID).getPluginPreferences();
- AnnotationPreference preference = EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
- // See bug 41689
- // String key= forward ? preference.getIsGoToNextNavigationTargetKey() : preference.getIsGoToPreviousNavigationTargetKey();
- String key = preference == null ? null : preference.getIsGoToNextNavigationTargetKey();
- return (key != null && preferences.getBoolean(key));
- }
-
- public void run() {
- // if (getTextEditor() instanceof StructuredTextEditor) {
- // ((StructuredTextEditor) getTextEditor()).gotoAnnotation(fForward);
- // }
- this.gotoAnnotation(fForward);
- }
-
- public void setEditor(ITextEditor editor) {
- super.setEditor(editor);
- update();
- }
-
- /**
- * Updates the annotation views that show the given annotation.
- *
- * @param annotation
- * the annotation
- */
- protected void updateAnnotationViews(Annotation annotation) {
- IMarker marker = null;
- if (annotation instanceof MarkerAnnotation)
- marker = ((MarkerAnnotation) annotation).getMarker();
-
- if (marker != null && !marker.equals(fLastMarkerTarget)) {
- try {
- IWorkbenchPage page = getTextEditor().getSite().getPage();
- IViewPart view = null;
- if (marker.isSubtypeOf(IMarker.PROBLEM)) {
- view = page.findView(IPageLayout.ID_PROBLEM_VIEW);
- }
- else if (marker.isSubtypeOf(IMarker.BOOKMARK)) {
- view = page.findView(IPageLayout.ID_BOOKMARKS);
- }
- if (view == null) {
- view = page.findView(IPageLayout.ID_TASK_LIST);
- }
- if (view != null) {
- Method method = view.getClass().getMethod("setSelection", new Class[]{IStructuredSelection.class, boolean.class}); //$NON-NLS-1$
- method.invoke(view, new Object[]{new StructuredSelection(marker), Boolean.TRUE});
- }
- }
- catch (CoreException x) {
- //
- }
- catch (NoSuchMethodException x) {
- //
- }
- catch (IllegalAccessException x) {
- //
- }
- catch (InvocationTargetException x) {
- //
- }
- // ignore exceptions, don't update any of the lists, just set statusline
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IHelpContextIds.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IHelpContextIds.java
deleted file mode 100644
index a9df2cde71..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IHelpContextIds.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-/**
- * @deprecated use org.eclipse.wst.sse.ui.internal.editor.IHelpContextIds instead TODO remove
- */
-public interface IHelpContextIds {
- // org.eclipse.wst.sse.ui.
- public static final String PREFIX = EditorPlugin.ID + "."; //$NON-NLS-1$
-
- // Structured Text Editor Preference Page
- // Appearance - Show line numbers, Tab width, etc
- public static final String PREFSRC_SOURCE_PAGE_HELPID = PREFIX + "xmlp1400"; //$NON-NLS-1$
- // Annotations
- public static final String PREF_ANNOTATION_MAIN_HELPID = PREFIX + "xmlp4000"; //$NON-NLS-1$
- public static final String PREF_ANNOTATION_ANALYZE_VALIDITY_HELPID = PREFIX + "xmlp4200"; //$NON-NLS-1$
- public static final String PREF_ANNOTATION_PRESENTATION_HELPID = PREFIX + "xmlp4300"; //$NON-NLS-1$
- // Navigation TODO infopop needed
- // QuickDiff TODO infopop needed
-
- // Web and XML Preference Page
- // Task Tags TODO infopop needed
- // Read-Only Text Style TODO infopop needed
-
- // Abstract Style Preference Page
- // Source Styles page
- public static final String PREFSTL_SOURCE_STYLES_PAGE_HELPID = PREFIX + "xmlp3000"; //$NON-NLS-1$
- // Text highlighting group box
- public static final String PREFSTL_TEXT_HIGHLIGHTING_HELPID = PREFIX + "xmlp3100"; //$NON-NLS-1$
- // Change button (no longer used??)
- /**
- * @deprecated looks like no one is using this
- */
- public static final String PREFSTL_CHANGE_BUTTON_HELPID = PREFIX + "xmlp3010"; //$NON-NLS-1$
-
- // Abstract Template Preference Page (base provides this entire page, so the below infopops are not required)
- // TODO remove these infopops?
- // Template page
- public static final String PREFMAC_MACROS_PAGE_HELPID = PREFIX + "xmlp2000"; //$NON-NLS-1$
- // List of templates, New.., Edit.., Remove, Restore Removed, Revert to Default
- public static final String PREFMAC_MACROS_LIST_HELPID = PREFIX + "xmlp2010"; //$NON-NLS-1$
- public static final String PREFMAC_ENABLED_AT_LOCATION_HELPID = PREFIX + "xmlp2020"; //$NON-NLS-1$
- // Import.., Export..
- // Pattern field
- public static final String PREFMAC_CONTENT_FIELD_HELPID = PREFIX + "xmlp2030"; //$NON-NLS-1$
- // Use code formatter checkbox
-
- // Abstract Source Editor Context Menu
- // Content Assist
- public static final String CONTMNU_CONTENTASSIST_HELPID = PREFIX + "xmlm1010"; //$NON-NLS-1$
- // Format Document
- public static final String CONTMNU_FORMAT_DOC_HELPID = PREFIX + "xmlm1030"; //$NON-NLS-1$
- // Format Active Elements
- public static final String CONTMNU_FORMAT_ELEMENTS_HELPID = PREFIX + "xmlm1040"; //$NON-NLS-1$
- // Cleanup Document
- public static final String CONTMNU_CLEANUP_DOC_HELPID = PREFIX + "xmlm1050"; //$NON-NLS-1$
- // Preferences TODO infopop needed
- // Properties TODO infopop needed
-
- // Source Editor View
- public static final String XML_SOURCE_VIEW_HELPID = PREFIX + "xmlm2000"; //$NON-NLS-1$
-
-
-
-
- // XML Files Preference Page
- // Line delimiter group
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.xml.IXMLEditorHelpContextIds
- */
- public static final String PREFFILE_EOL_CODE_HELPID = PREFIX + "xmlp6000"; //$NON-NLS-1$
- // Encoding group
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.xml.IXMLEditorHelpContextIds
- */
- public static final String PREFFILE_ENCODING_HELPID = PREFIX + "xmlp6100"; //$NON-NLS-1$
-
- // XML Source Preference Page
- // Formatting group - Split lines, Line width, Set one property per line, Split multiple attributes each on a new line, Indent using tabs, Clear all blank lines
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.xml.IXMLEditorHelpContextIds
- */
- public static final String PREFSRC_FORMATTING_HELPID = PREFIX + "xmlp1200"; //$NON-NLS-1$
- // Content assist group - Automatically make suggestions, Prompt when these characters are inserted
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.xml.IXMLEditorHelpContextIds
- */
- public static final String PREFSRC_CONTENT_ASSIST_HELPID = PREFIX + "xmlp1300"; //$NON-NLS-1$
- // Using Inferred Grammar
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.xml.IXMLEditorHelpContextIds
- */
- public static final String PREF_INFERRED_GRAMMAR_HELPID = PREFIX + "xmlp4400"; //$NON-NLS-1$
-
- // XML Cleanup dialog
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.xml.IXMLEditorHelpContextIds
- */
- public static final String CLEANUP_XML_HELPID = PREFIX + "xmlm1200"; //$NON-NLS-1$
-
- // HTML Source Preference Page
- // Preferred markup case group
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.html.IHTMLEditorHelpContextIds
- */
- public static final String PREFSRC_PREFERRED_MARKUP_HELPID = PREFIX + "xmlp1500"; //$NON-NLS-1$
-
- // HTML Cleanup dialog
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.html.IHTMLEditorHelpContextIds
- */
- public static final String CLEANUP_HTML_HELPID = PREFIX + "xmlm1100"; //$NON-NLS-1$
-
- // HTML Content Settings
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.html.IHTMLEditorHelpContextIds
- */
- public static final String WEB_CONTENT_SETTINGS_HELPID = PREFIX + "misc0170"; //$NON-NLS-1$
-
- // JavaScript Style Preference Page
- // Change button for the JavaScript style page (no longer used??)
- /**
- * @deprecated looks like no one is using this
- */
- public static final String PREFSTL_CHANGE_BUTTON_FOR_JS_HELPID = PREFIX + "xmlp3020"; //$NON-NLS-1$
-
- // JSP Fragment Property Page
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.jsp.IJSPEditorHelpContextIds
- */
- public static final String JSP_FRAGMENT_HELPID = PREFIX + "jspf1000"; //$NON-NLS-1$
-
- // CSS Cleanup dialog
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.css.ICSSEditorHelpContextIds
- */
- public static final String CLEANUP_CSS_HELPID = PREFIX + "xmlm1300"; //$NON-NLS-1$
-
- // CSS Content Settings
- /**
- * @deprecated moved to org.eclipse.wst.sse.ui.css.ICSSEditorHelpContextIds
- */
- public static final String CSS_CONTENT_SETTINGS_HELPID = PREFIX + "misc0180"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IModelProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IModelProvider.java
deleted file mode 100644
index e7dc86f8db..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IModelProvider.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-public interface IModelProvider extends IDocumentProvider {
- IStructuredModel getModel(Object element);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IReleasable.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IReleasable.java
deleted file mode 100644
index eb425ae024..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/IReleasable.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-public interface IReleasable {
- /**
- * Generic catch-all for releasing resources and other references
- */
- void release();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ISourceViewerActionBarContributor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ISourceViewerActionBarContributor.java
deleted file mode 100644
index 515dc575bc..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ISourceViewerActionBarContributor.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import org.eclipse.ui.IEditorActionBarContributor;
-
-public interface ISourceViewerActionBarContributor extends IEditorActionBarContributor {
-
- /**
- * Enables disables actions that are specific to the source viewer (and should only work when
- * the source viewer is enabled)
- * @param enabled true if source viewer is currently enabled, false otherwise
- */
- public void setViewerSpecificContributionsEnabled(boolean enabled);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ITemporaryAnnotation.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ITemporaryAnnotation.java
deleted file mode 100644
index 18153d8adb..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ITemporaryAnnotation.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-public interface ITemporaryAnnotation {
- Object getKey();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/Logger.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/Logger.java
deleted file mode 100644
index 14960afa76..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/Logger.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if desired,
- * the console. This class should only be used by classes in this plugin. Other
- * plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static Plugin fPlugin = EditorPlugin.getDefault();
- private static final String fPluginId = fPlugin.getDescriptor().getUniqueIdentifier();
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
-
- public static final int OK = IStatus.OK; // 0
- public static final int INFO = IStatus.INFO; // 1
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int ERROR = IStatus.ERROR; // 4
-
- public static final int OK_DEBUG = 200 + OK;
- public static final int INFO_DEBUG = 200 + INFO;
- public static final int WARNING_DEBUG = 200 + WARNING;
- public static final int ERROR_DEBUG = 200 + ERROR;
-
- /**
- * Adds message to log.
- * @param level severity level of the message (OK, INFO, WARNING, ERROR, OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message text to add to the log
- * @param exception exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, fPluginId, severity, message, exception);
- fPlugin.getLog().log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- * @param message text to print
- * @param category category of the message, to be compared with /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, fPluginId, IStatus.OK, message, exception);
- fPlugin.getLog().log(statusObj);
- }
- }
-
- /**
- * @return true if the plugin for this logger is debugging
- */
- public static boolean isDebugging() {
- return fPlugin.isDebugging();
- }
-
- /**
- * Determines if currently tracing a category
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(fPluginId + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/NullModelProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/NullModelProvider.java
deleted file mode 100644
index 5ab42e0d1d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/NullModelProvider.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.AnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.texteditor.AbstractDocumentProvider;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-/**
- * An IModelProvider that builds StructuredModels on top of IDocuments. A
- * prototype for "any IEditorInput" support
- *
- * *** VERY UNTESTED ***
- * TODO: Currently BROKEN
- */
-public class NullModelProvider extends AbstractDocumentProvider implements IModelProvider {
- /**
- * Utility method also used in subclasses
- */
- protected static IModelManager getModelManager() {
- // get the model manager from the plugin
- // note: we can use the static "ID" variable, since we pre-req that plugin
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- private static NullModelProvider _instance = null;
-
- private HashMap fModelMap = new HashMap(1);
-
- public static synchronized NullModelProvider getInstance() {
- if (_instance == null) {
- _instance = new NullModelProvider();
- }
- return _instance;
- }
-
- public NullModelProvider() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createAnnotationModel(java.lang.Object)
- */
- protected IAnnotationModel createAnnotationModel(Object element) {
- return new AnnotationModel();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createDocument(java.lang.Object)
- */
- protected IDocument createDocument(Object element) {
- // return getModel(element).getStructuredDocument();
- return new Document();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#createElementInfo(java.lang.Object)
- */
- // protected ElementInfo createElementInfo(Object element) throws CoreException {
- // if (fModelMap.get(element) != null)
- // fModelMap.put(element, getModelManager().createUnManagedStructuredModelFor(ContentTypeIdentifierForXML.ContentTypeID_XML));
- // return super.createElementInfo(element);
- // }
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#disposeElementInfo(java.lang.Object, org.eclipse.ui.texteditor.AbstractDocumentProvider.ElementInfo)
- */
- protected void disposeElementInfo(Object element, ElementInfo info) {
- fModelMap.remove(element);
- super.disposeElementInfo(element, info);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) {
- return;
- }
-
- /* (non-Javadoc)
- */
- public IStructuredModel getModel(Object element) {
- return (IStructuredModel) fModelMap.get(element);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#getOperationRunner(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IRunnableContext getOperationRunner(IProgressMonitor monitor) {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ReadOnlyAwareDropTargetAdapter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ReadOnlyAwareDropTargetAdapter.java
deleted file mode 100644
index 3347033772..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ReadOnlyAwareDropTargetAdapter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.ui.extension.ExtendedEditorDropTargetAdapter;
-
-
-public class ReadOnlyAwareDropTargetAdapter extends ExtendedEditorDropTargetAdapter {
-
- public ReadOnlyAwareDropTargetAdapter() {
- super();
- }
-
- public void drop(DropTargetEvent event) {
- IDocument document = getTextViewer().getDocument();
- if (document instanceof IStructuredDocument) {
- if (((IStructuredDocument) document).containsReadOnly(getDropOffset(event), 0)) {
- event.operations = DND.DROP_NONE;
- event.detail = DND.DROP_NONE;
- getTextViewer().getTextWidget().redraw();
- getTextViewer().getTextWidget().update();
- getTextViewer().getTextWidget().getDisplay().beep();
- }
- }
- super.drop(event);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckActionWrapper.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckActionWrapper.java
deleted file mode 100644
index 6906eda2a0..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckActionWrapper.java
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IPartListener;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.ui.extension.IExtendedEditorAction;
-import org.eclipse.wst.sse.ui.extension.IExtendedSimpleEditor;
-import org.eclipse.wst.sse.ui.extension.SpellCheckProviderBuilder;
-import org.eclipse.wst.sse.ui.extensions.ISelfValidateEditAction;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckAction;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckProvider;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckTarget;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-
-
-/**
- * Spell Check action
- */
-public class SpellCheckActionWrapper extends Action implements IExtendedEditorAction, ISelfValidateEditAction, IPartListener {
- protected SpellCheckAction action = null;
- protected IWorkbenchPart activePart = null;
-
- protected IExtendedSimpleEditor fEditor = null;
- protected SpellCheckProvider provider = null;
-
- public SpellCheckActionWrapper() {
- super();
-
- IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService();
- service.addPartListener(this);
- partActivated(service.getActivePart());
-
- //TODO DBK performance modification - change to delegate
- // DBK There appears to only be one extender, and it doesn't specify
- // DBK the icon / text -- it is determined by the target action.
- // DBK This forces this plug-in to load the provider plug-in solely
- // DBK to ask it what to display. Since presumably this is static,
- // DBK I've moved it to here. Alternatively, you can comment out
- // DBK the setInitializationData method, add the appropriate interface,
- // DBK and then extract the values from the extension itself (again,
- // DBK thereby avoiding the load of the provider plug-in).
- // setId("org.eclipse.wst.sse.ui.spellcheck");
- // setActionDefinitionId("org.eclipse.wst.sse.ui.spellcheck");
-
- IPluginDescriptor localDescriptor = Platform.getPluginRegistry().getPluginDescriptor(EditorPlugin.ID);
- setText(localDescriptor.getResourceString("%Spell_Check_label")); //$NON-NLS-1$
- setToolTipText(localDescriptor.getResourceString("%Spell_Check_tooltip")); //$NON-NLS-1$
-
- setImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_CTOOL16_SPELLCHECK));
- setDisabledImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_DTOOL16_SPELLCHECK));
- setHoverImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_ETOOL16_SPELLCHECK));
- }
-
- private void initializeSpellCheckProviderAction() {
- // DBK performance modification - There is only one extender, yet there is a loop?
- // DBK No references to multiple providers in run() method either.
- // DBK I suggest reworking this to be a single-point extension.
- SpellCheckProvider[] providers = SpellCheckProviderBuilder.getInstance().getSpellCheckProviders();
- final int n = providers.length;
- for (int i = 0; i < n; i++) {
- action = providers[i].createSpellCheckAction();
- }
- update();
-
- // TODO DBK performance modification - copied into this plug-in, this is now unnecessary code
- // if (action == null) return;
- // IAction a = (IAction)action;
- //
- // setText(a.getText());
- // setToolTipText(a.getToolTipText());
- // setImageDescriptor(a.getImageDescriptor());
- // setHoverImageDescriptor(a.getHoverImageDescriptor());
- // setDisabledImageDescriptor(a.getDisabledImageDescriptor());
- }
-
- /**
- */
- public boolean isVisible() {
- if (fEditor == null)
- return true;
-
- IEditorPart part = fEditor.getEditorPart();
- if (part == null)
- return true;
-
- String cls = part.getClass().getName();
- if ("org.eclipse.wst.html.ui.HTMLEditor".equals(cls)) //$NON-NLS-1$
- return false;
-
- Object target = part.getAdapter(SpellCheckTarget.class);
- return (target != null);
- }
-
- public void partActivated(IWorkbenchPart part) {
- IExtendedSimpleEditor editor = null;
- if (part != null && part != activePart) {
- if (part instanceof IExtendedSimpleEditor)
- editor = (IExtendedSimpleEditor) part;
- else if (part.getAdapter(IExtendedSimpleEditor.class) != null)
- editor = (IExtendedSimpleEditor) part.getAdapter(IExtendedSimpleEditor.class);
- else if (part.getAdapter(ITextEditor.class) instanceof IExtendedSimpleEditor)
- editor = (IExtendedSimpleEditor) part.getAdapter(ITextEditor.class);
- }
- this.activePart = part;
- setActiveExtendedEditor(editor);
- // lock onto the first valid editor part
- if (editor != null) {
- IPartService service = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getPartService();
- service.removePartListener(this);
- }
- update();
- }
-
- public void partBroughtToTop(IWorkbenchPart part) {
- // do nothing
- }
-
- public void partClosed(IWorkbenchPart part) {
- if (part == null || part == fEditor) {
- setActiveExtendedEditor(null);
- update();
- }
- }
-
- public void partDeactivated(IWorkbenchPart part) {
- // do nothing
- }
-
- public void partOpened(IWorkbenchPart part) {
- // do nothing
- }
-
- public void run() {
- if (action == null)
- initializeSpellCheckProviderAction();
- if (action == null || !isEnabled()) {
- MessageDialog.openInformation(getDisplay().getActiveShell(), WorkbenchMessages.getString("Information"), //$NON-NLS-1$
- WorkbenchMessages.getString("PluginAction.operationNotAvailableMessage")); //$NON-NLS-1$
- setEnabled(false);
- return;
- }
- IAction a = (IAction) action;
- a.run();
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- */
- public void setActiveExtendedEditor(IExtendedSimpleEditor targetEditor) {
- fEditor = targetEditor;
- }
-
- public void update() {
- if (fEditor == null) {
- setEnabled(false);
- return;
- }
-
- if (action != null) {
- action.update();
- setEnabled(((IAction) action).isEnabled());
- return;
- }
-
- // Default is true since action isn't instantiated until run();
- // a second test is done later to see if the action is **really** ready.
- setEnabled(true);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckTargetImpl.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckTargetImpl.java
deleted file mode 100644
index e2edd10564..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/SpellCheckTargetImpl.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.IFindReplaceTarget;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckElement;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckException;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckOptionDialog;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckSelectionManager;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckTarget;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellChecker;
-import org.eclipse.wst.sse.ui.util.Assert;
-
-
-/**
- * SpellCheckTargetImpl
- */
-public class SpellCheckTargetImpl implements SpellCheckTarget {
-
- public static class EditorSpellCheckException extends SpellCheckException {
- EditorSpellCheckException(String msg) {
- super(msg);
- }
-
- public IStatus getStatus() {
- return new Status(IStatus.ERROR, EditorPlugin.ID, 0, getMessage(), this);
- }
- }
-
- private SpellChecker checker;
- private StructuredTextEditor editor;
- private IFindReplaceTarget target;
- public static final String ID = "spellchecktarget"; //$NON-NLS-1$
-
- public SpellCheckTargetImpl() {
- super();
- }
-
- /**
- * @see ISpellCheckTarget#beginRecording()
- */
- public void beginRecording(Object requester, String label) {
- if (editor == null)
- return;
-
- IStructuredModel model = editor.getModel();
- if (model == null)
- return;
-
- model.beginRecording(requester, label);
- }
-
- /**
- * @see ISpellCheckTarget#canPerformChange()
- */
- public boolean canPerformChange() {
- if (editor == null || checker == null || target == null)
- return false;
-
- //return target.isEditable() && editor.isEditable() && !editor.isEditorInputReadOnly();
- return target.isEditable() && editor.isEditable();
- }
-
- /**
- * @see ISpellCheckTarget#canPerformChangeAll()
- */
- public boolean canPerformChangeAll() {
- return canPerformChange();
- }
-
- /**
- * @see ISpellCheckTarget#canPerformIgnore()
- */
- public boolean canPerformIgnore() {
- return (editor != null && checker != null ? true : false);
- }
-
- /**
- * @see ISpellCheckTarget#canPerformIgnoreAll()
- */
- public boolean canPerformIgnoreAll() {
- return (editor != null && checker != null ? true : false);
- }
-
- /**
- * @see ISpellCheckTarget#canPerformSpellCheck()
- */
- public boolean canPerformSpellCheck() {
- return (editor != null && checker != null ? true : false);
- }
-
- /**
- * @see ISpellCheckTarget#endRecording()
- */
- public void endRecording(Object requester) {
- if (editor == null)
- return;
-
- IStructuredModel model = editor.getModel();
- if (model == null)
- return;
-
- model.endRecording(requester);
- }
-
- /**
- * @see ISpellCheckTarget#findAndSelect(int, String)
- */
- public int findAndSelect(int pos, String find) {
- return (target != null ? target.findAndSelect(pos, find, true, true, true) : -1);
- }
-
- /**
- * @see ISpellCheckTarget#getAndSelectNextMisspelledElement(boolean)
- */
- public SpellCheckElement getAndSelectNextMisspelledElement(boolean init) throws SpellCheckException {
- if (checker == null || editor == null || target == null)
- return null;
-
- IStructuredModel sm = editor.getModel();
- IStructuredDocument fm = sm.getStructuredDocument();
-
- int start;
- if (init) {
- start = 0;
- }
- else {
- Point pt = target.getSelection();
- start = pt.x + pt.y;
- }
-
- IStructuredDocumentRegion node = fm.getRegionAtCharacterOffset(start);
- if (node == null) {
- return null;
- }
-
- ITextRegion startRegion = node.getRegionAtCharacterOffset(start);
- if (startRegion == null) {
- return null;
- }
-
- boolean skip = true;
- while (node != null) {
- ITextRegionList regions = node.getRegions();
- int size = regions.size();
- for (int i = 0; i < size; ++i) {
- ITextRegion r = regions.get(i);
- if (skip && startRegion.equals(r)) {
- skip = false;
- }
- if (skip == false) {
- if (isValidType(r.getType())) {
- String text;
- if (start > node.getStartOffset(r)) {
- text = node.getText(r);
- int offset = start - node.getStartOffset(r);
- for (; offset < text.length(); ++offset) {
- if (!Character.isLetterOrDigit(text.charAt(offset - 1))) {
- break;
- }
- }
- text = text.substring(offset);
- }
- else {
- text = node.getText(r);
- }
- SpellCheckElement[] elms = checker.createSingleWords(text);
- if (elms != null) {
- for (int j = 0; j < elms.length; ++j) {
- SpellCheckElement element = checker.verifySpell(elms[j]);
- if (element.isSpellError()) {
- target.findAndSelect(start, element.getString(), true, true, true);
- return element;
- }
- }
- }
- }
- }
- }
- node = node.getNext();
- }
-
- return null;
- }
-
- /**
- * @see ISpellCheckTarget#getOptionDialog()
- */
- public SpellCheckOptionDialog getOptionDialog() {
- return null;
- }
-
- /**
- * @see ISpellCheckTarget#getSpellCheckSelectionManager()
- */
- public SpellCheckSelectionManager getSpellCheckSelectionManager() {
- if (editor == null)
- return null;
- return (SpellCheckSelectionManager) editor.getViewerSelectionManager();
- }
-
- /**
- */
- protected boolean isValidType(String type) {
- return false;
- }
-
- /**
- * @see ISpellCheckTarget#replaceSelection(String)
- */
- public void replaceSelection(String text, Shell shell) throws SpellCheckException {
- if (target == null)
- return;
- IStatus status = editor.validateEdit(shell);
- if (!status.isOK()) {
- throw new EditorSpellCheckException(status.getMessage());
- }
-
- target.replaceSelection(text);
- }
-
- /**
- * @see ISpellCheckTarget#setSpellChecker(ISpellChecker)
- */
- public void setSpellChecker(SpellChecker checker) {
- this.checker = checker;
- }
-
- /* (non-Javadoc)
- */
- public void setTextEditor(ITextEditor editor) {
- Assert.isTrue(editor instanceof StructuredTextEditor);
- this.editor = (StructuredTextEditor) editor;
- target = (IFindReplaceTarget) editor.getAdapter(IFindReplaceTarget.class);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StorageModelProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StorageModelProvider.java
deleted file mode 100644
index 78dd53ab44..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StorageModelProvider.java
+++ /dev/null
@@ -1,421 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.AnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.editors.text.FileDocumentProvider;
-import org.eclipse.ui.editors.text.StorageDocumentProvider;
-import org.eclipse.ui.texteditor.IElementStateListener;
-import org.eclipse.wst.sse.core.FactoryRegistry;
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.IExtendedStorageEditorInput;
-import org.eclipse.wst.sse.ui.internal.debug.BreakpointRulerAction;
-import org.eclipse.wst.sse.ui.internal.extension.BreakpointProviderBuilder;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryProvider;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistry;
-
-
-/**
- * A StorageDocumentProvider that is IStructuredModel aware
- */
-public class StorageModelProvider extends StorageDocumentProvider implements IModelProvider {
-
- protected class InternalElementStateListener implements IElementStateListener {
- public void elementContentAboutToBeReplaced(Object element) {
- // we just forward the event
- StorageModelProvider.this.fireElementContentAboutToBeReplaced(element);
- }
-
- public void elementContentReplaced(Object element) {
- // Force a reload of the markers into annotations since their previous Positions
- // have been deleted. Disconnecting and reconnecting forces a call to the
- // private catchupWithMarkers method.
- StorageInfo info = (StorageInfo) getElementInfo(element);
-
- if (info != null && info.fModel != null) {
- info.fModel.disconnect(info.fDocument);
- }
-
- // we just forward the event
- StorageModelProvider.this.fireElementContentReplaced(element);
-
- if (info != null && info.fModel != null) {
- info.fModel.connect(info.fDocument);
- }
- }
-
- public void elementDeleted(Object element) {
- // we just forward the event
- StorageModelProvider.this.fireElementDeleted(element);
- }
-
- public void elementDirtyStateChanged(Object element, boolean isDirty) {
- // we just forward the event
- StorageModelProvider.this.fireElementDirtyStateChanged(element, isDirty);
- }
-
- public void elementMoved(Object originalElement, Object movedElement) {
- // we just forward the event
- StorageModelProvider.this.fireElementMoved(originalElement, movedElement);
- }
- }
-
- /**
- * Collection of info that goes with a model.
- */
- protected class ModelInfo {
- public IAnnotationModel fAnnotationModel;
- public IEditorInput fElement;
- public boolean fShouldReleaseOnInfoDispose;
- public IStructuredModel fStructuredModel;
-
- public ModelInfo(IStructuredModel structuredModel, IEditorInput element, IAnnotationModel model, boolean selfCreated) {
- fElement = element;
- fStructuredModel = structuredModel;
- fAnnotationModel = model;
- fShouldReleaseOnInfoDispose = selfCreated;
- }
- }
-
- private static StorageModelProvider fInstance = null;
- private static IModelManager fModelManager;
-
- public synchronized static StorageModelProvider getInstance() {
- if (fInstance == null)
- fInstance = new StorageModelProvider();
- return fInstance;
- }
-
- /**
- * Utility method also used in subclasses
- */
- protected static IModelManager getModelManager() {
- if (fModelManager == null) {
- // get the model manager from the plugin
- // note: we can use the static "ID" variable, since we pre-req that plugin
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- fModelManager = plugin.getModelManager();
- }
- return fModelManager;
- }
-
- protected IElementStateListener fInternalListener;
- /** IStructuredModel information of all connected elements */
- private Map fModelInfoMap = new HashMap();
-
- protected StorageModelProvider() {
- super();
- fInternalListener = new InternalElementStateListener();
- }
-
- public void addProviderFactories(IStructuredModel structuredModel) {
- // (mostly) COPIED FROM FileModelProvider
- EditorPlugin plugin = ((EditorPlugin) Platform.getPlugin(EditorPlugin.ID));
- AdapterFactoryRegistry adapterRegistry = plugin.getAdapterFactoryRegistry();
- Iterator adapterFactoryList = adapterRegistry.getAdapterFactories();
-
- IFactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
- if (factoryRegistry == null) {
- factoryRegistry = new FactoryRegistry();
- structuredModel.setFactoryRegistry(factoryRegistry);
- }
-
- while (adapterFactoryList.hasNext()) {
- try {
- AdapterFactoryProvider provider = (AdapterFactoryProvider) adapterFactoryList.next();
- if (provider.isFor(structuredModel.getModelHandler())) {
- provider.addAdapterFactories(structuredModel);
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- // END COPY FileModelProvider
- }
-
- protected String computePath(IStorageEditorInput input) {
- /**
- * Typically CVS will return a path of "filename.ext" and the input's
- * name will be "filename.ext version". The path must be used to load
- * the model so that the suffix will be available to compute the
- * contentType properly. The editor input name can then be set as the
- * base location for display on the editor title bar.
- *
- */
- String path = null;
- boolean addHash = false;
- try {
- IStorage storage = input.getStorage();
- if (storage != null) {
- IPath storagePath = storage.getFullPath();
- String name = storage.getName();
- // if either the name or storage path are null or they are identical, add a hash to it to guarantee uniqueness
- addHash = storagePath == null || storagePath.toString().equals(name);
- if (storagePath != null)
- path = storagePath.makeAbsolute().toString();
- if (path == null)
- path = name;
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- finally {
- if (path == null)
- path = ""; //$NON-NLS-1$
- }
- if (addHash)
- path = input.hashCode() + path;
- return path;
- }
-
- // public boolean canSaveDocument(Object element) {
- // return false;
- // }
-
- protected IAnnotationModel createAnnotationModel(Object element) throws CoreException {
- if (element instanceof IStorageEditorInput) {
- IStorageEditorInput input = (IStorageEditorInput) element;
- String contentType = (getModel(input) != null ? getModel(input).getContentTypeIdentifier() : null);
- String ext = BreakpointRulerAction.getFileExtension((IEditorInput) element);
- IResource res = BreakpointProviderBuilder.getInstance().getResource(input, contentType, ext);
- String id = input.getName();
- if (input.getStorage() != null)
- id = input.getStorage().getFullPath().toString();
- // we can only create a resource marker annotationmodel off of a valid resource
- if (res != null)
- return new StructuredResourceMarkerAnnotationModel(res, id);
- else
- return new AnnotationModel();
- }
- return super.createAnnotationModel(element);
- }
-
- protected IDocument createDocument(Object element) {
- return getModel(element).getStructuredDocument();
- }
-
- /**
- * Also create ModelInfo - extra resource synchronization classes should
- * be stored within the ModelInfo
- */
- protected ElementInfo createElementInfo(Object element) throws CoreException {
- // create the corresponding ModelInfo if necessary
- if (getModelInfoFor((IEditorInput) element) == null) {
- createModelInfo((IEditorInput) element);
- }
-
- ElementInfo info = super.createElementInfo(element);
- return info;
- }
-
- public void createModelInfo(IEditorInput input) {
- if (getModelInfoFor(input) == null) {
- IStructuredModel structuredModel = selfCreateModel(input);
- createModelInfo(input, structuredModel, true);
- }
- }
-
- /**
- * To be used when model is provided to us, ensures that when setInput is used on this input, the
- * given model will be used.
- */
- public void createModelInfo(IEditorInput input, IStructuredModel structuredModel, boolean releaseModelOnDisconnect) {
- // we have to make sure factories are added, whether we created or not.
- if (getModelInfoFor(input) != null || getModelInfoFor(structuredModel) != null)
- return;
-
- if (input instanceof IExtendedStorageEditorInput) {
- ((IExtendedStorageEditorInput) input).addElementStateListener(fInternalListener);
- }
-
- addProviderFactories(structuredModel);
-
- ModelInfo modelInfo = new ModelInfo(structuredModel, input, null, releaseModelOnDisconnect);
- fModelInfoMap.put(input, modelInfo);
-
- try {
- modelInfo.fAnnotationModel = createAnnotationModel(input);
- }
- catch (CoreException e) {
- // just continue without one
- }
- }
-
- protected void disposeElementInfo(Object element, ElementInfo info) {
- if (element instanceof IEditorInput) {
- IEditorInput input = (IEditorInput) element;
- ModelInfo modelInfo = getModelInfoFor(input);
- disposeModelInfo(modelInfo);
- }
- super.disposeElementInfo(element, info);
- }
-
- /**
- * disconnect from this model info
- * @param info
- */
- public void disposeModelInfo(ModelInfo info) {
- if (info.fElement instanceof IStorageEditorInput) {
- if (info.fElement instanceof IExtendedStorageEditorInput) {
- ((IExtendedStorageEditorInput) info.fElement).removeElementStateListener(fInternalListener);
- }
- if (info.fShouldReleaseOnInfoDispose) {
- info.fStructuredModel.releaseFromEdit();
- }
- }
- fModelInfoMap.remove(info.fElement);
- }
-
- /**
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor, java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- new FileDocumentProvider().saveDocument(monitor, element, document, overwrite);
- }
-
- /**
- * Overridden to use ModelInfo's annotation model
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object)
- */
- public IAnnotationModel getAnnotationModel(Object element) {
- // override behavior an retrieve the annotation model from the model info
- ModelInfo info = getModelInfoFor((IEditorInput) element);
- if (info != null)
- return info.fAnnotationModel;
- return null;
- }
-
- protected IEditorInput getInputFor(IDocument document) {
- IStructuredModel model = getModelManager().getExistingModelForRead(document);
- IEditorInput input = getInputFor(model);
- model.releaseFromRead();
- return input;
- }
-
- protected IEditorInput getInputFor(IStructuredModel structuredModel) {
- IEditorInput result = null;
- ModelInfo info = getModelInfoFor(structuredModel);
- if (info != null)
- result = info.fElement;
- return result;
- }
-
- public IStructuredModel getModel(IEditorInput element) {
- IStructuredModel result = null;
- ModelInfo info = getModelInfoFor(element);
- if (info != null) {
- result = info.fStructuredModel;
- }
- return result;
- }
-
- /* (non-Javadoc)
- */
- public IStructuredModel getModel(Object element) {
- if (element instanceof IEditorInput)
- return getModel((IEditorInput) element);
- return null;
- }
-
- protected ModelInfo getModelInfoFor(IEditorInput element) {
- ModelInfo result = (ModelInfo) fModelInfoMap.get(element);
- return result;
- }
-
- protected ModelInfo getModelInfoFor(IStructuredModel structuredModel) {
- ModelInfo result = null;
- if (structuredModel != null) {
- ModelInfo[] modelInfos = (ModelInfo[]) fModelInfoMap.values().toArray(new ModelInfo[0]);
- for (int i = 0; i < modelInfos.length; i++) {
- ModelInfo info = modelInfos[i];
- if (structuredModel.equals(info.fStructuredModel)) {
- result = info;
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * Method loadModel.
- * @param input
- * @return IStructuredModel
- */
- public IStructuredModel loadModel(IStorageEditorInput input) {
- return loadModel(input, false);
- }
-
- /**
- * Method loadModel.
- * @param input
- * @param logExceptions
- * @return IStructuredModel
- */
- public IStructuredModel loadModel(IStorageEditorInput input, boolean logExceptions) {
- InputStream contents = null;
- try {
- contents = input.getStorage().getContents();
- }
- catch (CoreException noStorageExc) {
- if (logExceptions)
- Logger.logException(ResourceHandler.getString("32concat_EXC_", new Object[]{input.getName()}), noStorageExc); //$NON-NLS-1$
- }
-
- IStructuredModel model = null;
- String path = computePath(input);
- try {
- // first parameter must be unique
- model = getModelManager().getModelForEdit(path, contents, null);
- model.setBaseLocation(input.getName());
- }
- catch (IOException e) {
- if (logExceptions)
- Logger.logException(ResourceHandler.getString("32concat_EXC_", new Object[]{input}), e); //$NON-NLS-1$
- }
- return model;
- }
-
- /**
- * @param input
- * @return
- */
- protected IStructuredModel selfCreateModel(IEditorInput input) {
- return loadModel((IStorageEditorInput) input);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredAnnotationType.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredAnnotationType.java
deleted file mode 100644
index f9d44deb24..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredAnnotationType.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-/**
- * @deprecated use Annotation.getType() now, with one of the types specified via extension point:
- * see <code>extension point="org.eclipse.ui.editors.annotationTypes"</code>
- * and <code>extension point="org.eclipse.ui.editors.markerAnnotationSpecification"</code>
-
- */
-final public class StructuredAnnotationType {
-
- public final static StructuredAnnotationType ALL = new StructuredAnnotationType();
- public final static StructuredAnnotationType UNKNOWN = new StructuredAnnotationType();
- public final static StructuredAnnotationType BOOKMARK = new StructuredAnnotationType();
- public final static StructuredAnnotationType TASK = new StructuredAnnotationType();
- public final static StructuredAnnotationType ERROR = new StructuredAnnotationType();
- public final static StructuredAnnotationType WARNING = new StructuredAnnotationType();
- public final static StructuredAnnotationType INFO = new StructuredAnnotationType();
- public final static StructuredAnnotationType SEARCH = new StructuredAnnotationType();
-
-
- private StructuredAnnotationType() {
- }
-
- public String toString() {
- if (this == ALL)
- return "StructuredAnnotationType.ALL"; //$NON-NLS-1$
-
- if (this == UNKNOWN)
- return "StructuredAnnotationType.UNKNOWN"; //$NON-NLS-1$
-
- if (this == BOOKMARK)
- return "StructuredAnnotationType.BOOKMARK"; //$NON-NLS-1$
-
- if (this == TASK)
- return "StructuredAnnotationType.TASK"; //$NON-NLS-1$
-
- if (this == ERROR)
- return "StructuredAnnotationType.ERROR"; //$NON-NLS-1$
-
- if (this == WARNING)
- return "StructuredAnnotationType.WARNING"; //$NON-NLS-1$
-
- if (this == SEARCH)
- return "StructuredAnnotationType.SEARCH"; //$NON-NLS-1$
-
- return ""; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentCommand.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentCommand.java
deleted file mode 100644
index 0dfc681f19..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentCommand.java
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ListIterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-import org.eclipse.jface.text.DocumentCommand;
-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.swt.events.VerifyEvent;
-
-/**
- * TODO Temporary subclass to workaround BUG44665
- *
- * Algorithm for intersects() methods changed.
- */
-/**
- * Represents a text modification as a document replace command. The text modification is given
- * as a <code>VerifyEvent</code> and translated into a document replace command relative
- * to a given offset. A document command can also be used to initialize a given <code>VerifyEvent</code>.<p>
- * A document command can also represent a list of related changes.
- */
-public class StructuredDocumentCommand extends DocumentCommand {
-
- /**
- * A command which is added to document commands.
- * @since 2.1
- */
- private static class Command implements Comparable {
- /** The offset of the range to be replaced */
- final int fOffset;
- /** The length of the range to be replaced. */
- final int fLength;
- /** The replacement text */
- private final String fText;
- /** The listern who owns this command */
- private final IDocumentListener fOwner;
-
- /**
- * Creates a new command with the given specification.
- *
- * @param offset the offset of the replace command
- * @param length the length of the replace command
- * @param text the text to replace with, may be <code>null</code>
- * @param owner the document command owner, may be <code>null</code>
- * @since 3.0
- */
- public Command(int offset, int length, String text, IDocumentListener owner) {
- if (offset < 0 || length < 0)
- throw new IllegalArgumentException();
- fOffset= offset;
- fLength= length;
- fText= text;
- fOwner= owner;
- }
-
- /**
- * Returns the length delta for this command.
- *
- * @return the length delta for this command
- */
- public int getDeltaLength() {
- return (fText == null ? 0 : fText.length()) - fLength;
- }
-
- /**
- * Executes the document command on the specified document.
- *
- * @param document the document on which to execute the command.
- * @throws BadLocationException in case this commands cannot be executed
- */
- public void execute(IDocument document) throws BadLocationException {
-
- if (fLength == 0 && fText == null)
- return;
-
- if (fOwner != null)
- document.removeDocumentListener(fOwner);
-
- document.replace(fOffset, fLength, fText);
-
- if (fOwner != null)
- document.addDocumentListener(fOwner);
- }
-
- /*
- * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
- */
- public int compareTo(final Object object) {
- if (equals(object))
- return 0;
-
- final Command command= (Command) object;
-
- // diff middle points if not intersecting
- if (fOffset + fLength <= command.fOffset || command.fOffset + command.fLength <= fOffset) {
- int value= (2 * fOffset + fLength) - (2 * command.fOffset + command.fLength);
- if (value != 0)
- return value;
- }
- // the answer
- return 42;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object object) {
- if (object == this)
- return true;
- if (! (object instanceof Command))
- return false;
- final Command command= (Command) object;
- return command.fOffset == fOffset && command.fLength == fLength;
- }
- }
-
- /**
- * An iterator, which iterates in reverse over a list.
- */
- private static class ReverseListIterator implements Iterator {
-
- /** The list iterator. */
- private final ListIterator fListIterator;
-
- /**
- * Creates a reverse list iterator.
- * @param listIterator the iterator that this reverse iterator is based upon
- */
- public ReverseListIterator(ListIterator listIterator) {
- if (listIterator == null)
- throw new IllegalArgumentException();
- fListIterator= listIterator;
- }
-
- /*
- * @see java.util.Iterator#hasNext()
- */
- public boolean hasNext() {
- return fListIterator.hasPrevious();
- }
-
- /*
- * @see java.util.Iterator#next()
- */
- public Object next() {
- return fListIterator.previous();
- }
-
- /*
- * @see java.util.Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- /**
- * A command iterator.
- */
- private static class CommandIterator implements Iterator {
-
- /** The command iterator. */
- private final Iterator fIterator;
-
- /** The original command. */
- private Command fCommand;
-
- /** A flag indicating the direction of iteration. */
- private boolean fForward;
-
- /**
- * Creates a command iterator.
- *
- * @param commands an ascending ordered list of commands
- * @param command the original command
- * @param forward the direction
- */
- public CommandIterator(final List commands, final Command command, final boolean forward) {
- if (commands == null || command == null)
- throw new IllegalArgumentException();
- fIterator= forward ? commands.iterator() : new ReverseListIterator(commands.listIterator(commands.size()));
- fCommand= command;
- fForward= forward;
- }
-
- /*
- * @see java.util.Iterator#hasNext()
- */
- public boolean hasNext() {
- return fCommand != null || fIterator.hasNext();
- }
-
- /*
- * @see java.util.Iterator#next()
- */
- public Object next() {
-
- if (! hasNext())
- throw new NoSuchElementException();
-
- if (fCommand == null)
- return fIterator.next();
-
- if (!fIterator.hasNext()) {
- final Command tempCommand= fCommand;
- fCommand= null;
- return tempCommand;
- }
-
- final Command command= (Command) fIterator.next();
- final int compareValue= command.compareTo(fCommand);
-
- if ((compareValue < 0) ^ ! fForward) {
- return command;
-
- } else if ((compareValue > 0) ^ ! fForward) {
- final Command tempCommand= fCommand;
- fCommand= command;
- return tempCommand;
-
- } else {
- throw new IllegalArgumentException();
- }
- }
-
- /*
- * @see java.util.Iterator#remove()
- */
- public void remove() {
- throw new UnsupportedOperationException();
- }
- }
-
- /** Must the command be updated */
- public boolean doit= false;
- /** The offset of the command. */
- public int offset;
- /** The length of the command */
- public int length;
- /** The text to be inserted */
- public String text;
- /**
- * The owner of the document command which will not be notified.
- * @since 2.1
- */
- public IDocumentListener owner;
- /**
- * The caret offset with respect to the document before the document command is executed.
- * @since 2.1
- */
- public int caretOffset;
- /**
- * Additional document commands.
- * @since 2.1
- */
- private final List fCommands= new ArrayList();
- /**
- * Indicates whether the caret should be shifted by this command.
- *
- * @since 3.0
- */
- public boolean shiftsCaret;
-
- /**
- * Translates a verify event into a document replace command using the given offset.
- *
- * @param event the event to be translated
- * @param modelRange the event range as model range
- */
- public void setEvent(VerifyEvent event, IRegion modelRange) {
-
- doit= true;
- text= event.text;
-
- offset= modelRange.getOffset();
- length= modelRange.getLength();
-
- owner= null;
- caretOffset= -1;
- shiftsCaret= true;
- fCommands.clear();
- }
-
- /**
- * Fills the given verify event with the replace text and the doit
- * flag of this document command. Returns whether the document command
- * covers the same range as the verify event considering the given offset.
- *
- * @param event the event to be changed
- * @param modelRange to be considered for range comparison
- * @return <code>true</code> if this command and the event cover the same range
- */
- public boolean fillEvent(VerifyEvent event, IRegion modelRange) {
- event.text= text;
- event.doit= (offset == modelRange.getOffset() && length == modelRange.getLength() && doit && caretOffset == -1);
- return event.doit;
- }
-
- /**
- * Adds an additional replace command. The added replace command must not overlap
- * with existing ones. If the document command owner is not <code>null</code>, it will not
- * get document change notifications for the particular command.
- *
- * @param offset the offset of the region to replace
- * @param length the length of the region to replace
- * @param text the text to replace with, may be <code>null</code>
- * @param owner the command owner, may be <code>null</code>
- * @throws BadLocationException if the added command intersects with an existing one
- * @since 2.1
- */
- public void addCommand(int offset, int length, String text, IDocumentListener owner) throws BadLocationException {
- final Command command= new Command(offset, length, text, owner);
-
- if (intersects(command))
- throw new BadLocationException();
-
- final int index= Collections.binarySearch(fCommands, command);
-
- // a command with exactly the same ranges exists already
- if (index >= 0)
- throw new BadLocationException();
-
- // binary search result is defined as (-(insertionIndex) - 1)
- final int insertionIndex= -(index + 1);
-
- // overlaps to the right?
- if (insertionIndex != fCommands.size() && intersects((Command) fCommands.get(insertionIndex), command))
- throw new BadLocationException();
-
- // overlaps to the left?
- if (insertionIndex != 0 && intersects((Command) fCommands.get(insertionIndex - 1), command))
- throw new BadLocationException();
-
- fCommands.add(insertionIndex, command);
- }
-
- /**
- * Returns an iterator over the commands in ascending position order.
- * The iterator includes the original document command.
- * Commands cannot be removed.
- *
- * @return returns the command iterator
- */
- public Iterator getCommandIterator() {
- Command command= new Command(offset, length, text, owner);
- return new CommandIterator(fCommands, command, true);
- }
-
- /**
- * Returns the number of commands including the original document command.
- *
- * @return returns the number of commands
- * @since 2.1
- */
- public int getCommandCount() {
- return 1 + fCommands.size();
- }
-
- /**
- * Returns whether the two given commands intersect.
- *
- * @param command0 the first command
- * @param command1 the second command
- * @return <code>true</code> if the commands intersect
- * @since 2.1
- */
- private boolean intersects(Command command0, Command command1) {
- // diff middle points if not intersecting
- if (command0.fOffset + command0.fLength <= command1.fOffset || command1.fOffset + command1.fLength <= command0.fOffset)
-// return (2 * command0.fOffset + command0.fLength) - (2 * command1.fOffset + command1.fLength) == 0;
- return false;
- else
- return true;
- }
-
- /**
- * Returns whether the given command intersects with this command.
- *
- * @param command the command
- * @return <code>true</code> if the command intersects with this command
- * @since 2.1
- */
- private boolean intersects(Command command) {
- // diff middle points if not intersecting
- if (offset + length <= command.fOffset || command.fOffset + command.fLength <= offset)
-// return (2 * offset + length) - (2 * command.fOffset + command.fLength) == 0;
- return false;
- else
- return true;
- }
-
- /**
- * Executes the document commands on a document.
- *
- * @param document the document on which to execute the commands
- * @since 2.1
- */
- public void execute(IDocument document) throws BadLocationException {
-
- if (length == 0 && text == null && fCommands.size() == 0)
- return;
-
- DefaultPositionUpdater updater= new DefaultPositionUpdater(getCategory());
- Position caretPosition= null;
- try {
- if (updateCaret()) {
- document.addPositionCategory(getCategory());
- document.addPositionUpdater(updater);
- caretPosition= new Position(caretOffset);
- document.addPosition(getCategory(), caretPosition);
- }
-
- final Command originalCommand= new Command(offset, length, text, owner);
- for (final Iterator iterator= new CommandIterator(fCommands, originalCommand, false); iterator.hasNext(); )
- ((Command) iterator.next()).execute(document);
-
- } catch (BadLocationException e) {
- // ignore
- } catch (BadPositionCategoryException e) {
- // ignore
- } finally {
- if (updateCaret()) {
- document.removePositionUpdater(updater);
- try {
- document.removePositionCategory(getCategory());
- } catch (BadPositionCategoryException e) {
- Assert.isTrue(false);
- }
- caretOffset= caretPosition.getOffset();
- }
- }
- }
-
- /**
- * Returns <code>true</code> if the caret offset should be updated, <code>false</code> otherwise.
- *
- * @return <code>true</code> if the caret offset should be updated, <code>false</code> otherwise
- * @since 3.0
- */
- private boolean updateCaret() {
- return shiftsCaret && caretOffset != -1;
- }
-
- /**
- * Returns the position category for the caret offset position.
- *
- * @return the position category for the caret offset position
- * @since 3.0
- */
- private String getCategory() {
- return toString();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentToTextAdapter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentToTextAdapter.java
deleted file mode 100644
index f9cc9113b2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredDocumentToTextAdapter.java
+++ /dev/null
@@ -1,1083 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentAdapter;
-import org.eclipse.jface.text.IDocumentAdapterExtension;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.jface.text.projection.ProjectionDocument;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.TextChangeListener;
-import org.eclipse.swt.custom.TextChangedEvent;
-import org.eclipse.swt.custom.TextChangingEvent;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-/**
- * Adapts IStructuredDocument events and methods to StyledTextContent events
- * and methods
- */
-public class StructuredDocumentToTextAdapter implements IDocumentAdapter, IDocumentAdapterExtension {
-
- // A pre-notification listener for the viewer's Document
- class DocumentListener implements IDocumentListener {
- protected boolean allTextChanged = false;
-
- protected DocumentEvent currentEvent;
-
- synchronized public void documentAboutToBeChanged(DocumentEvent event) {
-
- pendingDocumentChangedEvent = true;
- allTextChanged = event.getOffset() <= 0 && event.getLength() >= StructuredDocumentToTextAdapter.this.getDocument().getLength();
- currentEvent = event;
-
- StructuredDocumentToTextAdapter.this.relayTextChanging(event.getOffset(), event.getLength(), event.getText());
- }
-
- synchronized public void documentChanged(DocumentEvent event) {
-
- if (currentEvent != null && event == currentEvent) {
- if (allTextChanged) {
- StructuredDocumentToTextAdapter.this.relayTextSet();
- }
- else {
- // temp work around for immediate thread
- // problem.
- // should have more general solution
- // soon. 'syncExec' are rumored to be
- // prone to hang.
- StructuredDocumentToTextAdapter.this.relayTextChanged();
- }
- }
-
- currentEvent = null;
- pendingDocumentChangedEvent = false;
- handlePendingEvents();
- lastEvent = null;
-
- }
- }
-
- /**
- * Changes to the Document/IStructuredDocument can extend beyond the text
- * change area and require more redrawing to keep the hilighting correct.
- * The event must be saved so that the redraw is only sent after a
- * textChanged event is received.
- */
- class StructuredDocumentListener implements IStructuredDocumentListener {
-
- public void newModel(NewModelEvent structuredDocumentEvent) {
-
- if (StructuredDocumentToTextAdapter.this.stopRelayingChanges) {
- if (Debug.debugStructuredDocument) {
- System.out.println("skipped relaying StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- return;
- }
- // should use textSet when all contents have
- // changed
- // otherwise need to use the pair of
- // textChanging and
- // textChanged.
- StructuredDocumentToTextAdapter.this.lastEvent = structuredDocumentEvent;
- }
-
- public void noChange(final NoChangeEvent structuredDocumentEvent) {
-
- if (Debug.debugStructuredDocument) {
- System.out.println("skipped relaying StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- if (structuredDocumentEvent.reason == NoChangeEvent.READ_ONLY_STATE_CHANGE) {
- if (pendingDocumentChangedEvent) {
- if (lastEventQueue == null) {
- lastEventQueue = new ArrayList();
- }
- lastEventQueue.add(structuredDocumentEvent);
- }
- else {
- StructuredDocumentToTextAdapter.this.lastEvent = structuredDocumentEvent;
- }
- }
- }
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
-
- if (StructuredDocumentToTextAdapter.this.stopRelayingChanges) {
- if (Debug.debugStructuredDocument) {
- System.out.println("not relaying StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- return;
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("saving StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- StructuredDocumentToTextAdapter.this.lastEvent = structuredDocumentEvent;
- }
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
-
- if (StructuredDocumentToTextAdapter.this.stopRelayingChanges) {
- if (Debug.debugStructuredDocument) {
- System.out.println("not relaying StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- return;
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("saving StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- StructuredDocumentToTextAdapter.this.lastEvent = structuredDocumentEvent;
- }
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
-
- if (StructuredDocumentToTextAdapter.this.stopRelayingChanges) {
- if (Debug.debugStructuredDocument) {
- System.out.println("not relaying StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- return;
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("saving StructuredDocumentEvent " + structuredDocumentEvent.getClass().getName()); //$NON-NLS-1$
- }
- StructuredDocumentToTextAdapter.this.lastEvent = structuredDocumentEvent;
- }
- }
-
- private final static boolean redrawBackground = true;
-
- /** The visible child document. */
- private ProjectionDocument fChildDocument;
-
- /** The master document */
- private IDocument fDocument;
-
- private StyledText fStyledTextWidget;
-
- /** The registered text changed listeners */
- private TextChangeListener[] fTextChangeListeners;
- protected DocumentListener internalDocumentListener;
-
- // The listeners for relaying DocumentEvents and
- // requesting repaints
- // after modification
- private IStructuredDocumentListener internalStructuredDocumentListener;
-
- protected StructuredDocumentEvent lastEvent = null;
- private List lastEventQueue;
- private boolean pendingDocumentChangedEvent;
-
- // could be problematic across multiple viewers
- private boolean stopRelayingChanges;
-
- // only use this temp work around if on GTK
- // it causes funny "cursor blinking" if used on windows
- private final boolean forceRedrawOnRegionChanged = Platform.getWS().equals("gtk"); //$NON-NLS-1$
-
- /**
- * TEST ONLY - TEST ONLY - TEST ONLY NOT API use this constructor only for
- * tests. Creates a new document adapter which is initiallly not connected
- * to any document.
- */
- public StructuredDocumentToTextAdapter() {
-
- internalStructuredDocumentListener = new StructuredDocumentListener();
- internalDocumentListener = new DocumentListener();
- // for testing only
- // setDocument(getModelManager().createStructuredDocumentFor(ContentTypeIdentifierForXML.ContentTypeID_XML));
- }
-
- /**
- * Creates a new document adapter which is initiallly not connected to any
- * document.
- */
- public StructuredDocumentToTextAdapter(StyledText styledTextWidget) {
-
- // do not use 'this()' in this case
- super();
- internalStructuredDocumentListener = new StructuredDocumentListener();
- internalDocumentListener = new DocumentListener();
- fStyledTextWidget = styledTextWidget;
- }
-
- /**
- * @see org.eclipse.swt.custom.StyledTextContent#getLine(int)
- */
- private String _getLine(int line) {
-
- if (getDocument() == null)
- return new String();
- try {
- IRegion r = getDocument().getLineInformation(line);
- if (r.getLength() > 0) {
- return getDocument().get(r.getOffset(), r.getLength());
- }
- else
- return new String();
- }
- catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.custom.StyledTextContent#addTextChangeListener(org.eclipse.swt.custom.TextChangeListener)
- */
- public synchronized void addTextChangeListener(TextChangeListener listener) {
-
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging,
- // if needed)
-
- if (Utilities.contains(fTextChangeListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("StructuredDocumentToTextAdapter::addTextChangedListeners. listener " + listener + " was added more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("StructuredDocumentToTextAdapter::addTextChangedListeners. Adding an instance of " + listener.getClass() + " as a listener on text adapter."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fTextChangeListeners != null) {
- // normally won't be null, but we need to be
- // sure, for first time through
- oldSize = fTextChangeListeners.length;
- }
- int newSize = oldSize + 1;
- TextChangeListener[] newListeners = new TextChangeListener[newSize];
- if (fTextChangeListeners != null) {
- System.arraycopy(fTextChangeListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fTextChangeListeners = newListeners;
- //
- }
- }
-
- /*
- * @see org.eclipse.swt.custom.StyledTextContent#getCharCount()
- */
- public int getCharCount() {
-
- // getDocument can sometimes be null during startup
- // and dispose
- if (getDocument() == null)
- return 0;
- return getDocument().getLength();
- }
-
- Display getDisplay() {
-
- // Note: the workbench should always have a display
- // (unless running headless), whereas Display.getCurrent()
- // only returns the display if the currently executing thread
- // has one.
- if (PlatformUI.isWorkbenchRunning())
- return PlatformUI.getWorkbench().getDisplay();
- else
- return null;
- }
-
- /**
- * Returns the visible document.
- *
- * @return IDocument
- */
- protected IDocument getDocument() {
-
- if (fChildDocument == null)
- return fDocument;
- return fChildDocument;
- }
-
- /**
- * Returns the parent document
- * @return the parent document
- */
- private IDocument getParentDocument() {
- return fDocument;
- }
-
- /**
- * Returns offset visible region of current document
- * @return 0 if no child document exists, offset of child document if possible, -1 otherwise
- */
- public int getDocumentModelAdjustment() {
-
- if (fChildDocument == null)
- return 0;
- IRegion coverage= fChildDocument.getProjectionMapping().getCoverage();
- if (coverage != null) {
- return coverage.getOffset();
- }
-
- return -1;
- }
-
- /**
- * Return the line at the given character offset without delimiters.
- * <p>
- *
- * @param offset
- * offset of the line to return. Does not include delimiters of
- * preceeding lines. Offset 0 is the first character of the
- * document.
- * @return the line text without delimiters
- */
- public java.lang.String getLine(int lineNumber) {
-
- if (lineNumber >= getLineCount()) {
- if (Debug.displayWarnings) {
- System.out.println("Development Debug: IStructuredDocument:getLine() error. lineNumber requested (" + lineNumber + ") was greater than number of lines(" + getLineCount() + "). EmptyString returned"); //$NON-NLS-1$//$NON-NLS-3$//$NON-NLS-2$
- }
- return ""; //$NON-NLS-1$
- }
- return _getLine(lineNumber);
- }
-
- /**
- * Return the line index at the given character offset.
- * <p>
- *
- * @param offset
- * offset of the line to return. The first character of the
- * document is at offset 0. An offset of getLength() is valid
- * and should answer the number of lines.
- * @return the line index. The first line is at index 0. If the character
- * at offset is a delimiter character, answer the line index of
- * the line that is delimited. For example, text = "\r\n\r\n",
- * delimiter = "\r\n", then: getLineAtOffset(0) == 0
- * getLineAtOffset(1) == 0 getLineAtOffset(2) == 1
- * getLineAtOffset(3) == 1 getLineAtOffset(4) == 2
- */
- public int getLineAtOffset(int offset) {
-
- if (getDocument() == null)
- return 0;
- int result = 0;
- try {
- if (fChildDocument != null) {
- result = fChildDocument.getLineOfOffset(offset);
- }
- else {
- result = getDocument().getLineOfOffset(offset);
- }
- }
- catch (BadLocationException e) {
- // should not occur, but seems too for child
- // document from
- // QEV, related to repainting overview ruler
- result = 0;
- }
- return result;
- }
-
- public int getLineCount() {
-
- if (getDocument() == null)
- return 0;
- return getDocument().getNumberOfLines();
- }
-
- /*
- * @see org.eclipse.swt.custom.StyledTextContent#getLineDelimiter
- */
- public String getLineDelimiter() {
- if (getParentDocument() instanceof IStructuredDocument) {
- return ((IStructuredDocument)getParentDocument()).getLineDelimiter();
- } else {
- return TextUtilities.getDefaultLineDelimiter(getDocument());
- }
- }
-
- /**
- * Return the character offset of the first character of the given line.
- * <p>
- *
- * @param lineIndex
- * index of the line. The first line is at index 0.
- * @return offset offset of the first character of the line. The first
- * character of the document is at offset 0. The return value
- * should include line delimiters. For example, text =
- * "\r\ntest\r\n", delimiter = "\r\n", then: getOffsetAtLine(0) ==
- * 0 getOffsetAtLine(1) == 2 getOffsetAtLine(2) == 8 NOTE: When
- * there is no text (i.e., no lines), getOffsetAtLine(0) is a
- * valid call that should return 0.
- */
- public int getOffsetAtLine(int lineIndex) {
-
- if (getDocument() == null)
- return 0;
- try {
- return getDocument().getLineOffset(lineIndex);
- }
- catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /**
- * @return org.eclipse.swt.custom.StyledText
- */
- public org.eclipse.swt.custom.StyledText getStyledTextWidget() {
-
- return fStyledTextWidget;
- }
-
- /**
- * Returns a string representing the content at the given range.
- * <p>
- *
- * @param start
- * the start offset of the text to return. Offset 0 is the
- * first character of the document.
- * @param length
- * the length of the text to return
- * @return the text at the given range
- */
- public String getTextRange(int start, int length) {
- try {
- return getParentDocument().get(getDocumentModelAdjustment() + start, length);
- }
- catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /**
- * assume only for "no change" events, for now
- */
- protected void handlePendingEvents() {
-
- if (lastEventQueue == null)
- return;
-
- Iterator iterator = lastEventQueue.iterator();
- while (iterator.hasNext()) {
- NoChangeEvent noChangeEvent = (NoChangeEvent) iterator.next();
- redrawNoChange(noChangeEvent);
- }
-
- lastEventQueue = null;
- lastEvent = null;
- }
-
- /**
- * this method is assumed to be called only for read only region changes.
- */
- protected void redrawNoChange(NoChangeEvent structuredDocumentEvent) {
-
- if (stopRelayingChanges)
- return;
- if (Debug.debugStructuredDocument) {
- System.out.println("maybe redraw stuff"); //$NON-NLS-1$
- }
-
- int startOffset = structuredDocumentEvent.getOriginalStart();
- int length = structuredDocumentEvent.getLength();
- redrawRangeWithLength(startOffset, length);
-
- }
-
- /**
- * Request a redraw of the text range occupied by the given
- * StructuredDocumentRegionsReplacedEvent
- *
- * @param structuredDocumentEvent
- */
- protected void redrawNodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
-
- if (stopRelayingChanges)
- return;
- if (Debug.debugStructuredDocument) {
- System.out.println("maybe redraw stuff"); //$NON-NLS-1$
- }
- // just the new stuff
- IStructuredDocumentRegionList newStructuredDocumentRegions = structuredDocumentEvent.getNewStructuredDocumentRegions();
-
- int nNewNodes = newStructuredDocumentRegions.getLength();
- if (nNewNodes > 0) {
- IStructuredDocumentRegion firstNode = newStructuredDocumentRegions.item(0);
- IStructuredDocumentRegion lastNode = newStructuredDocumentRegions.item(nNewNodes - 1);
- redrawRange(firstNode.getStartOffset(), lastNode.getEndOffset());
- }
- }
-
- /**
- * Redraws the give offsets in terms of the StructuredDocument. If only
- * part of the model is visible, ensures that only the visible portion of
- * the given range is redrawn.
- *
- * @param startModelOffset
- * @param endModelOffset
- */
- synchronized private void redrawRange(final int startModelOffset, final int endModelOffset) {
-
- if (getDocument() == null)
- return;
- if (Debug.debugStructuredDocument) {
- System.out.println("redraw stuff: " + startModelOffset + "-" + endModelOffset); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (fChildDocument == null) {
- Runnable runnable = new Runnable() {
- public void run() {
- getStyledTextWidget().redrawRange(startModelOffset, endModelOffset - startModelOffset, redrawBackground);
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
-
- }
- else {
- int high = getDocument().getLength();
- int adjustment = getDocumentModelAdjustment();
- int startOffset = startModelOffset - adjustment;
- int endOffset = endModelOffset - adjustment;
- // not visible
- if (endOffset < 0 || startOffset > high)
- return;
- // restrict lower bound
- if (startOffset < 0) {
- startOffset = 0;
- }
- // restrict upper bound
- if (endOffset > high) {
- endOffset = high;
- }
- int length = endOffset - startOffset;
- // redrawBackground with false would be faster
- // but assumes background (or font) is not
- // changing
- final int finalStartOffset = startOffset;
- final int finallength = length;
-
- if (fChildDocument == null) {
- Runnable runnable = new Runnable() {
- public void run() {
- getStyledTextWidget().redrawRange(finalStartOffset, finallength, redrawBackground);
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
- }
-
- }
- }
-
- /**
- * Redraws the give offsets in terms of the Flat Node model. If only part
- * of the model is visible, ensures that only the visible portion of the
- * given range is redrawn.
- *
- * @param startModelOffset
- * @param endModelOffset
- */
- synchronized private void redrawRangeWithLength(final int startModelOffset, final int length) {
-
- if (getDocument() == null)
- return;
- if (Debug.debugStructuredDocument) {
- System.out.println("redraw stuff: " + startModelOffset + "-" + length); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (fChildDocument == null) {
- Runnable runnable = new Runnable() {
- public void run() {
- getStyledTextWidget().redrawRange(startModelOffset, length, redrawBackground);
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
- }
- else {
- int high = getDocument().getLength();
- int adjustment = getDocumentModelAdjustment();
- int startOffset = startModelOffset - adjustment;
- int endOffset = startOffset + length - 1;
- // not visible
- if (endOffset < 0 || startOffset > high)
- return;
- // restrict lower bound
- if (startOffset < 0) {
- startOffset = 0;
- }
- // restrict upper bound
- if (endOffset > high) {
- endOffset = high;
- }
-
- // note: length of the child documnet should be
- // updated,
- // need to investigate why its not at this
- // point, but is
- // probably just because the document event
- // handling is not
- // completely finished.
- int newLength = endOffset - startOffset; // d283007
-
- // redrawBackground with false would be faster
- // but assumes background (or font) is not
- // changing
- final int finalStartOffset = startOffset;
- final int finalNewLength = newLength;
- Runnable runnable = new Runnable() {
- public void run() {
- getStyledTextWidget().redrawRange(finalStartOffset, finalNewLength, redrawBackground);
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
- }
- }
-
- /**
- * Request a redraw of the text range occupied by the given
- * RegionChangedEvent for certain (not all) ITextRegion contexts
- *
- * @param structuredDocumentEvent
- */
- protected void redrawRegionChanged(RegionChangedEvent structuredDocumentEvent) {
-
- if (stopRelayingChanges) {
- return;
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("maybe redraw stuff"); //$NON-NLS-1$
- }
- // no redraw needed if mere region change
- // unless its one of our embedded regions,
- // in which case we redraw the whole thing
- ITextRegion region = structuredDocumentEvent.getRegion();
- //String type = region.getType();
-
- // (nsd) TODO: try to make this reliable somehow
- // without being directly content dependent
- // if ((region instanceof ITextRegionContainer) ||
- // (type == XMLJSPRegionContexts.BLOCK_TEXT) ||
- // (type == XMLJSPRegionContexts.JSP_CONTENT)) {
- // IStructuredDocumentRegion flatNode =
- // structuredDocumentEvent.getStructuredDocumentRegion();
- // // redraw background of false is faster,
- // // but assumes background (or font) is not
- // changing
- // redrawRange(flatNode.getStartOffset(region),
- // flatNode.getEndOffset(region));
- // }
- if (forceRedrawOnRegionChanged) {
- // workaround for redrawing problems on Linux-GTK
- int startOffset = structuredDocumentEvent.getOffset();
- int endOffset = structuredDocumentEvent.getOffset() + structuredDocumentEvent.getLength();
- try {
- IRegion startLine = structuredDocumentEvent.fDocument.getLineInformationOfOffset(startOffset);
- IRegion endLine = structuredDocumentEvent.fDocument.getLineInformationOfOffset(endOffset);
- if (startLine != null && endLine != null) {
- redrawRange(startLine.getOffset(), endLine.getOffset() + endLine.getLength());
- }
- }
- catch (BadLocationException e) {
- // nothing for now
- }
- }
- }
-
- /**
- * Request a redraw of the text range occupied by the given
- * RegionsReplacedEvent
- *
- * @param structuredDocumentEvent
- */
- protected void redrawRegionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
-
- if (stopRelayingChanges)
- return;
- if (Debug.debugStructuredDocument) {
- System.out.println("maybe redraw stuff"); //$NON-NLS-1$
- }
- ITextRegionList newRegions = structuredDocumentEvent.getNewRegions();
- int nRegions = newRegions.size();
- if (nRegions > 0) {
- ITextRegion firstRegion = newRegions.get(0);
- ITextRegion lastRegion = newRegions.get(nRegions - 1);
- IStructuredDocumentRegion flatNode = structuredDocumentEvent.getStructuredDocumentRegion();
- redrawRange(flatNode.getStartOffset(firstRegion), flatNode.getEndOffset(lastRegion));
- }
- }
-
- protected void redrawTextChanged() {
-
- if (lastEvent != null) {
- // update display, since some cases can effect
- // highlighting beyond the changed text area.
- if (lastEvent instanceof StructuredDocumentRegionsReplacedEvent)
- redrawNodesReplaced((StructuredDocumentRegionsReplacedEvent) lastEvent);
- if (lastEvent instanceof RegionsReplacedEvent)
- redrawRegionsReplaced((RegionsReplacedEvent) lastEvent);
- if (lastEvent instanceof RegionChangedEvent)
- redrawRegionChanged((RegionChangedEvent) lastEvent);
- // moved following line to 'document changed' so
- // the "last event" can be
- // re-drawn after pending re-draws
- //lastEvent = null;
- }
- }
-
- /**
- * Sends a text replace event to all registered listeners.
- */
- synchronized protected void relayTextChanged() {
-
- if (stopRelayingChanges) {
- if (Debug.debugStructuredDocument && getDocument() != null) {
- System.out.println("NOT relaying text changed (" + getDocument().getLength() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return;
- }
- if (Debug.debugStructuredDocument && getDocument() != null) {
- System.out.println("relaying text changed (" + getDocument().getLength() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- final TextChangedEvent textChangedEvent = new TextChangedEvent(this);
-
- // we must assign listeners to local variable, since
- // the add and remove listener
- // methods can change the actual instance of the
- // listener array from another thread
-
- Runnable runnable = new Runnable() {
- public void run() {
- if (fTextChangeListeners != null) {
- Object[] holdListeners = fTextChangeListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- // this is a safe cast, since addListeners
- // requires a IStructuredDocumentListener
- ((TextChangeListener) holdListeners[i]).textChanged(textChangedEvent);
- }
- }
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
- redrawTextChanged();
- }
-
- /**
- * Sends a text change to all registered listeners
- */
- synchronized protected void relayTextChanging(int requestedStart, int requestedLength, String requestedChange) {
-
- if (getDocument() == null)
- return;
- if (stopRelayingChanges) {
- if (Debug.debugStructuredDocument && getDocument() != null) {
- System.out.println("NOT relaying text changing: " + requestedStart + ":" + getDocument().getLength()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return;
- }
- if (Debug.debugStructuredDocument && getDocument() != null) {
- System.out.println("relaying text changing: " + requestedStart + ":" + getDocument().getLength()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- lastEvent = null;
- try {
- final TextChangingEvent textChangingEvent = new TextChangingEvent(this);
-
- textChangingEvent.start = requestedStart;
- textChangingEvent.replaceCharCount = requestedLength;
- textChangingEvent.newCharCount = (requestedChange == null ? 0 : requestedChange.length());
- textChangingEvent.replaceLineCount = getDocument().getNumberOfLines(requestedStart, requestedLength) - 1;
- textChangingEvent.newText = requestedChange;
- textChangingEvent.newLineCount = (requestedChange == null ? 0 : getDocument().computeNumberOfLines(requestedChange));
-
- // we must assign listeners to local variable,
- // since the add and remove listner
- // methods can change the actual instance of the
- // listener array from another thread
- Runnable runnable = new Runnable() {
- public void run() {
- if (fTextChangeListeners != null) {
- TextChangeListener[] holdListeners = fTextChangeListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- // this is a safe cast, since
- // addListeners requires a
- // IStructuredDocumentListener
- holdListeners[i].textChanging(textChangingEvent);
- }
- }
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
- }
- catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /**
- * Sends a text set event to all registered listeners. Widget should
- * redraw itself automatically.
- */
- synchronized protected void relayTextSet() {
-
- if (stopRelayingChanges) {
- if (Debug.debugStructuredDocument && getDocument() != null) {
- System.out.println("NOT relaying text set (" + getDocument().getLength() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return;
- }
- if (Debug.debugStructuredDocument && getDocument() != null) {
- System.out.println("relaying text set (" + getDocument().getLength() + ")"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- lastEvent = null;
- final TextChangedEvent textChangedEvent = new TextChangedEvent(this);
-
- // we must assign listeners to local variable, since
- // the add and remove listner
- // methods can change the actual instance of the
- // listener array from another thread
- Runnable runnable = new Runnable() {
- public void run() {
- if (fTextChangeListeners != null) {
- TextChangeListener[] holdListeners = fTextChangeListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- holdListeners[i].textSet(textChangedEvent);
- }
- }
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.swt.custom.StyledTextContent#removeTextChangeListener(org.eclipse.swt.custom.TextChangeListener)
- */
- public synchronized void removeTextChangeListener(final TextChangeListener listener) {
-
- if ((fTextChangeListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the
- // request
- if (!Utilities.contains(fTextChangeListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("StructuredDocumentToTextAdapter::removeTextChangedListeners. listener " + listener + " was not present. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("StructuredDocumentToTextAdapter::addTextChangedListeners. Removing an instance of " + listener.getClass() + " as a listener on text adapter."); //$NON-NLS-2$//$NON-NLS-1$
- }
- final int oldSize = fTextChangeListeners.length;
- int newSize = oldSize - 1;
- final TextChangeListener[] newListeners = new TextChangeListener[newSize];
-
- Runnable runnable = new Runnable() {
- public void run() {
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fTextChangeListeners[i] != listener) {
- // copy old to new if its not the
- // one we are removing
- newListeners[index++] = fTextChangeListeners[i];
- }
- }
- }
- };
- runOnDisplayThreadIfNeedede(runnable);
- // now that we have a new array, let's
- // switch it for the old one
- fTextChangeListeners = newListeners;
- }
- }
- }
-
- /**
- * Replace the text with "newText" starting at position "start" for a
- * length of "replaceLength".
- * <p>
- * Implementors have to notify TextChanged listeners after the content has
- * been updated. The TextChangedEvent should be set as follows:
- * <ul>
- * <li>event.type = SWT.TextReplaced
- * <li>event.start = start of the replaced text
- * <li>event.numReplacedLines = number of replaced lines
- * <li>event.numNewLines = number of new lines
- * <li>event.replacedLength = length of the replaced text
- * <li>event.newLength = length of the new text
- * </ul>
- * <b>NOTE: </b> numNewLines is the number of inserted lines and
- * numReplacedLines is the number of deleted lines based on the change
- * that occurs visually. For example:
- * <ul>
- * <li>(replacedText, newText) ==> (numReplacedLines, numNewLines)
- * <li>("", "\n") ==> (0, 1)
- * <li>("\n\n", "a") ==> (2, 0)
- * <li>("a", "\n\n") ==> (0, 2)
- * <li>("\n", "") ==> (1, 0)
- * </ul>
- * </p>
- *
- * @param start
- * start offset of text to replace, none of the offsets include
- * delimiters of preceeding lines, offset 0 is the first
- * character of the document
- * @param replaceLength
- * start offset of text to replace
- * @param newText
- * start offset of text to replace
- */
- public void replaceTextRange(int start, int replaceLength, String text) {
-
- if (getParentDocument() instanceof IStructuredDocument) {
- // the structuredDocument initiates the "changing"
- // and "changed" events.
- // they are both fired by the time this method
- // returns.
- ((IStructuredDocument)getParentDocument()).replaceText(this, start + getDocumentModelAdjustment(), replaceLength, text);
- } else {
- try {
- getDocument().replace(start, replaceLength, text);
- } catch (BadLocationException x) {
- throw new SourceEditingRuntimeException(x);
- }
- }
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentAdapterExtension#resumeForwardingDocumentChanges()
- */
- public void resumeForwardingDocumentChanges() {
-
- // from re-reading the textSet API in StyledText, we
- // must call
- // textSet if all the contents changed. If all the
- // contents did
- // not change, we need to call the pair of APIs,
- // textChanging and
- // textChanged. So, if we ever keep careful track of
- // changes
- // during stop forwarding and resume forwarding, we
- // can
- // investigate change make use of the pair of APIs.
- stopRelayingChanges = false;
- relayTextSet();
- }
-
- /**
- * This 'Runnable' should be very brief, and should not "call out" to
- * other code which itself might call syncExec, or deadlock might occur.
- *
- * @param r
- */
- private void runOnDisplayThreadIfNeedede(Runnable r) {
- // if there is no Display at all (that is, running headless),
- // or if we are already running on the display thread, then
- // simply execute the runnable.
- if (getDisplay() == null || (Thread.currentThread() == getDisplay().getThread())) {
- r.run();
- }
- else {
- // otherwise force the runnable to run on the display thread.
- getDisplay().syncExec(r);
- }
- }
-
- /**
- * @param newModel
- */
- public void setDocument(IDocument document) {
-
- if (getDocument() != null) {
- getDocument().removePrenotifiedDocumentListener(internalDocumentListener);
- }
- lastEvent = null;
- if (document instanceof ProjectionDocument) {
- fChildDocument = (ProjectionDocument) document;
- _setDocument(fChildDocument.getMasterDocument());
- }
- else {
- fChildDocument = null;
- _setDocument(document);
- }
- if (getDocument() != null) {
- getDocument().addPrenotifiedDocumentListener(internalDocumentListener);
- }
- }
-
- private void _setDocument(IDocument newDoc) {
- if ((fDocument != null) && (fDocument instanceof IStructuredDocument)) {
- ((IStructuredDocument)fDocument).removeModelChangedListener(internalStructuredDocumentListener);
- }
- fDocument = newDoc;
- if ((fDocument != null) && (fDocument instanceof IStructuredDocument)) {
- ((IStructuredDocument)fDocument).addModelChangedListener(internalStructuredDocumentListener);
- }
- }
-
- /**
- * TODO remove in C5
- * @deprecated should call setDocument instead (removing in C5)
- */
- public void setModel(IStructuredDocument newModel) {
- }
-
- /**
- * @see IDocument#setText
- */
- public void setText(String string) {
-
- if (fChildDocument == null) {
- if (getParentDocument() instanceof IStructuredDocument) {
- ((IStructuredDocument)getParentDocument()).setText(this, string);
- } else {
- getParentDocument().set(string);
- }
- } else
- fChildDocument.set(string);
- relayTextSet();
- }
-
- /**
- * This method was added to make testing easier. Normally, the widget is
- * specified on the constructor.
- */
- public void setWidget(StyledText widget) {
-
- fStyledTextWidget = widget;
- }
-
- /**
- * @see org.eclipse.jface.text.IDocumentAdapterExtension#stopForwardingDocumentChanges()
- */
- public void stopForwardingDocumentChanges() {
-
- stopRelayingChanges = true;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredLineChangeHover.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredLineChangeHover.java
deleted file mode 100644
index cdeb41a0e8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredLineChangeHover.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.source.LineChangeHover;
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * Escapes diff hover presentation text (converts < to &lt; > to &gt; etc...)
- * so that html in the diff file (displayed in hover) isn't presented as style (bold, italic, colors, etc...)
- * @author pavery
- */
-public class StructuredLineChangeHover extends LineChangeHover {
- // /*
- // * @see org.eclipse.jface.text.source.LineChangeHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int)
- // */
- // public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- // return StringUtils.convertToHTMLContent(super.getHoverInfo(sourceViewer, lineNumber));
- // }
- // /*
- // * @see org.eclipse.jface.text.source.LineChangeHover#getHoverInfo(org.eclipse.jface.text.source.ISourceViewer, int, int, int)
- // */
- // public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber, int first, int number) {
- // return StringUtils.convertToHTMLContent(super.getHoverInfo(sourceViewer, lineNumber, first, number));
- // }
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.source.IAnnotationHoverExtension#getInformationControlCreator()
- */
- public IInformationControlCreator getInformationControlCreator() {
- // use the default information control creator that just displays text as text, not html content
- // because there is no special html that should be presented when just showing diff
- // in the future, sourceviewer should be used instead of this plain text control like java uses
- // SourceViewerInformationControl
- return new IInformationControlCreator() {
- public IInformationControl createInformationControl(Shell parent) {
- return new DefaultInformationControl(parent);
- }
- };
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredMarkerAnnotation.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredMarkerAnnotation.java
deleted file mode 100644
index 6522d4335d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredMarkerAnnotation.java
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.debug.ui.DebugUITools;
-import org.eclipse.debug.ui.IDebugModelPresentation;
-import org.eclipse.search.ui.SearchUI;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-
-
-/**
- * This is overridden to get around the problem of being registered as a
- * org.eclipse.wst.validation.problemmarker rather than a
- * org.eclipse.core.resource.problemmarker
- * causing all problems to be skipped in the OverviewRuler
- */
-public class StructuredMarkerAnnotation extends MarkerAnnotation {
-
- private static final int NO_IMAGE = 0;
- // private static final int ORIGINAL_MARKER_IMAGE= 1;
- // private static final int QUICKFIX_IMAGE= 2;
- // private static final int QUICKFIX_ERROR_IMAGE= 3;
- // private static final int OVERLAY_IMAGE= 4;
- // private static final int GRAY_IMAGE= 5;
- private static final int BREAKPOINT_IMAGE = 6;
-
- private String fType = null;
- private int fImageType;
- private IDebugModelPresentation fPresentation;
-
- /**
- * Constructor
- * @param marker
- */
- StructuredMarkerAnnotation(IMarker marker) {
- super(marker);
- // sets fType, for use w/ StructuredAnnotationAccess
- initAnnotationType();
- }
-
- /**
- * Initializes the annotation's icon representation and its drawing layer
- * based upon the properties of the underlying marker.
- */
- protected void initAnnotationType() {
- // fQuickFixIconEnabled= PreferenceConstants.getPreferenceStore().getBoolean(PreferenceConstants.EDITOR_CORRECTION_INDICATION);
- fImageType = NO_IMAGE;
- IMarker marker = getMarker();
- if (MarkerUtilities.isMarkerType(marker, IBreakpoint.BREAKPOINT_MARKER)) {
-
- if (fPresentation == null)
- fPresentation = DebugUITools.newDebugModelPresentation();
-
- setImage(null); // see bug 32469
- setLayer(4);
- fImageType = BREAKPOINT_IMAGE;
-
- fType = TemporaryAnnotation.ANNOT_UNKNOWN;
-
- }
- else {
- fType = TemporaryAnnotation.ANNOT_UNKNOWN;
- try {
- if (marker.isSubtypeOf(IMarker.PROBLEM)) {
- int severity = marker.getAttribute(IMarker.SEVERITY, -1);
- switch (severity) {
- case IMarker.SEVERITY_ERROR :
- fType = TemporaryAnnotation.ANNOT_ERROR;
- break;
- case IMarker.SEVERITY_WARNING :
- fType = TemporaryAnnotation.ANNOT_WARNING;
- break;
- case IMarker.SEVERITY_INFO :
- fType = TemporaryAnnotation.ANNOT_INFO;
- break;
- }
- }
- else if (marker.isSubtypeOf(IMarker.TASK))
- fType = TemporaryAnnotation.ANNOT_TASK;
- else if (marker.isSubtypeOf(SearchUI.SEARCH_MARKER)) {
- fType = TemporaryAnnotation.ANNOT_SEARCH;
- }
- else if (marker.isSubtypeOf(IMarker.BOOKMARK))
- fType = TemporaryAnnotation.ANNOT_BOOKMARK;
-
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.MarkerAnnotation#getImage(org.eclipse.swt.widgets.Display)
- */
- protected Image getImage(Display display) {
- if (fImageType == BREAKPOINT_IMAGE) {
- Image result = super.getImage(display);
- if (result == null) {
- IMarker marker = getMarker();
- if (marker != null && marker.exists()) {
- result = fPresentation.getImage(getMarker());
- setImage(result);
- }
- }
- return result;
- }
- return super.getImage(display);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredResourceMarkerAnnotationModel.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredResourceMarkerAnnotationModel.java
deleted file mode 100644
index a4dd617366..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredResourceMarkerAnnotationModel.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.internal.ui.IInternalDebugUIConstants;
-import org.eclipse.jface.text.Position;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.IBreakpointConstants;
-
-
-/**
- * Source editor resource marker annotation model implementation
- */
-public class StructuredResourceMarkerAnnotationModel extends ResourceMarkerAnnotationModel {
- protected IResource fMarkerResource;
- protected String fSecondaryMarkerAttributeValue;
- public final static String SECONDARY_ID_KEY = IBreakpointConstants.RESOURCE_PATH;
-
- /**
- * Constructor
- * @param resource
- */
- public StructuredResourceMarkerAnnotationModel(IResource resource) {
- super(resource);
- fMarkerResource = resource;
- }
-
- public StructuredResourceMarkerAnnotationModel(IResource resource, String secondaryID) {
- super(resource);
- fMarkerResource = resource;
- fSecondaryMarkerAttributeValue = secondaryID;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#createMarkerAnnotation(org.eclipse.core.resources.IMarker)
- */
- protected MarkerAnnotation createMarkerAnnotation(IMarker marker) {
- return new StructuredMarkerAnnotation(marker);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#getMarkerPosition(org.eclipse.core.resources.IMarker)
- */
- public Position getMarkerPosition(IMarker marker) {
- Position pos = super.getMarkerPosition(marker);
- try {
- // 4/26 (pa) IInternalDebugUIConstants.INSTRUCTION_POINTER changed to IInternalDebugUIConstants.ANN_INSTR_POINTER_CURRENT
- if ((pos == null || pos.getLength() == 0) && marker.getType() == IInternalDebugUIConstants.ANN_INSTR_POINTER_CURRENT) {
- pos = createPositionFromMarker(marker);
- }
- }
- catch (CoreException e) {
- // just return pos from super class
- }
- return pos;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel#isAcceptable(org.eclipse.core.resources.IMarker)
- */
- protected boolean isAcceptable(IMarker marker) {
- try {
- Object attr = marker.getAttribute(IBreakpointConstants.ATTR_HIDDEN);
- if(attr != null && ((Boolean)attr).equals(Boolean.TRUE))
- return false;
- } catch (CoreException e) {
- // ignore
- }
-
- if (fSecondaryMarkerAttributeValue == null)
- return super.isAcceptable(marker);
- return super.isAcceptable(marker) && fSecondaryMarkerAttributeValue.equalsIgnoreCase(marker.getAttribute(SECONDARY_ID_KEY, "")); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredSharedTextColors.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredSharedTextColors.java
deleted file mode 100644
index 8c74e35b7b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredSharedTextColors.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.text.source.ISharedTextColors;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * TODO remove in C5 or earlier
- * @deprecated use the base SharedTextColors or
- * PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry()
- * instead (removing in C5 or earlier)
- */
-public class StructuredSharedTextColors implements ISharedTextColors {
- private Map fDisplayTable;
-
- public StructuredSharedTextColors() {
- super();
- }
-
- public Color getColor(RGB rgb) {
- if (rgb == null)
- return null;
-
- if (fDisplayTable == null)
- fDisplayTable = new HashMap(2);
-
- Display display = PlatformUI.getWorkbench().getDisplay();
-
- Map colorTable = (Map) fDisplayTable.get(display);
- if (colorTable == null) {
- colorTable = new HashMap(10);
- fDisplayTable.put(display, colorTable);
- }
-
- Color color = (Color) colorTable.get(rgb);
- if (color == null) {
- color = new Color(display, rgb);
- colorTable.put(rgb, color);
- }
-
- return color;
- }
-
- public void dispose() {
- if (fDisplayTable != null) {
- Iterator j = fDisplayTable.values().iterator();
- while (j.hasNext()) {
- Iterator i = ((Map) j.next()).values().iterator();
- while (i.hasNext()) {
- ((Color) i.next()).dispose();
- // technically would probably not need to remove,
- // but at least makes inspection/probing easier
- i.remove();
- }
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextAnnotationHover.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextAnnotationHover.java
deleted file mode 100644
index eb0dc851f9..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextAnnotationHover.java
+++ /dev/null
@@ -1,350 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class StructuredTextAnnotationHover implements IAnnotationHover {
-
- protected HTMLPrinter printer = new HTMLPrinter();
-
- /**
- * Provides a set of convenience methods for creating HTML pages.
- * Taken from org.eclipse.jdt.internal.ui.text.HTMLPrinter
- */
- protected class HTMLPrinter {
-
- public HTMLPrinter() {
- }
-
- private String replace(String text, char c, String s) {
-
- int previous = 0;
- int current = text.indexOf(c, previous);
-
- if (current == -1)
- return text;
-
- StringBuffer buffer = new StringBuffer();
- while (current > -1) {
- buffer.append(text.substring(previous, current));
- buffer.append(s);
- previous = current + 1;
- current = text.indexOf(c, previous);
- }
- buffer.append(text.substring(previous));
-
- return buffer.toString();
- }
-
- public String convertToHTMLContent(String content) {
- content = replace(content, '<', "&lt;"); //$NON-NLS-1$
- return replace(content, '>', "&gt;"); //$NON-NLS-1$
- }
-
- public String read(Reader rd) {
-
- StringBuffer buffer = new StringBuffer();
- char[] readBuffer = new char[2048];
-
- try {
- int n = rd.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n = rd.read(readBuffer);
- }
- return buffer.toString();
- }
- catch (IOException x) {
- }
-
- return null;
- }
-
- public void insertPageProlog(StringBuffer buffer, int position) {
- buffer.insert(position, "<html><body text=\"#000000\" bgcolor=\"#FFFF88\"><font size=-1>"); //$NON-NLS-1$
- }
-
- public void addPageProlog(StringBuffer buffer) {
- insertPageProlog(buffer, buffer.length());
- }
-
- public void addPageEpilog(StringBuffer buffer) {
- buffer.append("</font></body></html>"); //$NON-NLS-1$
- }
-
- public void startBulletList(StringBuffer buffer) {
- buffer.append("<ul>"); //$NON-NLS-1$
- }
-
- public void endBulletList(StringBuffer buffer) {
- buffer.append("</ul>"); //$NON-NLS-1$
- }
-
- public void addBullet(StringBuffer buffer, String bullet) {
- if (bullet != null) {
- buffer.append("<li>"); //$NON-NLS-1$
- buffer.append(bullet);
- buffer.append("</li>"); //$NON-NLS-1$
- }
- }
-
- public void addSmallHeader(StringBuffer buffer, String header) {
- if (header != null) {
- buffer.append("<h5>"); //$NON-NLS-1$
- buffer.append(header);
- buffer.append("</h5>"); //$NON-NLS-1$
- }
- }
-
- public void addParagraph(StringBuffer buffer, String paragraph) {
- if (paragraph != null) {
- buffer.append("<p>"); //$NON-NLS-1$
- buffer.append(paragraph);
- }
- }
-
- public void addParagraph(StringBuffer buffer, Reader paragraphReader) {
- if (paragraphReader != null)
- addParagraph(buffer, read(paragraphReader));
- }
- }
-
- /**
- * Returns the distance to the ruler line.
- */
- protected int compareRulerLine(Position position, IDocument document, int line) {
-
- if (position.getOffset() > -1 && position.getLength() > -1) {
- try {
- int markerLine = document.getLineOfOffset(position.getOffset());
- if (line == markerLine)
- return 1;
- if (markerLine <= line && line <= document.getLineOfOffset(position.getOffset() + position.getLength()))
- return 2;
- }
- catch (BadLocationException x) {
- }
- }
-
- return 0;
- }
-
- /*
- * Formats the message of this hover to fit onto the screen.
- */
- private String formatHoverText(String text, ISourceViewer sourceViewer) {
- String lineDelim = new String();
- try {
- lineDelim = sourceViewer.getDocument().getLineDelimiter(0);
- }
- catch (org.eclipse.jface.text.BadLocationException exception) {
- // skip, just use default
- }
- Display display = sourceViewer.getTextWidget().getDisplay();
-
- // replace special characters in text with html entity (like <, >, & to &lt;, &gt;, &&;)
- text = StringUtils.convertToHTMLContent(text);
-
- Reader textReader = new StringReader(text);
- GC gc = new GC(display);
- try {
- StringBuffer buf = new StringBuffer();
-
- StructuredTextLineBreakingReader reader = new StructuredTextLineBreakingReader(textReader, gc, getHoverWidth(display));
- String line = reader.readLine();
- while (line != null) {
- if (buf.length() != 0) {
- buf.append(lineDelim);
- }
- buf.append(line);
- line = reader.readLine();
- }
- return buf.toString();
- }
- catch (IOException exception) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(exception);
- }
- finally {
- gc.dispose();
- }
- }
-
- /*
- * Formats several message as HTML text.
- */
- private String formatMultipleHoverText(List messages) {
-
- StringBuffer buffer = new StringBuffer();
- printer.addPageProlog(buffer);
- printer.addParagraph(buffer, ResourceHandler.getString("Multiple_errors")); //$NON-NLS-1$
-
- printer.startBulletList(buffer);
- Iterator e = messages.iterator();
- while (e.hasNext())
- printer.addBullet(buffer, printer.convertToHTMLContent((String) e.next()));
- printer.endBulletList(buffer);
-
- printer.addPageEpilog(buffer);
- return buffer.toString();
- }
-
- /**
- * @see IVerticalRulerHover#getHoverInfo(ISourceViewer, int)
- */
- public String getHoverInfo(ISourceViewer sourceViewer, int lineNumber) {
- IMarker marker = getMarker(sourceViewer, lineNumber);
- List messages = new ArrayList(marker == null ? 0 : 1);
- if (marker != null) {
- String text = marker.getAttribute(IMarker.MESSAGE, (String) null);
- if (text != null) {
- messages.add(text);
- }
- }
- List temporaryAnnotations = getTemporaryAnnotationsForLine(sourceViewer, lineNumber);
- for (int i = 0; i < temporaryAnnotations.size(); i++) {
- String message = ((Annotation) temporaryAnnotations.get(i)).getText();
- if (message != null) {
- boolean duplicated = false;
- for (int j = 0; j < messages.size(); j++)
- duplicated = duplicated || messages.get(j).equals(message);
- if (!duplicated)
- messages.add(message);
- // else
- // System.out.println("duplicated message found: " + StringUtils.escape(message));
- }
- else
- messages.add(((ITemporaryAnnotation) temporaryAnnotations.get(i)).toString());
- }
- if (messages.size() > 1)
- return formatMultipleHoverText(messages);
- else if (messages.size() > 0)
- return formatHoverText(messages.get(0).toString(), sourceViewer);
- else
- return null;
- }
-
- private int getHoverWidth(Display display) {
- Rectangle displayBounds = display.getBounds();
- int hoverWidth = displayBounds.width - (display.getCursorLocation().x - displayBounds.x);
- hoverWidth -= 12; // XXX: Add some space to the border, Revisit
- if (hoverWidth < 200) {
- hoverWidth = 200;
- }
- return hoverWidth;
- }
-
- /**
- * Returns one marker which includes the ruler's line of activity.
- */
- protected IMarker getMarker(ISourceViewer viewer, int line) {
-
- IDocument document = viewer.getDocument();
- IAnnotationModel model = viewer.getAnnotationModel();
-
- if (model == null)
- return null;
-
- List exact = new ArrayList();
- List including = new ArrayList();
-
- Iterator e = model.getAnnotationIterator();
- while (e.hasNext()) {
- Object o = e.next();
- if (o instanceof MarkerAnnotation) {
- MarkerAnnotation a = (MarkerAnnotation) o;
- switch (compareRulerLine(model.getPosition(a), document, line)) {
- case 1 :
- exact.add(a.getMarker());
- break;
- case 2 :
- including.add(a.getMarker());
- break;
- }
- }
- }
-
- return select(exact, including);
- }
-
- /**
- * Returns one marker which includes the ruler's line of activity.
- */
- protected List getTemporaryAnnotationsForLine(ISourceViewer viewer, int line) {
-
- IDocument document = viewer.getDocument();
- IAnnotationModel model = viewer.getAnnotationModel();
-
- if (model == null)
- return null;
-
- List exact = new ArrayList();
- List including = new ArrayList();
-
- Iterator e = model.getAnnotationIterator();
- while (e.hasNext()) {
- Object o = e.next();
- if (o instanceof ITemporaryAnnotation) {
- ITemporaryAnnotation a = (ITemporaryAnnotation) o;
- Position position = model.getPosition((Annotation) a);
- if (position == null)
- continue;
-
- switch (compareRulerLine(position, document, line)) {
- case 1 :
- exact.add(a);
- break;
- case 2 :
- including.add(a);
- break;
- }
- }
- }
-
- return exact;
- }
-
- /**
- * Selects one marker from the two lists.
- */
- protected IMarker select(List firstChoice, List secondChoice) {
- if (!firstChoice.isEmpty())
- return (IMarker) firstChoice.get(0);
- if (!secondChoice.isEmpty())
- return (IMarker) secondChoice.get(0);
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextColors.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextColors.java
deleted file mode 100644
index 3b1d723fee..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextColors.java
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.ui.util.EditorUtility;
-
-
-/**
- * TODO remove in C5
- * @deprecated Text attributes can be created on the fly and the base
- * ColorRegistry can be used to access cached colors.
- */
-public class StructuredTextColors {
- private static ArrayList instances = null;
-
- public TextAttribute RTF_HTML_COMMENT_BORDER = null;
- public TextAttribute RTF_HTML_COMMENT_TEXT = null;
- public TextAttribute RTF_JSP_JAVA_DIRECTIVE = null;
- public TextAttribute RTF_TAG_BORDER = null;
- public TextAttribute RTF_TAG_NAME = null;
- public TextAttribute RTF_TAG_ATTRIBUTE_NAME = null;
- public TextAttribute RTF_TAG_ATTRIBUTE_VALUE = null;
- public TextAttribute RTF_TAG_ATTRIBUTE_EQUALS = null;
- public TextAttribute RTF_HTML_SCRIPTING_CONTENT = null;
- public TextAttribute RTF_JSP_SCRIPTING_CONTENT = null;
- public TextAttribute SCRIPT_AREA_BORDER = null;
- public TextAttribute CDATA_MARKER_BORDER = null;
- public TextAttribute CDATA_TEXT = null;
- public TextAttribute RTF_JSP_GENERIC_BORDER = null;
- public TextAttribute DOCTYPE_BORDER = null;
- public TextAttribute DOCTYPE_NAME = null;
- public TextAttribute DOCTYPE_EXTERNAL_ID = null;
- public TextAttribute DOCTYPE_EXTERNAL_ID_PUBREF = null;
- public TextAttribute DOCTYPE_EXTERNAL_ID_SYSREF = null;
- public TextAttribute PI_CONTENT = null;
- public TextAttribute PI_BORDER = null;
- public TextAttribute DECL_BORDER = null;
- public TextAttribute XML_CONTENT = null;
-
- /**
- */
- public StructuredTextColors() {
- super();
- init();
-
- }
-
- /**
- * @deprecated use EditorUtility.getColor instead. Note that method is only temporary
- * till the base has better support for the base themes
- */
- public Color getColor(RGB rgb) {
- return EditorUtility.getColor(rgb);
- }
-
- /**
- * @deprecated - since no longer a singleton, will
- * eventually do away with this method. And, instead of
- * this class, can use SharedStructuredTextColors instead, for
- * pure Color caching. This class can still be used for text attributes.
- */
- public synchronized static StructuredTextColors getInstance() {
- // returning a new instance every time
- // StructuredTextColors colors = new StructuredTextColors();
- // // save for disposal later, just in case client doesn't do it
- // if(instances == null)
- // instances = new ArrayList(6);
- // instances.add(colors);
- return new StructuredTextColors();
- }
-
- /**
- * This method added specifically for "shutdown" code, where the
- * class needs to dispoose of its colors, but if its never been
- * initialized (that is, never used) then we don't want to create it
- * just for the sake of disposing it.
- */
- public static List getInstancesIfExists() {
- return instances;
- }
-
- protected void init() {
- // use null for background to maintain current system backgound.
- Color defaultForeground = null;
- Color defaultBackground = null;
-
- // DEEMPHASIZE = new TextAttribute(getColor(DARK_GREY), defaultBackground, SWT.NORMAL);
-
- RTF_HTML_COMMENT_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- RTF_HTML_COMMENT_TEXT = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- RTF_JSP_JAVA_DIRECTIVE = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- RTF_TAG_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- RTF_TAG_NAME = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- RTF_TAG_ATTRIBUTE_NAME = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- RTF_TAG_ATTRIBUTE_VALUE = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- RTF_TAG_ATTRIBUTE_EQUALS = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- RTF_HTML_SCRIPTING_CONTENT = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- RTF_JSP_SCRIPTING_CONTENT = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- SCRIPT_AREA_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- CDATA_MARKER_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- CDATA_TEXT = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- RTF_JSP_GENERIC_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- DOCTYPE_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- DOCTYPE_NAME = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- DOCTYPE_EXTERNAL_ID = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- DOCTYPE_EXTERNAL_ID_PUBREF = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- DOCTYPE_EXTERNAL_ID_SYSREF = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
-
- PI_CONTENT = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- PI_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- DECL_BORDER = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- XML_CONTENT = new TextAttribute(defaultForeground, defaultBackground, SWT.NORMAL);
- }
-
- /**
- * @param args java.lang.String[]
- */
- public static void main(String[] args) {
-
- // simple check on "system colors"
- Display display = PlatformUI.getWorkbench().getDisplay();
- if (display == null) {
- throw new IllegalStateException("must be ran in workbench"); //$NON-NLS-1$
- }
- System.out.println("COLOR_WHITE: " + display.getSystemColor(SWT.COLOR_WHITE)); //$NON-NLS-1$
- System.out.println("COLOR_BLACK: " + display.getSystemColor(SWT.COLOR_BLACK)); //$NON-NLS-1$
- System.out.println("COLOR_RED: " + display.getSystemColor(SWT.COLOR_RED)); //$NON-NLS-1$
- System.out.println("COLOR_DARK_RED: " + display.getSystemColor(SWT.COLOR_DARK_RED)); //$NON-NLS-1$
- System.out.println("COLOR_GREEN: " + display.getSystemColor(SWT.COLOR_GREEN)); //$NON-NLS-1$
- System.out.println("COLOR_DARK_GREEN: " + display.getSystemColor(SWT.COLOR_DARK_GREEN)); //$NON-NLS-1$
- System.out.println("COLOR_YELLOW: " + display.getSystemColor(SWT.COLOR_YELLOW)); //$NON-NLS-1$
- System.out.println("COLOR_DARK_YELLOW: " + display.getSystemColor(SWT.COLOR_DARK_YELLOW)); //$NON-NLS-1$
- System.out.println("COLOR_BLUE: " + display.getSystemColor(SWT.COLOR_BLUE)); //$NON-NLS-1$
- System.out.println("COLOR_DARK_BLUE: " + display.getSystemColor(SWT.COLOR_DARK_BLUE)); //$NON-NLS-1$
- System.out.println("COLOR_MAGENTA: " + display.getSystemColor(SWT.COLOR_MAGENTA)); //$NON-NLS-1$
- System.out.println("COLOR_DARK_MAGENTA: " + display.getSystemColor(SWT.COLOR_DARK_MAGENTA)); //$NON-NLS-1$
- System.out.println("COLOR_CYAN: " + display.getSystemColor(SWT.COLOR_CYAN)); //$NON-NLS-1$
- System.out.println("COLOR_DARK_CYAN: " + display.getSystemColor(SWT.COLOR_DARK_CYAN)); //$NON-NLS-1$
- System.out.println("COLOR_GRAY: " + display.getSystemColor(SWT.COLOR_GRAY)); //$NON-NLS-1$
- System.out.println("COLOR_DARK_GRAY: " + display.getSystemColor(SWT.COLOR_DARK_GRAY)); //$NON-NLS-1$
- /*
- public static final int COLOR_WHITE = 1;
- public static final int COLOR_BLACK = 2;
- public static final int COLOR_RED = 3;
- public static final int COLOR_DARK_RED = 4;
- public static final int COLOR_GREEN = 5;
- public static final int COLOR_DARK_GREEN = 6;
- public static final int COLOR_YELLOW = 7;
- public static final int COLOR_DARK_YELLOW = 8;
- public static final int COLOR_BLUE = 9;
- public static final int COLOR_DARK_BLUE = 10;
- public static final int COLOR_MAGENTA = 11;
- public static final int COLOR_DARK_MAGENTA = 12;
- public static final int COLOR_CYAN = 13;
- public static final int COLOR_DARK_CYAN = 14;
- public static final int COLOR_GRAY = 15;
- public static final int COLOR_DARK_GRAY = 16;
- */
- }
-
- /**
- * This method typically does not need to be called by clients.
- * It is intended to be called during shutdown, to be sure OS handles
- * are released.
- */
- public void dispose() {
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
deleted file mode 100644
index 26f78866fb..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextEditor.java
+++ /dev/null
@@ -1,2637 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.text.MessageFormat;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.ILog;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-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.preference.IPreferenceStore;
-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.ITextHover;
-import org.eclipse.jface.text.ITextOperationTarget;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-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.IAnnotationModelExtension;
-import org.eclipse.jface.text.source.IChangeRulerColumn;
-import org.eclipse.jface.text.source.ICharacterPairMatcher;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.LineChangeHover;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseMoveListener;
-import org.eclipse.swt.events.MouseTrackAdapter;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.editors.text.ILocationProvider;
-import org.eclipse.ui.editors.text.TextEditor;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.ide.IDEActionFactory;
-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.IShowInTargetList;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.ui.texteditor.DefaultRangeIndicator;
-import org.eclipse.ui.texteditor.IAbstractTextEditorHelpContextIds;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.IDocumentProviderExtension;
-import org.eclipse.ui.texteditor.IElementStateListener;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.IWorkbenchActionDefinitionIds;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
-import org.eclipse.ui.texteditor.TextOperationAction;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.tasklist.TaskList;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.IModelLifecycleListener;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IModelStateListenerExtended;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.ModelLifecycleEvent;
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.sse.core.util.Utilities;
-import org.eclipse.wst.sse.ui.extension.ExtendedConfigurationBuilder;
-import org.eclipse.wst.sse.ui.extension.ExtendedEditorActionBuilder;
-import org.eclipse.wst.sse.ui.extension.ExtendedEditorDropTargetAdapter;
-import org.eclipse.wst.sse.ui.extension.IExtendedContributor;
-import org.eclipse.wst.sse.ui.extension.IExtendedMarkupEditor;
-import org.eclipse.wst.sse.ui.extension.IExtendedMarkupEditorExtension;
-import org.eclipse.wst.sse.ui.extension.IPopupMenuContributor;
-import org.eclipse.wst.sse.ui.extensions.ConfigurationPointCalculator;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.NullSourceEditingTextTools;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.SourceEditingTextTools;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckTarget;
-import org.eclipse.wst.sse.ui.internal.debug.BreakpointRulerAction;
-import org.eclipse.wst.sse.ui.internal.debug.EditBreakpointAction;
-import org.eclipse.wst.sse.ui.internal.debug.ManageBreakpointAction;
-import org.eclipse.wst.sse.ui.internal.debug.ToggleBreakpointAction;
-import org.eclipse.wst.sse.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.sse.ui.internal.extension.BreakpointProviderBuilder;
-import org.eclipse.wst.sse.ui.internal.openon.OpenFileHyperlinkTracker;
-import org.eclipse.wst.sse.ui.internal.openon.OpenOnAction;
-import org.eclipse.wst.sse.ui.internal.selection.SelectionHistory;
-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectEnclosingAction;
-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectHistoryAction;
-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectNextAction;
-import org.eclipse.wst.sse.ui.internal.selection.StructureSelectPreviousAction;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.preferences.CommonEditorPreferenceNames;
-import org.eclipse.wst.sse.ui.ui.ActionDefinitionIds;
-import org.eclipse.wst.sse.ui.ui.StructuredTextEditorActionConstants;
-import org.eclipse.wst.sse.ui.ui.text.DocumentRegionEdgeMatcher;
-import org.eclipse.wst.sse.ui.util.Assert;
-import org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration;
-import org.eclipse.wst.sse.ui.views.contentoutline.StructuredContentOutlineConfiguration;
-import org.eclipse.wst.sse.ui.views.contentoutline.StructuredTextEditorContentOutlinePage;
-import org.eclipse.wst.sse.ui.views.properties.ConfigurablePropertySheetPage;
-import org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration;
-import org.eclipse.wst.sse.ui.views.properties.ShowPropertiesAction;
-import org.eclipse.wst.sse.ui.views.properties.StructuredPropertySheetConfiguration;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-
-public class StructuredTextEditor extends TextEditor implements IExtendedMarkupEditor, IExtendedMarkupEditorExtension, IDocumentListener, IShowInTargetList {
-
- class InternalElementStateListener implements IElementStateListener {
-
- public void elementContentAboutToBeReplaced(Object element) {
- // we just forward the event
- handleElementContentAboutToBeReplaced(element);
- }
-
- public void elementContentReplaced(Object element) {
- // we just forward the event
- handleElementContentReplaced(element);
- }
-
- public void elementDeleted(Object element) {
- // we just forward the event
- handleElementDeleted(element);
- }
-
- public void elementDirtyStateChanged(Object element, boolean isDirty) {
- // we just forward the event
- handleElementDirtyStateChanged(element, isDirty);
- }
-
- public void elementMoved(Object originalElement, Object movedElement) {
- // we just forward the event
- handleElementMoved(originalElement, movedElement);
- }
- }
-
- class InternalModelStateListener implements IModelStateListenerExtended {
- public void modelAboutToBeChanged(IStructuredModel model) {
- if (getTextViewer() != null) {
- getTextViewer().setRedraw(false);
- }
- }
-
- public void modelAboutToBeReinitialized(IStructuredModel structuredModel) {
- if (getTextViewer() != null) {
- getTextViewer().setRedraw(false);
- getTextViewer().unconfigure();
- SourceViewerConfiguration config = getSourceViewerConfiguration();
- if (config instanceof StructuredTextViewerConfiguration) {
- ((StructuredTextViewerConfiguration) config).unConfigure(getSourceViewer());
- }
- }
- }
-
- public void modelChanged(IStructuredModel model) {
- if (getTextViewer() != null) {
- getTextViewer().setRedraw(true);
- updateMenuText();
- }
- }
-
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
- // do nothing
- }
-
- public void modelReinitialized(IStructuredModel structuredModel) {
- try {
- if (getSourceViewer() != null) {
- getSourceViewer().configure(getSourceViewerConfiguration());
- }
- }
- catch(Exception e) {
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=1166
- // investigate each error case post beta
- Logger.logException("problem trying to configure after model change", e);
- }
- finally {
- // so we don't freeze workbench (eg. during page language or content type change)
- ((ITextViewerExtension) getSourceViewer()).setRedraw(true);
- }
- }
-
- // Note: this one should probably be used to
- // control viewer
- // instead of viewer having its own listener
- public void modelResourceDeleted(IStructuredModel model) {
- // do nothing
- }
-
- public void modelResourceMoved(IStructuredModel originalmodel, IStructuredModel movedmodel) {
- // do nothing
- }
- }
-
- private class ViewerModelLifecycleListener implements IModelLifecycleListener {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelLifecycleListener#processPostModelEvent(org.eclipse.wst.sse.core.ModelLifecycleEvent)
- */
- public void processPostModelEvent(ModelLifecycleEvent event) {
- // reconnect the textviewer on document instance change
- if (event.getType() == ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED) {
- if (getTextViewer() != null && getTextViewer().getControl() != null && !getTextViewer().getControl().isDisposed() && event.getModel().equals(getModel())) {
- getTextViewer().setModel(event.getModel(), getDocumentProvider().getAnnotationModel(getEditorInput()));
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.IModelLifecycleListener#processPreModelEvent(org.eclipse.wst.sse.core.ModelLifecycleEvent)
- */
- public void processPreModelEvent(ModelLifecycleEvent event) {
- }
- }
-
- class MouseTracker extends MouseTrackAdapter implements MouseMoveListener {
- /** The tracker's subject control. */
- private Control fSubjectControl;
-
- /**
- * Creates a new mouse tracker.
- */
- public MouseTracker() {
- // do nothing
- }
-
- public void mouseHover(MouseEvent event) {
- // System.out.println("hover: "+event.x + "x" + event.y);
- hoverX = event.x;
- hoverY = event.y;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent e) {
- hoverX = e.x;
- hoverY = e.y;
- }
-
- /**
- * Starts this mouse tracker. The given control becomes this tracker's
- * subject control. Installs itself as mouse track listener on the
- * subject control.
- *
- * @param subjectControl
- * the subject control
- */
- public void start(Control subjectControl) {
- fSubjectControl = subjectControl;
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.addMouseMoveListener(this);
- fSubjectControl.addMouseTrackListener(this);
- fSubjectControl.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- stop();
- }
- });
- }
- }
-
- /**
- * Stops this mouse tracker. Removes itself as mouse track, mouse
- * move, and shell listener from the subject control.
- */
- public void stop() {
- if (fSubjectControl != null && !fSubjectControl.isDisposed()) {
- fSubjectControl.removeMouseMoveListener(this);
- fSubjectControl.removeMouseTrackListener(this);
- fSubjectControl = null;
- }
- }
- }
-
- protected final static char[] BRACKETS = {'{', '}', '(', ')', '[', ']'};
- protected static final String DOT = "."; //$NON-NLS-1$
- protected static final String SSE_MODEL_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
-
- /** Non-NLS strings */
- private static final String EDITOR_CONTEXT_MENU_ID = "org.eclipse.wst.sse.ui.StructuredTextEditor.context"; //$NON-NLS-1$
- public static final String GROUP_NAME_ADDITIONS = "additions"; //$NON-NLS-1$
- public static final String GROUP_NAME_FORMAT = "Format"; //$NON-NLS-1$
- public static final String GROUP_NAME_FORMAT_EXT = "Format.ext"; //$NON-NLS-1$
- /**
- * Constant for representing an error status. This is considered a value
- * object.
- */
- static final protected IStatus STATUS_ERROR = new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.INFO, "ERROR", null); //$NON-NLS-1$
- /**
- * Constant for representing an ok status. This is considered a value
- * object.
- */
- static final protected IStatus STATUS_OK = new Status(IStatus.OK, EditorPlugin.ID, IStatus.OK, "OK", null); //$NON-NLS-1$
-
- /**
- * @param args
- * java.lang.String[]
- */
- public static void main(String[] args) {
- StructuredTextEditor editor = null;
- try {
- editor = new StructuredTextEditor();
- System.out.println("Created: " + editor); //$NON-NLS-1$
- }
- catch (Throwable e) {
- e.printStackTrace();
- }
- }
-
- // development time/debug variables only
- private int adapterRequests;
- private long adapterTime;
- private Runnable fCurrentRunnable = null;
- private boolean fDirtyBeforeDocumentEvent = false;
- protected ExtendedEditorDropTargetAdapter fDropAdapter;
- protected DropTarget fDropTarget;
- protected boolean fEditorDisposed = false;
- private IEditorPart fEditorPart;
- private InternalModelStateListener fInternalModelStateListener;
- private ArrayList fLegalInsertModes;
-
- protected MouseTracker fMouseTracker;
- private boolean forceReadOnly = false;
- protected IContentOutlinePage fOutlinePage;
- protected IPropertySheetPage fPropertySheetPage;
- String[] fShowInTargetIds = new String[]{IPageLayout.ID_RES_NAV};
- private IAction fShowPropertiesAction = null;
- private SpellCheckTarget fSpellCheckTarget = null;
- private IStructuredModel fStructuredModel;
- protected int hoverX = -1;
- protected int hoverY = -1;
- private InternalElementStateListener internalElementStateListener = new InternalElementStateListener();
- private IModelLifecycleListener fInternalLifeCycleListener = new ViewerModelLifecycleListener();
- private boolean shouldClose = false;
- private long startPerfTime;
- /** The open file hyperlink tracker */
- private OpenFileHyperlinkTracker fHyperlinkTracker;
-
- public StructuredTextEditor() {
-
- super();
- initializeDocumentProvider(null);
- }
-
- /**
- * Constructor to be used for special case of "forcing" read only ... such
- * as by needed for editors which modify more than one resource, some of
- * which may be editable, but others may be readonly, so none can be
- * editable.
- */
- public StructuredTextEditor(boolean doForceReadOnly) {
- this();
- setForceReadOnly(doForceReadOnly);
- }
-
- /*
- * This method is just to make firePropertyChanged accessbible from some
- * (anonomous) inner classes.
- */
- protected void _firePropertyChange(int property) {
- super.firePropertyChange(property);
- }
-
- protected void addContextMenuActions(IMenuManager menu) {
- // Only offer actions that affect the text if the viewer allows
- // modification and supports any of these operations
- IAction formatAll = getAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT);
- IAction formatSelection = getAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS);
- IAction cleanupAll = getAction(StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT);
- boolean enableFormatMenu = (formatAll != null && formatAll.isEnabled()) || (formatSelection != null && formatSelection.isEnabled()) || (cleanupAll != null && cleanupAll.isEnabled());
-
- if (getSourceViewer().isEditable() && enableFormatMenu) {
- String label = ResourceHandler.getString("FormatMenu.label"); //$NON-NLS-1$ = "Format"
- MenuManager subMenu = new MenuManager(label, GROUP_NAME_FORMAT);
- subMenu.add(new GroupMarker(GROUP_NAME_FORMAT_EXT));
- addAction(subMenu, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT);
- addAction(subMenu, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS);
- subMenu.add(new GroupMarker(GROUP_NAME_ADDITIONS));
- addAction(menu, ITextEditorActionConstants.GROUP_EDIT, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT);
- menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, subMenu);
- }
-
- // Some Design editors (DTD) rely on this view for their own uses
- menu.appendToGroup(IWorkbenchActionConstants.VIEW_EXT, fShowPropertiesAction);
- }
-
- /**
- * @return the IStructuredDocumentRegion that the text selection in the
- * editor resolves to, or <code>null</code> if the range covers
- * more than one region.
- */
- public IStructuredDocumentRegion getSelectedDocumentRegion() {
- Point p = getSelectionRange();
- int start = p.x;
- int end = p.x + p.y;
-
- IStructuredDocumentRegion firstSdRegion = ((IStructuredDocument) getDocument()).getRegionAtCharacterOffset(start);
- IStructuredDocumentRegion secondSdRegion = ((IStructuredDocument) getDocument()).getRegionAtCharacterOffset(end);
- if (firstSdRegion != null && secondSdRegion != null) {
- if (firstSdRegion.equals(secondSdRegion) || firstSdRegion.getEndOffset() == end) {
- // the selection is on the same region or
- // the selection ends right on the end of the first region
- return firstSdRegion;
- }
- }
- return null;
- }
-
- /**
- * @param sdRegion
- * the IStructuredDocumentRegion that you want to check
- * selection on
- * @return the ITextRegion that the text selection in the editor resolves
- * to, or <code>null</code> if the range covers more than one
- * region or none.
- */
- public ITextRegion getSelectedTextRegion(IStructuredDocumentRegion sdRegion) {
- Assert.isNotNull(sdRegion);
-
- Point p = getSelectionRange();
- int start = p.x;
- int end = p.x + p.y;
-
- ITextRegion first = sdRegion.getRegionAtCharacterOffset(start);
- ITextRegion second = sdRegion.getRegionAtCharacterOffset(end);
- if (first != null && second != null) {
- if (first.equals(second) || sdRegion.getEndOffset(first) == end) {
- // the selection is on the same region
- // the selection ends right on the end of the first region
- return first;
- }
- }
- return null;
- }
-
- protected void addExtendedContextMenuActions(IMenuManager menu) {
- IEditorActionBarContributor c = getEditorSite().getActionBarContributor();
- if (c instanceof IPopupMenuContributor) {
- ((IPopupMenuContributor) c).contributeToPopupMenu(menu);
- }
- else {
- ExtendedEditorActionBuilder builder = new ExtendedEditorActionBuilder();
- IExtendedContributor pmc = builder.readActionExtensions(getConfigurationPoints());
- if (pmc != null) {
- pmc.setActiveEditor(this);
- pmc.contributeToPopupMenu(menu);
- }
- }
- }
-
- protected void addExtendedRulerContextMenuActions(IMenuManager menu) {
- // none at this level
- }
-
- public boolean isFindOccurrencesRegionType(String type) {
- String[] accept = getFindOccurrencesRegionTypes();
- for (int i = 0; i < accept.length; i++) {
- if (accept[i].equals(type))
- return true;
- }
- return false;
- }
-
- /**
- * Subclasses should override to allow find occurrences for different
- * region types.
- *
- * @return
- */
- protected String[] getFindOccurrencesRegionTypes() {
- return new String[0];
- }
-
- // private void addFindOccurrencesAction(String matchType, String
- // matchText, IMenuManager menu) {
- //
- // AbstractFindOccurrencesAction action = new
- // AbstractFindOccurrencesAction(getFileInEditor(), new
- // SearchUIConfiguration(), (IStructuredDocument) getDocument(),
- // matchType, matchText, getProgressMonitor());
- // action.setText("Occurrences of \"" + matchText + "\" in File");
- // menu.appendToGroup(ITextEditorActionConstants.GROUP_EDIT, action);
- // }
-
- /**
- * Instead of us closing directly, we have to close with our containing
- * (multipage) editor, if it exists.
- */
- public void close(final boolean save) {
- if (getSite() == null) {
- // if site hasn't been set yet, then we're not
- // completely open
- // so set a flag not to open
- shouldClose = true;
- }
- else {
- if (getEditorPart() != null) {
- Display display = getSite().getShell().getDisplay();
- display.asyncExec(new Runnable() {
-
- public void run() {
-
- getSite().getPage().closeEditor(getEditorPart(), save);
- }
- });
- }
- else {
- super.close(save);
- }
- }
- }
-
- /**
- * Compute and set double-click action for the source editor, depending on
- * the model being used.
- */
- protected void computeAndSetDoubleClickAction(IStructuredModel model) {
- if (model == null)
- return;
- // If we're editing a JSP file, make
- // double-clicking on the ruler set
- // a breakpoint instead of setting a bookmark.
- String ext = BreakpointRulerAction.getFileExtension(getEditorInput());
- if (BreakpointProviderBuilder.getInstance().isAvailable(model.getContentTypeIdentifier(), ext)) {
- setAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK, getAction(ActionDefinitionIds.ADD_BREAKPOINTS));
- }
- else {
- // note: the following set action to bookmarks
- // (normally the
- // default)
- // is normally set in super 'createActions'
- // method,
- // [which is just called once, during init],
- // but we'll put it
- // here in this else clause too. The only time
- // it would really be
- // needed is if
- // the same instance of the editor
- // was used first to edit an JSP model, then
- // used for non-JSP model
- // (e.g. XHTML) ...
- // which should be rare, but it is technically
- // possible when using
- // frames
- // and may be more common in future versions
- setAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK, getAction(IDEActionFactory.BOOKMARK.getId()));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.ExtendedTextEditor#configureSourceViewerDecorationSupport(org.eclipse.ui.texteditor.SourceViewerDecorationSupport)
- */
- protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
- support.setCharacterPairMatcher(createCharacterPairMatcher());
- support.setMatchingCharacterPainterPreferenceKeys(CommonEditorPreferenceNames.MATCHING_BRACKETS, CommonEditorPreferenceNames.MATCHING_BRACKETS_COLOR);
-
- super.configureSourceViewerDecorationSupport(support);
- }
-
- protected void createActions() {
- super.createActions();
- ResourceBundle resourceBundle = ResourceHandler.getResourceBundle();
- // TextView Action - moving the selected text to
- // the clipboard
- // override the cut/paste/delete action to make
- // them run on read-only
- // files
- Action action = new TextOperationAction(resourceBundle, "Editor.Cut.", this, ITextOperationTarget.CUT, true); //$NON-NLS-1$
- action.setActionDefinitionId(IWorkbenchActionDefinitionIds.CUT);
- setAction(ITextEditorActionConstants.CUT, action);
- WorkbenchHelp.setHelp(action, IAbstractTextEditorHelpContextIds.CUT_ACTION);
- // TextView Action - inserting the clipboard
- // content at the current
- // position
- // override the cut/paste/delete action to make
- // them run on read-only
- // files
- action = new TextOperationAction(resourceBundle, "Editor.Paste.", this, ITextOperationTarget.PASTE, true); //$NON-NLS-1$
- action.setActionDefinitionId(IWorkbenchActionDefinitionIds.PASTE);
- setAction(ITextEditorActionConstants.PASTE, action);
- WorkbenchHelp.setHelp(action, IAbstractTextEditorHelpContextIds.PASTE_ACTION);
- // TextView Action - deleting the selected text or
- // if selection is
- // empty the character at the right of the current
- // position
- // override the cut/paste/delete action to make
- // them run on read-only
- // files
- action = new TextOperationAction(resourceBundle, "Editor.Delete.", this, ITextOperationTarget.DELETE, true); //$NON-NLS-1$
- action.setActionDefinitionId(IWorkbenchActionDefinitionIds.DELETE);
- setAction(ITextEditorActionConstants.DELETE, action);
- WorkbenchHelp.setHelp(action, IAbstractTextEditorHelpContextIds.DELETE_ACTION);
- // SourceView Action - requesting information at
- // the current insertion
- // position
- action = new TextOperationAction(ResourceHandler.getResourceBundle(), StructuredTextEditorActionConstants.ACTION_NAME_INFORMATION + DOT, this, ISourceViewer.INFORMATION, true);
- action.setActionDefinitionId(ActionDefinitionIds.INFORMATION);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_INFORMATION, action);
- markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_INFORMATION, true);
- // SourceView Action - requesting content assist to
- // show completetion
- // proposals for the current insert position
- action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS + DOT, this, ISourceViewer.CONTENTASSIST_PROPOSALS, true);
- WorkbenchHelp.setHelp(action, IHelpContextIds.CONTMNU_CONTENTASSIST_HELPID);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, action);
- markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS, true);
- // SourceView Action - requesting content assist to
- // show the content
- // information for the current insert position
- action = new TextOperationAction(ResourceHandler.getResourceBundle(), StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION + DOT, this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION);
- action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION, action);
- markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION, true);
- // StructuredTextViewer Action - requesting
- // correction assist to show
- // correction proposals for the current position
- action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_QUICK_FIX + DOT, this, StructuredTextViewer.QUICK_FIX, true);
- action.setActionDefinitionId(ActionDefinitionIds.QUICK_FIX);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_QUICK_FIX, action);
- markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_QUICK_FIX, true);
- // StructuredTextViewer Action - requesting format
- // of the whole
- // document
- action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT + DOT, this, StructuredTextViewer.FORMAT_DOCUMENT);
- action.setActionDefinitionId(ActionDefinitionIds.FORMAT_DOCUMENT);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, action);
- markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, true);
- markAsSelectionDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT, true);
- // StructuredTextViewer Action - requesting format
- // of the active
- // elements
- action = new TextOperationAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS + DOT, this, StructuredTextViewer.FORMAT_ACTIVE_ELEMENTS);
- action.setActionDefinitionId(ActionDefinitionIds.FORMAT_ACTIVE_ELEMENTS);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, action);
- markAsStateDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, true);
- markAsSelectionDependentAction(StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS, true);
- // StructuredTextEditor Action - add breakpoints
- action = new ToggleBreakpointAction(this, getVerticalRuler());
- setAction(ActionDefinitionIds.ADD_BREAKPOINTS, action);
- // StructuredTextEditor Action - manage breakpoints
- action = new ManageBreakpointAction(this, getVerticalRuler());
- setAction(ActionDefinitionIds.MANAGE_BREAKPOINTS, action);
- // StructuredTextEditor Action - edit breakpoints
- action = new EditBreakpointAction(this, getVerticalRuler());
- setAction(ActionDefinitionIds.EDIT_BREAKPOINTS, action);
- // StructuredTextViewer Action - open file on selection
- action = new OpenOnAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE + DOT, this);
- action.setActionDefinitionId(ActionDefinitionIds.OPEN_FILE);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE, action);
-
- fShowPropertiesAction = new ShowPropertiesAction();
-
- SelectionHistory selectionHistory = new SelectionHistory(this);
- action = new StructureSelectEnclosingAction(this, selectionHistory);
- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_ENCLOSING);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_ENCLOSING, action);
-
- action = new StructureSelectNextAction(this, selectionHistory);
- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_NEXT);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_NEXT, action);
-
- action = new StructureSelectPreviousAction(this, selectionHistory);
- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_PREVIOUS);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_PREVIOUS, action);
-
- action = new StructureSelectHistoryAction(this, selectionHistory);
- action.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_HISTORY);
- setAction(StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_HISTORY, action);
- selectionHistory.setHistoryAction((StructureSelectHistoryAction) action);
- }
-
- /**
- * Creates and returns a <code>LineChangeHover</code> to be used on this
- * editor's change ruler column. This default implementation returns a
- * plain <code>LineChangeHover</code>. Subclasses may override.
- *
- * @return the change hover to be used by this editors quick diff display
- */
- protected LineChangeHover createChangeHover() {
- //return new LineChangeHover();
- return new StructuredLineChangeHover();
- }
-
- protected ICharacterPairMatcher createCharacterPairMatcher() {
- ICharacterPairMatcher matcher = null;
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
- String[] ids = getConfigurationPoints();
- for (int i = 0; matcher == null && i < ids.length; i++) {
- matcher = (ICharacterPairMatcher) builder.getConfiguration(DocumentRegionEdgeMatcher.ID, ids[i]);
- }
- if (matcher == null) {
- matcher = new ICharacterPairMatcher() {
- public void dispose() {
- }
-
- public void clear() {
- }
-
- public IRegion match(IDocument iDocument, int i) {
- return null;
- }
-
- public int getAnchor() {
- return ICharacterPairMatcher.LEFT;
- }
- };
- }
- return matcher;
- }
-
- protected ContentOutlineConfiguration createContentOutlineConfiguration() {
- ContentOutlineConfiguration cfg = null;
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
- String[] ids = getConfigurationPoints();
- for (int i = 0; cfg == null && i < ids.length; i++) {
- cfg = (ContentOutlineConfiguration) builder.getConfiguration(ContentOutlineConfiguration.ID, ids[i]);
- }
- return cfg;
- }
-
- protected void createModelDependentFields() {
- // none at this level
- }
-
- protected PropertySheetConfiguration createPropertySheetConfiguration() {
- PropertySheetConfiguration cfg = null;
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
- String[] ids = getConfigurationPoints();
- for (int i = 0; cfg == null && i < ids.length; i++) {
- cfg = (PropertySheetConfiguration) builder.getConfiguration(PropertySheetConfiguration.ID, ids[i]);
- }
- return cfg;
- }
-
- /**
- * We override the super version of this method for the sole purpose of
- * using one of our own special viewer configuration objects.
- */
- public void createPartControl(Composite parent) {
- StructuredTextViewerConfiguration newViewerConfiguration = createSourceViewerConfiguration();
- SourceViewerConfiguration oldViewerConfiguration = getSourceViewerConfiguration();
- if (oldViewerConfiguration instanceof StructuredTextViewerConfiguration && !((StructuredTextViewerConfiguration) oldViewerConfiguration).getDeclaringID().equals(newViewerConfiguration.getDeclaringID()))
- setSourceViewerConfiguration(newViewerConfiguration);
-
- super.createPartControl(parent);
-
- // reset the input now that the editor is
- // initialized and can handle it
- // properly
- // TODO - urgent, SSE v6: THIS SHOULDN'T BE DONE HERE
- // ANYMORE - but for now, have to to get 'configure' to work right?
- // but causes two pass initialization! Does fixing this require base
- // fix?
- setInput(getEditorInput());
-
- if (isBrowserLikeLinks())
- enableBrowserLikeLinks();
- }
-
- /**
- * Loads the Show In Target IDs from the Extended Configuration extension
- * point.
- *
- * @return
- */
- protected String[] createShowInTargetIds() {
- List allIds = new ArrayList(0);
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
- String[] configurationIds = getConfigurationPoints();
- for (int i = 0; i < configurationIds.length; i++) {
- IConfigurationElement el = builder.getConfigurationElement("showintarget", configurationIds[i]); //$NON-NLS-1$
- if (el != null) {
- String someIds = el.getAttribute("ids"); //$NON-NLS-1$
- if (someIds != null && someIds.length() > 0) {
- String[] ids = StringUtils.unpack(someIds);
- for (int j = 0; j < ids.length; j++) {
- // trim, just to keep things clean
- String id = ids[j].trim();
- if (!allIds.contains(id)) {
- allIds.add(id);
- }
- }
- }
- }
- }
-
- if (!allIds.contains(IPageLayout.ID_RES_NAV)) {
- allIds.add(IPageLayout.ID_RES_NAV);
- }
- return (String[]) allIds.toArray(new String[0]);
- }
-
- /**
- * @return
- */
- protected SourceEditingTextTools createSourceEditingTextTools() {
- SourceEditingTextTools tools = null;
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
- String[] ids = getConfigurationPoints();
- for (int i = 0; tools == null && i < ids.length; i++) {
- tools = (SourceEditingTextTools) builder.getConfiguration(NullSourceEditingTextTools.ID, ids[i]);
- }
- if (tools == null) {
- tools = NullSourceEditingTextTools.getInstance();
- }
- return tools;
- }
-
- /**
- * Creates the source viewer to be used by this editor
- */
- protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
- fAnnotationAccess = createAnnotationAccess();
- fOverviewRuler = createOverviewRuler(getSharedColors());
- StructuredTextViewer sourceViewer = createStructedTextViewer(parent, verticalRuler, styles);
- initSourceViewer(sourceViewer);
- return sourceViewer;
- }
-
- protected StructuredTextViewerConfiguration createSourceViewerConfiguration() {
- StructuredTextViewerConfiguration cfg = null;
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
- String[] ids = getConfigurationPoints();
- for (int i = 0; cfg == null && i < ids.length; i++) {
- cfg = (StructuredTextViewerConfiguration) builder.getConfiguration(StructuredTextViewerConfiguration.ID, ids[i]);
- }
- if (cfg == null) {
- cfg = new StructuredTextViewerConfiguration();
- cfg.setDeclaringID(getClass().getName() + "#default"); //$NON-NLS-1$
- }
- cfg.setEditorPart(this);
- return cfg;
- }
-
- protected SpellCheckTarget createSpellCheckTarget() {
- SpellCheckTarget target = null;
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
- String[] ids = getConfigurationPoints();
- for (int i = 0; target == null && i < ids.length; i++) {
- target = (SpellCheckTarget) builder.getConfiguration(SpellCheckTargetImpl.ID, ids[i]);
- }
- if (target == null) {
- target = new SpellCheckTargetImpl();
- }
- target.setTextEditor(this);
- return target;
- }
-
- protected StructuredTextViewer createStructedTextViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
- return new StructuredTextViewer(parent, verticalRuler, getOverviewRuler(), isOverviewRulerVisible(), styles);
- }
-
- /**
- * @see DekstopPart#dispose
- */
- public void dispose() {
- Logger.trace("Source Editor", "StructuredTextEditor::dispose entry"); //$NON-NLS-1$ //$NON-NLS-2$
- if (org.eclipse.wst.sse.core.util.Debug.perfTestAdapterClassLoading) {
- System.out.println("Total calls to getAdapter: " + adapterRequests); //$NON-NLS-1$
- System.out.println("Total time in getAdapter: " + adapterTime); //$NON-NLS-1$
- System.out.println("Average time per call: " + (adapterTime / adapterRequests)); //$NON-NLS-1$
- }
-
- // just for work around for document memory leak
- // related to last position (stored in plugin!)
- // holding on to 'selection' which holds instance
- // of document
- // caution, this is making use of internal classes
- TextEditorPlugin.getDefault().setLastEditPosition(new EditPosition(getEditorInput(), getEditorSite().getId(), TextSelection.emptySelection(), new Position(getCaretPosition())));
-
- // subclass may not have mouse tracker created
- // need to check for null before stopping
- if (fMouseTracker != null) {
- fMouseTracker.stop();
- fMouseTracker = null;
- }
-
- if (isBrowserLikeLinks())
- disableBrowserLikeLinks();
-
- // added this 2/19/2004 to match the 'add' in
- // intializeDocumentProvider.
- if (getDocumentProvider() != null)
- getDocumentProvider().removeElementStateListener(internalElementStateListener);
-
- // added this 2/20/2004 based on probe results --
- // seems should be handled by setModel(null), but
- // that's a more radical change.
- // and, technically speaking, should not be needed,
- // but makes a memory leak
- // less severe.
- if (fStructuredModel != null) {
- if (fStructuredModel.getStructuredDocument() != null)
- fStructuredModel.getStructuredDocument().removeDocumentListener(this);
- fStructuredModel.removeModelStateListener(getInternalModelStateListener());
- }
-
- getDocument().removeDocumentListener(this);
- // check if we've been canceled ... that is,
- // changes to model
- // have not been saved. If so, and if someone else
- // is sharing
- // us in read mode, then we need to force a reload
- // of model.
- IStructuredModel model = getModel();
- boolean needReload = isDirty() && (model.getReferenceCountForEdit() == 0) && (model.getReferenceCountForRead() > 0);
- IEditorInput input = getEditorInput();
- if (needReload) {
- doReload(model, input);
- }
- fEditorDisposed = true;
- disposeModelDependentFields();
- // some things in the configuration need to clean
- // up after themselves
- SourceViewerConfiguration config = getSourceViewerConfiguration();
- if (config instanceof StructuredTextViewerConfiguration) {
- ((StructuredTextViewerConfiguration) config).unConfigure(getSourceViewer());
- }
-
- fDropTarget.dispose();
-
- setPreferenceStore(null);
-
- // strictly speaking, but following null outs
- // should not be needed,
- // but in the event of a memory leak, they make the
- // memory leak less
- // severe
- fDropAdapter = null;
- fDropTarget = null;
-
- super.dispose();
- Logger.trace("Source Editor", "StructuredTextEditor::dispose exit"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Disposes model specific editor helpers such as statusLineHelper.
- * Basically any code repeated in update() & dispose() should be placed
- * here.
- */
- protected void disposeModelDependentFields() {
-
- // none at this level
- }
-
- // This is for the IDocumentListener interface
- public void documentAboutToBeChanged(DocumentEvent event) {
- fDirtyBeforeDocumentEvent = isDirty();
- }
-
- // This is for the IDocumentListener interface
- public void documentChanged(DocumentEvent event) {
- if (isEditorInputReadOnly()) {
- // stop listening to document event
- // caused by the undo after validateEdit
- final int offset = event.getOffset() + event.getLength();
- fCurrentRunnable = new Runnable() {
- public void run() {
- if (!fEditorDisposed) {
- IStatus status = validateEdit(getSite().getShell());
- if (status != null && status.isOK()) {
- // nothing to do if 'ok'
- }
- else {
- getModel().getUndoManager().undo();
- getSourceViewer().setSelectedRange(offset, 0);
- if (!fDirtyBeforeDocumentEvent) {
- // reset dirty state if
- // model not dirty before
- // document event
- getModel().setDirtyState(false);
- }
- }
- }
- fCurrentRunnable = null;
- }
- };
- // We need to ensure that this is run via
- // 'asyncExec' since these
- // notifications can come from a non-ui thread.
- //
- // The non-ui thread call would occur when
- // creating a new file
- // under
- // ClearCase (or other library) control. The
- // creation of the new
- // file
- // would trigger a validateEdit call, on
- // another thread, that would
- // prompt the user to add the new file to
- // version control.
- Display display = getDisplay();
- if (display != null) {
- if (Thread.currentThread() != display.getThread())
- // TODO-future: there's probably a better
- // way than relying on asycnExec
- display.asyncExec(fCurrentRunnable);
- else
- fCurrentRunnable.run();
- }
- }
- }
-
- private Display getDisplay() {
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- * This method is marked as public temporarily for Page Designer to fix a
- * validateEdit problem. This method should not be used by anyone else as
- * it may be removed in a future release. Please let us know if you think
- * you really need this.
- *
- * @deprecated
- */
- public void doReload(IStructuredModel model, IEditorInput input) {
- if (input instanceof IFileEditorInput)
- doReload(model, (IFileEditorInput) input);
- else if (input instanceof IStorageEditorInput) {
- InputStream inStream = null;
- try {
- inStream = Utilities.getMarkSupportedStream(((IStorageEditorInput) input).getStorage().getContents());
- }
- catch (CoreException ce) {
- // no op
- }
- try {
- model.reload(inStream);
- }
- catch (IOException e) {
- // shouldn't be possible for IStorage.
- }
- }
- }
-
- /**
- * This method is marked as public temporarily for Page Designer to fix a
- * validateEdit problem. This method should not be used by anyone else as
- * it may be removed in a future release. Please let us know if you think
- * you really need this.
- *
- * @deprecated
- */
- public void doReload(IStructuredModel model, IFileEditorInput input) {
- InputStream inStream = null;
- rememberSelection(); // save current cursor
- // position
- try {
-
- // If an opened file has gone out of sync
- // before startup, not
- // forcing the
- // read will result in a fatal exception for
- // the entire Workbench
- inStream = Utilities.getMarkSupportedStream(input.getFile().getContents(true));
- model.reload(inStream);
- model.resetSynchronizationStamp(input.getFile());
- restoreSelection(); // restore cursor position
- // after model reloads
- }
- catch (org.eclipse.core.runtime.CoreException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- catch (java.io.IOException e) { // UnsupportedEncoding should be here
- // !
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- finally {
- if (inStream != null) {
- try {
- inStream.close();
- }
- catch (IOException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- }
- }
- }
-
- /**
- * @see ITextEditor#doRevertToSaved
- */
- public void doRevertToSaved() {
- super.doRevertToSaved();
- if (fOutlinePage != null && fOutlinePage instanceof IUpdate)
- ((IUpdate) fOutlinePage).update();
- // update menu text
- updateMenuText();
- }
-
- public void doSave(IProgressMonitor progressMonitor) {
- try {
- getModel().aboutToChangeModel();
- updateEncodingMemento();
- super.doSave(progressMonitor);
- }
- finally {
- getModel().changedModel();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#doSetInput(org.eclipse.ui.IEditorInput)
- */
- protected void doSetInput(IEditorInput input) throws CoreException {
- if (isBrowserLikeLinks())
- disableBrowserLikeLinks();
-
- boolean preventModelUnloading = (input != null) && (input == getEditorInput() && getModel() != null);
- IDocumentProvider newDocumentProvider = getModelProviderFor(input);
- // disconnect input from old document provider
- // (a workaround for bugzilla 44382) NOTE: this is
- // not a complete
- // workaround (see bugzilla bug for details)
- if ((!preventModelUnloading) && (getDocumentProvider() != null && (!getDocumentProvider().equals(newDocumentProvider)) && (getEditorInput() != null))) {
- getDocumentProvider().disconnect(getEditorInput());
- }
- initializeDocumentProvider(newDocumentProvider);
- if (preventModelUnloading)
- ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager().getExistingModelForEdit(getModel().getId());
-
- super.doSetInput(input);
-
- if (isBrowserLikeLinks())
- enableBrowserLikeLinks();
-
- if (preventModelUnloading)
- getModel().releaseFromEdit();
- if (getDocumentProvider() instanceof IModelProvider) {
- IStructuredModel model = ((IModelProvider) getDocumentProvider()).getModel(getEditorInput());
- if (fStructuredModel != null || model != null)
- setModel(model);
- }
-
- // start editor with smart insert mode
- setInsertMode(SMART_INSERT);
- }
-
- protected void abstractTextEditorContextMenuAboutToShow(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(IWorkbenchActionConstants.GROUP_ADD));
- menu.add(new Separator(ITextEditorActionConstants.GROUP_REST));
- menu.add(new Separator(IWorkbenchActionConstants.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);
- }
- }
-
- /**
- * Sets up this editor's context menu before it is made visible.
- *
- * @param menu
- * the menu
- */
- public void editorContextMenuAboutToShow(IMenuManager menu) {
- // To be consistant with the Java Editor, we want
- // to remove
- // ShiftRight and ShiftLeft from the context menu.
- //
- // ShiftRight and ShiftLeft were added in the super
- // implemenation of
- // this method. We want to skip it and call
- // AbstractTextEditor's
- // implementation directly. The easiest way is to
- // copy the method here.
-
- //super.editorContextMenuAboutToShow(menu);
- abstractTextEditorContextMenuAboutToShow(menu);
-
- addContextMenuActions(menu);
- addExtendedContextMenuActions(menu);
- }
-
- public Object getAdapter(Class required) {
- if (org.eclipse.wst.sse.core.util.Debug.perfTestAdapterClassLoading) {
- startPerfTime = System.currentTimeMillis();
- }
- Object result = null;
- // text editor
- if (ITextEditor.class.equals(required)) {
- result = this;
- }
- // content outline page
- else if (IContentOutlinePage.class.equals(required)) {
- if (fOutlinePage == null || fOutlinePage.getControl() == null || fOutlinePage.getControl().isDisposed()) {
- ContentOutlineConfiguration cfg = createContentOutlineConfiguration();
- if (cfg != null) {
- if (cfg instanceof StructuredContentOutlineConfiguration) {
- ((StructuredContentOutlineConfiguration) cfg).setEditor(this);
- }
- StructuredTextEditorContentOutlinePage outlinePage = new StructuredTextEditorContentOutlinePage();
- outlinePage.setConfiguration(cfg);
- outlinePage.setViewerSelectionManager(getViewerSelectionManager());
- outlinePage.setModel(getModel());
- fOutlinePage = outlinePage;
- }
- }
- result = fOutlinePage;
- }
- // property sheet page, but only if the input's
- // editable
- else if (IPropertySheetPage.class.equals(required) && !forceReadOnly && isEditable()) {
- if (fPropertySheetPage == null || fPropertySheetPage.getControl() == null || fPropertySheetPage.getControl().isDisposed()) {
- PropertySheetConfiguration cfg = createPropertySheetConfiguration();
- if (cfg != null) {
- if (cfg instanceof StructuredPropertySheetConfiguration) {
- ((StructuredPropertySheetConfiguration) cfg).setEditor(this);
- }
- ConfigurablePropertySheetPage propertySheetPage = new ConfigurablePropertySheetPage();
- propertySheetPage.setConfiguration(cfg);
- propertySheetPage.setViewerSelectionManager(getViewerSelectionManager());
- propertySheetPage.setModel(getModel());
- fPropertySheetPage = propertySheetPage;
- }
- }
- result = fPropertySheetPage;
- }
- else if (SpellCheckTarget.class.equals(required)) {
- result = getSpellCheckTarget();
- }
- else if (SourceEditingTextTools.class.equals(required)) {
- result = createSourceEditingTextTools();
- }
- else {
- Document document = getDOMDocument();
- if (document != null && document instanceof INodeNotifier) {
- result = ((INodeNotifier) document).getAdapterFor(required);
- }
- if (result == null) {
- result = getModel().getAdapter(required);
- }
- // others
- if (result == null)
- result = super.getAdapter(required);
- }
- if (org.eclipse.wst.sse.core.util.Debug.perfTestAdapterClassLoading) {
- long stop = System.currentTimeMillis();
- adapterRequests++;
- adapterTime += (stop - startPerfTime);
- }
- if (org.eclipse.wst.sse.core.util.Debug.perfTestAdapterClassLoading) {
- System.out.println("Total calls to getAdapter: " + adapterRequests); //$NON-NLS-1$
- System.out.println("Total time in getAdapter: " + adapterTime); //$NON-NLS-1$
- System.out.println("Average time per call: " + (adapterTime / adapterRequests)); //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * IExtendedMarkupEditor method
- */
- public Node getCaretNode() {
- IStructuredModel model = getModel();
- if (model == null)
- return null;
- int pos = getCaretPosition();
- IndexedRegion inode = model.getIndexedRegion(pos);
- if (inode == null)
- inode = model.getIndexedRegion(pos - 1);
- return (inode instanceof Node) ? (Node) inode : null;
- }
-
- /**
- * IExtendedSimpleEditor method
- */
- public int getCaretPosition() {
- ViewerSelectionManager vsm = getViewerSelectionManager();
- if (vsm == null)
- return -1;
- // nsd_TODO: are we being overly paranoid?
- StructuredTextViewer stv = getTextViewer();
- if (stv != null && stv.getControl() != null && !stv.getControl().isDisposed() && getSourceViewer().getVisibleRegion().getOffset() != 0) {
- return vsm.getCaretPosition() + getSourceViewer().getVisibleRegion().getOffset();
- }
- return vsm.getCaretPosition();
- }
-
- protected String[] getConfigurationPoints() {
- String contentTypeIdentifierID = null;
- if (getModel() != null)
- contentTypeIdentifierID = getModel().getContentTypeIdentifier();
- return ConfigurationPointCalculator.getConfigurationPoints(this, contentTypeIdentifierID, ConfigurationPointCalculator.SOURCE, StructuredTextEditor.class);
- }
-
- /**
- * IExtendedMarkupEditorExtension method
- */
- public Node getCursorNode() {
- if (getModel() != null)
- return (Node) getModel().getIndexedRegion(getCursorOffset());
- else
- return null;
- }
-
- /**
- * IExtendedMarkupEditorExtension method
- */
- public int getCursorOffset() {
- if (hoverX >= 0 && hoverY >= 0)
- return getOffsetAtLocation(hoverX, hoverY);
- return getCaretPosition();
- }
-
- /**
- * added checks to overcome bug such that if we are shutting down in an
- * error condition, then viewer will have already been disposed.
- */
- protected String getCursorPosition() {
- String result = null;
- // this may be too expensive in terms of
- // performance, to do this check
- // every time, just to gaurd against error
- // condition.
- // perhaps there's a better way?
- if (getSourceViewer() != null && getSourceViewer().getTextWidget() != null && !getSourceViewer().getTextWidget().isDisposed()) {
- result = super.getCursorPosition();
- }
- else {
- result = "0:0"; //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * IExtendedSimpleEditor method
- */
- public IDocument getDocument() {
- // ITextViewer tv = getTextViewer();
- // return (tv != null) ? tv.getDocument() : null;
- // The TextViewer may not be available at init
- // time.
- // The right way to get the document is thru
- // DocumentProvider.
- IDocumentProvider dp = getDocumentProvider();
- return (dp != null) ? dp.getDocument(getEditorInput()) : null;
- }
-
- /**
- * IExtendedMarkupEditor method
- */
- public Document getDOMDocument() {
- IStructuredModel model = getModel();
- if (model != null) {
- return (Document) model.getAdapter(Document.class);
- }
- return null;
- }
-
- /**
- */
- public IEditorPart getEditorPart() {
- if (fEditorPart == null)
- return this;
- return fEditorPart;
- }
-
- /**
- * Gets the forceReadOnly.
- *
- * @return Returns a boolean
- * @deprecated -- don't use ... will be come private, since intended for
- * special short term use.
- */
- public boolean getForceReadOnly() {
- return forceReadOnly;
- }
-
- private InternalModelStateListener getInternalModelStateListener() {
- if (fInternalModelStateListener == null) {
- fInternalModelStateListener = new InternalModelStateListener();
- }
- return fInternalModelStateListener;
- }
-
- /**
- * This value is set in initialize from input
- */
- public IStructuredModel getModel() {
- // was causing an exception when several editors
- // open
- // and then "close all"
- // while we did put in protection in 'isDirty'
- // for the null document provider assert failure,
- // we'll
- // just log this error.
- if (getDocumentProvider() == null) {
- // this indicated an error in startup sequence
- Logger.trace("Model Centric Editor", "Program Info Only: document provider was null when model requested"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- boolean initialModelNull = false;
- if (fStructuredModel == null)
- initialModelNull = true;
- if (fStructuredModel == null) {
- if (getDocumentProvider() instanceof IModelProvider) {
- fStructuredModel = ((IModelProvider) getDocumentProvider()).getModel(getEditorInput());
- }
- if (initialModelNull && fStructuredModel != null) {
- // DMW: 9/1/2002 -- why is update called
- // here? No change
- // has been indicated? I'd like to remove,
- // but will leave for
- // now to avoid breaking this hack. Should
- // measure/breakpoint
- // to see how large the problem is. May
- // cause performance
- // problems.
- // DMW: 9/8/2002 -- not sure why this was
- // here initially,
- // but the intent/hack must have been to
- // call update if this
- // was the first time fStructuredModel was
- // set. So,
- // I added the logic to check for that
- // "first time"
- // case. It would appear we don't really
- // need.
- // may remove in future when can test more.
- update();
- }
- }
- return fStructuredModel;
- }
-
- /**
- * Retrieve an IModelProvider suitable for the given input. Subclasses
- * should override as needed.
- *
- * @param input
- * @return
- */
- protected IDocumentProvider getModelProviderFor(IEditorInput input) {
- if (input instanceof IFileEditorInput) {
- return FileModelProvider.getInstance();
- }
- else if (input instanceof IStorageEditorInput) {
- return StorageModelProvider.getInstance();
- }
- else if (input.getAdapter(ILocationProvider.class) != null) {
- return TextFileModelProvider.getInstance();
- }
- else {
- return NullModelProvider.getInstance();
- }
- }
-
- /**
- * Jumps to the error next according to the given direction based off
- * JavaEditor#gotoAnnotation()
- *
- * @param forward
- * is the direction
- */
- public void gotoAnnotation(boolean forward) {
- ISelectionProvider provider = getSelectionProvider();
- ITextSelection s = (ITextSelection) provider.getSelection();
- Position errorPosition = new Position(s.getOffset(), s.getLength());
- Annotation nextError = getNextAnnotation(s.getOffset(), forward, errorPosition);
- if (nextError != null) {
- IMarker marker = null;
- if (nextError instanceof MarkerAnnotation)
- marker = ((MarkerAnnotation) nextError).getMarker();
- // temp annotations aren't in task list, only
- // persistant
- if (marker != null) {
- IWorkbenchPage page = getSite().getPage();
- IViewPart view = view = page.findView(IPageLayout.ID_TASK_LIST);
- if (view instanceof TaskList) {
- StructuredSelection ss = new StructuredSelection(marker);
- ((TaskList) view).setSelection(ss, true);
- }
- }
- selectAndReveal(errorPosition.getOffset(), errorPosition.getLength());
- }
- }
-
- /*
- * based off of JavaEditor#getNextAnnotation()
- */
- private Annotation getNextAnnotation(int offset, boolean forward, Position errorPosition) {
- Annotation nextError = null;
- Position nextErrorPosition = null;
- IDocument document = getDocumentProvider().getDocument(getEditorInput());
- int endOfDocument = document.getLength();
- int distance = 0;
- IAnnotationModel model = getDocumentProvider().getAnnotationModel(getEditorInput());
- Iterator e = model.getAnnotationIterator();
- while (e.hasNext()) {
- Object o = e.next();
- if (o instanceof Annotation) {
- Annotation a = (Annotation) o;
- if (!isNavigationTargetType(a))
- continue;
- Position p = model.getPosition(a);
- if (!p.includes(offset)) {
- int currentDistance = 0;
- if (forward) {
- currentDistance = p.getOffset() - offset;
- if (currentDistance <= 0)
- currentDistance = endOfDocument - offset + p.getOffset();
- }
- else {
- currentDistance = offset - p.getOffset();
- if (currentDistance <= 0)
- currentDistance = offset + endOfDocument - p.getOffset();
- }
- if (nextError == null || currentDistance < distance) {
- distance = currentDistance;
- nextError = a;
- nextErrorPosition = p;
- }
- }
- }
- }
- if (nextErrorPosition != null) {
- errorPosition.setOffset(nextErrorPosition.getOffset());
- errorPosition.setLength(nextErrorPosition.getLength());
- }
- return nextError;
- }
-
- /**
- * Computes the document offset underlying the given text widget graphics
- * coordinates.
- *
- * @param x
- * the x coordinate inside the text widget
- * @param y
- * the y coordinate inside the text widget
- * @return the document offset corresponding to the given point
- */
- protected int getOffsetAtLocation(int x, int y) {
- StyledText styledText = getSourceViewer().getTextWidget();
- if (styledText != null && !styledText.isDisposed()) {
- try {
- int widgetOffset = styledText.getOffsetAtLocation(new Point(x, y));
- if (getSourceViewer() instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension = (ITextViewerExtension5) getSourceViewer();
- return extension.widgetOffset2ModelOffset(widgetOffset);
- }
- return widgetOffset + getSourceViewer().getVisibleRegion().getOffset();
- }
- catch (IllegalArgumentException e) {
- return getSourceViewer().getVisibleRegion().getLength();
- }
- }
- return getCaretPosition();
- }
-
- /**
- * IExtendedMarkupEditor method
- */
- public List getSelectedNodes() {
- ViewerSelectionManager vsm = getViewerSelectionManager();
- return (vsm != null) ? vsm.getSelectedNodes() : null;
- }
-
- /**
- * IExtendedSimpleEditor method
- */
- public Point getSelectionRange() {
- ITextViewer tv = getSourceViewer();
- if (tv == null)
- return new Point(-1, -1);
- else
- return tv.getSelectedRange();
- }
-
- /**
- * Array of ID Strings that define the default show in targets for this
- * editor.
- *
- * @see org.eclipse.ui.part.IShowInTargetList#getShowInTargetIds()
- * @return the array of ID Strings that define the default show in targets
- * for this editor.
- */
- public String[] getShowInTargetIds() {
- return fShowInTargetIds;
- }
-
- public SpellCheckTarget getSpellCheckTarget() {
- if (fSpellCheckTarget == null) {
- fSpellCheckTarget = createSpellCheckTarget();
- }
- return fSpellCheckTarget;
- }
-
- private IStatusLineManager getStatusLineManager() {
- AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
- IWorkbenchWindow window = plugin.getWorkbench().getActiveWorkbenchWindow();
- if (window == null)
- return null;
- IWorkbenchPage page = window.getActivePage();
- if (page == null)
- return null;
- IEditorPart editor = page.getActiveEditor();
- if (editor == null)
- return null;
- IEditorActionBarContributor contributor = editor.getEditorSite().getActionBarContributor();
- if (contributor instanceof EditorActionBarContributor) {
- return ((EditorActionBarContributor) contributor).getActionBars().getStatusLineManager();
- }
- return null;
- }
-
- /**
- * Returns the editor's source viewer. This method was created to expose
- * the protected final getSourceViewer() method.
- *
- * @return the editor's source viewer
- */
- public StructuredTextViewer getTextViewer() {
- return (StructuredTextViewer) getSourceViewer();
- }
-
- public ViewerSelectionManager getViewerSelectionManager() {
- if (getTextViewer() != null)
- return getTextViewer().getViewerSelectionManager();
- return null;
- //if (fViewerSelectionManager == null) {
- ////
- //// its required to pass along the underlying
- // widget so that the
- // ViewerSectionManager
- //// can listen to changes in it, via the
- // CaretMediator
- //// Note: the getViewer != null check was put in
- // to avoid a null
- // pointer, if in fact
- //// there was an error that prevented complete
- // instantiation.
- //if (fTextViewer != null) {
- //StyledText textWidget =
- // fTextViewer.getTextWidget();
- //fViewerSelectionManager = new
- // ViewerSelectionManagerImpl(fTextViewer);
- //}
- //}
- //return fViewerSelectionManager;
- }
-
- protected void handleElementContentAboutToBeReplaced(Object element) {
- // do nothing
- }
-
- protected void handleElementContentReplaced(Object element) {
- // do nothing, the model provider should reload the
- // model
- }
-
- protected void handleElementDeleted(Object element) {
- // do nothing, the superclass will close() us
- }
-
- protected void handleElementDirtyStateChanged(Object element, boolean isDirty) {
- // do nothing, the superclass will fire a proeprty
- // change
- }
-
- protected void handleElementMoved(Object oldElement, Object newElement) {
- // do nothing, the editor input will be changed
- }
-
- public void init(IEditorSite site, IEditorInput input) throws PartInitException {
- // if we've gotten an error elsewhere, before
- // we've actually opened, then don't open.
- if (shouldClose) {
- setSite(site);
- close(false);
- }
- else {
- super.init(site, input);
- }
- }
-
- public void initializeDocumentProvider(IDocumentProvider documentProvider) {
- if (getDocumentProvider() != null)
- getDocumentProvider().removeElementStateListener(internalElementStateListener);
- if (documentProvider != null) {
- setDocumentProvider(documentProvider);
- }
- if (documentProvider != null)
- documentProvider.addElementStateListener(internalElementStateListener);
- }
-
- protected void initializeDrop(ITextViewer textViewer) {
- int operations = DND.DROP_COPY | DND.DROP_MOVE;
- fDropTarget = new DropTarget(textViewer.getTextWidget(), operations);
- fDropAdapter = new ReadOnlyAwareDropTargetAdapter();
- fDropAdapter.setTargetEditor(this);
- fDropAdapter.setTargetIDs(getConfigurationPoints());
- fDropAdapter.setTextViewer(textViewer);
- fDropTarget.setTransfer(fDropAdapter.getTransfers());
- fDropTarget.addDropListener(fDropAdapter);
- }
-
- protected void initializeEditor() {
- super.initializeEditor();
- fEncodingSupport = null;
- setPreferenceStore(createCombinedPreferenceStore());
-
- setRangeIndicator(new DefaultRangeIndicator());
- setEditorContextMenuId(EDITOR_CONTEXT_MENU_ID);
- initializeDocumentProvider(null);
- // set the infopop for source viewer
- String helpId = getHelpContextId();
- if (helpId == null) // no infopop set, use default
- helpId = IHelpContextIds.XML_SOURCE_VIEW_HELPID;
- setHelpContextId(helpId);
- // defect 203158 - disable ruler context menu for
- // beta
- //setRulerContextMenuId(RULER_CONTEXT_MENU_ID);
- configureInsertMode(SMART_INSERT, true);
-
- // enable the base source editor activity when editor opens
-// try {
-// WTPActivityBridge.getInstance().enableActivity(CORE_SSE_ACTIVITY_ID, true);
-// } catch (Throwable t) {
-// // if something goes wrong with enabling activity, just log the error but dont
-// // have it break the editor
-// Logger.log(Logger.WARNING_DEBUG, t.getMessage(), t);
-// }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.editors.text.TextEditor#initializeKeyBindingScopes()
- */
- protected void initializeKeyBindingScopes() {
- setKeyBindingScopes(new String[]{"org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"}); //$NON-NLS-1$
- }
-
- protected void initSourceViewer(StructuredTextViewer sourceViewer) {
- // ensure decoration support is configured
- getSourceViewerDecorationSupport(sourceViewer);
- fMouseTracker = new MouseTracker();
- fMouseTracker.start(sourceViewer.getTextWidget());
- initializeDrop(sourceViewer);
- }
-
- /*
- * @see IEditorPart#isDirty
- */
- public boolean isDirty() {
- // because we're not perfectly forced read only ...
- if (forceReadOnly)
- return false;
- // IDocumentProvider p = getDocumentProvider();
- // if (p == null)
- // return false;
- //
- // if (getModel() == null)
- // return false;
- // return getModel().isDirty();
- return super.isDirty();
- }
-
- /*
- * temp impl for V2 (eventually will use super's method, keying off of
- * IDocumentProvider ... or IDocumentProviderExtension
- */
- public boolean isEditable() {
- boolean result = true;
- if (forceReadOnly) {
- result = false;
- }
- else {
- result = super.isEditable();
- }
- return result;
- }
-
- /*
- * @see ITextEditorExtension#isEditorInputReadOnly()
- */
- public boolean isEditorInputReadOnly() {
- if (forceReadOnly)
- return true;
- return super.isEditorInputReadOnly();
- }
-
- /**
- * Returns whether the given annotation type is configured as a target
- * type for the "Go to Next/Previous Annotation" actions. Copied from
- * org.eclipse.jdt.internal.ui.javaeditor.JavaEditor
- *
- * @param type
- * the annotation type
- * @return <code>true</code> if this is a target type,
- * <code>false</code> otherwise
- * @since 3.0
- */
- protected boolean isNavigationTargetType(Annotation annotation) {
- Preferences preferences = Platform.getPlugin("org.eclipse.ui.editors").getPluginPreferences(); //$NON-NLS-1$
- AnnotationPreference preference = getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
- // See bug 41689
- // String key= forward ?
- // preference.getIsGoToNextNavigationTargetKey()
- // :
- // preference.getIsGoToPreviousNavigationTargetKey();
- String key = preference == null ? null : preference.getIsGoToNextNavigationTargetKey();
- return (key != null && preferences.getBoolean(key));
- }
-
- /*
- * @see IEditorPart#isSaveOnCloseNeeded()
- */
- public boolean isSaveOnCloseNeeded() {
- // because we're not perfect, never allow
- // save attempt on forceReadOnly
- if (forceReadOnly || getModel() == null)
- return false;
- return getModel().isSaveNeeded();
- }
-
- /**
- * Posts the update code "behind" the running operation.
- */
- protected void postOnDisplayQue(Runnable runnable) {
- org.eclipse.ui.IWorkbench workbench = org.eclipse.ui.PlatformUI.getWorkbench();
- org.eclipse.ui.IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();
- if (windows != null && windows.length > 0) {
- Display display = windows[0].getShell().getDisplay();
- display.asyncExec(runnable);
- }
- else
- runnable.run();
- }
-
- /**
- * This method was made public for use by editors that use
- * StructuredTextEditor (like PageDesigner)
- *
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#rememberSelection()
- */
- public void rememberSelection() {
- super.rememberSelection();
- }
-
- /**
- * This method was made public for use by editors that use
- * StructuredTextEditor (like PageDesigner)
- *
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#restoreSelection()
- */
- public void restoreSelection() {
- // catch odd case where source viewer has no text
- // widget (defect
- // 227670)
- if ((getSourceViewer() != null) && (getSourceViewer().getTextWidget() != null))
- super.restoreSelection();
- }
-
- protected void rulerContextMenuAboutToShow(IMenuManager menu) {
- menu.add(getAction(ActionDefinitionIds.ADD_BREAKPOINTS));
- menu.add(getAction(ActionDefinitionIds.MANAGE_BREAKPOINTS));
- menu.add(getAction(ActionDefinitionIds.EDIT_BREAKPOINTS));
- menu.add(new Separator());
- super.rulerContextMenuAboutToShow(menu);
- addExtendedRulerContextMenuActions(menu);
- }
-
- /**
- * Overridden to expose part activation handling for multi-page editors
- *
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#safelySanityCheckState(org.eclipse.ui.IEditorInput)
- */
- public void safelySanityCheckState(IEditorInput input) {
- super.safelySanityCheckState(input);
- }
-
- public void setEditorPart(IEditorPart editorPart) {
- fEditorPart = editorPart;
- }
-
- /**
- * Sets the forceReadOnly.
- *
- * @param forceReadOnly
- * The forceReadOnly to set
- * @deprecated -- use constructor only
- */
- public void setForceReadOnly(boolean forceReadOnly) {
- this.forceReadOnly = forceReadOnly;
- }
-
- /**
- * We expose this normally protected method so clients can provide their
- * own help.
- *
- * @param helpContextId
- * the help context id
- */
- public void setHelpContextId(String helpContextId) {
- // used by (requested by) WSED
- super.setHelpContextId(helpContextId);
- // allows help to be set at any time (not just on
- // AbstractTextEditor's
- // creation)
- if ((getHelpContextId() != null) && (getSourceViewer() != null) && (getSourceViewer().getTextWidget() != null))
- WorkbenchHelp.setHelp(getSourceViewer().getTextWidget(), getHelpContextId());
- }
-
- /**
- * @deprecated - use initializeDocumentProvider/setInput Note this weird
- * API, setModel which takes input as parameter. Is provided
- * for those editors which don't otherwise have to know about
- * models's. (Is hard/impossible to override the setInput
- * method.)
- */
- public void setModel(IFileEditorInput input) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(getDocumentProvider());
- if (fStructuredModel != null) {
- if (getDocument() != null) {
- getDocument().removeDocumentListener(this);
- fStructuredModel.removeModelStateListener(getInternalModelStateListener());
- }
- }
- if (!(getDocumentProvider() instanceof FileModelProvider)) {
- initializeDocumentProvider(FileModelProvider.getInstance());
- }
- // ((FileModelProvider)
- // getDocumentProvider()).createModelInfo(input);
- // fStructuredModel = ((FileModelProvider)
- // getDocumentProvider()).getModel(input);
- // model will be null in some error conditions.
- if (fStructuredModel == null) {
- close(false);
- }
- // DMW: checked for site after moving to 3/22
- // (2.1M4) Eclipse base.
- /// Later code in super classes were causing NPE's
- // because site, etc.,
- // hasn't been
- // initialized yet. If site is still null at this
- // point, we are
- // assuming
- // setInput and update are called later, perhaps
- // elsewhere.
- // But if site is not null (such as in DTD Editor)
- // then setInput and
- // update must
- // be called here.
- // if (getSite() != null) {
- setInput(input);
- fStructuredModel = ((FileModelProvider) getDocumentProvider()).getModel(input);
- if (fStructuredModel != null) {
- getDocument().addDocumentListener(this);
- fStructuredModel.addModelStateListener(getInternalModelStateListener());
- }
- // update() should be called whenever the model is
- // set or changed
- update();
- // }
- }
-
- /**
- * Sets the model field within this editor, use only when: 1) there is no
- * IEditorInput (very special case, not well tested) 2) there is an
- * IEditorInput but the corresponding model needs to be set separately
- */
- public void setModel(IStructuredModel newModel) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(getDocumentProvider());
- if (fStructuredModel != null) {
- fStructuredModel.removeModelLifecycleListener(fInternalLifeCycleListener);
- if (fStructuredModel.getStructuredDocument() != null) {
- fStructuredModel.getStructuredDocument().removeDocumentListener(this);
- }
- fStructuredModel.removeModelStateListener(getInternalModelStateListener());
- }
- fStructuredModel = newModel;
- if (fStructuredModel != null) {
- if (fStructuredModel.getStructuredDocument() != null) {
- fStructuredModel.getStructuredDocument().addDocumentListener(this);
- }
- fStructuredModel.addModelStateListener(getInternalModelStateListener());
- fStructuredModel.addModelLifecycleListener(fInternalLifeCycleListener);
- }
- // update() should be called whenever the model is
- // set or changed
- update();
- }
-
- /**
- * @deprecated - initialize with a document provider and use setInput or
- * setModel(IStructuredModel)
- * @param newModel
- * @param input
- */
- public void setModel(IStructuredModel newModel, IFileEditorInput input) {
- // _setAnnotationModel(input);
- // setModel(newModel);
- org.eclipse.wst.sse.core.util.Assert.isNotNull(getDocumentProvider());
- if (fStructuredModel != null) {
- fStructuredModel.removeModelLifecycleListener(fInternalLifeCycleListener);
- fStructuredModel.removeModelStateListener(getInternalModelStateListener());
- if (fStructuredModel.getStructuredDocument() != null) {
- fStructuredModel.getStructuredDocument().removeDocumentListener(this);
- }
- }
- if (getDocumentProvider() instanceof FileModelProvider)
- ((FileModelProvider) getDocumentProvider()).createModelInfo(input, newModel, false);
- fStructuredModel = newModel;
- // setInput in super will allow titles to be
- // updated, etc.
- setInput(input);
- if (fStructuredModel != null) {
- if (fStructuredModel.getStructuredDocument() != null) {
- fStructuredModel.getStructuredDocument().addDocumentListener(this);
- }
- fStructuredModel.addModelStateListener(getInternalModelStateListener());
- fStructuredModel.addModelLifecycleListener(fInternalLifeCycleListener);
- }
- // update() should be called whenever the model is
- // set or changed
- update();
- }
-
- /**
- * @deprecated - no longer used
- */
- protected void setPropertySheetPageFont(Font font) {
- // if ((getPropertySheetPage() != null) &&
- // (getPropertySheetPage().getControl() != null))
- // getPropertySheetPage().getControl().setFont(font);
- }
-
- /*
- * Sets raw fPropertySheetPage. Used by CSS Editor. (?)
- *
- * @deprecated - no longer used
- */
- protected void setRawPropertySheetPage(IPropertySheetPage isp) {
- // fPropertySheetPage = isp;
- }
-
- /**
- * Sets the editor's source viewer configuration which it uses to
- * configure it's internal source viewer. This method was overwritten so
- * that viewer configuration could be set after editor part was created.
- */
- protected void setSourceViewerConfiguration(SourceViewerConfiguration config) {
- super.setSourceViewerConfiguration(config);
- StructuredTextViewer stv = getTextViewer();
- if (stv != null) {
- // there should be no need to unconfigure
- // before configure because
- // configure will
- // also unconfigure before configuring
- stv.unconfigure();
- stv.configure(config);
- }
- }
-
- /**
- * Overridden to allow custom tab title for multi-page editors
- *
- * @see org.eclipse.ui.part.WorkbenchPart#setTitle(java.lang.String)
- */
- public void setTitle(String title) {
- super.setTitle(title);
- }
-
- private void statusError(IStatus status) {
- statusError(status.getMessage());
- ErrorDialog.openError(getSite().getShell(), null, null, status);
- }
-
- private void statusError(String message) {
- IStatusLineManager manager = getStatusLineManager();
- if (manager == null)
- return;
- manager.setErrorMessage(message);
- getSite().getShell().getDisplay().beep();
- }
-
- /**
- * update() should be called whenever the model is set or changed (as in
- * swapped)
- */
- public void update() {
- IAnnotationModel annotationModel = getDocumentProvider().getAnnotationModel(getEditorInput());
- if (getTextViewer() != null)
- getTextViewer().setModel(getModel(), annotationModel);
- if (fOutlinePage != null && fOutlinePage instanceof StructuredTextEditorContentOutlinePage) {
- ContentOutlineConfiguration cfg = createContentOutlineConfiguration();
- if (cfg instanceof StructuredContentOutlineConfiguration) {
- ((StructuredContentOutlineConfiguration) cfg).setEditor(this);
- }
- ((StructuredTextEditorContentOutlinePage) fOutlinePage).setModel(getModel());
- ((StructuredTextEditorContentOutlinePage) fOutlinePage).setViewerSelectionManager(getViewerSelectionManager());
- ((StructuredTextEditorContentOutlinePage) fOutlinePage).setConfiguration(cfg);
- }
- if (fPropertySheetPage != null && fPropertySheetPage instanceof ConfigurablePropertySheetPage) {
- PropertySheetConfiguration cfg = createPropertySheetConfiguration();
- if (cfg instanceof StructuredPropertySheetConfiguration) {
- ((StructuredPropertySheetConfiguration) cfg).setEditor(this);
- }
- ((ConfigurablePropertySheetPage) fPropertySheetPage).setModel(getModel());
- ((ConfigurablePropertySheetPage) fPropertySheetPage).setViewerSelectionManager(getViewerSelectionManager());
- ((ConfigurablePropertySheetPage) fPropertySheetPage).setConfiguration(cfg);
- }
- if (getViewerSelectionManager() != null)
- getViewerSelectionManager().setModel(getModel());
- disposeModelDependentFields();
-
- fShowInTargetIds = createShowInTargetIds();
-
- // workaround for bugzilla#56801
- // updates/reinstalls QuickDiff because some QuickDiff info is lost
- // when SourceViewer.setModel/setDocument is called
- updateDiffer();
- // setSourceViewerConfiguration() was called once
- // in
- // StructuredTextMultiPageEditorPart.createSourcePage()
- // to set the SourceViewerConfiguration first so
- // the text editor won't
- // use the default configuration first
- // and switch to the
- // StructuredTextViewerConfiguration later.
- // However, the source viewer was not created yet
- // at the time. Need to
- // call setSourceViewerConfiguration() again here
- // so getSourceViewer().configure(configuration) in
- // setSourceViewerConfiguration() will be called.
- // DMW: removed setSouceViewerConfiguration since
- // shouldn't need the
- // general case
- // an longer, but added 'updateConfiguration' so it
- // can still be
- // sensitive
- // to resource/model changes.
- // setSourceViewerConfiguration();
- updateSourceViewerConfiguration();
- // (nsd) we never change it, so why null it out?
- // else {
- // super.setPreferenceStore(null);
- // }
- createModelDependentFields();
- computeAndSetDoubleClickAction(getModel());
- }
-
- /**
- * Remove the QuickDiff annotation model from the SourceViewer's
- * Annotation model if it exists
- */
- private void removeDiffer() {
- // get annotation model extension
- ISourceViewer viewer = getSourceViewer();
- if (viewer == null)
- return;
-
- IAnnotationModel m = viewer.getAnnotationModel();
- IAnnotationModelExtension model;
- if (m instanceof IAnnotationModelExtension)
- model = (IAnnotationModelExtension) m;
- else
- return;
-
- // remove the quick differ if it already exists in the annotation
- // model
- model.removeAnnotationModel(IChangeRulerColumn.QUICK_DIFF_MODEL_ID);
- }
-
- /**
- * Updates/reinstalls QuickDiff
- */
- private void updateDiffer() {
- // workaround for bugzilla#56801
- // updates/reinstalls QuickDiff because some QuickDiff info is lost
- // when SourceViewer.setModel/setDocument is called
-
- if (isChangeInformationShowing()) {
- showChangeInformation(false);
- removeDiffer();
- showChangeInformation(true);
- }
- }
-
- /**
- * Updates all content dependent actions.
- */
- protected void updateContentDependentActions() {
- super.updateContentDependentActions();
- // super.updateContentDependentActions only updates
- // the enable/disable
- // state of all
- // the content dependent actions.
- // StructuredTextEditor's undo and redo actions
- // have a detail label and
- // description.
- // They needed to be updated.
- if (!fEditorDisposed)
- updateMenuText();
- }
-
- protected void updateEncodingMemento() {
- IStructuredDocument doc = getModel().getStructuredDocument();
- EncodingMemento memento = doc.getEncodingMemento();
- IDocumentCharsetDetector detector = getModel().getModelHandler().getEncodingDetector();
- if (memento != null && detector != null)
- detector.set(doc);
- String enc = null;
- try {
- enc = detector.getEncoding();
- }
- catch (IOException e) {
- // TODO Temporary till API settles down.
- e.printStackTrace();
- }
- memento.setDetectedCharsetName(enc);
- }
-
- /** Translatable strings */
- private static final String UNDO_ACTION_DESC = ResourceHandler.getString("Undo__{0}._UI_"); //$NON-NLS-1$ = "Undo: {0}."
- private static final String UNDO_ACTION_DESC_DEFAULT = ResourceHandler.getString("Undo_Text_Change._UI_"); //$NON-NLS-1$ = "Undo Text Change."
- private static final String UNDO_ACTION_TEXT = ResourceHandler.getString("&Undo_{0}_@Ctrl+Z_UI_"); //$NON-NLS-1$ = "&Undo {0} @Ctrl+Z"
- private static final String UNDO_ACTION_TEXT_DEFAULT = ResourceHandler.getString("&Undo_Text_Change_@Ctrl+Z_UI_"); //$NON-NLS-1$ = "&Undo Text Change @Ctrl+Z"
- private static final String REDO_ACTION_DESC = ResourceHandler.getString("Redo__{0}._UI_"); //$NON-NLS-1$ = "Redo: {0}."
- private static final String REDO_ACTION_DESC_DEFAULT = ResourceHandler.getString("Redo_Text_Change._UI_"); //$NON-NLS-1$ = "Redo Text Change."
- private static final String REDO_ACTION_TEXT = ResourceHandler.getString("&Redo_{0}_@Ctrl+Y_UI_"); //$NON-NLS-1$ = "&Redo {0} @Ctrl+Y"
- private static final String REDO_ACTION_TEXT_DEFAULT = ResourceHandler.getString("&Redo_Text_Change_@Ctrl+Y_UI_"); //$NON-NLS-1$ = "&Redo Text Change @Ctrl+Y"
-
-
- protected void updateMenuText() {
- if (fStructuredModel != null && !fStructuredModel.isModelStateChanging() && getTextViewer().getTextWidget() != null) {
- // performance: don't force an update of the action bars unless
- // required as it is expensive
- String previousUndoText = null;
- String previousUndoDesc = null;
- String previousRedoText = null;
- String previousRedoDesc = null;
- boolean updateActions = false;
- IAction undoAction = getAction(ITextEditorActionConstants.UNDO);
- IAction redoAction = getAction(ITextEditorActionConstants.REDO);
- if (undoAction != null) {
- previousUndoText = undoAction.getText();
- previousUndoDesc = undoAction.getDescription();
- updateActions = updateActions || previousUndoText == null || previousUndoDesc == null;
- undoAction.setText(UNDO_ACTION_TEXT_DEFAULT);
- undoAction.setDescription(UNDO_ACTION_DESC_DEFAULT);
- }
- if (redoAction != null) {
- previousRedoText = redoAction.getText();
- previousRedoDesc = redoAction.getDescription();
- updateActions = updateActions || previousRedoText == null || previousRedoDesc == null;
- redoAction.setText(REDO_ACTION_TEXT_DEFAULT);
- redoAction.setDescription(REDO_ACTION_DESC_DEFAULT);
- }
- if (fStructuredModel.getUndoManager() != null) {
- StructuredTextUndoManager undoManager = fStructuredModel.getUndoManager();
- // get undo command
- Command undoCommand = undoManager.getUndoCommand();
- // set undo label and description
- undoAction.setEnabled(undoManager.undoable());
- if (undoCommand != null) {
- String label = undoCommand.getLabel();
- if (label != null) {
- String customText = MessageFormat.format(UNDO_ACTION_TEXT, new String[]{label});
- updateActions = updateActions || customText == null || previousUndoText == null || !customText.equals(previousUndoText);
- undoAction.setText(customText);
- }
- String desc = undoCommand.getDescription();
- if (desc != null) {
- String customDesc = MessageFormat.format(UNDO_ACTION_DESC, new String[]{desc});
- updateActions = updateActions || customDesc == null || previousRedoDesc == null || !customDesc.equals(previousUndoDesc);
- undoAction.setDescription(customDesc);
- }
- }
- // get redo command
- Command redoCommand = undoManager.getRedoCommand();
- // set redo label and description
- redoAction.setEnabled(undoManager.redoable());
- if (redoCommand != null) {
- String label = redoCommand.getLabel();
- if (label != null) {
- String customText = MessageFormat.format(REDO_ACTION_TEXT, new String[]{label});
- updateActions = updateActions || customText == null || previousRedoText == null || !customText.equals(previousRedoText);
- redoAction.setText(customText);
- }
- String desc = redoCommand.getDescription();
- if (desc != null) {
- String customDesc = MessageFormat.format(REDO_ACTION_DESC, new String[]{desc});
- updateActions = updateActions || customDesc == null || previousRedoDesc == null || !customDesc.equals(previousRedoDesc);
- redoAction.setDescription(customDesc);
- }
- }
- }
- // tell the action bars to update
- if (updateActions) {
- if (getEditorSite().getActionBars() != null) {
- getEditorSite().getActionBars().updateActionBars();
- }
- else if (getEditorPart() != null && getEditorPart().getEditorSite().getActionBars() != null) {
- getEditorPart().getEditorSite().getActionBars().updateActionBars();
- }
- }
- }
- }
-
- protected void updateSourceViewerConfiguration() {
- SourceViewerConfiguration configuration = getSourceViewerConfiguration();
- if ((configuration == null) || !(configuration instanceof StructuredTextViewerConfiguration)) {
- configuration = createSourceViewerConfiguration();
- setSourceViewerConfiguration(configuration);
- }
- else {
- StructuredTextViewerConfiguration newViewerConfiguration = createSourceViewerConfiguration();
- if (!((StructuredTextViewerConfiguration) configuration).getDeclaringID().equals(newViewerConfiguration.getDeclaringID())) {
- // d282894 use newViewerConfiguration
- configuration = newViewerConfiguration;
- setSourceViewerConfiguration(configuration);
- }
- }
- IResource resource = null;
- if (getEditorInput() instanceof IFileEditorInput) {
- resource = ((IFileEditorInput) getEditorInput()).getFile();
- if (resource.getType() != IResource.PROJECT)
- resource = resource.getProject();
- ((StructuredTextViewerConfiguration) configuration).configureOn(resource);
- }
- if (getSourceViewer() != null) {
- getSourceViewer().configure(configuration);
- IAction contentAssistAction = getAction(StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS);
- if (contentAssistAction instanceof IUpdate) {
- ((IUpdate) contentAssistAction).update();
- }
- }
- // eventually will replace above with something
- // like what follows
- // it, but some of our "processors" require too
- // much initialization
- // during configuration.
- // SourceViewerConfiguration configuration =
- // getSourceViewerConfiguration();
- //
- // // should always be an instance of our special
- // configuration, but
- // just in case
- // // not, we'll do nothing if it isn't.
- // if (configuration!= null && configuration
- // instanceof
- // StructuredTextViewerConfiguration) {
- //
- // IResource resource = null;
- // if (getEditorInput() instanceof
- // IFileEditorInput) {
- // resource = ((IFileEditorInput)
- // getEditorInput()).getFile();
- // if (resource.getType() != IResource.PROJECT)
- // resource = resource.getProject();
- // // note: configureOn is responsible for updating
- // what ever
- // // in our configuration is sensitive to resource
- // ((StructuredTextViewerConfiguration)
- // configuration).configureOn(resource);
- // }
- //
- // }
- }
-
- public IStatus validateEdit(Shell context) {
- IStatus status = STATUS_OK;
- IEditorInput input = getEditorInput();
- if (input instanceof IFileEditorInput) {
- if (input == null) {
- String msg = ResourceHandler.getString("Error_opening_file_UI_"); //$NON-NLS-1$
- status = new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.INFO, msg, null);
- }
- else {
- validateState(input);
- sanityCheckState(input);
- if (isEditorInputReadOnly()) {
- String fname = input.getName();
- if (input instanceof IStorageEditorInput) {
- try {
- IStorage s = ((IStorageEditorInput) input).getStorage();
- if (s != null) {
- IPath path = s.getFullPath();
- if (path != null) {
- fname += path.toString();
- }
- else {
- fname += s.getName();
- }
- }
- }
- catch (CoreException e) { // IStorage is just for
- // file name,
- // and it's an optional,
- // therefore
- // it is safe to ignore this
- // exception.
- }
- }
- String msg = ResourceHandler.getString("_UI_File_is_read_only", new Object[]{fname}); //$NON-NLS-1$ = "File {0}is read-only."
- status = new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.INFO, msg, null);
- }
- }
- }
- return status;
- }
-
- protected void validateState(IEditorInput input) {
- IDocumentProvider provider = getDocumentProvider();
- if (provider instanceof IDocumentProviderExtension) {
- IDocumentProviderExtension extension = (IDocumentProviderExtension) provider;
- try {
- boolean wasReadOnly = isEditorInputReadOnly();
- extension.validateState(input, getSite().getShell());
- if (getSourceViewer() != null)
- getSourceViewer().setEditable(isEditable());
- if (wasReadOnly != isEditorInputReadOnly())
- updateStateDependentActions();
- }
- catch (CoreException x) {
- ILog log = Platform.getPlugin(PlatformUI.PLUGIN_ID).getLog();
- log.log(x.getStatus());
- statusError(x.getStatus());
- }
- }
- }
-
- protected void installEncodingSupport() {
- fEncodingSupport = null;
- }
-
- /**
- * @return the IFile from the currently active editor
- */
- public IFile getFileInEditor() {
- IStructuredModel model = getModel();
- return ResourcesPlugin.getWorkspace().getRoot().getFileForLocation(new Path(model.getBaseLocation()));
- }
-
- /**
- * Return whether the browser like links should be enabled according to
- * the preference store settings.
- *
- * @return <code>true</code> if the browser like links should be enabled
- */
- private boolean isBrowserLikeLinks() {
- IPreferenceStore store = getPreferenceStore();
- return store.getBoolean(CommonEditorPreferenceNames.BROWSER_LIKE_LINKS);
- }
-
- /**
- * Enables browser like links.
- */
- private void enableBrowserLikeLinks() {
- if (fHyperlinkTracker == null) {
- fHyperlinkTracker = new OpenFileHyperlinkTracker(getSourceViewer());
- fHyperlinkTracker.setHyperlinkPreferenceKeys(CommonEditorPreferenceNames.LINK_COLOR, CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER, CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK);
- fHyperlinkTracker.install(getPreferenceStore());
- }
- }
-
- /**
- * Disables browser like links.
- */
- private void disableBrowserLikeLinks() {
- if (fHyperlinkTracker != null) {
- fHyperlinkTracker.uninstall();
- fHyperlinkTracker = null;
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.AbstractTextEditor#handlePreferenceStoreChanged(org.eclipse.jface.util.PropertyChangeEvent)
- */
- protected void handlePreferenceStoreChanged(PropertyChangeEvent event) {
- String property = event.getProperty();
-
- if (CommonEditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS.equals(property)) {
- updateHoverBehavior();
- }
- if (CommonEditorPreferenceNames.BROWSER_LIKE_LINKS.equals(property)) {
- if (isBrowserLikeLinks())
- enableBrowserLikeLinks();
- else
- disableBrowserLikeLinks();
- return;
- }
- super.handlePreferenceStoreChanged(event);
- }
-
- /**
- * Create a preference store that combines the source editor preferences
- * with the base editor's preferences.
- *
- * @return IPreferenceStore
- */
- private IPreferenceStore createCombinedPreferenceStore() {
- IPreferenceStore sseEditorPrefs = ((AbstractUIPlugin) Platform.getPlugin(EditorPlugin.ID)).getPreferenceStore();
- IPreferenceStore baseEditorPrefs = EditorsUI.getPreferenceStore();
- return new ChainedPreferenceStore(new IPreferenceStore[]{sseEditorPrefs, baseEditorPrefs});
- }
-
- /*
- * Update the hovering behavior depending on the preferences.
- */
- private void updateHoverBehavior() {
- SourceViewerConfiguration configuration = getSourceViewerConfiguration();
- String[] types = configuration.getConfiguredContentTypes(getSourceViewer());
-
- for (int i = 0; i < types.length; i++) {
-
- String t = types[i];
-
- ISourceViewer sourceViewer = getSourceViewer();
- if (sourceViewer instanceof ITextViewerExtension2) {
- // Remove existing hovers
- ((ITextViewerExtension2) sourceViewer).removeTextHovers(t);
-
- int[] stateMasks = configuration.getConfiguredTextHoverStateMasks(getSourceViewer(), t);
-
- if (stateMasks != null) {
- for (int j = 0; j < stateMasks.length; j++) {
- int stateMask = stateMasks[j];
- ITextHover textHover = configuration.getTextHover(sourceViewer, t, stateMask);
- ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, stateMask);
- }
- }
- else {
- ITextHover textHover = configuration.getTextHover(sourceViewer, t);
- ((ITextViewerExtension2) sourceViewer).setTextHover(textHover, t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
- }
- else
- sourceViewer.setTextHover(configuration.getTextHover(sourceViewer, t), t);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextLineBreakingReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextLineBreakingReader.java
deleted file mode 100644
index d1cb5710c8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextLineBreakingReader.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.swt.graphics.GC;
-
-/*
- * Not a real reader. Could change if requested
- */
-public class StructuredTextLineBreakingReader {
-
- private BufferedReader fReader;
- private GC fGC;
- private int fMaxWidth;
- private String fLine;
- private int fIndex;
-
- /**
- * Creates a reader that breaks an input text to fit in a given width.
- * @param reader Reader of the input text
- * @param gc The graphic context that defines the currently used font sizes
- * @param maxLineWidth The max width (pixes) where the text has to fit in
- */
- public StructuredTextLineBreakingReader(Reader reader, GC gc, int maxLineWidth) {
- fReader = new BufferedReader(reader);
- fGC = gc;
- fMaxWidth = maxLineWidth;
- fLine = null;
- fIndex = 0;
- }
-
- private int findNextBreakIndex(int currIndex) {
- int currWidth = 0;
- int lineLength = fLine.length();
-
- while (currIndex < lineLength) {
- char ch = fLine.charAt(currIndex);
- int nextIndex = currIndex + 1;
- // leading whitespaces are counted to the following word
- if (Character.isWhitespace(ch)) {
- while (nextIndex < lineLength && Character.isWhitespace(fLine.charAt(nextIndex))) {
- nextIndex++;
- }
- }
- while (nextIndex < lineLength && !Character.isWhitespace(fLine.charAt(nextIndex))) {
- nextIndex++;
- }
- String word = fLine.substring(currIndex, nextIndex);
- int wordWidth = fGC.textExtent(word).x;
- int nextWidth = wordWidth + currWidth;
- if (nextWidth > fMaxWidth && wordWidth < fMaxWidth) {
- return currIndex;
- }
- currWidth = nextWidth;
- currIndex = nextIndex;
- }
- return currIndex;
- }
-
- private int findWordBegin(int idx) {
- while (idx < fLine.length() && Character.isWhitespace(fLine.charAt(idx))) {
- idx++;
- }
- return idx;
- }
-
- /**
- * Reads the next line. The lengths of the line will not exceed the gived maximum
- * width.
- */
- public String readLine() throws IOException {
- if (fLine == null) {
- String line = fReader.readLine();
- if (line == null) {
- return null;
- }
- int lineLen = fGC.textExtent(line).x;
- if (lineLen < fMaxWidth) {
- return line;
- }
- fLine = line;
- fIndex = 0;
- }
- int breakIdx = findNextBreakIndex(fIndex);
- String res = fLine.substring(fIndex, breakIdx);
- if (breakIdx < fLine.length()) {
- fIndex = findWordBegin(breakIdx);
- }
- else {
- fLine = null;
- }
- return res;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextReconciler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextReconciler.java
deleted file mode 100644
index 4483cd83f3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextReconciler.java
+++ /dev/null
@@ -1,742 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
-import org.eclipse.jface.text.reconciler.Reconciler;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.wst.sse.core.IModelLifecycleListener;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.ModelLifecycleEvent;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-import org.eclipse.wst.sse.ui.internal.reconcile.IStructuredReconcilingStrategy;
-import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy;
-import org.eclipse.wst.sse.ui.util.Assert;
-
-
-/**
- * Reconciler that maps different partitions to different strategies.
- * Strategies contain one or more Steps
- * Steps contain code that validates dirty regions
- *
- * Is aware of StructuredDocumentEvents which determine if a reconcile should be done or not.
- * On partition change events in the document, all strategies are called.
- *
- * @author pavery
- */
-public class StructuredTextReconciler extends Reconciler implements IStructuredDocumentListener, IModelLifecycleListener {
-
- /**
- * Cancels any running reconcile operations via progress monitor.
- * Ensures that strategies are released on close of the editor.
- */
- private class SourceWidgetDisposeListener implements DisposeListener {
-
- public void widgetDisposed(DisposeEvent e) {
- getLocalProgressMonitor().setCanceled(true);
- //getProgressMonitor().setCanceled(true);
- // release all strategies
- if (fDefaultStrategy != null && fDefaultStrategy instanceof IReleasable) {
- ((IReleasable) fDefaultStrategy).release();
- fDefaultStrategy = null;
- }
- if (!fStrategyTypes.isEmpty()) {
- Iterator it = fStrategyTypes.iterator();
- IReconcilingStrategy strategy = null;
- while (it.hasNext()) {
- strategy = getReconcilingStrategy((String) it.next());
- if (strategy instanceof IReleasable) {
- ((IReleasable) strategy).release();
- strategy = null;
- }
- }
- }
- }
- }
-
- /**
- * Reconclies the entire document when the document in the viewer is changed.
- * This happens when the document is initially opened, as well as after a save-as
- */
- private class SourceTextInputListener implements ITextInputListener {
-
- public void inputDocumentAboutToBeChanged(IDocument oldInput, IDocument newInput) {
- // do nothing
- }
-
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
-
- setDocumentOnAllStrategies(newInput);
- setEntireDocumentDirty(newInput);
- }
- }
-
- public static final String TRACE_FILTER = "reconciler"; //$NON-NLS-1$
-
- /** set true after first install to prevent duplicate work done in the install method (since install gets called multiple times)*/
- private boolean fIsInstalled = false;
-
- /** flag set via structured document events */
- private boolean fNeedsValidation = true;
-
- /** the list of partition types for which there are strategies */
- List fStrategyTypes = null;
-
- /** document that this reconciler works on */
- private IDocument fLocalDocument = null;
-
- /** to cancel any long running reconciles if someone closes the editor */
- private SourceWidgetDisposeListener fDisposeListener = null;
-
- /** for initital reconcile when document is opened*/
- private SourceTextInputListener fTextInputListener = null;
-
- /** local queue of dirty regions (created here) to be reconciled */
- private List fLocalDirtyRegionQueue = null;
-
- // use our own local for now until we resolve abstract calling it on every document change
- // resulting in some of our strategies getting cut short and not adding/removing annotations correctly
- private IProgressMonitor fLocalProgressMonitor = null;
-
- /** strategy called for unmapped partitions */
- IReconcilingStrategy fDefaultStrategy;
-
- /** the strategy that runs validators contributed via reconcileValidator ext point */
- private ValidatorStrategy fValidatorStrategy;
-
- /** local copy of model manager */
- private IModelManager modelManager = null;
-
- /**
- * Creates a new StructuredTextReconciler
- */
- public StructuredTextReconciler() {
- super();
- configure();
- }
-
- private void configure() {
- fStrategyTypes = new ArrayList();
-
- // we are always incremental
- setIsIncrementalReconciler(true);
- setDelay(500);
- //setProgressMonitor(new NullProgressMonitor());
- setLocalProgressMonitor(new NullProgressMonitor());
- fDisposeListener = new SourceWidgetDisposeListener();
- fTextInputListener = new SourceTextInputListener();
- fLocalDirtyRegionQueue = new ArrayList();
- }
-
- /**
- * Gets the default strategy for this reconciler.
- * @return the default strategy
- */
- protected IReconcilingStrategy getDefaultStrategy() {
- return fDefaultStrategy;
- }
-
- protected void initialProcess() {
- // only happens ONCE on first dirty region in queue (not on doucment open)
- // not useful to us at the moment
- }
-
- /**
- * @see org.eclipse.jface.text.reconciler.IReconciler#install(ITextViewer)
- */
- public void install(ITextViewer textViewer) {
- // we might be called multiple times with the same viewer,
- // maybe after being uninstalled as well, so track separately
- if (fIsInstalled)
- return;
-
- super.install(textViewer);
- textViewer.getTextWidget().addDisposeListener(fDisposeListener);
- textViewer.addTextInputListener(fTextInputListener);
-
- // getProgressMonitor().setCanceled(false);
- getLocalProgressMonitor().setCanceled(false);
-
- fIsInstalled = true;
- }
-
- /**
- * The viewer has been set on this Reconciler.
- * @return true if the viewer has been set on this Reconciler, false otherwise.
- */
- public boolean isInstalled() {
- return fIsInstalled;
- }
-
- /**
- * Cleanup listeners.
- * @see org.eclipse.jface.text.reconciler.IReconciler#uninstall()
- */
- public void uninstall() {
- if (fIsInstalled) {
- fIsInstalled = false;
- //getProgressMonitor().setCanceled(true);
- getLocalProgressMonitor().setCanceled(true);
-
- getTextViewer().removeTextInputListener(fTextInputListener);
-
- super.uninstall();
- }
- if (fLocalDocument != null && fLocalDocument instanceof IStructuredDocument) {
- // remove structured document listener
- ((IStructuredDocument) fLocalDocument).removeModelChangedListener(this);
- // remove lifecycle listener on the model
- unhookModelLifecycleListener(fLocalDocument);
- }
- fLocalDocument = null;
- }
-
- /**
- * We keep a local copy of the dirty region queue for compacting.
- *
- * @see org.eclipse.jface.text.reconciler.AbstractReconciler#process(org.eclipse.jface.text.reconciler.DirtyRegion)
- */
- protected void process(DirtyRegion dirtyRegion) {
- // called here so that it only kick off after .5 seconds
- // but fNeedsValidation flag is set in structuredDoucmentsEvents below
- runStrategies();
- }
-
- /**
- * Runs the appropriate strategies on the dirty region queue.
- * The reconciler currently handles these reconciling scenarios:
- *
- * <ul>
- * <li>partition change</li>
- * <li>routine text edits</li>
- * <li>entire document change</li>
- * <li>the default strategy</li>
- * </ul>
- *
- */
- private void runStrategies() {
- DirtyRegion dirtyRegion = null;
- while (fDefaultStrategy != null && isInstalled() && fNeedsValidation) {
- // this flag may be set to true if more dirty regions come in while this method is running
- fNeedsValidation = false;
- Logger.trace(TRACE_FILTER, "start RUNNING STRATEGIES IN RECONCILER"); //$NON-NLS-1$
- dirtyRegion = compactDirtyRegionQueue();
- // will be null if there is nothing in the queue
- if (dirtyRegion != null) {
- Logger.trace(TRACE_FILTER, "RUNNING with dirty region:" + dirtyRegion.getOffset() + ":" + dirtyRegion.getLength()); //$NON-NLS-1$ //$NON-NLS-2$
- try {
- if (isEntireDocumentChange(dirtyRegion))
- processAll();
- else
- processPartial(dirtyRegion);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- }
-
- /**
- * @param dirtyRegion
- * @return
- */
- private boolean isEntireDocumentChange(DirtyRegion dirtyRegion) {
- return getDocument().getLength() == dirtyRegion.getLength();
- }
-
- /**
- * This method reduces the dirty region queue to the least common dirty region. (the region that overlaps all dirty regions)
- * Needs to be synchronized or we tend to "lose" dirty regions.
- *
- * @return a condensed DirtyRegion representing all that was in the queue at the time this was called, or <code>null</code> if the queue is empty
- */
- private synchronized DirtyRegion compactDirtyRegionQueue() {
- StringBuffer traceInfo = new StringBuffer();
- if (Logger.isTracing(TRACE_FILTER))
- traceInfo.append("[reconciler] COMPACTING STARTING... localDirtyRegionQueue.size():" + fLocalDirtyRegionQueue.size()); //$NON-NLS-1$
-
- if (fLocalDirtyRegionQueue.size() == 1)
- return (DirtyRegion) fLocalDirtyRegionQueue.remove(0);
-
- int min = -1;
- int max = -1;
- if (!fLocalDirtyRegionQueue.isEmpty()) {
- DirtyRegion dr = null;
- for (int i = 0; i < fLocalDirtyRegionQueue.size(); i++) {
- dr = (DirtyRegion) fLocalDirtyRegionQueue.get(i);
- if (dr == null)
- continue;
-
- if (Logger.isTracing(TRACE_FILTER))
- traceInfo.append("\r\n\r\n -> compacting dirty region (" + i + ")" + " start:" + dr.getOffset() + " length:" + dr.getLength()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
-
- //possibly expand the dirty region start
- if (min == -1 || min > dr.getOffset())
- min = dr.getOffset();
- // possibly expand the dirty region end
- if (max == -1 || max < dr.getOffset() + dr.getLength())
- max = dr.getOffset() + dr.getLength();
- }
- fLocalDirtyRegionQueue.clear();
- }
- if (Logger.isTracing(TRACE_FILTER)) {
- traceInfo.append("\r\n\r\nCOMPACTING DONE... dirtyRangeStart:" + min + " dirtyRangeEnd:" + max + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- Logger.trace(TRACE_FILTER, traceInfo.toString());
- }
- return (min != -1) ? createDirtyRegion(min, max - min, DirtyRegion.INSERT) : null;
- }
-
- /**
- * Process the entire StructuredDocument.
- * Much more resource intensive than simply running a strategy on a dirty region.
- */
- protected void processAll() {
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] >StructuredTextReconciler: PROCESSING ALL"); //$NON-NLS-1$
- IDocument doc = getDocument();
- DirtyRegion durty = null;
- ITypedRegion tr[] = doc.getDocumentPartitioner().computePartitioning(0, doc.getLength());
- IReconcilingStrategy s = null;
- for (int i = 0; i < tr.length; i++) {
- durty = createDirtyRegion(tr[i], DirtyRegion.INSERT);
- s = getReconcilingStrategy(tr[i].getType());
- if (s != null) {
- if (s instanceof IStructuredReconcilingStrategy)
- ((IStructuredReconcilingStrategy) s).reconcile(durty, durty, true);
- else
- s.reconcile(durty, durty);
- }
- // run validator strategy every time, it figures out if it has a validator for this partition
- // pass in true for "refreshAll" flag = true indicating that the entire document is being reconciled, only do it once
- if (fValidatorStrategy != null)
- fValidatorStrategy.reconcile(tr[i], durty, true);
- }
- // we ran the whole doc already now we can reset the strategies
- resetStrategies();
- }
-
- /**
- * Process a subsection of the document.
- */
- protected void processPartial(DirtyRegion durty) {
- IDocument doc = getDocument();
- HashSet alreadyRan = new HashSet();
- ITypedRegion tr[] = doc.getDocumentPartitioner().computePartitioning(durty.getOffset(), durty.getLength());
- IReconcilingStrategy s = null;
- for (int i = 0; i < tr.length; i++) {
- durty = createDirtyRegion(tr[i], DirtyRegion.INSERT);
- // keeping track of already ran might not be the way to do it...
- if (!alreadyRan.contains(tr[i].getType())) {
- alreadyRan.add(tr[i].getType());
- s = getReconcilingStrategy(tr[i].getType());
- if (s != null)
- s.reconcile(durty, durty);
- }
- // run validator strategy every time, it figures out if it has a validator for this parition
- if (fValidatorStrategy != null)
- fValidatorStrategy.reconcile(tr[i], durty, false);
- }
- resetStrategies();
- }
-
- private DirtyRegion createDirtyRegion(ITypedRegion tr, String type) {
- return createDirtyRegion(tr.getOffset(), tr.getLength(), type);
- }
-
- private DirtyRegion createDirtyRegion(int offset, int length, String type) {
- DirtyRegion durty = null;
- IDocument doc = getDocument();
- // safety for BLE
- int docLen = doc.getLength();
- if (offset + length > docLen)
- length = docLen - offset;
-
- if (doc != null) {
- try {
- durty = new DirtyRegion(offset, length, type, doc.get(offset, length));
- }
- catch (BadLocationException e) {
- e.printStackTrace();
- }
- }
- return durty;
- }
-
- /**
- * Resets any flags that were set (eg. flags set during processAll())
- */
- protected void resetStrategies() {
- Iterator it = fStrategyTypes.iterator();
- String type = null;
- while (it.hasNext()) {
- type = (String) it.next();
- if (getReconcilingStrategy(type) instanceof IStructuredReconcilingStrategy)
- ((IStructuredReconcilingStrategy) getReconcilingStrategy(type)).reset();
- }
- }
-
- /**
- * Gets a strategy that is made to handle the given dirtyRegion.
- * @param dirtyRegion
- * @return a strategy that is made to handle the given dirtyRegion, or the default strategy for this reconciler if there isn't one
- */
- protected IReconcilingStrategy getAppropriateStrategy(DirtyRegion dirtyRegion) {
- String[] partitions = getPartitions(dirtyRegion);
- // for now just grab first partition type in dirty region
- IReconcilingStrategy rs = null;
- if (partitions.length > 0)
- rs = getReconcilingStrategy(partitions[0]);
- return rs != null ? rs : fDefaultStrategy;
- }
-
- /**
- * Utility method to get partitions of a dirty region
- * @param dirtyRegion
- * @return
- */
- protected String[] getPartitions(DirtyRegion dirtyRegion) {
- ITypedRegion[] regions = getPartitioner().computePartitioning(dirtyRegion.getOffset(), dirtyRegion.getLength());
- String[] partitions = new String[regions.length];
- for (int i = 0; i < regions.length; i++)
- partitions[i] = regions[i].getType();
- return partitions;
- }
-
- /**
- * assumes isInstalled() == true
- * @return the document partitioner for the document this reconciler is working on.
- */
- protected IDocumentPartitioner getPartitioner() {
- return getDocument().getDocumentPartitioner();
- }
-
- /**
- * Reinitializes listeners and sets new document onall strategies.
- * @see org.eclipse.jface.text.reconciler.AbstractReconciler#reconcilerDocumentChanged(IDocument)
- */
- protected void reconcilerDocumentChanged(IDocument document) {
-
- // unhook old lifecycle listner
- unhookModelLifecycleListener(fLocalDocument);
-
- // add new lifecycle listener
- hookUpModelLifecycleListener(document);
-
- if (fLocalDocument != null && fLocalDocument instanceof IStructuredDocument)
- ((IStructuredDocument) fLocalDocument).removeModelChangedListener(this);
-
- fLocalDocument = document;
-
- if (document != null && document instanceof IStructuredDocument)
- ((IStructuredDocument) fLocalDocument).addModelChangedListener(this);
-
- setDocumentOnAllStrategies(document);
- }
-
-
-
- /**
- * @param document
- */
- private void hookUpModelLifecycleListener(IDocument document) {
- IStructuredModel sModel = getStructuredModelForRead(document);
- try {
- if(sModel != null) {
- sModel.addModelLifecycleListener(this);
- }
- }
- finally {
- if(sModel != null)
- sModel.releaseFromRead();
- }
- }
-
- /**
- *
- * @param document
- */
- private void unhookModelLifecycleListener(IDocument document) {
- IStructuredModel sModel = getStructuredModelForRead(document);
- try {
- if(sModel != null) {
- sModel.removeModelLifecycleListener(this);
- }
- }
- finally {
- if(sModel != null)
- sModel.releaseFromRead();
- }
- }
-
- /**
- * Sets the progress monitor for this reconciler. Used to cancel potentially long running operations.
- * @see org.eclipse.jface.text.reconciler.AbstractReconciler#setProgressMonitor(IProgressMonitor)
- */
- // public void setProgressMonitor(IProgressMonitor monitor) {
- // super.setProgressMonitor(monitor);
- // if(fDefaultStrategy != null && fDefaultStrategy instanceof IReconcilingStrategyExtension)
- // ((IReconcilingStrategyExtension)fDefaultStrategy).setProgressMonitor(monitor);
- // }
- /**
- * Sets the default reconciling strategy.
- * @param strategy
- */
- public void setDefaultStrategy(IReconcilingStrategy strategy) {
- Assert.isNotNull(strategy, "Can't set default strategy to null"); //$NON-NLS-1$
-
- fDefaultStrategy = strategy;
- fDefaultStrategy.setDocument(getDocument());
- if (fDefaultStrategy instanceof IReconcilingStrategyExtension)
- ((IReconcilingStrategyExtension) fDefaultStrategy).setProgressMonitor(getLocalProgressMonitor());
- //((IReconcilingStrategyExtension)fDefaultStrategy).setProgressMonitor(getProgressMonitor());
- }
-
- /**
- * Sets the strategy for a given contentType (partitionType)
- * @see org.eclipse.jface.text.reconciler.Reconciler#setReconcilingStrategy(org.eclipse.jface.text.reconciler.IReconcilingStrategy, java.lang.String)
- */
- public void setReconcilingStrategy(IReconcilingStrategy strategy, String contentType) {
- super.setReconcilingStrategy(strategy, contentType);
- if (strategy != null) {
- strategy.setDocument(fLocalDocument);
- if (strategy instanceof IReconcilingStrategyExtension) {
- ((IReconcilingStrategyExtension) strategy).setProgressMonitor(getLocalProgressMonitor());
- }
- }
- fStrategyTypes.add(contentType);
- }
-
- public void newModel(NewModelEvent structuredDocumentEvent) {
- // do nothing
- }
-
- public void noChange(NoChangeEvent structuredDocumentEvent) {
- // do nothing
- }
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] >StructuredTextReconciler: *NODES REPLACED"); //$NON-NLS-1$
-
- // if partition changed, create a full document dirty region (causes processAll)
- DirtyRegion dr = partitionChanged(structuredDocumentEvent) ? createDirtyRegion(0, getDocument().getLength(), DirtyRegion.INSERT) : createDirtyRegion(structuredDocumentEvent.getOriginalStart(), structuredDocumentEvent.getLength(), DirtyRegion.INSERT);
- fLocalDirtyRegionQueue.add(dr);
-
- fNeedsValidation = true;
- }
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] >StructuredTextReconciler: *REGION CHANGED: \r\n\r\n created dirty region from flat model event >> :" + structuredDocumentEvent.getOriginalStart() + ":" + structuredDocumentEvent.getLength() + "\r\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- String dirtyRegionType = structuredDocumentEvent.getDeletedText().equals("") ? DirtyRegion.INSERT : DirtyRegion.REMOVE; //$NON-NLS-1$
- DirtyRegion dr = createDirtyRegion(structuredDocumentEvent.getOriginalStart(), structuredDocumentEvent.getLength(), dirtyRegionType);
-
- fLocalDirtyRegionQueue.add(dr);
-
- fNeedsValidation = true;
- }
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] >StructuredTextReconciler: *REGIONS REPLACED: \r\n\r\n created dirty region from flat model event >> :" + structuredDocumentEvent.getOriginalStart() + ":" + structuredDocumentEvent.getLength() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- DirtyRegion dr = createDirtyRegion(structuredDocumentEvent.getOriginalStart(), structuredDocumentEvent.getLength(), DirtyRegion.INSERT);
- fLocalDirtyRegionQueue.add(dr);
-
- fNeedsValidation = true;
- }
-
- /**
- * Checks if the StructuredDocumentEvent involved a partition change.
- * If there's a partition change, we know we should run all strategies just to be sure we cover the new regions and
- * remove obsolete annotations.
- *
- * A primitive check for now.
- * @param structuredDocumentEvent
- * @return
- */
- private boolean partitionChanged(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
- boolean changed = false;
-
- IDocumentPartitioner partitioner = structuredDocumentEvent.getStructuredDocument().getDocumentPartitioner();
-
- IStructuredDocumentRegionList oldNodes = structuredDocumentEvent.getOldStructuredDocumentRegions();
- IStructuredDocumentRegionList newNodes = structuredDocumentEvent.getNewStructuredDocumentRegions();
-
- IStructuredDocumentRegion oldNode = (oldNodes.getLength() > 0) ? oldNode = oldNodes.item(0) : null;
- IStructuredDocumentRegion newNode = (newNodes.getLength() > 0) ? newNodes.item(0) : null;
-
- if (oldNode != null && newNode != null)
- changed = partitioner.getContentType(oldNode.getStartOffset()).equals(partitioner.getContentType(newNode.getStartOffset()));
-
- return changed;
- }
-
- /**
- * We use our own local progress monitor to cancel long running strategies/steps.
- * Currently used when widget is disposed (user is trying to close the editor), and on uninstall.
- *
- * @return the local progress monitor
- */
- IProgressMonitor getLocalProgressMonitor() {
- return fLocalProgressMonitor;
- }
-
- private void setLocalProgressMonitor(IProgressMonitor pm) {
- fLocalProgressMonitor = pm;
- // set on default strategy
- if (fDefaultStrategy != null && fDefaultStrategy instanceof IReconcilingStrategyExtension)
- ((IReconcilingStrategyExtension) fDefaultStrategy).setProgressMonitor(pm);
- // set on all other strategies
- if (!fStrategyTypes.isEmpty()) {
- Iterator it = fStrategyTypes.iterator();
- String type = null;
- while (it.hasNext()) {
- type = (String) it.next();
- if (getReconcilingStrategy(type) instanceof IReconcilingStrategyExtension)
- ((IReconcilingStrategyExtension) getReconcilingStrategy(type)).setProgressMonitor(pm);
- }
- }
- }
-
- /**
- * Set the strategy that runs validators from the reconcileValidator extension point.
- * @param the ValidatorStrategy
- */
- public void setValidatorStrategy(ValidatorStrategy strategy) {
- fValidatorStrategy = strategy;
- if (fValidatorStrategy != null)
- fValidatorStrategy.setDocument(getDocument());
- }
-
- /**
- * Get the strategy that runs validators from the reconcileValidator extension point.
- * @param the ValidatorStrategy
- */
- public ValidatorStrategy getValidatorStrategy() {
- return fValidatorStrategy;
- }
-
- /**
- * Propagates a new document to all strategies and steps.
- * @param document
- */
- protected void setDocumentOnAllStrategies(IDocument document) {
- if(isInstalled()) {
- // default strategies
- if (fDefaultStrategy != null)
- fDefaultStrategy.setDocument(document);
-
- // external validator strategy
- if(fValidatorStrategy != null)
- fValidatorStrategy.setDocument(document);
-
- // set document on all regular strategies
- super.reconcilerDocumentChanged(document);
- }
- }
-
- protected void setEntireDocumentDirty(IDocument document) {
-
- // make the entire document dirty
- // this also happens on a "save as"
- if (document != null && isInstalled() && fLocalDirtyRegionQueue.size() == 0) {
-
- // since we're marking the entire doc dirty
- fLocalDirtyRegionQueue.clear();
-
- DirtyRegion entireDocument = createDirtyRegion(0, document.getLength(), DirtyRegion.INSERT);
- fLocalDirtyRegionQueue.add(entireDocument);
-
- // set this so reconcile won't be "short circuited"
- fNeedsValidation = true;
- }
- }
-
- /**
- */
- public void processPreModelEvent(ModelLifecycleEvent event) {
-
- if(event.getType() == ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED) {
-
- // clear the dirty region queue
- fLocalDirtyRegionQueue.clear();
-
- // note: old annotations are removed via the strategies on AbstractStructuredTextReconcilingStrategy#setDocument(...)
- }
- }
-
- /**
- */
- public void processPostModelEvent(ModelLifecycleEvent event) {
-
- // if underlying StructuredDocument changed, need to reconnect it here...
- // ex. file is modified outside the workbench
- if(event.getType() == ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED) {
- IStructuredDocument sDoc = event.getModel().getStructuredDocument();
-
- setDocumentOnAllStrategies(sDoc);
-
- // ensure that the document is re-reconciled
- setEntireDocumentDirty(sDoc);
- }
- }
-
- /**
- * Remember to release model after use!!
- * @return
- */
- public IStructuredModel getStructuredModelForRead(IDocument doc) {
-
- IStructuredModel sModel = null;
- if(doc != null)
- sModel = getModelManager().getExistingModelForRead(doc);
- return sModel;
- }
-
- /**
- * Avoid excessive calls to Platform.getPlugin(ModelPlugin.ID)
- * @return sse model manager
- */
- protected IModelManager getModelManager() {
-
- if (this.modelManager == null)
- this.modelManager = ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager();
- return this.modelManager;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextSelectionChangedEvent.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextSelectionChangedEvent.java
deleted file mode 100644
index 90d479f4d5..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextSelectionChangedEvent.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-
-/**
- * This event is used by the SourceEditorTreeViewer to tell the ViewerSelectionManager that
- * the selection really came from a user click on the content outliner, instead of being set programatically.
- */
-public class StructuredTextSelectionChangedEvent extends org.eclipse.jface.viewers.SelectionChangedEvent {
-
- public StructuredTextSelectionChangedEvent(ISelectionProvider source, ISelection selection) {
- super(source, selection);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextUndoManagerImpl.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextUndoManagerImpl.java
deleted file mode 100644
index 5742d30e41..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextUndoManagerImpl.java
+++ /dev/null
@@ -1,607 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.emf.common.command.BasicCommandStack;
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.emf.common.command.CommandStackListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.NoChangeEvent;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.RegionsReplacedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.CommandCursorPosition;
-import org.eclipse.wst.sse.core.undo.StructuredTextCommand;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.core.util.Utilities;
-import org.eclipse.wst.sse.ui.internal.undo.StructuredTextCommandImpl;
-import org.eclipse.wst.sse.ui.internal.undo.StructuredTextCompoundCommandImpl;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.view.events.ITextSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.TextSelectionChangedEvent;
-
-
-public class StructuredTextUndoManagerImpl implements CommandStackListener, StructuredTextUndoManager, ITextSelectionListener {
-
-
- class UndoManagerStructuredDocumentListener implements IStructuredDocumentListener {
-
-
- public void newModel(NewModelEvent structuredDocumentEvent) {
- // Do nothing. Do not push the new model's structuredDocument changes onto the undo command stack,
- // or else the user may be able to undo an existing file to an empty file.
- }
-
- public void noChange(NoChangeEvent structuredDocumentEvent) {
- // Since "no change", do nothing.
- }
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
- processStructuredDocumentEvent(structuredDocumentEvent);
- }
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
- processStructuredDocumentEvent(structuredDocumentEvent);
- }
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
- processStructuredDocumentEvent(structuredDocumentEvent);
- }
-
- }
-
- /** Translatable strings */
- protected static final String TEXT_CHANGE_TEXT = ResourceHandler.getString("Text_Change_UI_"); // used in undo/redo action text/desc //$NON-NLS-1$ = "Text Change"
- protected ITextViewer[] fTextViewers = null;
- protected IStructuredModel fStructuredModel = null;
- protected CommandStack fCommandStack = null;
- protected StructuredTextCompoundCommandImpl fCompoundCommand = null;
- protected StructuredTextCommandImpl fTextCommand = null;
- protected boolean fRecording = false;
- protected boolean fUndoManagementEnabled = true;
- protected Object fRequester;
- protected String fCompoundCommandLabel = null;
- protected String fCompoundCommandDescription = null;
- protected int fRecordingCount = 0;
- protected int fUndoCursorPosition = -1;
- protected int fUndoSelectionLength = 0;
- protected int fCursorPosition = 0;
- IStructuredDocumentListener fStructuredDocumentListener = new UndoManagerStructuredDocumentListener();
-
- public StructuredTextUndoManagerImpl() {
- this(new BasicCommandStack());
- }
-
- public StructuredTextUndoManagerImpl(CommandStack commandStack) {
- setCommandStack(commandStack);
- }
-
- protected void addTextViewer(ITextViewer textViewer) {
- if (!Utilities.contains(fTextViewers, textViewer)) {
- int oldSize = 0;
-
- if (fTextViewers != null) {
- // normally won't be null, but we need to be sure, for first time through
- oldSize = fTextViewers.length;
- }
-
- int newSize = oldSize + 1;
- ITextViewer[] newTextViewers = new ITextViewer[newSize];
- if (fTextViewers != null) {
- System.arraycopy(fTextViewers, 0, newTextViewers, 0, oldSize);
- }
-
- // add the new text viewer to last position
- newTextViewers[newSize - 1] = textViewer;
-
- // now switch new for old
- fTextViewers = newTextViewers;
- }
- else {
- removeTextViewer(textViewer);
- addTextViewer(textViewer);
- }
- }
-
- public void beginCompoundChange() {
- if (fStructuredModel != null)
- fStructuredModel.aboutToChangeModel();
-
- if (fRecording)
- beginRecording(this, fCompoundCommandLabel, fCompoundCommandDescription, fUndoCursorPosition, fUndoSelectionLength);
- else
- beginRecording(this);
- }
-
- public void beginRecording(Object requester) {
- beginRecording(requester, null, null);
- }
-
- public void beginRecording(Object requester, int cursorPosition, int selectionLength) {
- beginRecording(requester, null, null);
-
- fUndoCursorPosition = cursorPosition;
- fUndoSelectionLength = selectionLength;
- }
-
- public void beginRecording(Object requester, String label) {
- beginRecording(requester, label, null);
- }
-
- public void beginRecording(Object requester, String label, int cursorPosition, int selectionLength) {
- beginRecording(requester, label, null);
-
- fUndoCursorPosition = cursorPosition;
- fUndoSelectionLength = selectionLength;
- }
-
- public void beginRecording(Object requester, String label, String description) {
- // save the requester
- fRequester = requester;
-
- // update label and desc only on the first level when recording is nested
- if (fRecordingCount == 0) {
- fCompoundCommandLabel = label;
- if (fCompoundCommandLabel == null)
- fCompoundCommandLabel = TEXT_CHANGE_TEXT;
-
- fCompoundCommandDescription = description;
- if (fCompoundCommandDescription == null)
- fCompoundCommandDescription = TEXT_CHANGE_TEXT;
-
- // clear commands
- fTextCommand = null;
- fCompoundCommand = null;
- }
-
- // update counter and flag
- fRecordingCount++;
- fRecording = true;
-
- // no undo cursor position and undo selection length specified
- // reset undo cursor position and undo selection length
- fUndoCursorPosition = -1;
- fUndoSelectionLength = 0;
- }
-
- public void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength) {
- beginRecording(requester, label, description);
-
- fUndoCursorPosition = cursorPosition;
- fUndoSelectionLength = selectionLength;
- }
-
- protected void checkRequester(Object requester) {
- if ((fRequester != null) && (!fRequester.equals(requester))) {
- // Force restart of recording so the last compound command is closed.
- //
- // However, we should not force restart of recording when the request came from StructuredDocumentToTextAdapter or XMLModelImpl
- // because cut/paste requests and character inserts to the textViewer are from StructuredDocumentToTextAdapter,
- // and requests to delete a node in the XMLTableTreeViewer are from XMLModelImpl (which implements IStructuredModel).
- if (!((requester instanceof StructuredDocumentToTextAdapter) || (requester instanceof IStructuredModel) || (requester instanceof IStructuredDocument))) {
- if (fRecording)
- endRecording(fRequester);
- else
- resetInternalCommands();
-
- // save the requester
- fRequester = requester;
- }
- }
- }
-
- /**
- * This is called with the {@link CommandStack}'s state has changed.
- */
- public void commandStackChanged(java.util.EventObject event) {
- resetInternalCommands();
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#connect
- */
- public void connect(ITextViewer textViewer) {
- addTextViewer(textViewer);
-
- if (fStructuredModel == null) {
- // connect to model
- IModelManagerPlugin modelManagerPlugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- IModelManager modelManager = modelManagerPlugin.getModelManager();
- fStructuredModel = modelManager.getExistingModelForRead(textViewer.getDocument());
- IStructuredDocument structuredDocument = fStructuredModel.getStructuredDocument();
- structuredDocument.addModelChangedListener(fStructuredDocumentListener);
- }
- }
-
- protected void createNewTextCommand(String textDeleted, String textInserted, int textStart, int textEnd) {
- StructuredTextCommandImpl textCommand = new org.eclipse.wst.sse.ui.internal.undo.StructuredTextCommandImpl(fStructuredModel.getStructuredDocument());
- textCommand.setLabel(TEXT_CHANGE_TEXT);
- textCommand.setDescription(TEXT_CHANGE_TEXT);
- textCommand.setTextStart(textStart);
- textCommand.setTextEnd(textEnd);
- textCommand.setTextDeleted(textDeleted);
- textCommand.setTextInserted(textInserted);
-
- if (fRecording) {
- if (fCompoundCommand == null) {
- StructuredTextCompoundCommandImpl compoundCommand = new StructuredTextCompoundCommandImpl();
- // undo cursor position and undo selection length were set in beginRecord
- // they were saved until the first text command (because empty compound cannot be pushed onto the stack)
- if (fUndoCursorPosition > -1) {
- compoundCommand.setUndoCursorPosition(fUndoCursorPosition);
- compoundCommand.setUndoSelectionLength(fUndoSelectionLength);
- }
- else {
- compoundCommand.setUndoCursorPosition(textStart);
- compoundCommand.setUndoSelectionLength(textDeleted.length());
- }
- // reset undo cursor position and undo selection length
- fUndoCursorPosition = -1;
- fUndoSelectionLength = 0;
-
- compoundCommand.setLabel(fCompoundCommandLabel);
- compoundCommand.setDescription(fCompoundCommandDescription);
- compoundCommand.append(textCommand);
- fCommandStack.execute(compoundCommand);
-
- fCompoundCommand = compoundCommand;
- }
- else {
- fCompoundCommand.append(textCommand);
- }
- }
- else {
- fCommandStack.execute(textCommand);
- }
-
- fTextCommand = textCommand;
- }
-
- /**
- * Disable undo management.
- */
- public void disableUndoManagement() {
- fUndoManagementEnabled = false;
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#disconnect
- */
- public void disconnect() {
- removeTextViewers();
-
- if ((fTextViewers == null || fTextViewers.length == 0) && fStructuredModel != null)
- disconnectFromModel();
- }
-
- public void disconnect(ITextViewer textViewer) {
- removeTextViewer(textViewer);
-
- if ((fTextViewers == null || fTextViewers.length == 0) && fStructuredModel != null)
- disconnectFromModel();
- }
-
- protected void disconnectFromModel() {
- IStructuredDocument structuredDocument = fStructuredModel.getStructuredDocument();
- structuredDocument.removeModelChangedListener(fStructuredDocumentListener);
- fStructuredModel.releaseFromRead();
- fStructuredModel = null;
- }
-
- /**
- * Enable undo management.
- */
- public void enableUndoManagement() {
- fUndoManagementEnabled = true;
- }
-
- public void endCompoundChange() {
- endRecording(this);
-
- if (fStructuredModel != null)
- fStructuredModel.changedModel();
- }
-
- public void endRecording(Object requester) {
- int cursorPosition = (fTextCommand != null) ? fTextCommand.getTextEnd() : -1;
- int selectionLength = 0;
-
- endRecording(requester, cursorPosition, selectionLength);
- }
-
- public void endRecording(Object requester, int cursorPosition, int selectionLength) {
- if (fCompoundCommand != null) {
- fCompoundCommand.setRedoCursorPosition(cursorPosition);
- fCompoundCommand.setRedoSelectionLength(selectionLength);
- }
-
- // end recording is a logical stopping point for text command,
- // even when fRecordingCount > 0 (in nested beginRecording)
- fTextCommand = null;
-
- // update counter and flag
- if (fRecordingCount > 0)
- fRecordingCount--;
- if (fRecordingCount == 0) {
- fRecording = false;
-
- // reset compound command only when fRecordingCount == 0
- fCompoundCommand = null;
- fCompoundCommandLabel = null;
- fCompoundCommandDescription = null;
- }
- }
-
- public CommandStack getCommandStack() {
- return fCommandStack;
- }
-
- /**
- * Get the redo command.
- */
- public Command getRedoCommand() {
- return fCommandStack.getRedoCommand();
- }
-
- /**
- * Get the last text viewer the undo manager is connected to.
- */
- public ITextViewer getTextViewer() {
- if ((fTextViewers != null) && (fTextViewers.length > 0))
- return fTextViewers[fTextViewers.length - 1];
- else
- return null;
- }
-
- /**
- * Get the undo command.
- */
- public Command getUndoCommand() {
- return fCommandStack.getUndoCommand();
- }
-
- protected void processStructuredDocumentEvent(StructuredDocumentEvent structuredDocumentEvent) {
- // Note: fListening tells us if we should listen to the StructuredDocumentEvent.
- // fListening is set to false right before the undo/redo process and then set to true again
- // right after the undo/redo process to block out and ignore all StructuredDocumentEvents generated
- // by the undo/redo process.
-
- // Process StructuredDocumentEvent if fListening is true.
- //
- // We are executing a command from the command stack if the requester is a command (for example, undo/redo).
- // We should not process the flat model event when we are executing a command from the command stack.
- if (fUndoManagementEnabled && !(structuredDocumentEvent.getOriginalSource() instanceof Command)) {
- // check requester
- checkRequester(structuredDocumentEvent.getOriginalSource());
-
- // process the structuredDocumentEvent
- String textDeleted = structuredDocumentEvent.getDeletedText();
- String textInserted = structuredDocumentEvent.getText();
- int textStart = structuredDocumentEvent.getOriginalStart();
- int textEnd = textStart + textInserted.length();
- processStructuredDocumentEvent(textDeleted, textInserted, textStart, textEnd);
- }
- }
-
- protected void processStructuredDocumentEvent(String textDeleted, String textInserted, int textStart, int textEnd) {
- if ((fTextCommand != null) && (textStart == fTextCommand.getTextEnd())) {
- // append to the text command
- fTextCommand.setTextDeleted(fTextCommand.getTextDeleted().concat(textDeleted));
- fTextCommand.setTextInserted(fTextCommand.getTextInserted().concat(textInserted));
- fTextCommand.setTextEnd(textEnd);
- }
- else if (
- // 267437 - undo string messed up when backspace and delete are intermixed
- (fTextCommand != null) && (textStart == fTextCommand.getTextStart() - (textEnd - textStart + 1)) && (textEnd <= fTextCommand.getTextEnd() - (textEnd - textStart + 1)) && (textDeleted.length() == 1) && (textInserted.length() == 0)) {
- // backspace pressed
-
- // erase a character just inserted
- if (fTextCommand.getTextInserted().length() > 0) {
- fTextCommand.setTextInserted(fTextCommand.getTextInserted().substring(0, fTextCommand.getTextEnd() - fTextCommand.getTextStart() - 1));
- fTextCommand.setTextEnd(textEnd);
- }
- // erase a character in the file
- else {
- fTextCommand.setTextDeleted(textDeleted.concat(fTextCommand.getTextDeleted()));
- fTextCommand.setTextStart(textStart);
- }
- }
- else {
- createNewTextCommand(textDeleted, textInserted, textStart, textEnd);
- }
-
- // save cursor position
- fCursorPosition = textEnd;
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#redo
- */
- public void redo() {
- if (redoable()) {
- try {
- if (fStructuredModel != null)
- fStructuredModel.aboutToChangeModel();
-
- Command redoCommand = getRedoCommand();
-
- fCommandStack.redo(); // make sure to redo before setting cursor
-
- // set cursor if cursorPosition is available
- if (redoCommand instanceof CommandCursorPosition) {
- int cursorPosition = ((CommandCursorPosition) redoCommand).getRedoCursorPosition();
- int selectionLength = ((CommandCursorPosition) redoCommand).getRedoSelectionLength();
-
- if (getTextViewer() != null && cursorPosition > -1)
- getTextViewer().setSelectedRange(cursorPosition, selectionLength);
- }
- else if (redoCommand instanceof StructuredTextCommand) {
- StructuredTextCommand structuredTextRedoCommand = (StructuredTextCommand) redoCommand;
- int cursorPosition = structuredTextRedoCommand.getTextStart() + structuredTextRedoCommand.getTextInserted().length();
-
- if (getTextViewer() != null && cursorPosition > -1)
- getTextViewer().setSelectedRange(cursorPosition, 0);
- }
- // else leave cursor alone for other commands
-
- }
- finally {
- if (fStructuredModel != null)
- fStructuredModel.changedModel();
- }
- }
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#redoable
- */
- public boolean redoable() {
- return fCommandStack.canRedo();
- }
-
- protected void removeTextViewer(ITextViewer textViewer) {
- if ((fTextViewers != null) && (textViewer != null)) {
- // if its not in the array, we'll ignore the request
- if (Utilities.contains(fTextViewers, textViewer)) {
- int oldSize = fTextViewers.length;
- int newSize = oldSize - 1;
- ITextViewer[] newTextViewers = new ITextViewer[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fTextViewers[i] == textViewer) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newTextViewers[index++] = fTextViewers[i];
- }
- }
- // now that we have a new array, let's switch it for the old one
- fTextViewers = newTextViewers;
- }
- }
- }
-
- protected void removeTextViewers() {
- if ((fTextViewers != null) && (fTextViewers.length > 0)) {
- for (int i = 0; i < fTextViewers.length; i++) {
- removeTextViewer(fTextViewers[i]);
- }
- }
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#reset
- */
- public void reset() {
- if (fCommandStack != null)
- fCommandStack.flush();
- }
-
- protected void resetInternalCommands() {
- fCompoundCommand = null;
- fTextCommand = null;
- }
-
- public void setCommandStack(CommandStack commandStack) {
- if (fCommandStack != null)
- fCommandStack.removeCommandStackListener(this);
-
- fCommandStack = commandStack;
-
- if (fCommandStack != null)
- fCommandStack.addCommandStackListener(this);
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#setMaximalUndoLevel
- */
- public void setMaximalUndoLevel(int undoLevel) {
- // Do nothing. StructuredTextUndoManager supports unlimited undo level.
- }
-
- public void textSelectionChanged(TextSelectionChangedEvent event) {
- if (event.getSource() == getTextViewer().getTextWidget()) {
- // only listen to textSelectionChanged event from text widget
- // ignore textSelectionChanged event caused by outline view selection, for example
-
- int newCursorPosition = event.getTextSelectionStart();
- if (newCursorPosition != fCursorPosition)
- // textSelectionChanged is a logical stopping point for text command
- fTextCommand = null;
- }
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#undo
- */
- public void undo() {
- // Force an endRecording before undo.
- //
- // For example, recording was turned on on the Design Page of PageDesigner.
- // Then undo is invoked on the Source Page. Recording should be stopped before we undo.
- // Note that redo should not be available when we switch to the Source Page.
- // Therefore, this force ending of recording is not needed in redo.
- if (fRecording)
- endRecording(this);
-
- if (undoable()) {
- try {
- if (fStructuredModel != null)
- fStructuredModel.aboutToChangeModel();
-
- Command undoCommand = getUndoCommand();
-
- fCommandStack.undo(); // make sure to undo before setting cursor
-
- // set cursor if cursorPosition is available
- if (undoCommand instanceof CommandCursorPosition) {
- int cursorPosition = ((CommandCursorPosition) undoCommand).getUndoCursorPosition();
- int selectionLength = ((CommandCursorPosition) undoCommand).getUndoSelectionLength();
-
- if (getTextViewer() != null && cursorPosition > -1)
- getTextViewer().setSelectedRange(cursorPosition, selectionLength);
- }
- else if (undoCommand instanceof StructuredTextCommand) {
- StructuredTextCommand structuredTextUndoCommand = (StructuredTextCommand) undoCommand;
- int cursorPosition = structuredTextUndoCommand.getTextStart() + structuredTextUndoCommand.getTextDeleted().length();
-
- if (getTextViewer() != null && cursorPosition > -1)
- getTextViewer().setSelectedRange(cursorPosition, 0);
- }
- // else leave cursor alone for other commands
- }
- finally {
- if (fStructuredModel != null)
- fStructuredModel.changedModel();
- }
- }
- }
-
- /**
- * @see org.eclipse.jface.text.IUndoManager#undoable
- */
- public boolean undoable() {
- return fCommandStack.canUndo();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java
deleted file mode 100644
index 503e1520b7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewer.java
+++ /dev/null
@@ -1,1129 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentAdapter;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewerExtension2;
-import org.eclipse.jface.text.IUndoManager;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.formatter.FormattingContext;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IContentFormatterExtension;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.jface.text.information.IInformationPresenter;
-import org.eclipse.jface.text.projection.ChildDocument;
-import org.eclipse.jface.text.projection.ProjectionDocument;
-import org.eclipse.jface.text.reconciler.IReconciler;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IOverviewRuler;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.viewers.ContentViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.swt.events.VerifyListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.IEditorStatusLine;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.cleanup.StructuredContentCleanupHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.ui.extension.IExtendedSimpleEditor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.style.IHighlighter;
-import org.eclipse.wst.sse.ui.util.PlatformStatusLineUtil;
-import org.eclipse.wst.sse.ui.view.events.INodeSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.ITextSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-
-public class StructuredTextViewer extends SourceViewer implements INodeSelectionListener, IDoubleClickListener {
-
- /** Text operation codes */
- public static final int CLEANUP_DOCUMENT = ISourceViewer.INFORMATION + 1;
- public static final int FORMAT_ACTIVE_ELEMENTS = ISourceViewer.INFORMATION + 3;
- private static final String FORMAT_ACTIVE_ELEMENTS_TEXT = ResourceHandler.getString("Format_Active_Elements_UI_"); //$NON-NLS-1$
- public static final int FORMAT_DOCUMENT = ISourceViewer.INFORMATION + 2;
-
- private static final String FORMAT_DOCUMENT_TEXT = ResourceHandler.getString("Format_Document_UI_"); //$NON-NLS-1$
- public static final int QUICK_FIX = ISourceViewer.INFORMATION + 4;
- private static final String TEXT_CUT = ResourceHandler.getString("Text_Cut_UI_"); //$NON-NLS-1$
- private static final String TEXT_PASTE = ResourceHandler.getString("Text_Paste_UI_"); //$NON-NLS-1$
- private static final String TEXT_SHIFT_LEFT = ResourceHandler.getString("Text_Shift_Left_UI_"); //$NON-NLS-1$ = "Text Shift Left"
- private static final String TEXT_SHIFT_RIGHT = ResourceHandler.getString("Text_Shift_Right_UI_"); //$NON-NLS-1$ = "Text Shift Right"
- protected StructuredContentCleanupHandler fContentCleanupHandler = null;
- protected IContentAssistant fCorrectionAssistant;
- protected boolean fCorrectionAssistantInstalled;
- private IHighlighter fHighlighter;
- private IStructuredModel fModel;
-
- private ViewerSelectionManager fViewerSelectionManager;
-
- /**
- * ModelViewer constructor comment.
- *
- * @param parent
- * org.eclipse.swt.widgets.Composite
- * @param ruler
- * org.eclipse.jface.text.source.IVerticalRuler
- * @param styles
- * int
- */
- public StructuredTextViewer(Composite parent, IVerticalRuler verticalRuler, int styles) {
-
- super(parent, verticalRuler, styles);
- }
-
- /**
- * @see org.eclipse.jface.text.source.SourceViewer#SourceViewer(Composite,
- * IVerticalRuler, IOverviewRuler, boolean, int)
- */
- public StructuredTextViewer(Composite parent, IVerticalRuler verticalRuler, IOverviewRuler overviewRuler, boolean showAnnotationsOverview, int styles) {
-
- super(parent, verticalRuler, overviewRuler, showAnnotationsOverview, styles);
- }
-
- public void activatePlugins() {
-
- if (fUndoManager != null) {
- // Save and hide undoManager so superclass won't reset the command
- // stack.
- IUndoManager undoManager = fUndoManager;
- fUndoManager = null;
- super.activatePlugins();
- // Now just connect. Remember not to reset.
- fUndoManager = undoManager;
- fUndoManager.connect(this);
- }
- else
- super.activatePlugins();
- }
-
- /**
- *
- */
- private void beep() {
-
- getTextWidget().getDisplay().beep();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextOperationTarget#canDoOperation(int)
- */
- public boolean canDoOperation(int operation) {
-
- switch (operation) {
- case CONTENTASSIST_PROPOSALS :
- {
- // (pa) if position isn't READ_ONLY (containsReadOnly()
- // returns false),
- // Otherwise, you DO want content assist (return true)
- if (getModel() != null && getModel().getStructuredDocument() != null)
- return (!getModel().getStructuredDocument().containsReadOnly(getSelectedRange().x, 0));
- else
- return false;
- }
- case CONTENTASSIST_CONTEXT_INFORMATION :
- {
- return true;
- }
- case QUICK_FIX :
- {
- return true;
- }
- case INFORMATION :
- {
- // the fInformationPresenter may not be set yet but you DO
- // want information
- // (this needs to be set to TRUE so menu item can become
- // active)
- return true;
- }
- case CLEANUP_DOCUMENT :
- {
- return (fContentCleanupHandler != null && isEditable());
- }
- case FORMAT_DOCUMENT :
- case FORMAT_ACTIVE_ELEMENTS :
- {
- return (fContentFormatter != null && isEditable());
- }
- }
- return super.canDoOperation(operation);
- }
-
- /**
- * Should be identical to superclass version except we don't set the undo
- * manager here. Also, we get the tab width from the preference manager.
- * Plus, we get our own special Highlighter. Plus we uninstall before
- * installing.
- */
- public void configure(SourceViewerConfiguration configuration) {
-
- if (getTextWidget() == null)
- return;
-
- setDocumentPartitioning(configuration.getConfiguredDocumentPartitioning(this));
-
- if (configuration instanceof StructuredTextViewerConfiguration) {
- if (fHighlighter != null) {
- fHighlighter.uninstall();
- }
- fHighlighter = ((StructuredTextViewerConfiguration) configuration).getHighlighter(this);
- fHighlighter.install(this);
- }
-
- // install content type independent plugins
- if (fPresentationReconciler != null)
- fPresentationReconciler.uninstall();
- fPresentationReconciler = configuration.getPresentationReconciler(this);
- if (fPresentationReconciler != null)
- fPresentationReconciler.install(this);
-
- IReconciler newReconciler = configuration.getReconciler(this);
- if (newReconciler != fReconciler || newReconciler == null || fReconciler == null) {
- if (fReconciler != null)
- fReconciler.uninstall();
- fReconciler = newReconciler;
- if (fReconciler != null)
- fReconciler.install(this);
- }
- if (fContentAssistant != null)
- fContentAssistant.uninstall();
- fContentAssistant = configuration.getContentAssistant(this);
- if (fContentAssistant != null) {
- fContentAssistant.install(this);
- fContentAssistantInstalled = true;
- }
- else {
- // 248036
- // disable the content assist operation if no content assistant
- enableOperation(CONTENTASSIST_PROPOSALS, false);
- }
-
- // correction assistant
- if (configuration instanceof StructuredTextViewerConfiguration) {
- if (fCorrectionAssistant != null)
- fCorrectionAssistant.uninstall();
- fCorrectionAssistant = ((StructuredTextViewerConfiguration) configuration).getCorrectionAssistant(this);
- if (fCorrectionAssistant != null) {
- fCorrectionAssistant.install(this);
- fCorrectionAssistantInstalled = true;
- }
- else {
- // disable the correction assist operation if no correction
- // assistant
- enableOperation(QUICK_FIX, false);
- }
- }
-
- fContentFormatter = configuration.getContentFormatter(this);
-
- // do not uninstall old information presenter if it's the same
- IInformationPresenter newInformationPresenter = configuration.getInformationPresenter(this);
- if (newInformationPresenter == null || fInformationPresenter == null || !(newInformationPresenter.equals(fInformationPresenter))) {
- if (fInformationPresenter != null)
- fInformationPresenter.uninstall();
- fInformationPresenter = newInformationPresenter;
- if (fInformationPresenter != null)
- fInformationPresenter.install(this);
- }
- // TODO: compare with ?new? V2 configure re:
- // getTextWidget().setTabs(configuration.getTabWidth(this));
- // see if it can replace following
- // Set tab width to configuration setting first.
- // Then override if model type is XML or HTML.
- getTextWidget().setTabs(configuration.getTabWidth(this));
- setAnnotationHover(configuration.getAnnotationHover(this));
- setOverviewRulerAnnotationHover(configuration.getOverviewRulerAnnotationHover(this));
- // added for V2
- setHoverControlCreator(configuration.getInformationControlCreator(this));
- // install content type specific plugins
- String[] types = configuration.getConfiguredContentTypes(this);
-
- // clear autoindent/autoedit strategies
- fAutoIndentStrategies = null;
- for (int i = 0; i < types.length; i++) {
- String t = types[i];
- setAutoIndentStrategy(configuration.getAutoIndentStrategy(this, t), t);
- setTextDoubleClickStrategy(configuration.getDoubleClickStrategy(this, t), t);
-
- int[] stateMasks= configuration.getConfiguredTextHoverStateMasks(this, t);
- if (stateMasks != null) {
- for (int j= 0; j < stateMasks.length; j++) {
- int stateMask= stateMasks[j];
- setTextHover(configuration.getTextHover(this, t, stateMask), t, stateMask);
- }
- } else {
- setTextHover(configuration.getTextHover(this, t), t, ITextViewerExtension2.DEFAULT_HOVER_STATE_MASK);
- }
-
- String[] prefixes = configuration.getIndentPrefixes(this, t);
- if (prefixes != null && prefixes.length > 0)
- setIndentPrefixes(prefixes, t);
- // removed 'defaultPrefix' for Eclipse V2 replaced with
- // defaultPrefixes
- /*
- * String prefix = configuration.getDefaultPrefix(this, t); if
- * (prefix != null && prefix.length() > 0)
- * setDefaultPrefix(prefix, t);
- */
- prefixes = configuration.getDefaultPrefixes(this, t);
- if (prefixes != null && prefixes.length > 0)
- setDefaultPrefixes(prefixes, t);
- }
- activatePlugins();
-
- // do any StructuredTextViewer-specific configuration
- if (configuration instanceof StructuredTextViewerConfiguration) {
- Map autoEditStrategies = ((StructuredTextViewerConfiguration) configuration).getAutoEditStrategies(this);
- if (autoEditStrategies != null) {
- Iterator partitionTypes = autoEditStrategies.keySet().iterator();
- while (partitionTypes.hasNext()) {
- String partitionType = partitionTypes.next().toString();
- Object strategies = autoEditStrategies.get(partitionType);
- if (strategies != null) {
- if (strategies instanceof List) {
- for (int i = 0; i < ((List) strategies).size(); i++) {
- IAutoEditStrategy strategy = (IAutoEditStrategy) ((List) strategies).get(i);
- prependAutoEditStrategy(strategy, partitionType);
- }
- }
- }
- }
- }
- }
- }
-
- /**
- * @param document
- * @param startOffset
- * @param endOffset
- * @return
- */
- private boolean containsReadOnly(IDocument document, int startOffset, int endOffset) {
-
- int start = startOffset;
- int end = endOffset;
- IStructuredDocument structuredDocument = null;
- if (document instanceof IStructuredDocument) {
- structuredDocument = (IStructuredDocument) document;
- }
- else {
- if (document instanceof ProjectionDocument) {
- IDocument doc = ((ProjectionDocument) document).getMasterDocument();
- if (doc instanceof IStructuredDocument) {
- structuredDocument = (IStructuredDocument) doc;
- int adjust = ((ProjectionDocument) document).getProjectionMapping().getCoverage().getOffset();
- start = adjust + start;
- end = adjust + end;
- }
- }
- }
- if (structuredDocument == null) {
- return false;
- }
- else {
- int length = end - start;
- return structuredDocument.containsReadOnly(start, length);
- }
- }
-
- protected IDocumentAdapter createDocumentAdapter() {
-
- IDocumentAdapter docAdapter = new StructuredDocumentToTextAdapter(getTextWidget());
- return docAdapter;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextOperationTarget#doOperation(int)
- */
- public void doOperation(int operation) {
-
- Point selection = getTextWidget().getSelection();
- int cursorPosition = selection.x;
- int selectionLength = selection.y - selection.x;
- switch (operation) {
- case UNDO :
- {
- IExtendedSimpleEditor editor = getActiveExtendedSimpleEditor();
- if (editor != null) {
- IStatus status = editor.validateEdit(getControl().getShell());
- if (status != null && status.isOK()) {
- // defect 277327 - added undoManager.connect(this) so that this viewer is set as the last added viewer in the undoManager
- if (fUndoManager != null) {
- fUndoManager.connect(this);
- }
- super.doOperation(UNDO);
- }
- }
- else {
- // defect 277327 - added undoManager.connect(this) so that this viewer is set as the last added viewer in the undoManager
- if (fUndoManager != null) {
- fUndoManager.connect(this);
- }
- super.doOperation(UNDO);
- }
- break;
- }
- case REDO :
- {
- IExtendedSimpleEditor editor = getActiveExtendedSimpleEditor();
- if (editor != null) {
- IStatus status = editor.validateEdit(getControl().getShell());
- if (status != null && status.isOK()) {
- // defect 277327 - added undoManager.connect(this) so that this viewer is set as the last added viewer in the undoManager
- if (fUndoManager != null) {
- fUndoManager.connect(this);
- }
- super.doOperation(REDO);
- }
- }
- else {
- // defect 277327 - added undoManager.connect(this) so that this viewer is set as the last added viewer in the undoManager
- if (fUndoManager != null) {
- fUndoManager.connect(this);
- }
- super.doOperation(REDO);
- }
- break;
- }
- case CUT :
- getModel().beginRecording(this, TEXT_CUT, TEXT_CUT, cursorPosition, selectionLength);
- super.doOperation(operation);
- selection = getTextWidget().getSelection();
- cursorPosition = selection.x;
- selectionLength = selection.y - selection.x;
- getModel().endRecording(this, cursorPosition, selectionLength);
- break;
- case PASTE :
- getModel().beginRecording(this, TEXT_PASTE, TEXT_PASTE, cursorPosition, selectionLength);
- super.doOperation(operation);
- selection = getTextWidget().getSelection();
- cursorPosition = selection.x;
- selectionLength = selection.y - selection.x;
- getModel().endRecording(this, cursorPosition, selectionLength);
- break;
- case CONTENTASSIST_PROPOSALS :
- // maybe not configured?
- if (fContentAssistant != null) {
- // CMVC 263269
- // need an explicit check here because the
- // contentAssistAction is no longer being updated on
- // cursor
- // position
- if (canDoOperation(CONTENTASSIST_PROPOSALS)) {
- String err = fContentAssistant.showPossibleCompletions();
- if(err != null) {
- // don't wanna beep if there is no error
- PlatformStatusLineUtil.displayErrorMessage(err);
- }
- PlatformStatusLineUtil.addOneTimeClearListener();
- }
- else
- beep();
- }
- break;
- case CONTENTASSIST_CONTEXT_INFORMATION :
- if (fContentAssistant != null) {
- String err = fContentAssistant.showContextInformation();
- PlatformStatusLineUtil.displayErrorMessage(err);
- PlatformStatusLineUtil.addOneTimeClearListener();
- //setErrorMessage(err);
- //new OneTimeListener(getTextWidget(), new ClearErrorMessage());
- }
- break;
- case QUICK_FIX :
- String msg = fCorrectionAssistant.showPossibleCompletions();
- setErrorMessage(msg);
- break;
- case SHIFT_RIGHT :
- getModel().beginRecording(this, TEXT_SHIFT_RIGHT, TEXT_SHIFT_RIGHT, cursorPosition, selectionLength);
- super.doOperation(SHIFT_RIGHT);
- selection = getTextWidget().getSelection();
- cursorPosition = selection.x;
- selectionLength = selection.y - selection.x;
- getModel().endRecording(this, cursorPosition, selectionLength);
- break;
- case SHIFT_LEFT :
- getModel().beginRecording(this, TEXT_SHIFT_LEFT, TEXT_SHIFT_LEFT, cursorPosition, selectionLength);
- super.doOperation(SHIFT_LEFT);
- selection = getTextWidget().getSelection();
- cursorPosition = selection.x;
- selectionLength = selection.y - selection.x;
- getModel().endRecording(this, cursorPosition, selectionLength);
- break;
- case FORMAT_DOCUMENT :
- try {
- // begin recording
- getModel().beginRecording(this, FORMAT_DOCUMENT_TEXT, FORMAT_DOCUMENT_TEXT, cursorPosition, selectionLength);
-
- // tell the model that we are about to make a big model
- // change
- fModel.aboutToChangeModel();
-
- // format
- IRegion region = getModelCoverage();
- if (fContentFormatter instanceof IContentFormatterExtension) {
- IContentFormatterExtension extension = (IContentFormatterExtension) fContentFormatter;
- IFormattingContext context = new FormattingContext();
- context.setProperty(FormattingContextProperties.CONTEXT_DOCUMENT, Boolean.TRUE);
- context.setProperty(FormattingContextProperties.CONTEXT_REGION, region);
- extension.format(getDocument(), context);
- }
- else {
- fContentFormatter.format(getDocument(), region);
- }
- }
- finally {
- // tell the model that we are done with the big model
- // change
- fModel.changedModel();
-
- // end recording
- selection = getTextWidget().getSelection();
- cursorPosition = selection.x;
- selectionLength = selection.y - selection.x;
- getModel().endRecording(this, cursorPosition, selectionLength);
- }
- break;
- case FORMAT_ACTIVE_ELEMENTS :
- try {
- // begin recording
- getModel().beginRecording(this, FORMAT_ACTIVE_ELEMENTS_TEXT, FORMAT_ACTIVE_ELEMENTS_TEXT, cursorPosition, selectionLength);
-
- // tell the model that we are about to make a big model
- // change
- fModel.aboutToChangeModel();
-
- // format
- Point s = getSelectedRange();
- IRegion region = new Region(s.x, s.y);
- fContentFormatter.format(getDocument(), region);
- }
- finally {
- // tell the model that we are done with the big model
- // change
- fModel.changedModel();
-
- // end recording
- selection = getTextWidget().getSelection();
- cursorPosition = selection.x;
- selectionLength = selection.y - selection.x;
- getModel().endRecording(this, cursorPosition, selectionLength);
- }
- break;
- default :
- super.doOperation(operation);
- }
- }
-
- /**
- * Notifies of a double click.
- *
- * @param event event object describing the double-click
- */
- public void doubleClick(DoubleClickEvent event) {
-
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- int selectionSize = selection.size();
- List selectedNodes = selection.toList();
- IndexedRegion doubleClickedNode = null;
- int selectionStart = 0;
- int selectionEnd = 0;
- if (selectionSize > 0) {
- // something selected
- // only one node can be double-clicked at a time
- // so, we get node 0
- doubleClickedNode = (IndexedRegion) selectedNodes.get(0);
- selectionStart = doubleClickedNode.getStartOffset();
- selectionEnd = doubleClickedNode.getEndOffset();
- // set new selection
- setSelectedRange(selectionStart, selectionEnd - selectionStart);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.TextViewer#findAndSelect(int,
- * java.lang.String, boolean, boolean, boolean, boolean)
- */
- protected int findAndSelect(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord, boolean regExSearch) {
- int result = super.findAndSelect(startPosition, findString, forwardSearch, caseSensitive, wholeWord, regExSearch);
-
- // findAndSelect calls fTextWidget.setSelectionRange(widgetPos, length) to set selection,
- // which does not fire text widget selection event.
- // Need to notify ViewerSelectionManager here.
- notifyViewerSelectionManager(getSelectedRange().x, getSelectedRange().y);
-
- return result;
- }
-
- protected IExtendedSimpleEditor getActiveExtendedSimpleEditor() {
- AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
- IWorkbenchWindow window = plugin.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor != null && editor instanceof IExtendedSimpleEditor) {
- return (IExtendedSimpleEditor) editor;
- }
- }
- }
- return null;
- }
-
-
- protected ViewerSelectionManager getDefaultViewerSelectionManager() {
- return new ViewerSelectionManagerImpl(this);
- }
-
- /**
- * @deprecated -- will be removed, or made protected in future.
- */
- public IStructuredModel getModel() {
-
- return fModel;
- }
-
- public ViewerSelectionManager getViewerSelectionManager() {
-
- if (fViewerSelectionManager == null) {
- ViewerSelectionManager viewerSelectionManager = getDefaultViewerSelectionManager();
- // use setter instead of field directly, so it get initialized
- // properly
- setViewerSelectionManager(viewerSelectionManager);
- }
- return fViewerSelectionManager;
- }
-
- protected void handleDispose() {
-
- Logger.trace("Source Editor", "StructuredTextViewer::handleDispose entry"); //$NON-NLS-1$ //$NON-NLS-2$
-
- // before we dispose, we set a special "empty" selection, to prevent
- // the "leak one document" that
- // otherwise occurs when editor closed (since last selection stays in
- // SelectedResourceManager.
- // the occurance of the "leak" isn't so bad, but makes debugging other
- // leaks very hard.
- setSelection(TextSelection.emptySelection());
-
- if (fViewerSelectionManager != null) {
- fViewerSelectionManager.removeNodeDoubleClickListener(this);
- fViewerSelectionManager.removeNodeSelectionListener(this);
- fViewerSelectionManager.release();
- }
- if ((fUndoManager != null) && (fUndoManager instanceof StructuredTextUndoManager)) {
- ((StructuredTextUndoManager) fUndoManager).disconnect(this);
- fUndoManager = null;
- }
- if (fHighlighter != null) {
- fHighlighter.uninstall();
- }
- super.handleDispose();
- // todo: make this setModel(null)
- fModel = null;
- Logger.trace("Source Editor", "StructuredTextViewer::handleDispose exit"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * TODO Temporary workaround for BUG44665
- */
- /**
- * overridden for read-only support
- */
-/* protected void handleVerifyEvent(VerifyEvent e) {
-
- // for now, we'll let super have a shot first
- // (may mess up undo stack, or something?)
-
- super.handleVerifyEvent(e);
- if (containsReadOnly(getVisibleDocument(), e.start, e.end)) {
- e.doit = false;
- beep();
- }
- }*/
-
- /**
- * nodeSelectionChanged method comment.
- */
- public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
-
- // Skip NodeSelectionChanged processing if this is the source of the
- // event.
- if (event.getSource().equals(this))
- return;
- List selectedNodes = new Vector(event.getSelectedNodes());
- boolean attrOrTextNodeSelected = false;
- int attrOrTextNodeStartOffset = 0;
- for (int i = 0; i < selectedNodes.size(); i++) {
- Object eachNode = selectedNodes.get(i);
- // replace attribute node with its parent
- if (eachNode instanceof Attr) {
- attrOrTextNodeSelected = true;
- attrOrTextNodeStartOffset = ((IndexedRegion) eachNode).getStartOffset();
- selectedNodes.set(i, ((Attr) eachNode).getOwnerElement());
- }
- // replace TextNode with its parent
- if ((eachNode instanceof Node) && (((Node) eachNode).getNodeType() == Node.TEXT_NODE)) {
- attrOrTextNodeSelected = true;
- attrOrTextNodeStartOffset = ((IndexedRegion) eachNode).getStartOffset();
- selectedNodes.set(i, ((Node) eachNode).getParentNode());
- }
- }
- if (nothingToSelect(selectedNodes)) {
- removeRangeIndication();
- }
- else {
- IndexedRegion startNode = (IndexedRegion) selectedNodes.get(0);
- IndexedRegion endNode = (IndexedRegion) selectedNodes.get(selectedNodes.size() - 1);
- int startOffset = startNode.getStartOffset();
- int endOffset = endNode.getEndOffset();
- // if end node is a child node of start node
- if (startNode.getEndOffset() > endNode.getEndOffset()) {
- endOffset = startNode.getEndOffset();
- }
- int length = endOffset - startOffset;
- // Move cursor only if the original source really came from
- // a ContentViewer (for example, the SourceEditorTreeViewer or the
- // XMLTableTreeViewer)
- // or a ContentOutlinePage (for example, the XSDTreeViewer).
- // Do not move the cursor if the source is a textWidget (which
- // means the selection came from the text viewer) or
- // if the source is the ViewerSelectionManager (which means the
- // selection was set programmatically).
- boolean moveCursor = (event.getSource() instanceof ContentViewer) || (event.getSource() instanceof IContentOutlinePage);
- // 20031012 (pa)
- // Changed moveCursor to "false" because it was causing the cursor
- // to jump to the beginning of the parent node in the case that a
- // child of the parent is deleted.
- // We really only want to set the range indicator on the left to
- // the range of the parent, but not move the cursor
- //setRangeIndication(startOffset, length, false);
- // 20040714 (nsd) Chnaged back to tru given that selection problems
- // caused by the Outline view appear fixed.
- setRangeIndication(startOffset, length, moveCursor);
- if ((moveCursor) && (attrOrTextNodeSelected)) {
- setSelectedRange(attrOrTextNodeStartOffset, 0);
- revealRange(attrOrTextNodeStartOffset, 0);
- }
-// if(moveCursor) {
-// System.out.print("moving");
-// }
-// else {
-// System.out.print("not moving");
-// }
-// System.out.println(" on NodeSelectionEvent: " + event.getSource());
- }
- }
-
- /**
- * @param selectedNodes
- * @return whether the IndexedNodes within the list should form a
- * selectionrange
- */
- private boolean nothingToSelect(List selectedNodes) {
- if (selectedNodes == null || selectedNodes.isEmpty() || selectedNodes.get(0) == null) // empty selections
- return true;
- if (getDocument() == null) // viewer shutdown
- return true;
- // if the range would be the entire document's length, there's nothing
- // to show
- IndexedRegion firstIndexedNode = (IndexedRegion) selectedNodes.get(0);
- return firstIndexedNode.getEndOffset() - firstIndexedNode.getStartOffset() >= getDocument().getLength();
- }
-
- /**
- * Use the active editor to set a status line message
- *
- * @param msg
- */
- protected void setErrorMessage(String msg) {
- AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
- IWorkbenchWindow window = plugin.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- IEditorStatusLine statusLine = (IEditorStatusLine) editor.getAdapter(IEditorStatusLine.class);
- if (statusLine != null)
- statusLine.setMessage(true, msg, null);
- }
- }
- }
- }
-
- public void setModel(IStructuredModel model) {
-
- setModel(model, null);
- }
-
- public void setModel(IStructuredModel model, IAnnotationModel annotationModel) {
- // due to various forms of init, sometimes
- // the same variable is set more than once
- // with the same data, causing unneccesary updates, so
- // we do nothing if someones' trying to set the same
- // model we already have
- //
- if ((fModel != null) && (fModel == model) && (getDocument() == model.getStructuredDocument())) {
- return;
- }
- fModel = model;
- setDocument(model.getStructuredDocument(), annotationModel);
- // notify highlighter
- if (fHighlighter != null) {
- fHighlighter.setDocument(model.getStructuredDocument());
- //fHighlighter.setModel(model);
- }
- StructuredTextUndoManager undoManager = (model == null) ? null : model.getUndoManager();
- // create a new one if the current one is not the right type
- if (undoManager == null)
- undoManager = new StructuredTextUndoManagerImpl();
- // there are side effects in setUndoManager
- setUndoManager(undoManager);
- // set undo manager for model
- model.setUndoManager(undoManager);
-
- // CaretEvent is not sent to ViewerSelectionManager after Save As.
- // Need to notify ViewerSelectionManager here.
- notifyViewerSelectionManager(getSelectedRange().x, getSelectedRange().y);
- }
-
- public void setUndoManager(IUndoManager undoManager) {
-
- // note: normally the connect/disconnect are done elsewhere
- // but while fixing defect 215714 found that in some cases its
- // being done too late. So, went ahead and did here. So, need
- // to be sure connect and disconnect can be called multiple times
- // with no harm done.
-
- // if we already have an undoManager, then presumably it was set as a
- // text change listner already.
- // so we'll remove it (as long as it was truely one of our
- // StructuredtextUndoManagers.)
- if ((fUndoManager != null) && (fViewerSelectionManager != null) && (fUndoManager instanceof StructuredTextUndoManager) && (fUndoManager instanceof ITextSelectionListener)) {
- fViewerSelectionManager.removeTextSelectionListener((ITextSelectionListener) fUndoManager);
- ((StructuredTextUndoManager) fUndoManager).disconnect(this);
- }
- super.setUndoManager(undoManager);
- if ((fUndoManager != null) && (fViewerSelectionManager != null) && (fUndoManager instanceof StructuredTextUndoManager) && (fUndoManager instanceof ITextSelectionListener)) {
- fViewerSelectionManager.addTextSelectionListener((ITextSelectionListener) fUndoManager);
- fUndoManager.connect(this);
- }
- }
-
- public void setViewerSelectionManager(ViewerSelectionManager viewerSelectionManager) {
-
- // disconnect from old one
- if (fViewerSelectionManager != null) {
- if ((fUndoManager != null) && (fUndoManager instanceof StructuredTextUndoManager) && (fUndoManager instanceof ITextSelectionListener)) {
- fViewerSelectionManager.removeTextSelectionListener((ITextSelectionListener) fUndoManager);
- }
- fViewerSelectionManager.removeNodeDoubleClickListener(this);
- fViewerSelectionManager.removeNodeSelectionListener(this);
- fViewerSelectionManager.release();
- // No need to removeSelectionChangedListener here. Done when
- // editor
- // calls "new ViewerSelectionManagerImpl(ITextViewer)".
- //removeSelectionChangedListener(fViewerSelectionManager);
- }
- fViewerSelectionManager = viewerSelectionManager;
- // connect to new one
- if (fViewerSelectionManager != null) {
- if ((fUndoManager != null) && (fUndoManager instanceof StructuredTextUndoManager) && (fUndoManager instanceof ITextSelectionListener)) {
- fViewerSelectionManager.addTextSelectionListener((ITextSelectionListener) fUndoManager);
- }
- fViewerSelectionManager.addNodeDoubleClickListener(this);
- fViewerSelectionManager.addNodeSelectionListener(this);
- // No need to addSelectionChangedListener here. Done when editor
- // calls "new ViewerSelectionManagerImpl(ITextViewer)".
- //addSelectionChangedListener(fViewerSelectionManager);
- }
- }
-
- /**
- * Uninstalls anything that was installed by configure
- */
- public void unconfigure() {
-
- Logger.trace("Source Editor", "StructuredTextViewer::unconfigure entry"); //$NON-NLS-1$ //$NON-NLS-2$
- if (fHighlighter != null) {
- fHighlighter.uninstall();
- }
- if (fPresentationReconciler != null) {
- fPresentationReconciler.uninstall();
- fPresentationReconciler = null;
- }
- if (fReconciler != null) {
- fReconciler.uninstall();
- fReconciler = null;
- }
- if (fContentAssistant != null) {
- fContentAssistant.uninstall();
- fContentAssistantInstalled = false;
- }
- if (fInformationPresenter != null)
- fInformationPresenter.uninstall();
-
- // doesn't seem to be handled elsewhere, so we'll be sure error
- // messages's are cleared.
- setErrorMessage(null);
-
- // unconfigure recently added to super class?!
- super.unconfigure();
- Logger.trace("Source Editor", "StructuredTextViewer::unconfigure exit"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Notify the ViewerSelectionManager when text is selected
- * programmatically, for example, by double-click processing or an editor
- * action like Edit->SelectAll
- */
- protected void notifyViewerSelectionManager(int offset, int length) {
- if (fViewerSelectionManager != null) {
- Event event = new Event();
- event.widget = getTextWidget();
- // sometimes null while closing
- if (event.widget != null) {
- SelectionEvent selectionEvent = new SelectionEvent(event);
- selectionEvent.x = offset;
- selectionEvent.y = length;
- fViewerSelectionManager.widgetSelected(selectionEvent);
- }
- }
- }
-
- /**
- * This method added to override super's implementation so that
- * setVisibleRegion will not force a start at beginning of line. This was
- * primarily needed when used as embedded editor. May need to make more
- * sophisiticated if we need it to act both ways, depending on a flag, or
- * something.
- */
- protected boolean updateVisibleDocument(IDocument visibleDocument, int visibleRegionOffset, int visibleRegionLength) throws BadLocationException {
- if (visibleDocument instanceof ChildDocument) {
- ChildDocument childDocument = (ChildDocument) visibleDocument;
- //IDocument document = childDocument.getParentDocument();
- //int line= document.getLineOfOffset(visibleRegionOffset);
- int offset = visibleRegionOffset; //document.getLineOffset(line);
- int length = visibleRegionLength; //(visibleRegionOffset -
- // offset)
- // + visibleRegionLength;
- Position parentRange = childDocument.getParentDocumentRange();
- if (offset != parentRange.getOffset() || length != parentRange.getLength()) {
- childDocument.setParentDocumentRange(offset, length);
- return true;
- }
- }
- return false;
- }
-
- /**
- * TODO Temporary workaround for BUG44665
- */
- /**
- * Internal verify listener.
- */
- class TextVerifyListener implements VerifyListener {
-
- /**
- * Indicates whether verify events are forwarded or ignored.
- * @since 2.0
- */
- private boolean fForward= true;
-
- /**
- * Tells the listener to forward received events.
- *
- * @param forward <code>true</code> if forwarding should be enabled.
- * @since 2.0
- */
- public void forward(boolean forward) {
- fForward= forward;
- }
-
- /*
- * @see VerifyListener#verifyText(VerifyEvent)
- */
- public void verifyText(VerifyEvent e) {
- if (fForward)
- handleVerifyEvent(e);
- }
- }
-
- /**
- * TODO Temporary workaround for BUG44665
- */
- /** Verify listener */
- private TextVerifyListener fVerifyListener= new TextVerifyListener();
- /**
- * TODO Temporary workaround for BUG44665
- */
- /** The most recent widget modification as document command */
- private StructuredDocumentCommand fDocumentCommand= new StructuredDocumentCommand();
-
- /**
- * TODO Temporary workaround for BUG44665
- */
- /**
- * @see VerifyListener#verifyText(VerifyEvent)
- */
- protected void handleVerifyEvent(VerifyEvent e) {
-
- // for read-only support
- if (containsReadOnly(getVisibleDocument(), e.start, e.end)) {
- e.doit = false;
- beep();
- return;
- }
-
- if (fEventConsumer != null) {
- fEventConsumer.processEvent(e);
- if (!e.doit)
- return;
- }
-
- IRegion modelRange= event2ModelRange(e);
- fDocumentCommand.setEvent(e, modelRange);
- customizeDocumentCommand(fDocumentCommand);
- int widgetCaret = 0;
- if (!fDocumentCommand.fillEvent(e, modelRange)) {
-
- boolean compoundChange= fDocumentCommand.getCommandCount() > 1;
- try {
-
- fVerifyListener.forward(false);
-
- if (compoundChange && fUndoManager != null)
- fUndoManager.beginCompoundChange();
-
- if (getSlaveDocumentManager() != null) {
- IDocument visible= getVisibleDocument();
- try {
- getSlaveDocumentManager().setAutoExpandMode(visible, true);
- fDocumentCommand.execute(getDocument());
- } finally {
- getSlaveDocumentManager().setAutoExpandMode(visible, false);
- }
- } else {
- fDocumentCommand.execute(getDocument());
- }
-
- if (getTextWidget() != null) {
- int documentCaret= fDocumentCommand.caretOffset;
- if (documentCaret == -1) {
- // old behavior of document command
- documentCaret= fDocumentCommand.offset + (fDocumentCommand.text == null ? 0 : fDocumentCommand.text.length());
- }
-
- widgetCaret= modelOffset2WidgetOffset(documentCaret);
- if (widgetCaret == -1) {
- // try to move it to the closest spot
- IRegion region= getModelCoverage();
- if (documentCaret <= region.getOffset())
- widgetCaret= 0;
- else if (documentCaret >= region.getOffset() + region.getLength())
- widgetCaret= getVisibleRegion().getLength();
- }
-
- }
- } catch (BadLocationException x) {
-
- if (TRACE_ERRORS)
- System.out.println("TextViewer.error.bad_location.verifyText"); //$NON-NLS-1$
-
- } finally {
-
- if (compoundChange && fUndoManager != null)
- fUndoManager.endCompoundChange();
-
- if (widgetCaret != -1) {
- // there is a valid widget caret
- getTextWidget().setCaretOffset(widgetCaret);
- }
-
- getTextWidget().showSelection();
-
- fVerifyListener.forward(true);
-
- }
- }
- }
-
- /**
- * TODO Temporary workaround for BUG44665
- */
- protected void customizeDocumentCommand(StructuredDocumentCommand command) {
- if (isIgnoringAutoEditStrategies())
- return;
-
- List strategies= (List) selectContentTypePlugin(command.offset, fAutoIndentStrategies);
- if (strategies == null)
- return;
-
- switch (strategies.size()) {
- // optimization
- case 0:
- break;
-
- case 1:
- ((IAutoEditStrategy) strategies.iterator().next()).customizeDocumentCommand(getDocument(), command);
- break;
-
- // make iterator robust against adding/removing strategies from within strategies
- default:
- strategies= new ArrayList(strategies);
-
- IDocument document= getDocument();
- for (final Iterator iterator= strategies.iterator(); iterator.hasNext(); )
- ((IAutoEditStrategy) iterator.next()).customizeDocumentCommand(document, command);
-
- break;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewerConfiguration.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewerConfiguration.java
deleted file mode 100644
index cfa3eb34bb..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/StructuredTextViewerConfiguration.java
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.IInformationControl;
-import org.eclipse.jface.text.IInformationControlCreator;
-import org.eclipse.jface.text.IUndoManager;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.presentation.IPresentationReconciler;
-import org.eclipse.jface.text.source.IAnnotationHover;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.ui.contentassist.IResourceDependentProcessor;
-import org.eclipse.wst.sse.ui.extension.IExtendedConfiguration;
-import org.eclipse.wst.sse.ui.internal.editor.HTMLTextPresenter;
-import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorBuilder;
-import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorMetaData;
-import org.eclipse.wst.sse.ui.internal.reconcile.validator.ValidatorStrategy;
-import org.eclipse.wst.sse.ui.internal.taginfo.DebugInfoHoverProcessor;
-import org.eclipse.wst.sse.ui.style.Highlighter;
-import org.eclipse.wst.sse.ui.style.IHighlighter;
-import org.eclipse.wst.sse.ui.taginfo.TextHoverManager;
-import org.eclipse.wst.sse.ui.util.EditorUtility;
-
-
-/**
- * Configuration for a TextViewer that shows Structured Text (XML)
- */
-public class StructuredTextViewerConfiguration extends SourceViewerConfiguration implements IExtendedConfiguration {
-
- public static final String ID = "textviewerconfiguration"; //$NON-NLS-1$
- protected String[] configuredContentTypes;
- protected IEditorPart editorPart;
- protected IContentAssistant fContentAssistant;
- private List fContentAssistProcessors = null;
- protected IContentAssistant fCorrectionAssistant;
- protected IHighlighter fHighlighter;
- protected StructuredTextReconciler fReconciler;
- protected IResource fResource = null;
- protected final String SSE_MODEL_ID = "org.eclipse.wst.sse.core"; // $NON-NLS-1$ //$NON-NLS-1$
- protected final String SSE_EDITOR_ID = "org.eclipse.wst.sse.ui"; // $NON-NLS-1$ //$NON-NLS-1$
- private String fDeclaringID;
- /**
- * @deprecated this should no longer be used (debug info hover help is part of bestmatch hover) TODO remove
- */
- protected DebugInfoHoverProcessor debugInfoHoverProcessor = null;
-
- /**
- * Default constructor.
- */
- public StructuredTextViewerConfiguration() {
- super();
- fContentAssistProcessors = new ArrayList();
- }
-
- /**
- * Content assist processors should be added to the ContentAssistant via
- * this method so that they are initialized/released properly.
- *
- * @param ca
- * @param processor
- * @param partitionType
- */
- public void addContentAssistProcessor(ContentAssistant ca, IContentAssistProcessor processor, String partitionType) {
-
- // save for reinit and release
- fContentAssistProcessors.add(processor);
- if (processor instanceof IResourceDependentProcessor)
- ((IResourceDependentProcessor) processor).initialize(fResource);
- ca.setContentAssistProcessor(processor, partitionType);
- }
-
- public void configureOn(IResource resource) {
-
- fResource = resource;
- updateForResource();
- }
-
- protected ValidatorStrategy createValidatorStrategy(String contentTypeId) {
-
- ValidatorStrategy validatorStrategy = new ValidatorStrategy((ITextEditor) editorPart, contentTypeId);
- ValidatorBuilder vBuilder = new ValidatorBuilder();
- ValidatorMetaData[] vmds = vBuilder.getValidatorMetaData("org.eclipse.wst.sse.ui.extensions"); //$NON-NLS-1$
- for (int i = 0; i < vmds.length; i++) {
- if (vmds[i].canHandleContentType(contentTypeId))
- validatorStrategy.addValidatorMetaData(vmds[i]);
- }
- return validatorStrategy;
- }
-
- /**
- * Returns the annotation hover which will provide the information to be
- * shown in a hover popup window when requested for the given source
- * viewer.
- *
- * @param sourceViewer
- * the source viewer to be configured by this configuration
- * @return an annotation hover or <code>null</code> if no hover support
- * should be installed
- */
- public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
-
- return new StructuredTextAnnotationHover();
- }
-
- /**
- * @param sourceViewer
- * @return a Map of partition content types to java.util.List of
- * IAutoEditStrategy objects
- */
- public Map getAutoEditStrategies(ISourceViewer sourceViewer) {
- return new HashMap();
- }
-
- /**
- * @see ISourceViewerConfiguration#getContentAssistant
- */
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
-
- if (fContentAssistant == null) {
- // Ensure that only one assistant is ever returned. Creating a
- // second assistant
- // that is added to a viewer can cause odd key-eating by the wrong
- // one.
- ContentAssistant assistant = new ContentAssistant();
- // content assistant configurations
- assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
- assistant.enableAutoActivation(true);
- assistant.setAutoActivationDelay(500);
- assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
- assistant.setContextInformationPopupOrientation(IContentAssistant.CONTEXT_INFO_ABOVE);
- assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer));
- fContentAssistant = assistant;
- }
- updateForResource();
- return fContentAssistant;
- }
-
- public IContentAssistant getCorrectionAssistant(ISourceViewer sourceViewer) {
-
- if (fCorrectionAssistant == null) {
- // Ensure that only one assistant is ever returned. Creating a
- // second assistant
- // that is added to a viewer can cause odd key-eating by the wrong
- // one.
- ContentAssistant assistant = new ContentAssistant();
- assistant.setDocumentPartitioning(getConfiguredDocumentPartitioning(sourceViewer));
- fCorrectionAssistant = assistant;
- }
- updateForResource();
- return fCorrectionAssistant;
- }
-
- /**
- * @return Returns the editorPart.
- */
- public IEditorPart getEditorPart() {
-
- return editorPart;
- }
-
- public IHighlighter getHighlighter(ISourceViewer viewer) {
-
- // assuming for now that only one highlighter is needed per
- // configuration,
- // and that its just configured for lots of different content types.
- // In the future, this may change, if its tied closer to the acutual
- // content
- // type (for example, made specifc for HTML vs. XML). I think it would
- // be little
- // imact to create a new instance each time.
- if (fHighlighter != null) {
- fHighlighter.uninstall();
- }
- else {
- fHighlighter = new Highlighter();
- }
- fHighlighter.setDocument((IStructuredDocument) ((StructuredTextViewer) viewer).getDocument());
- return fHighlighter;
- }
-
- /*
- * @see SourceViewerConfiguration#getHoverControlCreator(ISourceViewer)
- */
- public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) {
-
- return getInformationControlCreator(sourceViewer, false);
- }
-
- private IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer, final boolean cutDown) {
-
- return new IInformationControlCreator() {
-
- public IInformationControl createInformationControl(Shell parent) {
-
- //int style= cutDown ? SWT.NONE : (SWT.V_SCROLL |
- // SWT.H_SCROLL);
- int style = SWT.NONE;
- return new DefaultInformationControl(parent, style, new HTMLTextPresenter(cutDown));
- }
- };
- }
-
- /**
- * Returns the information presenter control creator. The creator is a
- * factory creating the presenter controls for the given source viewer.
- * This implementation always returns a creator for <code>DefaultInformationControl</code>
- * instances. (Copied from JavaSourceViewerConfiguration)
- *
- * @param sourceViewer
- * the source viewer to be configured by this configuration
- * @return an information control creator
- */
- protected IInformationControlCreator getInformationPresenterControlCreator(ISourceViewer sourceViewer) {
-
- return new IInformationControlCreator() {
-
- public IInformationControl createInformationControl(Shell parent) {
-
- int shellStyle = SWT.RESIZE;
- int style = SWT.V_SCROLL | SWT.H_SCROLL;
- return new DefaultInformationControl(parent, shellStyle, style, new HTMLTextPresenter(false));
- }
- };
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getOverviewRulerAnnotationHover(org.eclipse.jface.text.source.ISourceViewer)
- */
- public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer arg0) {
-
- return new StructuredTextAnnotationHover();
- }
-
- protected ITextEditor getTextEditor() {
-
- ITextEditor editor = null;
- if (editorPart instanceof ITextEditor)
- editor = (ITextEditor) editorPart;
- if (editor == null && editorPart != null)
- editor = (ITextEditor) editorPart.getAdapter(ITextEditor.class);
- return editor;
- }
-
- /**
- * @see ISourceViewerConfiguration#getUndoManager
- */
- public IUndoManager getUndoManager(ISourceViewer sourceViewer) {
-
- return new StructuredTextUndoManagerImpl();
- }
-
- /**
- * @param editorPart
- * The editorPart to set.
- */
- public void setEditorPart(IEditorPart editorPart) {
-
- this.editorPart = editorPart;
- }
-
- /**
- * This method is allow any cleanup to take place that is not otherwise
- * done in the viewer's unConfigure method. In some cases, things may be
- * done "twice" ... so uninstall, release, etc., should be prepared.
- */
- public void unConfigure(ISourceViewer viewer) {
-
- editorPart = null;
- // if there's any processor's we're hanging on to,
- // be sure they have a chance to clean themselves up.
- if (fHighlighter != null) {
- fHighlighter.uninstall();
- }
- if (fContentAssistant != null) {
- fContentAssistant.uninstall();
- }
- if (fReconciler != null) {
- fReconciler.uninstall();
- }
- if (fContentAssistant != null) {
- unconfigureContentAssistProcessors();
- }
- }
-
- /**
- *
- */
- private void unconfigureContentAssistProcessors() {
-
- if (!fContentAssistProcessors.isEmpty()) {
- Iterator it = fContentAssistProcessors.iterator();
- IContentAssistProcessor p = null;
- while (it.hasNext()) {
- p = (IContentAssistProcessor) it.next();
- if (p instanceof IReleasable)
- ((IReleasable) p).release();
- }
- }
- }
-
- protected void updateForResource() {
-
- if (!fContentAssistProcessors.isEmpty()) {
- Iterator it = fContentAssistProcessors.iterator();
- IContentAssistProcessor p = null;
- while (it.hasNext()) {
- p = (IContentAssistProcessor) it.next();
- if (p instanceof IResourceDependentProcessor)
- ((IResourceDependentProcessor) p).initialize(fResource);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void setDeclaringID(String targetID) {
-
- fDeclaringID = targetID;
- }
-
- /**
- * @return Returns the declaringID.
- */
- public String getDeclaringID() {
-
- return fDeclaringID;
- }
-
- /**
- * use this constructor to have reconciler
- */
- public StructuredTextViewerConfiguration(IEditorPart textEditor) {
-
- this();
- editorPart = textEditor;
- }
-
- public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
-
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getTabWidth(org.eclipse.jface.text.source.ISourceViewer)
- */
- public int getTabWidth(ISourceViewer sourceViewer) {
- return ((AbstractUIPlugin)Platform.getPlugin(EditorPlugin.ID)).getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
- }
-
- /*
- * @see SourceViewerConfiguration#getConfiguredTextHoverStateMasks(ISourceViewer, String)
- * @since 2.1
- */
- public int[] getConfiguredTextHoverStateMasks(ISourceViewer sourceViewer, String contentType) {
- // content type does not matter when getting hover state mask
- TextHoverManager.TextHoverDescriptor[] hoverDescs= EditorPlugin.getDefault().getTextHoverManager().getTextHovers();
- int stateMasks[]= new int[hoverDescs.length];
- int stateMasksLength= 0;
- for (int i= 0; i < hoverDescs.length; i++) {
- if (hoverDescs[i].isEnabled()) {
- int j= 0;
- int stateMask= EditorUtility.computeStateMask(hoverDescs[i].getModifierString());
- while (j < stateMasksLength) {
- if (stateMasks[j] == stateMask)
- break;
- j++;
- }
- if (j == stateMasksLength)
- stateMasks[stateMasksLength++]= stateMask;
- }
- }
- if (stateMasksLength == hoverDescs.length)
- return stateMasks;
-
- int[] shortenedStateMasks= new int[stateMasksLength];
- System.arraycopy(stateMasks, 0, shortenedStateMasks, 0, stateMasksLength);
- return shortenedStateMasks;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/TextFileModelProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/TextFileModelProvider.java
deleted file mode 100644
index d343506028..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/TextFileModelProvider.java
+++ /dev/null
@@ -1,466 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.AnnotationModel;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.editors.text.FileDocumentProvider;
-import org.eclipse.ui.editors.text.ILocationProvider;
-import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.eclipse.ui.texteditor.IElementStateListener;
-import org.eclipse.wst.sse.core.FactoryRegistry;
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.IExtendedStorageEditorInput;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryProvider;
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistry;
-
-
-/**
- * A TextFileDocumentProvider that is IStructuredModel aware. This
- * implementation is marked as final since it will change significantly in C4,
- * possibly even be removed.
- */
-public final class TextFileModelProvider extends TextFileDocumentProvider implements IModelProvider {
-
- /**
- * Collection of info that goes with a model.
- */
- protected class ModelInfo {
- public IAnnotationModel fAnnotationModel;
- public IEditorInput fElement;
- public boolean fShouldReleaseOnInfoDispose;
- public IStructuredModel fStructuredModel;
-
- public ModelInfo(IStructuredModel structuredModel, IEditorInput element, IAnnotationModel model, boolean selfCreated) {
- fElement = element;
- fStructuredModel = structuredModel;
- fAnnotationModel = model;
- fShouldReleaseOnInfoDispose = selfCreated;
- }
- }
-
- private static TextFileModelProvider fInstance = null;
- private static IModelManager fModelManager;
-
- public synchronized static TextFileModelProvider getInstance() {
- if (fInstance == null)
- fInstance = new TextFileModelProvider();
- return fInstance;
- }
-
- /**
- * Utility method also used in subclasses
- */
- protected static IModelManager getModelManager() {
- if (fModelManager == null) {
- // get the model manager from the plugin
- // note: we can use the static "ID" variable, since we pre-req
- // that plugin
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- fModelManager = plugin.getModelManager();
- }
- return fModelManager;
- }
-
- protected IElementStateListener fInternalListener;
- /** IStructuredModel information of all connected elements */
- private Map fModelInfoMap = new HashMap();
-
- protected TextFileModelProvider() {
- super();
- }
-
- public void addProviderFactories(IStructuredModel structuredModel) {
- // (mostly) COPIED FROM FileModelProvider
- EditorPlugin plugin = ((EditorPlugin) Platform.getPlugin(EditorPlugin.ID));
- AdapterFactoryRegistry adapterRegistry = plugin.getAdapterFactoryRegistry();
- Iterator adapterFactoryList = adapterRegistry.getAdapterFactories();
-
- IFactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
- if (factoryRegistry == null) {
- factoryRegistry = new FactoryRegistry();
- structuredModel.setFactoryRegistry(factoryRegistry);
- }
-
- while (adapterFactoryList.hasNext()) {
- try {
- AdapterFactoryProvider provider = (AdapterFactoryProvider) adapterFactoryList.next();
- if (provider.isFor(structuredModel.getModelHandler())) {
- provider.addAdapterFactories(structuredModel);
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- // END COPY FileModelProvider
- }
-
- protected String computePath(IEditorInput input) {
- /**
- * Typically CVS will return a path of "filename.ext" and the input's
- * name will be "filename.ext version". The path must be used to load
- * the model so that the suffix will be available to compute the
- * contentType properly. The editor input name can then be set as the
- * base location for display on the editor title bar.
- */
- String path = null;
- boolean addHash = false;
- try {
- if (input instanceof IStorageEditorInput) {
- IStorage storage = ((IStorageEditorInput) input).getStorage();
- if (storage != null) {
- IPath storagePath = storage.getFullPath();
- String name = storage.getName();
- // if either the name or storage path are null or they are
- // identical, add a hash to it to guarantee uniqueness
- addHash = storagePath == null || storagePath.toString().equals(name);
- if (storagePath != null)
- path = storagePath.makeAbsolute().toString();
- if (path == null)
- path = name;
- }
- }
- else if (input.getAdapter(ILocationProvider.class) != null) {
- IPath locationPath = ((ILocationProvider) input.getAdapter(ILocationProvider.class)).getPath(input);
- if (locationPath != null) {
- path = locationPath.toString();
- }
- }
-
- }
- catch (CoreException e) {
- Logger.logException(e);
- return null;
- }
- finally {
- if (path == null)
- path = ""; //$NON-NLS-1$
- }
- if (addHash)
- path = input.hashCode() + path;
- return path;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#commitFileBuffer(org.eclipse.core.runtime.IProgressMonitor,
- * org.eclipse.ui.editors.text.TextFileDocumentProvider.FileInfo,
- * boolean)
- */
- protected void commitFileBuffer(IProgressMonitor monitor, FileInfo info, boolean overwrite) throws CoreException {
- IStructuredModel model = getModel(info.fElement);
- if (model != null) {
- String contents = model.getStructuredDocument().get();
- info.fTextFileBuffer.getDocument().set(contents);
- }
- super.commitFileBuffer(monitor, info, overwrite);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.editors.text.TextFileDocumentProvider#createAnnotationModel(org.eclipse.core.resources.IFile)
- */
- protected IAnnotationModel createAnnotationModel(IFile file) {
- String id = file.getFullPath().toString();
- IAnnotationModel model = new StructuredResourceMarkerAnnotationModel(file, id);
- IEditorInput input = null;
- Iterator i = getConnectedElementsIterator();
- while (input == null && i.hasNext()) {
- FileInfo info = (FileInfo) i.next();
- if (getSystemFile(info).equals(file)) {
- input = (IEditorInput) info.fElement;
- }
- }
- ModelInfo modelInfo = getModelInfoFor(input);
- modelInfo.fAnnotationModel = model;
- return model;
- }
-
- public IDocument getDocument(Object element) {
- return getModel(element).getStructuredDocument();
- }
-
- /**
- * Also create ModelInfo - extra resource synchronization classes should
- * be stored within the ModelInfo
- */
- protected FileInfo createFileInfo(Object element) throws CoreException {
- FileInfo info = super.createFileInfo(element);
- // create the corresponding ModelInfo if necessary
- if (getModelInfoFor((IEditorInput) element) == null) {
- createModelInfo((IEditorInput) element);
- }
-
- return info;
- }
-
- public void createModelInfo(IEditorInput input) {
- if (getModelInfoFor(input) == null) {
- IStructuredModel structuredModel = selfCreateModel(input);
- createModelInfo(input, structuredModel, true);
- }
- }
-
- /**
- * To be used when model is provided to us, ensures that when setInput is
- * used on this input, the given model will be used.
- */
- public void createModelInfo(IEditorInput input, IStructuredModel structuredModel, boolean releaseModelOnDisconnect) {
- // we have to make sure factories are added, whether we created or
- // not.
- if (getModelInfoFor(input) != null || getModelInfoFor(structuredModel) != null)
- return;
-
- if (input instanceof IExtendedStorageEditorInput) {
- ((IExtendedStorageEditorInput) input).addElementStateListener(fInternalListener);
- }
-
- addProviderFactories(structuredModel);
-
- ModelInfo modelInfo = new ModelInfo(structuredModel, input, null, releaseModelOnDisconnect);
- // to help with downstream usage, create a dummy/"null" annotation model
- if (!(input instanceof IFileEditorInput)) {
- modelInfo.fAnnotationModel = new AnnotationModel();
- }
- fModelInfoMap.put(input, modelInfo);
- }
-
- protected void disposeFileInfo(Object element, FileInfo info) {
- if (element instanceof IEditorInput) {
- IEditorInput input = (IEditorInput) element;
- ModelInfo modelInfo = getModelInfoFor(input);
- disposeModelInfo(modelInfo);
- }
- super.disposeFileInfo(element, info);
- }
-
- /**
- * disconnect from this model info
- *
- * @param info
- */
- public void disposeModelInfo(ModelInfo info) {
- if (info.fElement instanceof IStorageEditorInput) {
- if (info.fElement instanceof IExtendedStorageEditorInput) {
- ((IExtendedStorageEditorInput) info.fElement).removeElementStateListener(fInternalListener);
- }
- if (info.fShouldReleaseOnInfoDispose) {
- info.fStructuredModel.releaseFromEdit();
- }
- }
- fModelInfoMap.remove(info.fElement);
- }
-
- /**
- * @see org.eclipse.ui.texteditor.AbstractDocumentProvider#doSaveDocument(org.eclipse.core.runtime.IProgressMonitor,
- * java.lang.Object, org.eclipse.jface.text.IDocument, boolean)
- */
- protected void doSaveDocument(IProgressMonitor monitor, Object element, IDocument document, boolean overwrite) throws CoreException {
- new FileDocumentProvider().saveDocument(monitor, element, document, overwrite);
- }
-
- /**
- * Overridden to use ModelInfo's annotation model
- *
- * @see org.eclipse.ui.texteditor.IDocumentProvider#getAnnotationModel(java.lang.Object)
- */
- public IAnnotationModel getAnnotationModel(Object element) {
- // override behavior an retrieve the annotation model from the model
- // info
- ModelInfo info = getModelInfoFor((IEditorInput) element);
- if (info != null)
- return info.fAnnotationModel;
- return null;
- }
-
- protected IEditorInput getInputFor(IDocument document) {
- IStructuredModel model = getModelManager().getExistingModelForRead(document);
- IEditorInput input = getInputFor(model);
- model.releaseFromRead();
- return input;
- }
-
- protected IEditorInput getInputFor(IStructuredModel structuredModel) {
- IEditorInput result = null;
- ModelInfo info = getModelInfoFor(structuredModel);
- if (info != null)
- result = info.fElement;
- return result;
- }
-
- public IStructuredModel getModel(IEditorInput element) {
- IStructuredModel result = null;
- ModelInfo info = getModelInfoFor(element);
- if (info != null) {
- result = info.fStructuredModel;
- }
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IStructuredModel getModel(Object element) {
- if (element instanceof IEditorInput)
- return getModel((IEditorInput) element);
- return null;
- }
-
- protected ModelInfo getModelInfoFor(IEditorInput element) {
- ModelInfo result = (ModelInfo) fModelInfoMap.get(element);
- return result;
- }
-
- protected ModelInfo getModelInfoFor(IStructuredModel structuredModel) {
- ModelInfo result = null;
- if (structuredModel != null) {
- ModelInfo[] modelInfos = (ModelInfo[]) fModelInfoMap.values().toArray(new ModelInfo[0]);
- for (int i = 0; i < modelInfos.length; i++) {
- ModelInfo info = modelInfos[i];
- if (structuredModel.equals(info.fStructuredModel)) {
- result = info;
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * Method loadModel.
- *
- * @param input
- * @return IStructuredModel
- */
- public IStructuredModel loadModel(IEditorInput input) {
- return loadModel(input, false);
- }
-
- /**
- * Method loadModel.
- *
- * @param input
- * @param logExceptions
- * @return IStructuredModel
- */
- public IStructuredModel loadModel(IEditorInput input, boolean logExceptions) {
- InputStream contents = null;
- IStructuredModel model = null;
- File file = getSystemFile(input);
- if (file != null) {
- String path = file.getAbsolutePath();
- try {
- contents = new FileInputStream(file);
- // first parameter must be unique
- model = getModelManager().getModelForEdit(path, contents, null);
- model.setBaseLocation(path);
- }
- catch (IOException e) {
- if (logExceptions)
- Logger.logException(ResourceHandler.getString("32concat_EXC_", new Object[]{input}), e); //$NON-NLS-1$
- }
- try {
- contents.close();
- }
- catch (Throwable e1) {
- // do nothing, this is just to ensure the resource isn't held
- // open
- }
- }
- return model;
- }
-
- /**
- * @param input
- * @return
- */
- private File getSystemFile(IEditorInput input) {
- File file = null;
- ILocationProvider provider = (ILocationProvider) input.getAdapter(ILocationProvider.class);
- if (provider != null) {
- IPath fullPath = provider.getPath(input);
- if (fullPath != null) {
- file = fullPath.toFile();
- }
- }
- return file;
- }
-
- /**
- * @param input
- * @return
- */
- protected IStructuredModel selfCreateModel(IEditorInput input) {
- return loadModel(input);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IDocumentProvider#resetDocument(java.lang.Object)
- */
- public void resetDocument(Object element) throws CoreException {
- super.resetDocument(element);
- FileInfo info = getFileInfo(element);
- File file = getSystemFile(info);
- if (file != null && file.exists()) {
- IStructuredModel model = getModel(element);
- InputStream fis = null;
- try {
- fis = new FileInputStream(file);
- }
- catch (FileNotFoundException e) {
- // possibly nothing if the file was deleted, shouldn't happen
- // otherwise
- }
- if (fis != null) {
- String oldContents = model.getStructuredDocument().get();
- try {
- model.reload(fis);
- info.fTextFileBuffer.getDocument().set(model.getStructuredDocument().get());
- }
- catch (IOException e1) {
- Logger.logException("Exception caught reloading model from " + file.getName(), e1); //$NON-NLS-1$
- model.getStructuredDocument().set(oldContents);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManager.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManager.java
deleted file mode 100644
index 3d62b134cc..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManager.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import java.util.List;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.view.events.ICaretListener;
-import org.eclipse.wst.sse.ui.view.events.INodeSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.ITextSelectionListener;
-
-
-public interface ViewerSelectionManager extends ICaretListener, IDoubleClickListener, ISelectionChangedListener, SelectionListener {
-
- void addNodeDoubleClickListener(IDoubleClickListener listener);
-
- void addNodeSelectionListener(INodeSelectionListener listener);
-
- void addTextSelectionListener(ITextSelectionListener listener);
-
- int getCaretPosition();
-
- List getSelectedNodes();
-
- void release();
-
- void removeNodeDoubleClickListener(IDoubleClickListener listener);
-
- void removeNodeSelectionListener(INodeSelectionListener listener);
-
- void removeTextSelectionListener(ITextSelectionListener listener);
-
- void setModel(IStructuredModel newModel);
-
- void setTextViewer(ITextViewer newTextViewer);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManagerImpl.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManagerImpl.java
deleted file mode 100644
index df8747576b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ViewerSelectionManagerImpl.java
+++ /dev/null
@@ -1,708 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.viewers.DoubleClickEvent;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.wst.sse.core.IModelStateListener;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.Utilities;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckSelectionListener;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckSelectionManager;
-import org.eclipse.wst.sse.ui.view.events.CaretEvent;
-import org.eclipse.wst.sse.ui.view.events.INodeSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.ITextSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-import org.eclipse.wst.sse.ui.view.events.TextSelectionChangedEvent;
-
-
-public class ViewerSelectionManagerImpl implements ViewerSelectionManager, SpellCheckSelectionManager {
-
- class InternalModelStateListener implements IModelStateListener {
-
- public void modelResourceDeleted(IStructuredModel model) {
- }
-
- public void modelAboutToBeChanged(IStructuredModel model) {
- setModelChanging(true);
- }
-
- public void modelChanged(IStructuredModel model) {
- setModelChanging(false);
- }
-
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
- }
-
- public void modelResourceMoved(IStructuredModel originalmodel, IStructuredModel movedmodel) {
- }
-
- }
-
- private IDoubleClickListener[] fNodeDoubleClickListeners;
- private INodeSelectionListener[] fNodeSelectionListeners;
- private ITextSelectionListener[] fTextSelectionListeners;
- private List fSelectedNodes;
- private int fCaretPosition = 0;
- private int fTextSelectionStart;
- private int fTextSelectionEnd;
- private IndexedRegion fTextSelectionStartNode;
- private IndexedRegion fTextSelectionEndNode;
- private CaretMediator fCaretMeditator;
- private boolean isFiringNodeDoubleClick = false;
- private boolean isFiringNodeSelectionChanged = false;
- protected IStructuredModel fModel;
- private InternalModelStateListener internalModelStateListener;
- private boolean fModelChanging = false;
-
- /**
- * @deprecated
- * Subclass should not access fTextWidget directly.
- * Subclass sub register as NodeSelectionListener and TextSelectionListener of
- * ViewerSelectionManager if selection info is needed.
- *
- * This field is restore temporarily until Page Designer fixed their problems.
- */
- protected StyledText fTextWidget;
-
- public ViewerSelectionManagerImpl() {
- internalModelStateListener = new InternalModelStateListener();
- }
-
- public ViewerSelectionManagerImpl(ITextViewer textViewer) {
- setTextViewer(textViewer);
-
- internalModelStateListener = new InternalModelStateListener();
- }
-
- public synchronized void addNodeDoubleClickListener(IDoubleClickListener listener) {
- // since its most certainly an error if someone is trying to add a
- // null listner,
- // we'll flag it explicitly and ignore
- if (listener == null) {
- Logger.log(Logger.WARNING, "Likely error in ViewerSelectionManagerImpl::addNodeDoubleClickListener should not be called with null listener"); //$NON-NLS-1$
- return;
- }
- // make sure listlistener not already in listening array
- // (and if it is, print a warning to aid debugging, if needed)
- if (Utilities.contains(fNodeDoubleClickListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("ViewerSelectionManager::addNodeDoubleClickListener. listener " + listener + " was added more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("ViewerSelectionManager::addNodeDoubleClickListener. Adding an instance of " + listener.getClass() + " as a listener on ViewerSelectionManager."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fNodeDoubleClickListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fNodeDoubleClickListeners.length;
- }
- int newSize = oldSize + 1;
- IDoubleClickListener[] newListeners = new IDoubleClickListener[newSize];
- if (fNodeDoubleClickListeners != null) {
- System.arraycopy(fNodeDoubleClickListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fNodeDoubleClickListeners = newListeners;
-
- }
- }
-
- public synchronized void addNodeSelectionListener(INodeSelectionListener listener) {
- // since its most certainly an error if someone is trying to add a
- // null listner,
- // we'll flag it explicitly and ignore
- if (listener == null) {
- Logger.log(Logger.WARNING, "Likely error in ViewerSelectionManagerImpl::addNodeSelectionListener should not but called with null listener"); //$NON-NLS-1$
- return;
- }
- // make sure listener is not already in listening array
- // (and if it is, print a warning to aid debugging, if needed)
- if (Utilities.contains(fNodeSelectionListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("ViewerSelectionManager::addNodeSelectionListener. listener " + listener + " was added more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("ViewerSelectionManager::addNodeSelectionListener. Adding an instance of " + listener.getClass() + " as a listener on ViewerSelectionManager."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fNodeSelectionListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fNodeSelectionListeners.length;
- }
- int newSize = oldSize + 1;
- INodeSelectionListener[] newListeners = new INodeSelectionListener[newSize];
- if (fNodeSelectionListeners != null) {
- System.arraycopy(fNodeSelectionListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fNodeSelectionListeners = newListeners;
-
- }
- }
-
- public synchronized void addTextSelectionListener(ITextSelectionListener listener) {
- // since its most certainly an error if someone is trying to add a
- // null listner,
- // we'll flag it explicitly and ignore
- if (listener == null) {
- Logger.log(Logger.WARNING, "Likely error in ViewerSelectionManagerImpl::addNodeSelectionListener should not but called with null listener"); //$NON-NLS-1$
- return;
- }
- // make sure listener is not already in listening array
- // (and if it is, print a warning to aid debugging, if needed)
- if (Utilities.contains(fTextSelectionListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("ViewerSelectionManager::addTextSelectionListener. listener " + listener + " was added more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("ViewerSelectionManager::addTextSelectionListener. Adding an instance of " + listener.getClass() + " as a listener on ViewerSelectionManager."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fTextSelectionListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fTextSelectionListeners.length;
- }
- int newSize = oldSize + 1;
- ITextSelectionListener[] newListeners = new ITextSelectionListener[newSize];
- if (fTextSelectionListeners != null) {
- System.arraycopy(fTextSelectionListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fTextSelectionListeners = newListeners;
-
- }
- }
-
- /**
- * This method listens to text widget caret movements. This method is
- * called when a caret (insertion point) move occurs that is NOT the
- * result of the text changing. Specifcally, as a result of mouse clicks,
- * PAGE_UP, RIGHT_ARROW, etc.
- */
- public void caretMoved(final CaretEvent event) {
- if (!isModelChanging()) {
- List selectedNodes = getTextWidgetSelectedNodes(event.getPosition());
- int caretPosition = event.getPosition();
- processSelectionChanged(event.getSource(), selectedNodes, caretPosition, caretPosition);
- }
- }
-
- protected void currentNodeChanged(Object source, List newSelectedNodes, int caretPosition) {
- // save current node; make sure to clone the selected nodes list, or
- // else there may be a side effect when listeners modify the list
- fSelectedNodes = new Vector(newSelectedNodes);
- // save current caret position
- fCaretPosition = caretPosition;
- // generate and fire event
- NodeSelectionChangedEvent nodeSelectionChangedEvent = new NodeSelectionChangedEvent(source, newSelectedNodes, caretPosition);
- fireNodeSelectionChangedEvent(nodeSelectionChangedEvent);
- }
-
- /**
- * Notifies of a double click.
- *
- * @param event
- * event object describing the double-click
- */
- public void doubleClick(DoubleClickEvent event) {
- if (!isModelChanging())
- fireNodeDoubleClickEvent(event);
- }
-
- protected void fireNodeDoubleClickEvent(DoubleClickEvent event) {
- if ((fNodeDoubleClickListeners != null) && (!isModelChanging())) {
- // we must assign listeners to local variable to be thread safe,
- // since the add and remove listner methods
- // can change this object's actual instance of the listener array
- // from another thread
- // (and since object assignment is atomic, we don't need to
- // synchronize
- isFiringNodeDoubleClick = true;
- try {
- IDoubleClickListener[] holdListeners = fNodeDoubleClickListeners;
-
- for (int i = 0; i < holdListeners.length; i++) {
- holdListeners[i].doubleClick(event);
- }
- }
- finally {
- isFiringNodeDoubleClick = false;
- }
- }
- }
-
- protected void fireNodeSelectionChangedEvent(NodeSelectionChangedEvent event) {
- if ((fNodeSelectionListeners != null) && (!isModelChanging())) {
- // we must assign listeners to local variable to be thread safe,
- // since the add and remove listner methods
- // can change this object's actual instance of the listener array
- // from another thread
- // (and since object assignment is atomic, we don't need to
- // synchronize
- isFiringNodeSelectionChanged = true;
- try {
- INodeSelectionListener[] holdListeners = fNodeSelectionListeners;
-
- for (int i = 0; i < holdListeners.length; i++) {
- holdListeners[i].nodeSelectionChanged(event);
- }
- }
- finally {
- isFiringNodeSelectionChanged = false;
- }
- }
- }
-
- protected void fireTextSelectionChangedEvent(TextSelectionChangedEvent event) {
- if ((fTextSelectionListeners != null) && (!isModelChanging())) {
- // we must assign listeners to local variable to be thread safe,
- // since the add and remove listner methods
- // can change this object's actual instance of the listener array
- // from another thread
- // (and since object assignment is atomic, we don't need to
- // synchronize
- ITextSelectionListener[] holdListeners = fTextSelectionListeners;
- //
- for (int i = 0; i < holdListeners.length; i++) {
- holdListeners[i].textSelectionChanged(event);
- }
- }
- }
-
- protected void fireSpellCheckSelectionChangedEvent() {
- if ((fSpellCheckSelectionListeners != null) && (!isModelChanging())) {
- // we must assign listeners to local variable to be thread safe,
- // since the add and remove listner methods
- // can change this object's actual instance of the listener array
- // from another thread
- // (and since object assignment is atomic, we don't need to
- // synchronize
- SpellCheckSelectionListener[] holdListeners = fSpellCheckSelectionListeners;
- //
- for (int i = 0; i < holdListeners.length; i++) {
- holdListeners[i].selectionChanged();
- }
- }
- }
-
- public int getCaretPosition() {
- return fCaretPosition;
- }
-
- public List getSelectedNodes() {
- return fSelectedNodes;
- }
- /**
- * @deprecated
- *
- * @return
- */
- protected List getTextWidgetSelectedNodes() {
- return getTextWidgetSelectedNodes(fTextSelectionStart);
- }
-
-
- protected List getTextWidgetSelectedNodes(int offset) {
- if (fModel == null)
- return new ArrayList(0);
-
- IndexedRegion firstSelectedNode = fModel.getIndexedRegion(offset);
- fTextSelectionStartNode = firstSelectedNode;
- fTextSelectionEndNode = firstSelectedNode;
-
- // Never send a "null" in the selection
- List selectedNodes = null;
- if(firstSelectedNode != null) {
- selectedNodes = new ArrayList(1);
- selectedNodes.add(firstSelectedNode);
- }
- else {
- selectedNodes = new ArrayList(0);
- }
- return selectedNodes;
- }
-
- protected boolean isCurrentNodeChanged(List newSelectedNodes) {
- return !newSelectedNodes.equals(fSelectedNodes);
- }
-
- protected boolean isModelChanging() {
- return fModelChanging;
- }
-
- protected boolean isTextSelectionChanged(int textSelectionStart, int textSelectionEnd) {
- return ((fTextSelectionStart != textSelectionStart) || (fTextSelectionEnd != textSelectionEnd));
- }
-
- protected void processSelectionChanged(Object source, List selectedNodes, int selectionStart, int selectionEnd) {
- if (source == null) {
- // source should not be null.
- // log this and ignore this selection changed event.
- // DMW: I "shortened" this log message by removing stack trace,
- // after receiving log
- // from support showing this error. It made the log file
- // confusing.
- // Not clear why the source was null, but probably only related to
- // initialization, or 'startup' with file open.
- Logger.log(Logger.ERROR, "ViewerSelectionManager::processSelectionChanged. Unexpected null source"); //$NON-NLS-1$
- }
- else {
- if (isTextSelectionChanged(selectionStart, selectionEnd))
- textSelectionChanged(source, selectionStart, selectionEnd);
-
- if (isCurrentNodeChanged(selectedNodes))
- currentNodeChanged(source, selectedNodes, selectionEnd);
- }
- }
-
- /**
- * @deprecated
- */
- protected void refresh() {
- //List selectedNodes = getTextWidgetSelectedNodes();
- //boolean nodeChanged = isCurrentNodeChanged(selectedNodes);
- //if (nodeChanged)
- // currentNodeChanged(this, selectedNodes, fCaretPosition);
- }
-
-
- public void release() {
- if (fCaretMeditator != null) {
- fCaretMeditator.removeCaretListener(this);
- fCaretMeditator.release();
- fCaretMeditator = null;
- }
-
- // remove this viewer selection manager from the old model's list of
- // model state listeners
- if (fModel != null)
- fModel.removeModelStateListener(internalModelStateListener);
- }
-
- public synchronized void removeNodeDoubleClickListener(IDoubleClickListener listener) {
- if ((fNodeDoubleClickListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fNodeDoubleClickListeners, listener)) {
- int oldSize = fNodeDoubleClickListeners.length;
- int newSize = oldSize - 1;
- IDoubleClickListener[] newListeners = new IDoubleClickListener[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fNodeDoubleClickListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fNodeDoubleClickListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fNodeDoubleClickListeners = newListeners;
- }
- }
- }
-
- public synchronized void removeNodeSelectionListener(INodeSelectionListener listener) {
- if ((fNodeSelectionListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fNodeSelectionListeners, listener)) {
- int oldSize = fNodeSelectionListeners.length;
- int newSize = oldSize - 1;
- INodeSelectionListener[] newListeners = new INodeSelectionListener[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fNodeSelectionListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fNodeSelectionListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fNodeSelectionListeners = newListeners;
- }
- }
- }
-
- public synchronized void removeTextSelectionListener(ITextSelectionListener listener) {
- if ((fTextSelectionListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fTextSelectionListeners, listener)) {
- int oldSize = fTextSelectionListeners.length;
- int newSize = oldSize - 1;
- ITextSelectionListener[] newListeners = new ITextSelectionListener[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fTextSelectionListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fTextSelectionListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fTextSelectionListeners = newListeners;
- }
- }
- }
-
- /**
- * This method listens to tree viewer selection changes. This method is
- * called when the selection from a tree viewer has changed.
- */
- public void selectionChanged(SelectionChangedEvent event) {
- // If selection is fired as a result of processing a node change
- // event, then ignore the selection.
- if (isFiringNodeSelectionChanged || isModelChanging())
- return;
-
- IStructuredSelection selection = (IStructuredSelection) event.getSelection();
- int selectionSize = selection.size();
- List selectedNodes = selection.toList();
- int selectionStart = 0;
- int selectionEnd = 0;
-
- // something selected
- if (selectionSize > 0) {
- IndexedRegion firstSelectedNode = (IndexedRegion) selectedNodes.get(0);
- selectionStart = firstSelectedNode.getStartOffset();
- selectionEnd = firstSelectedNode.getEndOffset();
-
- // remove all except the first selected node
- selectedNodes = new Vector(1);
- selectedNodes.add(firstSelectedNode);
- }
-
- // Tell the listeners the original source of NodeSelectionChanged
- // event.
- Object source = event.getSource();
-
- // Use ViewerSelectionManager as the source if the selection was set
- // programmatically.
- if ((event.getSource() instanceof TreeViewer) && !(event instanceof StructuredTextSelectionChangedEvent))
- source = this;
-
- processSelectionChanged(source, selectedNodes, selectionStart, selectionEnd);
- }
-
- protected void setCaretPosition(int caretPosition) {
- fCaretPosition = caretPosition;
- }
-
- public void setModel(IStructuredModel newModel) {
- if (newModel != fModel) {
- // remove this viewer selection manager from the old model's list
- // of model state listeners
- if (fModel != null)
- fModel.removeModelStateListener(internalModelStateListener);
-
- fModel = newModel;
-
- // add this viewer selection manager to the new model's list of
- // model state listeners
- fModel.addModelStateListener(internalModelStateListener);
- }
- }
-
- protected void setModelChanging(boolean modelChanging) {
- fModelChanging = modelChanging;
- }
-
- /**
- * This is the viewer who's caret postion we monitor to determine when to
- * check if the node has changed. We don't actually need, or save, the
- * viewer, but do need its text widget, and will register this
- * viewer selection manager as a listener of the text widget's text selection.
- */
- public void setTextViewer(ITextViewer newTextViewer) {
- // unhook from previous, if any
- if (fCaretMeditator != null)
- fCaretMeditator.removeCaretListener(this);
-
- if (newTextViewer != null) {
- StyledText textWidget = newTextViewer.getTextWidget();
- if (textWidget != null) {
- // create new caretmediator, if it doesn't exist yet
- if (fCaretMeditator == null) {
- fCaretMeditator = new CaretMediator(textWidget);
- }
- else {
- fCaretMeditator.setTextWidget(textWidget);
- }
- // and register as a listner
- fCaretMeditator.addCaretListener(this);
-
- // listen to text selections
- textWidget.addSelectionListener(this);
- }
-
- /**
- * TODO
- * Subclass should not access fTextWidget directly.
- * Subclass sub register as NodeSelectionListener and TextSelectionListener of
- * ViewerSelectionManager if selection info is needed.
- *
- * The following line is restore temporarily until Page Designer fixed their problems.
- */
- fTextWidget = textWidget;
- }
- }
-
- protected void textSelectionChanged(Object source, int textSelectionStart, int textSelectionEnd) {
- // save current text selection
- fTextSelectionStart = textSelectionStart;
- fTextSelectionEnd = textSelectionEnd;
- // save current caret position
- fCaretPosition = fTextSelectionEnd;
- // generate and fire event
- TextSelectionChangedEvent textSelectionChangedEvent = new TextSelectionChangedEvent(source, fTextSelectionStart, fTextSelectionEnd);
- fireTextSelectionChangedEvent(textSelectionChangedEvent);
-
- // SpellCheck dialog also needs to listen text selection change
- fireSpellCheckSelectionChangedEvent();
- }
-
- /**
- * This method listens to text widget default selection changes. This
- * method is called when default selection occurs in the control. For
- * example, on some platforms default selection occurs in a List when the
- * user double-clicks an item or types return in a Text.
- */
- public void widgetDefaultSelected(SelectionEvent event) {
- if (!isModelChanging()) {
- List selectedNodes = getTextWidgetSelectedNodes(event.x);
- int selectionStart = event.x;
- int selectionEnd = event.y;
- processSelectionChanged(event.getSource(), selectedNodes, selectionStart, selectionEnd);
- }
- }
-
- /**
- * This method listens to text widget text selection changes. This method
- * is called when the text selection in a text widget has changed.
- */
- public void widgetSelected(SelectionEvent event) {
- // If selection is fired as a result of processing a node change
- // event, then ignore the selection.
- if (isFiringNodeSelectionChanged || isModelChanging())
- return;
-
- widgetDefaultSelected(event);
- }
-
- // ISpellCheckSelectionManager
- protected SpellCheckSelectionListener[] fSpellCheckSelectionListeners;
-
- /**
- * @see SpellCheckSelectionManager#addSpellCheckSelectionListener(SpellCheckSelectionListener)
- */
- public void addSpellCheckSelectionListener(SpellCheckSelectionListener listener) {
- // since its most certainly an error if someone is trying to add a
- // null listner,
- // we'll flag it explicitly and ignore
- if (listener == null) {
- Logger.log(Logger.WARNING, "Likely error in ViewerSelectionManagerImpl::addSpellCheckSelectionListener should not but called with null listener"); //$NON-NLS-1$
- return;
- }
- // make sure listener is not already in listening array
- // (and if it is, print a warning to aid debugging, if needed)
-
- if (Utilities.contains(fSpellCheckSelectionListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("ViewerSelectionManager::addSpellCheckSelectionListener. listener " + listener + " was added more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("ViewerSelectionManager::addSpellCheckSelectionListener. Adding an instance of " + listener.getClass() + " as a listener on ViewerSelectionManager."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fSpellCheckSelectionListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fSpellCheckSelectionListeners.length;
- }
- int newSize = oldSize + 1;
- SpellCheckSelectionListener[] newListeners = new SpellCheckSelectionListener[newSize];
- if (fSpellCheckSelectionListeners != null) {
- System.arraycopy(fSpellCheckSelectionListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fSpellCheckSelectionListeners = newListeners;
- }
- }
-
- /**
- * @see SpellCheckSelectionManager#removeSpellCheckSelectionListener(SpellCheckSelectionListener)
- */
- public void removeSpellCheckSelectionListener(SpellCheckSelectionListener listener) {
- if ((fSpellCheckSelectionListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fSpellCheckSelectionListeners, listener)) {
- int oldSize = fSpellCheckSelectionListeners.length;
- int newSize = oldSize - 1;
- SpellCheckSelectionListener[] newListeners = new SpellCheckSelectionListener[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fSpellCheckSelectionListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fSpellCheckSelectionListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fSpellCheckSelectionListeners = newListeners;
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IRelevanceCompletionProposal.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IRelevanceCompletionProposal.java
deleted file mode 100644
index bd78cfe75d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IRelevanceCompletionProposal.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.contentassist;
-
-
-/**
- * CompletionProposal with a relevance value.
- * The relevance value is used to sort the completion proposals. Proposals with higher relevance
- * should be listed before proposals with lower relevance.
- *
- * @author pavery
- */
-public interface IRelevanceCompletionProposal {
- /**
- * Returns the relevance of the proposal.
- */
- int getRelevance();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IResourceDependentProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IResourceDependentProcessor.java
deleted file mode 100644
index 1ec9659ef7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentassist/IResourceDependentProcessor.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.contentassist;
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * Interface for classes that require an IResource to operate properly (eg. some ContentAssistProcessors)
- *
- * @author pavery
- */
-public interface IResourceDependentProcessor {
- void initialize(IResource resource);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboList.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboList.java
deleted file mode 100644
index 4f4668cc3c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboList.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.contentproperties.ui;
-
-
-
-import java.util.ArrayList;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.swt.events.FocusListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-
-public class ComboList {
-
-
- private List list;
- private Combo combo;
-
- public ComboList(Composite parent, int style) {
- combo = new Combo(parent, style);
- list = new ArrayList();
- }
-
- public void add(String key, String value) {
- checkError();
- combo.add(key);
- list.add(value);
- }
-
- public void add(String key, String value, int index) {
- checkError();
- combo.add(key, index);
- list.add(index, value);
- }
-
- public String getValue(String key) {
- if (key == null)
- return null;
- int index = -1;
- checkError();
- for (int i = 0; i < combo.getItemCount(); i++) {
- if (!combo.getItem(i).equals(key))
- continue;
- index = i;
- break;
- }
- if (index != -1)
- return (String) list.get(index);
- else
- return null;
- }
-
- public String getKey(String value) {
- if (value == null)
- return null;
- int index = -1;
- checkError();
- for (int i = 0; i < list.size(); i++) {
- if (!list.get(i).equals(value))
- continue;
- index = i;
- break;
- }
- if (index != -1)
- return combo.getItem(index);
- else
- return null;
- }
-
- public String getSelectedValue() {
- checkError();
- int index = getSelectionIndex();
- if (index < 0)
- return null;
- return getValue(getItem(index));
- }
-
- public boolean existsAsValue(String str) {
- if (list.indexOf(str) >= 0)
- return true;
- else
- return false;
- }
-
- public boolean existsAsKey(String str) {
- if (combo.indexOf(str) >= 0)
- return true;
- else
- return false;
- }
-
- public Map createHashtable() {
- checkError();
- Map m = new Hashtable();
- for (int i = 0; i < list.size(); i++)
- m.put(combo.getItem(i), list.get(i));
- return m;
- }
-
-
- public boolean isConsistency() {
-
- if (list.size() == combo.getItemCount())
- return true;
- else
- return false;
- }
-
- private void checkError() {
- if (!isConsistency()) {
- Logger.log(Logger.WARNING, "Difference between the number of keys[" + combo.getItemCount() + "] and the number of values[" + list.size() + "] in ComboList"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- }
-
- public boolean equals(Object obj) {
- return combo.equals(obj);
- }
-
- public void sortByKey(int offset) {
- if (offset < 0 || offset > this.combo.getItemCount() - 1)
- return;
- checkError();
- //
- for (int i = offset; i < combo.getItemCount() - 1; i++) {
- for (int j = i + 1; j < combo.getItemCount(); j++) {
- if (getItem(i).compareTo(getItem(j)) > 0) {
- exchangePosition(i, j);
- }
- }
- }
- }
-
- private void exchangePosition(int i, int j) {
- String tmpKey = getItem(i);
- Object tmpValue = list.remove(i);
-
- combo.setItem(i, getItem(j));
- list.add(i, list.remove(j - 1));
-
- combo.setItem(j, tmpKey);
- list.add(j, tmpValue);
- }
-
-
- /*
- following methods is original method of Combo class.
- */
- public void add(String key) {
- checkError();
- combo.add(key);
- list.add(key);
- }
-
- public void add(String key, int index) {
- checkError();
- combo.add(key, index);
- list.add(index, key);
- }
-
-
- public void remove(int index) {
- checkError();
- combo.remove(index);
- list.remove(index);
- }
-
- public void remove(String str) {
- checkError();
- combo.remove(str);
- list.remove(str);
- }
-
- public void setItem(int index, String str) {
- checkError();
- combo.setItem(index, str);
- list.remove(index);
- list.add(index, str);
- }
-
- public void setItem(String[] strArray) {
- checkError();
- combo.setItems(strArray);
- for (int i = 0; i < strArray.length; i++)
- list.add(strArray[i]);
- }
-
- public int indexOf(String str) {
- return combo.indexOf(str);
- }
-
- public void select(int index) {
- combo.select(index);
- }
-
- public void setLayout(org.eclipse.swt.widgets.Layout lo) {
- combo.setLayout(lo);
- }
-
- public int getSelectionIndex() {
- return combo.getSelectionIndex();
- }
-
- public String getItem(int index) {
- return combo.getItem(index);
- }
-
- public void setText(String str) {
- combo.setText(str);
- }
-
- public String getText() {
- return combo.getText();
- }
-
- public void addSelectionListener(org.eclipse.swt.events.SelectionListener listener) {
- combo.addSelectionListener(listener);
-
- }
-
- public void addModifyListener(org.eclipse.swt.events.ModifyListener listener) {
- combo.addModifyListener(listener);
- }
-
- public void setLayoutData(Object layoutData) {
- combo.setLayoutData(layoutData);
- }
-
- public Object getLayoutData() {
- return combo.getLayoutData();
- }
-
- public org.eclipse.swt.graphics.Point computeSize(int wHint, int hHint) {
- return combo.computeSize(wHint, hHint);
- }
-
- public int getItemCount() {
- return combo.getItemCount();
- }
-
- public void setEnabled(boolean enabled) {
- combo.setEnabled(enabled);
- }
-
- public boolean getEnabled() {
- return combo.getEnabled();
- }
-
- public void setSelection(Point point) {
- combo.setSelection(point);
- }
-
- public void deselect(int i) {
- combo.deselect(i);
- }
-
- public void deselectAll() {
- combo.deselectAll();
- }
-
- public boolean setFocus() {
- return combo.setFocus();
- }
-
- public void addFocusListener(FocusListener listener) {
- combo.addFocusListener(listener);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboListOnPropertyPage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboListOnPropertyPage.java
deleted file mode 100644
index 48adf27965..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ComboListOnPropertyPage.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.contentproperties.ui;
-
-
-
-import org.eclipse.swt.widgets.Composite;
-
-
-public final class ComboListOnPropertyPage extends ComboList {
-
-
- private String currentApplyValue;
-
- public ComboListOnPropertyPage(Composite parent, int style) {
- super(parent, style);
- }
-
- public final String getApplyValue() {
- return currentApplyValue;
- }
-
- public final void setApplyValue(String currentApplyValue) {
- this.currentApplyValue = currentApplyValue;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ContentSettingsPropertyPage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ContentSettingsPropertyPage.java
deleted file mode 100644
index 4511273c74..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/contentproperties/ui/ContentSettingsPropertyPage.java
+++ /dev/null
@@ -1,292 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.contentproperties.ui;
-
-
-
-import java.util.Hashtable;
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.dialogs.PropertyPage;
-import org.eclipse.wst.sse.contentproperties.ContentSettings;
-import org.eclipse.wst.sse.contentproperties.ContentSettingsCreator;
-import org.eclipse.wst.sse.contentproperties.IContentSettings;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-
-public abstract class ContentSettingsPropertyPage extends PropertyPage {
-
- protected IContentSettings contentSettings;
- protected Composite composite;
- protected ComboListOnPropertyPage[] combo;
- protected int numberOfCombo;
- protected Composite propertyPage;
- protected int numCols = 1;
- protected int numRows = 1;
-
- protected final String DOCUMENT_LABEL = ResourceHandler.getString("UI_Default_HTML_DOCTYPE_ID___1"); //$NON-NLS-1$
- protected final String CSS_LABEL = ResourceHandler.getString("UI_CSS_profile___2"); //$NON-NLS-1$
- protected final String DEVICE_LABEL = ResourceHandler.getString("UI_Target_Device___3"); //$NON-NLS-1$
-
- // for validateEdit()
- private static final IStatus STATUS_OK = new Status(IStatus.OK, EditorPlugin.ID, IStatus.OK, "OK", null); //$NON-NLS-1$
- private static final IStatus STATUS_ERROR = new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.INFO, "ERROR", null); //$NON-NLS-1$
-
- public ContentSettingsPropertyPage() {
- super();
- }
-
- protected abstract void createSettingsPageGUI();
-
- //protected abstract void applySelectedPropertyValue(String str,int index);
- protected abstract void deleteNoneProperty(int index);
-
- protected abstract void putSelectedPropertyInto(Map properties, String str, int i);
-
-
- protected Control createContents(Composite parent) {
-
- contentSettings = ContentSettingsCreator.create();
-
- propertyPage = createComposite(parent, numCols, numRows);
-
- createSettingsPageGUI();
-
- return propertyPage;
-
-
- }
-
-
-
- protected Composite createComposite(Composite parent, int numColumns, int numRows) {
- Composite composite = new Composite(parent, SWT.NONE);
-
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- //GridData
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- // data.horizontalSpan=numColumns;
- // data.verticalSpan=numRows;
-
- composite.setLayoutData(data);
- return composite;
- }
-
-
- protected ComboListOnPropertyPage createComboBoxOf(String title) {
-
- Label label = new Label(propertyPage, SWT.LEFT);
- label.setText(title);
- if (title != null && title.startsWith(ResourceHandler.getString("UI_Default_HTML_DOCTYPE_ID___1"))) { //$NON-NLS-1$
- GridData data = new GridData();
- data.horizontalIndent = 10;
- label.setLayoutData(data);
- }
- ComboListOnPropertyPage combo = new ComboListOnPropertyPage(propertyPage, SWT.READ_ONLY);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- //data.horizontalAlignment= GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- combo.setLayoutData(data);
- return combo;
- }
-
-
- protected void setSelectionItem(ComboListOnPropertyPage combo, String value) {
- if (combo.getItemCount() <= 0)
- return;
- combo.setApplyValue(value);
- String item = combo.getKey(value);
- if (item != null)
- combo.select(combo.indexOf(item));
- else
- combo.select(0);
-
- }
-
-
-
- protected boolean isInitValueChanged(String before, String after) {
- if (before == null && after == null)
- return false;
- if (before != null && before.equals(after))
- return false;
- return true;
- }
-
- public boolean performOk() {
- Map properties = new Hashtable();
- if (validateState() == false) {
- cleanUp();
- return true;
- }
- for (int i = 0; i < numberOfCombo; i++) {
- // get selected item in Combo box.
- String str = combo[i].getSelectedValue();
- if (str == null)
- continue;
- // if no change, skip setProperty
- if (!isInitValueChanged(combo[i].getApplyValue(), str))
- continue;
- // if NONE is selected, delete attr instance (and write .contentsettings.)
- if (str != null && str.length() == 0)
- deleteNoneProperty(i);
- else
- putSelectedPropertyInto(properties, str, i);
- //applySelectedPropertyValue(str,i);
-
- // set apply value in ComboListOnPropertyPage.
- combo[i].setApplyValue(str);
- }
- if (properties != null && !properties.isEmpty())
- contentSettings.setProperties((IResource) super.getElement(), properties);
- if (properties != null)
- properties.clear();
- properties = null;
- if (!contentSettings.existsProperties((IResource) super.getElement()))
- contentSettings.deleteAllProperties((IResource) super.getElement());
- return true;
- }
-
-
-
- protected void performDefaults() {
- super.performDefaults();
- // selected(applied) item is restored.
- for (int i = 0; i < numberOfCombo; i++) {
- //String appliedValue = combo[i].getApplyValue();
- //setSelectionItem(combo[i],appliedValue);
- combo[i].select(0); // select none.
-
- }
-
- }
-
- /*
- * Validate Edit. Similar function will be in
- * HTMLCommand.java
- * ContentSettingsPropertyPage.java
- * CSSActionManager.java
- * DesignRedoAction.java
- * DesignUndoAction.java
- * HTMLConversionProcessor.java
- */
- private boolean validateState() {
-
- // get IFile of .contentsettings
- final String name = ContentSettings.getContentSettingsName();
- final IResource resource = (IResource) super.getElement();
- final IProject project = resource.getProject();
- IFile file = project.getFile(name);
-
- if (file != null && !file.exists())
- return true; //Is this really OK?
- //If false should be returned,
- //This statemant can be removed,
- //since ModelManagerUtil.validateEdit()
- //returns error to this case.
-
- Shell shell = getControl().getShell();
- IStatus status = validateEdit(file, shell);
- return status.isOK() ? true : false;
- }
-
- private void cleanUp() {
- // Are There any way to guarantee to call cleanUp() to re-load downloaded .contentsettings file
- // after ContentSettings.releaseCache() in ContentSettingSelfHandler class, which is called by resourceChangeEvent
- }
-
- /**
- * Method validateEdit.
- * @param file org.eclipse.core.resources.IFile
- * @param context org.eclipse.swt.widgets.Shell
- * @return IStatus
- */
- public static IStatus validateEdit(IFile file, Shell context) {
- if (file == null || !file.exists())
- return STATUS_ERROR;
- if (!(file.isReadOnly()))
- return STATUS_OK;
-
- IPath fullIPath = file.getProject().getLocation();
- fullIPath = fullIPath.append(file.getName());
-
- final long beforeModifiedFromJavaIO = fullIPath.toFile().lastModified();
- final long beforeModifiedFromIFile = file.getModificationStamp();
-
- IStatus status = ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{file}, context);
- if (!status.isOK())
- return status;
-
- final long afterModifiedFromJavaIO = fullIPath.toFile().lastModified();
- final long afterModifiedFromIFile = file.getModificationStamp();
-
- if (beforeModifiedFromJavaIO != afterModifiedFromJavaIO) {
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- IModelManager manager = plugin.getModelManager();
- IStructuredModel model = manager.getExistingModelForRead(file);
- if (model != null) {
- if (!model.isDirty()) {
- try {
- file.refreshLocal(IResource.DEPTH_ONE, null);
- }
- catch (CoreException e) {
- return STATUS_ERROR;
- }
- finally {
- model.releaseFromRead();
- }
- }
- else {
- model.releaseFromRead();
- }
- }
- }
-
- if ((beforeModifiedFromJavaIO != afterModifiedFromJavaIO) || (beforeModifiedFromIFile != afterModifiedFromIFile)) {
- // the file is replaced. Modification cannot be
- // applied.
- return STATUS_ERROR;
- }
- return STATUS_OK;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/AbstractDropAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/AbstractDropAction.java
deleted file mode 100644
index 0be2f653a7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/AbstractDropAction.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-/**
- */
-public abstract class AbstractDropAction implements IDropAction {
-
-
- /**
- * @see IDropAction#isSupportedData(Object)
- */
- public boolean isSupportedData(Object data) {
- return true;
- }
-
- /**
- * @see IDropAction#run(DropTargetEvent, IExtendedSimpleEditor)
- */
- public abstract boolean run(DropTargetEvent event, IExtendedSimpleEditor targetEditor);
-
- /*
- * replace targetEditor's current selection by "text"
- */
- protected boolean insert(String text, IExtendedSimpleEditor targetEditor) {
- if (text == null || text.length() == 0) {
- return false;
- }
-
- Point pt = targetEditor.getSelectionRange();
- IDocument doc = targetEditor.getDocument();
-
- try {
- doc.replace(pt.x, pt.y, text);
- }
- catch (BadLocationException e) {
- return false;
- }
-
- if (targetEditor instanceof ITextEditor) {
- ISelectionProvider sp = ((ITextEditor) targetEditor).getSelectionProvider();
- ISelection sel = new TextSelection(pt.x, text.length());
- sp.setSelection(sel);
- }
-
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedConfigurationBuilder.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedConfigurationBuilder.java
deleted file mode 100644
index 80a7474a3f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedConfigurationBuilder.java
+++ /dev/null
@@ -1,204 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.extension.RegistryReader;
-
-
-/**
- * Simple generic ID to class to mapping. Loads a specified class defined in a
- * configuration element with the matching element name and target ID. Example
- * plugin.xml section: <extension
- * point="org.eclipse.wst.sse.ui.extendedconfiguration">
- * <contentoutlineconfiguration
- * target="org.eclipse.wst.sse.dtd.ui.StructuredTextEditorDTD"
- * class="org.eclipse.wst.sse.dtd.ui.views.contentoutline.DTDContentOutlineConfiguration"/>
- * </extension> Used in code by
- * getConfiguration("contentoutlineconfiguration",
- * "org.eclipse.wst.sse.dtd.ui.StructuredTextEditorDTD");
- */
-public class ExtendedConfigurationBuilder extends RegistryReader {
- private static final String ATT_CLASS = "class"; //$NON-NLS-1$
- private static final String ATT_TARGET = "target"; //$NON-NLS-1$
- private static Map configurationMap = null;
- private final static boolean debugTime = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/extendedconfigurationbuilder/time")); //$NON-NLS-1$ //$NON-NLS-2$
- private static final String EP_EXTENDEDCONFIGURATION = "extendedconfiguration"; //$NON-NLS-1$
- private static ExtendedConfigurationBuilder instance = null;
-
- /**
- * Creates an extension. If the extension plugin has not
- * been loaded a busy cursor will be activated during the duration of
- * the load.
- *
- * @param element the config element defining the extension
- * @param classAttribute the name of the attribute carrying the class
- * @returns the extension object if successful. If an error occurs when createing
- * executable extension, the exception is logged, and null returned.
- */
- public static Object createExtension(final IConfigurationElement element, final String classAttribute, final String targetID) {
- final Object[] result = new Object[1];
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- try {
- result[0] = element.createExecutableExtension(classAttribute);
- }
- catch (Throwable e) {
- // catch and log ANY exception from extension point
- Logger.logException("error loading class " + classAttribute + " for " + targetID, e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- result[0] = element.createExecutableExtension(classAttribute);
- }
- catch (Throwable e) {
- // catch and log ANY exception from extension point
- Logger.logException("error loading class " + classAttribute + " for " + targetID, e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- });
- }
- return result[0];
- }
-
- /**
- * @return Returns the instance.
- */
- public synchronized static ExtendedConfigurationBuilder getInstance() {
- if (instance == null)
- instance = new ExtendedConfigurationBuilder();
- return instance;
- }
-
- long time0 = 0;
-
- private ExtendedConfigurationBuilder() {
- super();
- }
-
- private Object createConfiguration(List configurations, String extensionType, String targetID) {
- if (configurations == null)
- return null;
- Object result = null;
- for (int i = 0; i < configurations.size(); i++) {
- IConfigurationElement element = (IConfigurationElement) configurations.get(i);
- if (element.getName().equals(extensionType) && element.getAttribute(ATT_TARGET).equals(targetID)) {
- result = createExtension(element, ATT_CLASS, targetID);
- }
- if (result != null) {
- if (result instanceof IExtendedConfiguration) {
- ((IExtendedConfiguration) result).setDeclaringID(targetID);
- }
- return result;
- }
- }
- return result;
- }
-
- private IConfigurationElement findConfigurationElement(List configurations, String extensionType, String targetID) {
- if (configurations == null)
- return null;
- IConfigurationElement result = null;
- for (int i = 0; i < configurations.size(); i++) {
- IConfigurationElement element = (IConfigurationElement) configurations.get(i);
- if (element.getName().equals(extensionType) && element.getAttribute(ATT_TARGET).equals(targetID)) {
- result = element;
- }
- }
- return result;
- }
-
- public Object getConfiguration(String extensionType, String targetID) {
- if (targetID == null || targetID.length() == 0)
- return null;
- if (debugTime) {
- time0 = System.currentTimeMillis();
- }
- if (configurationMap == null) {
- configurationMap = new HashMap(0);
- synchronized (configurationMap) {
- readRegistry(Platform.getPluginRegistry(), EditorPlugin.ID, EP_EXTENDEDCONFIGURATION);
- if (debugTime) {
- System.out.println(getClass().getName() + "#readRegistry(): " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- time0 = System.currentTimeMillis();
- }
- }
- }
- List configurations = (List) configurationMap.get(extensionType);
- Object o = createConfiguration(configurations, extensionType, targetID);
- if (debugTime) {
- if (o != null)
- System.out.println(getClass().getName() + "#getConfiguration(" + extensionType + ", " + targetID + "): configuration loaded in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- else
- System.out.println(getClass().getName() + "#getConfiguration(" + extensionType + ", " + targetID + "): ran in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- return o;
- }
-
- public IConfigurationElement getConfigurationElement(String extensionType, String targetID) {
- if (targetID == null || targetID.length() == 0)
- return null;
- if (debugTime) {
- time0 = System.currentTimeMillis();
- }
- if (configurationMap == null) {
- configurationMap = new HashMap(0);
- synchronized (configurationMap) {
- readRegistry(Platform.getPluginRegistry(), EditorPlugin.ID, EP_EXTENDEDCONFIGURATION);
- if (debugTime) {
- System.out.println(getClass().getName() + "#readRegistry(): " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- time0 = System.currentTimeMillis();
- }
- }
- }
- List configurations = (List) configurationMap.get(extensionType);
- IConfigurationElement element = findConfigurationElement(configurations, extensionType, targetID);
- if (debugTime) {
- if (element != null)
- System.out.println(getClass().getName() + "#getConfigurationElement(" + extensionType + ", " + targetID + "): configuration loaded in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- else
- System.out.println(getClass().getName() + "#getConfigurationElement(" + extensionType + ", " + targetID + "): ran in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- return element;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected boolean readElement(IConfigurationElement element) {
- String name = element.getName();
- List configurations = (List) configurationMap.get(name);
- if (configurations == null) {
- configurations = new ArrayList(1);
- configurationMap.put(name, configurations);
- }
- configurations.add(element);
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorActionBuilder.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorActionBuilder.java
deleted file mode 100644
index eea86c1c0e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorActionBuilder.java
+++ /dev/null
@@ -1,670 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-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.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IKeyBindingService;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.part.MultiPageEditorSite;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.extension.ActionDescriptor;
-import org.eclipse.wst.sse.ui.internal.extension.RegistryReader;
-
-
-/**
- * This class reads the registry for extensions that plug into 'editorActions' extension point.
- */
-
-public class ExtendedEditorActionBuilder extends RegistryReader {
-
- public class ExtendedContributor implements IExtendedContributor, IMenuListener {
- private IExtendedSimpleEditor activeExtendedEditor = null;
-
- private List cache;
- private Map map = new HashMap();
- private IMenuManager menuBar = null;
-
- private Set menus = new HashSet();
-
- public ExtendedContributor(List cache) {
- this.cache = cache;
- }
-
- public void contributeToMenu(IMenuManager menu) {
- menuBar = menu;
- long time0 = System.currentTimeMillis();
- for (int i = 0; i < cache.size(); i++) {
- Object obj = cache.get(i);
- if (obj instanceof IConfigurationElement) {
- IConfigurationElement menuElement = (IConfigurationElement) obj;
- if ((menuElement.getName()).equals(TAG_MENU)) {
- contributeMenu(menuElement, menu, true);
- if (debugMenu)
- System.out.println(getClass().getName() + "#contributeToMenu() added: " + menuElement.getAttribute(ATT_ID)); //$NON-NLS-1$
- }
- }
- else if (obj instanceof ActionDescriptor) {
- ActionDescriptor ad = (ActionDescriptor) obj;
- IMenuManager mm = contributeMenuAction(ad, menu, true, false);
- if (mm != null) {
- map.put(ad.getContributionItem(), mm);
- mm.addMenuListener(this);
- menus.add(mm);
- if (debugMenu)
- System.out.println(getClass().getName() + "#contributeToMenu() added: " + ad.getId()); //$NON-NLS-1$
- }
- }
- }
- if (debugContributeTime)
- System.out.println(getClass().getName() + "#contributeToMenu(): ran in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void contributeToPopupMenu(IMenuManager menu) {
- long time0 = System.currentTimeMillis();
- for (int i = 0; i < cache.size(); i++) {
- Object obj = cache.get(i);
- if (obj instanceof IConfigurationElement) {
- IConfigurationElement menuElement = (IConfigurationElement) obj;
- if ((menuElement.getName()).equals(TAG_POPUPMENU)) {
- contributeMenu(menuElement, menu, true);
- }
- }
- else if (obj instanceof ActionDescriptor) {
- ActionDescriptor ad = (ActionDescriptor) obj;
- IAction a = ad.getAction();
- if (a instanceof IExtendedEditorAction) {
- // uncaught exceptions could cause the menu to not be shown
- try {
-
- IExtendedEditorAction eea = (IExtendedEditorAction) a;
- eea.setActiveExtendedEditor(activeExtendedEditor);
- eea.update();
- if (eea.isVisible()) {
- IMenuManager parent = contributeMenuAction(ad, menu, true, true);
- if (debugPopup && parent != null)
- System.out.println(getClass().getName() + "#contributeToPopupMenu() added: " + ad.getId()); //$NON-NLS-1$
- }
- }
- catch (Throwable e) {
- Logger.logException(e);
- }
-
- }
- else {
- IMenuManager parent = contributeMenuAction(ad, menu, true, true);
- if (debugPopup && parent != null)
- System.out.println(getClass().getName() + "#contributeToPopupMenu() added: " + ad.getId()); //$NON-NLS-1$
- }
- }
- }
- if (debugContributeTime)
- System.out.println(getClass().getName() + "#contributeToPopupMenu(): ran in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void contributeToStatusLine(IStatusLineManager manager) {
- // nothing from here
- }
-
- public void contributeToToolBar(IToolBarManager manager) {
- long time0 = System.currentTimeMillis();
- for (int i = 0; i < cache.size(); i++) {
- Object obj = cache.get(i);
- if (obj instanceof ActionDescriptor) {
- ActionDescriptor ad = (ActionDescriptor) obj;
- IAction a = ad.getAction();
- if (a instanceof IExtendedEditorAction) {
- IExtendedEditorAction eea = (IExtendedEditorAction) a;
- eea.setActiveExtendedEditor(activeExtendedEditor);
- eea.update();
- if (eea.isVisible()) {
- boolean contributed = contributeToolbarAction(ad, manager, true);
- if (debugToolbar && contributed)
- System.out.println(getClass().getName() + "#contributeToToolBar() added: " + ad.getId()); //$NON-NLS-1$
- }
- else {
- if (debugToolbar)
- System.out.println(getClass().getName() + "#contributeToToolBar(): [skipped] " + ad.getId()); //$NON-NLS-1$
- }
- }
- else {
- boolean contributed = contributeToolbarAction(ad, manager, true);
- if (debugToolbar && contributed)
- System.out.println(getClass().getName() + "#contributeToToolBar() added: " + ad.getId()); //$NON-NLS-1$
- }
- }
- }
- if (debugContributeTime)
- System.out.println(getClass().getName() + "#contributeToToolBar(): ran in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- public void dispose() {
- Iterator it = menus.iterator();
- while (it.hasNext()) {
- Object o = it.next();
- if (o instanceof IMenuManager) {
- ((IMenuManager) o).removeMenuListener(this);
- }
- }
- }
-
- /**
- * Do not use. @deprecated: will be deleted soon
- */
- public void init(IActionBars bars) {
- // nothing from here
- }
-
- public void init(IActionBars bars, IWorkbenchPage page) {
- // nothing from here
- }
-
- public void menuAboutToShow(IMenuManager menu) {
- // slows down the menu and interferes with it for other editors; optimize on visibility
- IEditorSite site = null;
- boolean activeEditorIsVisible = false;
-
- if (activeExtendedEditor != null && activeExtendedEditor.getEditorPart() != null)
- site = activeExtendedEditor.getEditorPart().getEditorSite();
- if (site == null)
- return;
-
- // Eclipse bug 48784 - [MPE] ClassCast exception Workbench page isPartVisiable for MultiPageSite
- if (site instanceof MultiPageEditorSite) {
- Object multiPageEditor = ((MultiPageEditorSite) site).getMultiPageEditor();
- activeEditorIsVisible = multiPageEditor.equals(site.getPage().getActiveEditor()) || multiPageEditor.equals(site.getPage().getActivePart());
- }
- else {
- activeEditorIsVisible = site.getWorkbenchWindow().getPartService().getActivePart().equals(activeExtendedEditor.getEditorPart());
- }
- if (!activeEditorIsVisible)
- return;
-
- IContributionItem[] items = menu.getItems();
- if (items == null || items.length == 0)
- return;
-
- for (int i = 0; i < items.length; ++i) {
- // add menu listener to submenu
- if (items[i] instanceof IMenuManager) {
- ((IMenuManager) items[i]).addMenuListener(this);
- menus.add(items[i]);
- }
- }
-
- Set keys = map.keySet();
- Iterator it = keys.iterator();
- while (it.hasNext()) {
- IContributionItem item = (IContributionItem) it.next();
- IMenuManager mm = (IMenuManager) map.get(item);
- if (menu.getId() != null && menu.getId().equals(mm.getId()) && item instanceof ActionContributionItem) {
- IAction action = ((ActionContributionItem) item).getAction();
-
- if (action instanceof IUpdate) {
- ((IUpdate) action).update();
- }
-
- boolean visible = true;
- if (action instanceof IExtendedEditorAction) {
- visible = ((IExtendedEditorAction) action).isVisible();
- }
- item.setVisible(visible);
- }
- }
- menu.update(false);
- }
-
- public void setActiveEditor(IEditorPart editor) {
- activeExtendedEditor = (editor instanceof IExtendedSimpleEditor) ? (IExtendedSimpleEditor) editor : null;
- IKeyBindingService svc = (editor != null) ? editor.getEditorSite().getKeyBindingService() : null;
- for (int i = 0; i < cache.size(); i++) {
- Object obj = cache.get(i);
- if (obj instanceof ActionDescriptor) {
- ActionDescriptor ad = (ActionDescriptor) obj;
- IAction action = ad.getAction();
- if (action instanceof IExtendedEditorAction) {
- ((IExtendedEditorAction) action).setActiveExtendedEditor(activeExtendedEditor);
- ((IExtendedEditorAction) action).update();
- // update visibility right now so that the menu will show/hide properly
- if (!((IExtendedEditorAction) action).isVisible() && ad.getContributionItem() != null)
- ad.getContributionItem().setVisible(false);
- if (svc != null && action.getActionDefinitionId() != null) {
- svc.registerAction(action);
- }
- }
- }
- }
-
- if (menuBar != null && editor != null) {
- // Class clz = editor.getClass();
- // while (clz != null) {
- // if (clz.getName().equals(targetID)) {
- // contributeToMenu(menuBar);
- // break;
- // }
- // clz = clz.getSuperclass();
- // }
- if (targetIDs.contains(editor.getEditorSite().getId())) {
- contributeToMenu(menuBar);
- }
- }
-
- updateToolbarActions();
- }
-
- public void updateToolbarActions() {
- for (int i = 0; i < cache.size(); i++) {
- Object obj = cache.get(i);
- if (obj instanceof ActionDescriptor) {
- ActionDescriptor ad = (ActionDescriptor) obj;
- if (ad.getToolbarPath() != null) {
- IAction action = ad.getAction();
- if (action instanceof IUpdate) {
- ((IUpdate) action).update();
- }
- }
- }
- }
- }
- }
-
- public static final String ATT_ID = "id"; //$NON-NLS-1$
- public static final String ATT_LABEL = "label"; //$NON-NLS-1$
- public static final String ATT_NAME = "name"; //$NON-NLS-1$
- public static final String ATT_PATH = "path"; //$NON-NLS-1$
-
- public static final String ATT_TARGET_ID = "targetID"; //$NON-NLS-1$
- protected final static boolean debugContributeTime = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/extendededitoractionbuilder/contributetime")); //$NON-NLS-1$ //$NON-NLS-2$
-
- protected final static boolean debugMenu = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/extendededitoractionbuilder/debugmenu")); //$NON-NLS-1$ //$NON-NLS-2$;
- protected final static boolean debugPopup = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/extendededitoractionbuilder/debugpopup")); //$NON-NLS-1$ //$NON-NLS-2$;
- protected final static boolean debugReadTime = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/extendededitoractionbuilder/readtime")); //$NON-NLS-1$ //$NON-NLS-2$
- protected final static boolean debugToolbar = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/extendededitoractionbuilder/debugtoolbar")); //$NON-NLS-1$ //$NON-NLS-2$;
-
- private static final String EXTENDED_EDITOR = "extendedEditor"; //$NON-NLS-1$
-
- public static final String PL_EXTENDED_EDITOR_ACTIONS = "extendedEditorActions"; //$NON-NLS-1$
-
- public static final String PLUGIN_ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$
- public static final String TAG_ACTION = "action"; //$NON-NLS-1$
-
- public static final String TAG_CONTRIBUTION_TYPE = "editorContribution"; //$NON-NLS-1$
-
- public static final String TAG_MENU = "menu"; //$NON-NLS-1$
- public static final String TAG_POPUPMENU = "popupmenu"; //$NON-NLS-1$
- public static final String TAG_RULERMENU = "rulermenu"; //$NON-NLS-1$
- public static final String TAG_SEPARATOR = "separator"; //$NON-NLS-1$
-
- protected List readingCache;
-
- protected String targetContributionTag;
- protected List targetIDs;
-
- /**
- * The constructor.
- */
- public ExtendedEditorActionBuilder() {
- super();
- }
-
- /**
- * Creates a menu from the information in the menu configuration element and adds it into the provided menu manager. If 'appendIfMissing' is true, and menu path slot is not found, it will be created and menu will be added into it. Otherwise, add operation will fail.
- */
- protected void contributeMenu(IConfigurationElement menuElement, IMenuManager mng, boolean appendIfMissing) {
- // Get config data.
- String id = menuElement.getAttribute(ATT_ID);
- String label = menuElement.getAttribute(ATT_LABEL);
- String path = menuElement.getAttribute(ATT_PATH);
- if (label == null) {
- Logger.log(Logger.ERROR, "Invalid Menu Extension (label == null): " + id); //$NON-NLS-1$
- return;
- }
-
- // Calculate menu path and group.
- String group = null;
- if (path != null) {
- int loc = path.lastIndexOf('/');
- if (loc != -1) {
- group = path.substring(loc + 1);
- path = path.substring(0, loc);
- }
- else {
- // assume that path represents a slot
- // so actual path portion should be null
- group = path;
- path = null;
- }
- }
-
- // Find parent menu.
- IMenuManager parent = mng;
- if (path != null) {
- parent = mng.findMenuUsingPath(path);
- if (parent == null) {
- //Logger.log("Invalid Menu Extension (Path is invalid): " + id);//$NON-NLS-1$
- return;
- }
- // IMenuManager.findMenuUsingPath() returns invisible menu item if the manager can't find
- // the specified path and create new MenuManager for it.
- // I don't know this is a specification or bug.
- // Anyway, to ensure the menu can be visible, setVisible(true) needs to be called.
- parent.setVisible(true);
- }
-
- // Find reference group.
- if (group == null)
- group = IWorkbenchActionConstants.MB_ADDITIONS;
- IContributionItem sep = parent.find(group);
- if (sep == null) {
- if (appendIfMissing)
- parent.add(new Separator(group));
- else {
- Logger.log(Logger.ERROR, "Invalid Menu Extension (Group is invalid): " + id); //$NON-NLS-1$
- return;
- }
- }
-
- // If the menu does not exist create it.
- IMenuManager newMenu = parent.findMenuUsingPath(id);
- if (newMenu == null)
- newMenu = new MenuManager(label, id);
-
- // Create separators.
- IConfigurationElement[] children = menuElement.getChildren(TAG_SEPARATOR);
- for (int i = 0; i < children.length; i++) {
- contributeSeparator(newMenu, children[i]);
- }
-
- // Add new menu
- try {
- parent.insertAfter(group, newMenu);
- }
- catch (IllegalArgumentException e) {
- Logger.log(Logger.ERROR, "Invalid Menu Extension (Group is missing): " + id); //$NON-NLS-1$
- }
- }
-
- /**
- * Contributes action from action descriptor into the provided menu manager.
- */
- protected IMenuManager contributeMenuAction(ActionDescriptor ad, IMenuManager menu, boolean appendIfMissing, boolean popupmenu) {
- if (ad.getContributionItem() == null || ad.getAction() == null)
- return null;
-
- // Get config data.
- String mpath = popupmenu ? ad.getPopupMenuPath() : ad.getMenuPath();
- String mgroup = popupmenu ? ad.getPopupMenuGroup() : ad.getMenuGroup();
- if (mpath == null && mgroup == null)
- return null;
-
- // Find parent menu.
- IMenuManager parent = menu;
- if (mpath != null) {
- parent = parent.findMenuUsingPath(mpath);
- if (parent == null) {
- //Logger.log("Invalid Menu Extension (Path is invalid): " + ad.getId()); //$NON-NLS-1$
- return null;
- }
- // IMenuManager.findMenuUsingPath() returns invisible menu item if the manager can't find
- // the specified path and create new MenuManager for it.
- // I don't know this is a specification or bug.
- // Anyway, to ensure the menu can be visible, setVisible(true) needs to be called.
- parent.setVisible(true);
- }
-
- // First remove existing menu item
- IContributionItem item = parent.find(ad.getId());
- if (item != null) {
- parent.remove(ad.getId());
- }
-
- // Find reference group.
- if (mgroup == null)
- mgroup = IWorkbenchActionConstants.MB_ADDITIONS;
- IContributionItem sep = parent.find(mgroup);
- if (sep == null) {
- if (appendIfMissing)
- parent.add(sep = new Separator(mgroup));
- else {
- Logger.log(Logger.ERROR, "Invalid Menu Extension (Group is invalid): " + ad.getId()); //$NON-NLS-1$
- return null;
- }
- }
-
- // Add action.
- try {
- if (popupmenu) {
- // Context menu need a newly created contribution item
- if (sep != null && sep.isGroupMarker())
- parent.appendToGroup(sep.getId(), ad.getAction());
- else
- parent.insertAfter(mgroup, ad.getAction());
- }
- else {
- // Normal menu need to add existing contribution item to remove it from menu listener
- if (sep != null && sep.isGroupMarker())
- parent.appendToGroup(sep.getId(), ad.getContributionItem());
- else
- parent.insertAfter(mgroup, ad.getContributionItem());
- }
- }
- catch (IllegalArgumentException e) {
- Logger.log(Logger.ERROR, "Invalid Menu Extension (Group is missing): " + ad.getId()); //$NON-NLS-1$
- parent = null;
- }
-
- return parent;
- }
-
- /**
- * Creates a named menu separator from the information in the configuration element. If the separator already exists do not create a second.
- */
- protected boolean contributeSeparator(IMenuManager menu, IConfigurationElement element) {
- String id = element.getAttribute(ATT_NAME);
- if (id == null || id.length() <= 0)
- return false;
- IContributionItem sep = menu.find(id);
- if (sep != null)
- return false;
- menu.add(new Separator(id));
- return true;
- }
-
- /**
- * Contributes action from the action descriptor into the provided tool bar manager.
- */
- protected boolean contributeToolbarAction(ActionDescriptor ad, IToolBarManager toolbar, boolean appendIfMissing) {
- if (ad.getContributionItem() == null || ad.getAction() == null)
- return false;
-
- // Get config data.
- String tpath = ad.getToolbarPath();
- String tgroup = ad.getToolbarGroup();
- if (tpath == null && tgroup == null)
- return false;
-
- // First remove existing toolbar item
- IContributionItem item = toolbar.find(ad.getId());
- if (item != null) {
- toolbar.remove(ad.getId());
- }
-
- // Find reference group.
- if (tgroup == null)
- tgroup = IWorkbenchActionConstants.MB_ADDITIONS;
- IContributionItem sep = toolbar.find(tgroup);
- if (sep == null) {
- if (appendIfMissing)
- toolbar.add(new Separator(tgroup));
- else {
- Logger.log(Logger.ERROR, "Invalid Toolbar Extension (Group is invalid): " + ad.getId()); //$NON-NLS-1$
- return false;
- }
- }
-
- // Add action to tool bar.
- try {
- if (sep != null && sep.isGroupMarker())
- toolbar.appendToGroup(sep.getId(), ad.getAction());
- else
- toolbar.insertAfter(tgroup, ad.getAction());
- }
- catch (IllegalArgumentException e) {
- Logger.log(Logger.ERROR, "Invalid Toolbar Extension (Group is missing): " + ad.getId()); //$NON-NLS-1$
- return false;
- }
- return true;
- }
-
- /**
- * This factory method returns a new ActionDescriptor for the configuration element. It should be implemented by subclasses.
- */
- protected ActionDescriptor createActionDescriptor(IConfigurationElement element) {
- ActionDescriptor ad = null;
- try {
- ad = new ActionDescriptor(element);
- // these cases like "class not found" are handled
- // at lower level, so no action if formed. In that
- // case, we also don't want to form an action descriptor.
- if ((ad != null) && (ad.getAction() == null)) {
- ad = null;
- }
- }
- catch (Throwable e) {
- Logger.traceException(EXTENDED_EDITOR, e);
- ad = null;
- }
- return ad;
- }
-
- /**
- * Returns the name of the part ID attribute that is expected in the target extension.
- */
- protected String getTargetID(IConfigurationElement element) {
- String value = element.getAttribute(ATT_TARGET_ID);
- return value != null ? value : "???"; //$NON-NLS-1$
- }
-
- /**
- * Reads editor contributor if specified directly in the 'editor' extension point, and all external contributions for this editor's ID registered in 'editorActions' extension point.
- */
- public IExtendedContributor readActionExtensions(String editorId) {
- return readActionExtensions(new String[]{editorId});
- }
-
- /**
- * Reads editor contributor if specified directly in the 'editor' extension point, and all external contributions for this editor's ID registered in 'editorActions' extension point.
- */
- public IExtendedContributor readActionExtensions(String[] ids) {
- long time0 = System.currentTimeMillis();
- ExtendedContributor ext = null;
- readContributions(ids, TAG_CONTRIBUTION_TYPE, PL_EXTENDED_EDITOR_ACTIONS);
- if (debugReadTime) {
- String idlist = ""; //$NON-NLS-1$
- if (ids.length > 0) {
- for (int i = 0; i < ids.length; i++) {
- idlist += ids[i];
- if (i < ids.length - 1)
- idlist += ","; //$NON-NLS-1$
- }
- }
- System.out.println(getClass().getName() + "#readActionExtensions(" + idlist + "): read in " + (System.currentTimeMillis() - time0) + "ms [" + (readingCache != null ? readingCache.size() : 0) + " contributions]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- if (readingCache != null) {
- ext = new ExtendedContributor(readingCache);
- readingCache = null;
- }
- return ext;
- }
-
- /**
- * Reads the contributions from the registry for the provided workbench part and the provided extension point IDs.
- */
- protected void readContributions(String[] ids, String tag, String extensionPoint) {
- readingCache = null;
- targetIDs = Arrays.asList(ids);
- targetContributionTag = tag;
- IPluginRegistry registry = Platform.getPluginRegistry();
- readRegistry(registry, PLUGIN_ID, extensionPoint);
- }
-
- /**
- * Implements abstract method to handle the provided XML element in the registry.
- */
- protected boolean readElement(IConfigurationElement element) {
- String tag = element.getName();
- if (tag.equals(targetContributionTag)) {
- String id = getTargetID(element);
- if (id == null || !targetIDs.contains(id)) {
- // This is not of interest to us - don't go deeper
- return true;
- }
- }
- else if (tag.equals(TAG_MENU)) {
- if (readingCache == null)
- readingCache = new ArrayList();
- readingCache.add(element);
- return true; // just cache the element - don't go into it
- }
- else if (tag.equals(TAG_POPUPMENU)) {
- if (readingCache == null)
- readingCache = new ArrayList();
- readingCache.add(element);
- return true; // just cache the element - don't go into it
- }
- else if (tag.equals(TAG_RULERMENU)) {
- if (readingCache == null)
- readingCache = new ArrayList();
- readingCache.add(element);
- return true; // just cache the element - don't go into it
- }
- else if (tag.equals(TAG_ACTION)) {
- if (readingCache == null)
- readingCache = new ArrayList();
- ActionDescriptor ad = createActionDescriptor(element);
- if (ad != null)
- readingCache.add(ad);
- return true; // just cache the action - don't go into
- }
- else {
- return false;
- }
-
- readElementChildren(element);
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorDropTargetAdapter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorDropTargetAdapter.java
deleted file mode 100644
index 4b7054aa8b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/ExtendedEditorDropTargetAdapter.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.custom.ST;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DropTargetAdapter;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.FileTransfer;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.dnd.TransferData;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Caret;
-
-/**
- * ExtendedEditorDropTargetAdapter
- */
-public class ExtendedEditorDropTargetAdapter extends DropTargetAdapter {
-
- private Transfer[] transfers = null;
- private String[] editorIds;
- private IExtendedSimpleEditor targetEditor = null;
- private ITextViewer textViewer = null;
- private int orgOffset = 0;
-
- private Point caret = null;
-
- public ExtendedEditorDropTargetAdapter() {
- super();
- }
-
- /**
- */
- public void setTargetEditor(IExtendedSimpleEditor targetEditor) {
- this.targetEditor = targetEditor;
- }
-
- public void setTargetIDs(String[] ids) {
- editorIds = ids;
- }
-
- public IExtendedSimpleEditor getTargetEditor() {
- return targetEditor;
- }
-
- public void setTextViewer(ITextViewer textViewer) {
- this.textViewer = textViewer;
- }
-
- public ITextViewer getTextViewer() {
- return textViewer;
- }
-
- /**
- * @return org.eclipse.swt.dnd.Transfer[]
- */
- public Transfer[] getTransfers() {
- if (transfers == null) {
- TransferBuilder tb = new TransferBuilder();
- if (editorIds == null || editorIds.length == 0)
- transfers = tb.getDropTargetTransfers(getTargetEditor().getClass().getName());
- else
- transfers = tb.getDropTargetTransfers(editorIds);
- }
- return transfers;
- }
-
- /**
- */
- public void dragEnter(DropTargetEvent event) {
- caret = null;
- TransferData data = null;
- Transfer[] ts = getTransfers();
- for (int i = 0; i < ts.length; i++) {
- for (int j = 0; j < event.dataTypes.length; j++) {
- if (ts[i].isSupportedType(event.dataTypes[j])) {
- data = event.dataTypes[j];
- break;
- }
- }
- if (data != null) {
- event.currentDataType = data;
- break;
- }
- }
-
- if (textViewer != null) {
- orgOffset = textViewer.getTextWidget().getCaretOffset();
- }
- }
-
- private Point toControl(Point point) {
- return (textViewer != null ? textViewer.getTextWidget().toControl(point) : point);
- }
-
- public void dragLeave(DropTargetEvent event) {
- if (textViewer != null) {
- StyledText st = textViewer.getTextWidget();
- st.setCaretOffset(orgOffset);
- st.redraw();
- st.update();
- }
- }
-
- /**
- */
- public void dragOver(DropTargetEvent event) {
- event.operations &= ~DND.DROP_MOVE;
- event.detail = DND.DROP_COPY;
-
- if (textViewer != null) {
- Point pt = toControl(new Point(event.x, event.y));
- StyledText st = textViewer.getTextWidget();
-
- // auto scroll
- Rectangle ca = st.getClientArea();
- int margin = st.getLineHeight();
-
- if (pt.y < margin) { // up
- st.invokeAction(ST.LINE_UP);
- }
- else if (pt.y > ca.height - margin) { // down
- st.invokeAction(ST.LINE_DOWN);
- }
-
- // draw insertion point
- int offset = getDropOffset(st, pt);
- if (offset != st.getCaretOffset()) {
- st.setCaretOffset(offset);
- st.setSelection(offset);
- }
-
- Point newCaret = st.getLocationAtOffset(offset);
- if (newCaret.equals(caret))
- return;
-
- Caret ct = st.getCaret();
- Point size = ct.getSize();
-
- GC gc = new GC(st);
- gc.setXORMode(true);
- gc.setLineWidth(size.x);
-
- // erase old caret
- if (caret != null) {
- Color originalForeground = gc.getForeground();
- gc.setForeground(st.getBackground());
- gc.drawLine(caret.x, caret.y, caret.x, caret.y + size.y);
- gc.setForeground(originalForeground);
- }
-
- st.redraw();
- st.update();
-
- // draw new caret
- caret = newCaret;
- if (ct.getImage() != null)
- gc.drawImage(ct.getImage(), caret.x, caret.y);
- else
- gc.drawLine(caret.x, caret.y, caret.x, caret.y + size.y);
-
- gc.dispose();
- }
- }
-
- protected int getDropOffset(DropTargetEvent event) {
- Point pt = getTextViewer().getTextWidget().toControl(new Point(event.x, event.y));
- StyledText st = textViewer.getTextWidget();
- return getDropOffset(st, pt);
- }
-
- private int getDropOffset(StyledText st, Point pt) {
- int offset = st.getCaretOffset();
- try {
- offset = st.getOffsetAtLocation(pt);
- }
- catch (IllegalArgumentException e) {
- // This is normal case if mouse cursor is on outside of valid text.
- boolean found = false;
- Point p = new Point((pt.x > 0 ? pt.x : 0), pt.y);
- // search nearest character
- for (; p.x > -1; p.x--) {
- try {
- offset = st.getOffsetAtLocation(p) + 1; // + 1 to place cursor at an end of line
- found = true;
- break;
- }
- catch (IllegalArgumentException ex) {
- }
- }
-
- if (!found) {
- offset = st.getCharCount();
- }
- }
- return offset;
- }
-
- /**
- */
- public void drop(DropTargetEvent event) {
- if (event.operations == DND.DROP_NONE)
- return;
-
- if (textViewer != null) {
- Point pt = toControl(new Point(event.x, event.y));
- StyledText st = textViewer.getTextWidget();
-
- int offset = getDropOffset(st, pt);
- if (offset != st.getCaretOffset()) {
- st.setCaretOffset(offset);
- }
-
- ISelectionProvider sp = textViewer.getSelectionProvider();
- ISelection sel = new TextSelection(offset, 0);
- sp.setSelection(sel);
- }
-
- Transfer[] ts = getTransfers();
- for (int i = 0; i < ts.length; i++) {
- if (ts[i].isSupportedType(event.currentDataType)) {
- if (doDrop(ts[i], event)) {
- break;
- }
- }
- }
- }
-
- /**
- */
- protected boolean doDrop(Transfer transfer, DropTargetEvent event) {
- TransferBuilder tb = new TransferBuilder();
-
- IDropAction[] as = null;
- if (editorIds != null && editorIds.length > 0)
- as = tb.getDropActions(editorIds, transfer.getClass().getName());
- else
- as = tb.getDropActions(getTargetEditor().getClass().getName(), transfer.getClass().getName());
-
- for (int i = 0; i < as.length; ++i) {
- IDropAction da = as[i];
- if (transfer instanceof FileTransfer) {
- String[] strs = (String[]) event.data;
- boolean[] bs = new boolean[strs.length];
- int c = 0;
- for (int j = 0; j < strs.length; ++j) {
- bs[j] = false;
- if (da.isSupportedData(strs[j])) {
- event.data = new String[]{strs[j]};
- if (!da.run(event, targetEditor)) {
- bs[j] = true;
- c++;
- }
- }
- else {
- bs[j] = true;
- c++;
- }
- }
- if (c == 0) {
- return true;
- }
-
- int k = 0;
- String[] rests = new String[c];
- for (int j = 0; j < strs.length; ++j) {
- if (bs[j])
- rests[k++] = strs[j];
- }
- event.data = rests;
- }
- else if (da.isSupportedData(event.data)) {
- if (da.run(event, targetEditor)) {
- return true;
- }
- }
- }
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FileDropAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FileDropAction.java
deleted file mode 100644
index 996280a41e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FileDropAction.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.swt.dnd.DropTargetEvent;
-
-/**
- * Action for file drop
- */
-public class FileDropAction extends AbstractDropAction {
-
-
- /* (non-Javadoc)
- */
- public boolean run(DropTargetEvent event, IExtendedSimpleEditor targetEditor) {
- String[] strs = (String[]) event.data;
- if (strs == null || strs.length == 0) {
- return false;
- }
-
- String str = ""; //$NON-NLS-1$
- for (int i = 0; i < strs.length; ++i) {
- IPath path = new Path(strs[i]);
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = root.getFileForLocation(path);
- if (file != null) {
- path = file.getProjectRelativePath();
- }
-
- str += "\"" + path.toString() + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return insert(str, targetEditor);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FormatProcessorsExtensionReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FormatProcessorsExtensionReader.java
deleted file mode 100644
index 04e5f663bf..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/FormatProcessorsExtensionReader.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.internal.registry.Extension;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.wst.sse.core.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.ui.internal.extension.RegistryReader;
-
-
-public class FormatProcessorsExtensionReader extends RegistryReader {
- private static FormatProcessorsExtensionReader instance;
- private Map map = new HashMap();
- private String processorClassName;
-
- public synchronized static FormatProcessorsExtensionReader getInstance() {
- if (instance == null) {
- instance = new FormatProcessorsExtensionReader();
-
- IPluginRegistry registry = Platform.getPluginRegistry();
- instance.readRegistry(registry, "org.eclipse.wst.sse.core", "formatProcessors"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return instance;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected boolean readElement(IConfigurationElement element) {
- if (element.getName().equals("processor")) { //$NON-NLS-1$
- String contentTypeId = element.getAttribute("contentTypeId"); //$NON-NLS-1$
- String processorClassName = element.getAttribute("class"); //$NON-NLS-1$
- String pluginID = ((Extension) element.getParent()).getParentIdentifier();
- ClassLoader classLoader = Platform.getPlugin(pluginID).getClass().getClassLoader();
- try {
- IStructuredFormatProcessor processor = (IStructuredFormatProcessor) Class.forName(processorClassName, false, classLoader).newInstance();
- map.put(contentTypeId, processor);
-
- return true;
- }
- catch (InstantiationException e) {
- e.printStackTrace();
- }
- catch (IllegalAccessException e) {
- e.printStackTrace();
- }
- catch (ClassNotFoundException e) {
- e.printStackTrace();
- }
- }
-
- return false;
- }
-
- public IStructuredFormatProcessor getFormatProcessor(String contentTypeId) {
- if (contentTypeId == null)
- return null;
-
- IStructuredFormatProcessor formatProcessor = null;
- if (map.containsKey(contentTypeId)) {
- formatProcessor = (IStructuredFormatProcessor) map.get(contentTypeId);
- }
- else {
- IContentTypeManager manager = Platform.getContentTypeManager();
- IContentType queryContentType = manager.getContentType(contentTypeId);
- Iterator iterator = map.keySet().iterator();
- boolean found = false;
- for (Iterator iter = map.keySet().iterator(); iter.hasNext();) {
- String elementContentTypeId = (String) iter.next();
- IContentType elementContentType = manager.getContentType(elementContentTypeId);
- if (queryContentType.isKindOf(elementContentType)) {
- formatProcessor = (IStructuredFormatProcessor) map.get(elementContentTypeId);
- map.put(contentTypeId, formatProcessor);
- found = true;
- break;
- }
- }
-
- if (!found)
- map.put(contentTypeId, null);
- }
-
- return formatProcessor;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IActionValidator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IActionValidator.java
deleted file mode 100644
index 2075ec717f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IActionValidator.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-public interface IActionValidator {
- boolean isValidAction();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IDropAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IDropAction.java
deleted file mode 100644
index c5efff1b5d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IDropAction.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.swt.dnd.DropTargetEvent;
-
-/**
- */
-public interface IDropAction {
-
-
- /**
- * @param data DropTargetEvent.data will be passed.
- * @return boolean true for supported data type
- */
- public boolean isSupportedData(Object data);
-
- /**
- * @return boolean true for the action is actually processed
- * false for the action is not processed.
- */
- public boolean run(DropTargetEvent event, IExtendedSimpleEditor targetEditor);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedConfiguration.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedConfiguration.java
deleted file mode 100644
index aaddf8c352..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedConfiguration.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-public interface IExtendedConfiguration {
- void setDeclaringID(String targetID);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedContributor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedContributor.java
deleted file mode 100644
index 9915c78b2d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedContributor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.ui.IEditorActionBarContributor;
-
-public interface IExtendedContributor extends IEditorActionBarContributor, IPopupMenuContributor {
- public void contributeToMenu(IMenuManager menu);
-
- public void contributeToToolBar(IToolBarManager manager);
-
- public void contributeToStatusLine(IStatusLineManager manager);
-
- public void updateToolbarActions();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedEditorAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedEditorAction.java
deleted file mode 100644
index ff8b78e3e6..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedEditorAction.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.ui.texteditor.IUpdate;
-
-public interface IExtendedEditorAction extends IUpdate {
-
- /**
- * Sets the active editor for the action.
- * Implementors should disconnect from the old editor, connect to the
- * new editor, and update the action to reflect the new editor.
- *
- * @param targetEditor the new editor target
- */
- public void setActiveExtendedEditor(IExtendedSimpleEditor targetEditor);
-
- /**
- * Returns whether this action item is visible
- *
- * @return <code>true</code> if this item is visible, and
- * <code>false</code> otherwise
- */
- public boolean isVisible();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditor.java
deleted file mode 100644
index b18eb6ab11..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditor.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import java.util.List;
-
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * IExtendedMarkupEditor
- */
-public interface IExtendedMarkupEditor extends IExtendedSimpleEditor {
-
-
- public Node getCaretNode();
-
- public List getSelectedNodes();
-
- public Document getDOMDocument();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditorExtension.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditorExtension.java
deleted file mode 100644
index 596b20fbc2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedMarkupEditorExtension.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-import org.w3c.dom.Node;
-
-
-public interface IExtendedMarkupEditorExtension extends IExtendedMarkupEditor {
- /**
- * Return the line under the mouse Cursor
- * @return
- */
- int getCursorOffset();
-
- /**
- * Return the DOM Node under the mouse Cursor
- * @return
- */
- Node getCursorNode();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedSimpleEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedSimpleEditor.java
deleted file mode 100644
index 153b624cfe..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IExtendedSimpleEditor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-
-public interface IExtendedSimpleEditor {
-
-
- public IEditorPart getEditorPart();
-
- public int getCaretPosition();
-
- public Point getSelectionRange();
-
- public IDocument getDocument();
-
- public IStatus validateEdit(Shell context);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IPopupMenuContributor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IPopupMenuContributor.java
deleted file mode 100644
index 812b13732e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/IPopupMenuContributor.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.jface.action.IMenuManager;
-
-public interface IPopupMenuContributor {
-
- public void contributeToPopupMenu(IMenuManager menu);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/SpellCheckProviderBuilder.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/SpellCheckProviderBuilder.java
deleted file mode 100644
index 93740d4931..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/SpellCheckProviderBuilder.java
+++ /dev/null
@@ -1,239 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckProvider;
-import org.eclipse.wst.sse.ui.internal.extension.RegistryReader;
-
-
-/**
- * Reads breakpoint extension registory and returns breakpoint provider
- * instances
- */
-public class SpellCheckProviderBuilder extends RegistryReader {
- private static SpellCheckProviderBuilder instance;
-
- protected String targetContributionTag;
- protected List cache;
- protected SpellCheckProvider[] providers = null;
-
- private static final String PLUGIN_ID = "org.eclipse.wst.sse.ui.extensions"; //$NON-NLS-1$
- private static final String PL_SPELLCHECK = "spellcheck"; //$NON-NLS-1$
-
- private static final String TAG_SPELLCHECK_CONTRIBUTION = "spellcheckContribution"; //$NON-NLS-1$
- private static final String TAG_PROVIDER = "provider"; //$NON-NLS-1$
-
- private static final String ATT_CLASS = "class"; //$NON-NLS-1$
-
- //private static final String ATT_ID = "id"; //$NON-NLS-1$
-
- /*
- * Constructor
- */
- private SpellCheckProviderBuilder() {
- }
-
- /**
- * returns singleton instance of SpellCheckProviderBuilder
- * @return SpellCheckProviderBuilder
- */
- public synchronized static SpellCheckProviderBuilder getInstance() {
- if (instance == null) {
- instance = new SpellCheckProviderBuilder();
- }
- return instance;
- }
-
- /*
- * Creates an array of breakpoint providers
- * @return SpellCheckProvider[]
- */
- protected SpellCheckProvider[] createSpellCheckProviders() {
- if (cache == null)
- return new SpellCheckProvider[0];
-
- final int num = cache.size();
- if (num == 0)
- return new SpellCheckProvider[0];
-
- SpellCheckProvider[] bp = new SpellCheckProvider[num];
- int j = 0;
- for (int i = 0; i < num; i++) {
- Object obj = cache.get(i);
- if (!(obj instanceof IConfigurationElement))
- continue;
-
- IConfigurationElement element = (IConfigurationElement) obj;
- if (!TAG_PROVIDER.equals(element.getName())) {
- continue;
- }
-
- SpellCheckProvider b = createSpellCheckProvider(element);
- if (b != null) {
- // b.setSourceEditingTextTools(new SourceEditingTextToolsImpl());
- bp[j] = b;
- j++;
- }
- }
-
- SpellCheckProvider[] bp2 = new SpellCheckProvider[j];
-
- for (int i = 0; i < j; i++) {
- bp2[i] = bp[i];
- }
-
- return bp2;
- }
-
- /*
- * Creates a breakpoint provider object to given element
- * @param element configuration element object
- * @return SpellCheckProvider
- */
- protected SpellCheckProvider createSpellCheckProvider(IConfigurationElement element) {
- Object obj = null;
- obj = createExtension(element, ATT_CLASS);
- if (obj == null)
- return null;
- return (obj instanceof SpellCheckProvider) ? (SpellCheckProvider) obj : null;
- }
-
- /**
- * Creates an extension. If the extension plugin has not
- * been loaded a busy cursor will be activated during the duration of
- * the load.
- *
- * @param element the config element defining the extension
- * @param classAttribute the name of the attribute carrying the class
- * @return the extension object
- * @throws CoreException
- */
- public static Object createExtension(final IConfigurationElement element, final String classAttribute) {
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- final Object[] result = new Object[1];
-
- if (plugin.isPluginActivated()) {
- try {
- return createExecutableExtension(element, classAttribute);
- }
- catch (Throwable e) {
- handleCreateExecutableException(result, e);
- }
- }
- else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- result[0] = createExecutableExtension(element, classAttribute);
- }
- catch (Throwable e) {
- handleCreateExecutableException(result, e);
- }
- }
- });
- }
- return result[0];
- }
-
- /**
- * @param result
- * @param e
- */
- private static void handleCreateExecutableException(Object[] result, Throwable e) {
- Logger.logException(e);
- result[0] = null;
-
- }
-
- /*
- * Creates an executable extension.
- * @param element the config element defining the extension
- * @param classAttribute the name of the attribute carrying the class
- * @return the extension object
- * @throws CoreException
- */
- static Object createExecutableExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
- return element.createExecutableExtension(classAttribute);
- }
-
- /**
- * Returns an array of spellcheck providers for a specified content type
- * handler
- * @param handler a content type handler
- * @param ext file extension
- * @return SpellCheckProvider[]
- */
- public SpellCheckProvider[] getSpellCheckProviders() {
- if (cache == null) {
- readContributions(TAG_SPELLCHECK_CONTRIBUTION, PL_SPELLCHECK);
- }
-
- if (providers == null) {
- providers = createSpellCheckProviders();
- }
-
- return providers;
- }
-
- /**
- * Returns an array of breakpoint providers
- * @return boolean
- */
- public boolean isAvailable() {
- return getSpellCheckProviders().length != 0 ? true : false;
- }
-
- /**
- * Reads the contributions from the registry for the provided workbench
- * part and the provided extension point ID.
- * @param tag
- * @param extensionPoint
- */
- protected void readContributions(String tag, String extensionPoint) {
- cache = null;
- targetContributionTag = tag;
- IPluginRegistry registry = Platform.getPluginRegistry();
- readRegistry(registry, PLUGIN_ID, extensionPoint);
- }
-
- /*
- */
- protected boolean readElement(IConfigurationElement element) {
- String tag = element.getName();
- if (tag.equals(targetContributionTag)) {
- readElementChildren(element);
- return true;
- }
- else if (tag.equals(TAG_PROVIDER)) {
- if (cache == null)
- cache = new ArrayList();
- cache.add(element);
- return true; // just cache the element - don't go into it
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TextDropAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TextDropAction.java
deleted file mode 100644
index 9cd9ed3494..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TextDropAction.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import org.eclipse.swt.dnd.DropTargetEvent;
-
-/**
- * TextDropAction
- */
-public class TextDropAction extends AbstractDropAction {
-
-
- /**
- * @see AbstractDropAction#run(DropTargetEvent, IExtendedSimpleEditor)
- */
- public boolean run(DropTargetEvent event, IExtendedSimpleEditor targetEditor) {
- return insert((String) event.data, targetEditor);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TransferBuilder.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TransferBuilder.java
deleted file mode 100644
index 608d0ab161..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extension/TransferBuilder.java
+++ /dev/null
@@ -1,425 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extension;
-
-
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.extension.DropActionProxy;
-import org.eclipse.wst.sse.ui.internal.extension.RegistryReader;
-
-
-/**
- * Builds drop target transfers, drag source transfers, and drop actions
- */
-public class TransferBuilder extends RegistryReader {
-
- private final static boolean debugTime = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.ui/transferbuilder/time")); //$NON-NLS-1$ //$NON-NLS-2$
-
- protected List targetIDs;
- protected String targetContributionTag;
- protected List cache;
-
- public static final String PL_DRAG_SOURCE_TRANSFERS = "dragSourceTransfers"; //$NON-NLS-1$
- public static final String PL_DROP_TARGET_TRANSFERS = "dropTargetTransfers"; //$NON-NLS-1$
-
- public static final String PLUGIN_ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$
-
- public static final String TAG_DRAG_SOURCE_CONTRIBUTION = "dragSourceContribution"; //$NON-NLS-1$
- public static final String TAG_DROP_TARGET_CONTRIBUTION = "dropTargetContribution"; //$NON-NLS-1$
-
- public static final String TAG_TRANSFER = "transfer"; //$NON-NLS-1$
- public static final String TAG_DROP_ACTION = "dropAction"; //$NON-NLS-1$
-
- public static final String ATT_CLASS = "class"; //$NON-NLS-1$
- public static final String ATT_ID = "id"; //$NON-NLS-1$
- public static final String ATT_TARGET_ID = "targetID"; //$NON-NLS-1$
- public static final String ATT_TRANSFER_ID = "transferID"; //$NON-NLS-1$
- public static final String ATT_SINGLETON = "singleton"; //$NON-NLS-1$
- public static final String ATT_METHOD = "method"; //$NON-NLS-1$
- public static final String ATT_PRIORITY = "priority"; //$NON-NLS-1$
-
- public static final String TRUE = "true"; //$NON-NLS-1$
-
- public static final String[] PRIORITIES = {"highest", "high", "mid", "low", "lowest"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
-
- /**
- * @param editorId
- * @return Transfer[]
- */
- public Transfer[] getDropTargetTransfers(String editorId) {
- return getDropTargetTransfers(new String[]{editorId});
- }
-
- /**
- * @param editorIds
- * @return Transfer[]
- */
- public Transfer[] getDropTargetTransfers(String[] editorIds) {
- long time0 = System.currentTimeMillis();
- readContributions(editorIds, TAG_DROP_TARGET_CONTRIBUTION, PL_DROP_TARGET_TRANSFERS);
- Transfer[] transfers = createTransfers();
- if (debugTime) {
- String idlist = ""; //$NON-NLS-1$
- if (editorIds.length > 0) {
- for (int i = 0; i < editorIds.length; i++) {
- idlist += editorIds[i];
- if (i < editorIds.length - 1)
- idlist += ","; //$NON-NLS-1$
- }
- }
- System.out.println(getClass().getName() + "#getDropTargetTransfers(" + idlist + "): " + transfers.length + " transfers created in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- }
- return transfers;
- }
-
- /**
- * @param editorId
- * @return Transfer[]
- */
- public Transfer[] getDragSourceTransfers(String editorId) {
- return getDragSourceTransfers(new String[]{editorId});
- }
-
- /**
- * @param editorIds
- * @return Transfer[]
- */
- public Transfer[] getDragSourceTransfers(String[] editorIds) {
- long time0 = System.currentTimeMillis();
- readContributions(editorIds, TAG_DRAG_SOURCE_CONTRIBUTION, PL_DRAG_SOURCE_TRANSFERS);
- Transfer[] transfers = createTransfers();
- if (debugTime)
- System.out.println(getClass().getName() + "#getDragSourceTransfers(" + editorIds + "): " + transfers.length + " transfers created in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return transfers;
- }
-
- /**
- * @param editorId
- * @param className
- * @return IDropAction[]
- */
- public IDropAction[] getDropActions(String editorId, String transferClassName) {
- return getDropActions(new String[]{editorId}, transferClassName);
- }
-
- /**
- * @param editorId
- * @param className
- * @return IDropAction[]
- */
- public IDropAction[] getDropActions(String[] editorIds, String transferClassName) {
- long time0 = System.currentTimeMillis();
- readContributions(editorIds, TAG_DROP_TARGET_CONTRIBUTION, PL_DROP_TARGET_TRANSFERS);
- String transferId = getTransferIdOfClassName(transferClassName);
- IDropAction[] actions = createDropActions(transferId);
- if (debugTime)
- System.out.println(getClass().getName() + "#getDropActions(" + editorIds + "): " + actions.length + " drop actions created in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- return actions;
- }
-
- /**
- * @param className
- * @return String
- */
- private String getTransferIdOfClassName(String className) {
- String id = ""; //$NON-NLS-1$
- final int num = cache.size();
- if (className == null || cache == null || num == 0)
- return id;
-
- for (int i = 0; i < num; i++) {
- Object obj = cache.get(i);
- if (obj instanceof IConfigurationElement) {
- IConfigurationElement element = (IConfigurationElement) obj;
- if (className.equals(element.getAttribute(ATT_CLASS))) {
- id = element.getAttribute(ATT_ID);
- break;
- }
- }
- }
-
- return (id.length() != 0 ? id : className);
- }
-
- /**
- * @return Transfer[]
- */
- protected Transfer[] createTransfers() {
- if (cache == null)
- return new Transfer[0];
-
- final int num = cache.size();
- if (num == 0)
- return new Transfer[0];
-
- Transfer[] ts = new Transfer[num];
- int j = 0;
- for (int p = 0; p < PRIORITIES.length; p++) {
- for (int i = 0; i < num; i++) {
- Object obj = cache.get(i);
- if (!(obj instanceof IConfigurationElement))
- continue;
-
- IConfigurationElement element = (IConfigurationElement) obj;
- if (!TAG_TRANSFER.equals(element.getName()))
- continue;
-
- if (PRIORITIES[p].equals(element.getAttribute(ATT_PRIORITY)) || (p == 2 && element.getAttribute(ATT_PRIORITY) == null)) {
- Transfer t = createTransfer(element);
- if (t != null) {
- ts[j] = t;
- j++;
- }
- }
- }
- }
-
- if (num == j)
- return ts;
-
- Transfer[] ts2 = new Transfer[j];
- for (int i = 0; i < j; i++) {
- ts2[i] = ts[i];
- }
-
- return ts2;
- }
-
- /**
- * @param element
- * @return Transfer
- */
- protected Transfer createTransfer(IConfigurationElement element) {
- Object obj = null;
- obj = createExtension(element, ATT_CLASS);
- if (obj == null)
- return null;
- return (obj instanceof Transfer) ? (Transfer) obj : null;
- }
-
- /**
- * @param transferId
- * @return IDropAction[]
- */
- protected IDropAction[] createDropActions(String transferId) {
- if (cache == null)
- return new IDropAction[0];
-
- final int num = cache.size();
- if (num == 0)
- return new IDropAction[0];
-
- IDropAction[] as = new IDropAction[num];
- int j = 0;
- for (int p = 0; p < PRIORITIES.length; p++) {
- for (int i = 0; i < num; i++) {
- Object obj = cache.get(i);
- if (!(obj instanceof IConfigurationElement))
- continue;
-
- IConfigurationElement element = (IConfigurationElement) obj;
- if (!(TAG_DROP_ACTION.equals(element.getName())) || !(transferId.equals(element.getAttribute(ATT_TRANSFER_ID))))
- continue;
-
- if (PRIORITIES[p].equals(element.getAttribute(ATT_PRIORITY)) || (p == 2 && element.getAttribute(ATT_PRIORITY) == null)) {
- IDropAction a = createDropAction(element);
- if (a != null) {
- as[j] = a;
- j++;
- }
- }
- }
- }
-
- if (num == j)
- return as;
-
- IDropAction[] as2 = new IDropAction[j];
- for (int i = 0; i < j; i++) {
- as2[i] = as[i];
- }
-
- return as2;
- }
-
- /**
- * @param element
- * @return IDropAction
- */
- protected IDropAction createDropAction(IConfigurationElement element) {
- Object obj = null;
- obj = createExtension(element, ATT_CLASS);
- if (obj == null)
- return null;
- return (obj instanceof IDropAction) ? (IDropAction) DropActionProxy.newInstance(obj) : null;
- }
-
- /**
- * Creates an extension. If the extension plugin has not
- * been loaded a busy cursor will be activated during the duration of
- * the load.
- * @param element
- * @param classAttribute
- * @return Object
- * @throws CoreException
- */
- public static Object createExtension(final IConfigurationElement element, final String classAttribute) {
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- final Object[] result = new Object[1];
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- try {
- return createExecutableExtension(element, classAttribute);
- }
- catch (CoreException e) {
- handleCreateExecutableException(result, e);
- }
- }
- else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- result[0] = createExecutableExtension(element, classAttribute);
- }
- catch (Throwable e) {
- handleCreateExecutableException(result, e);
- }
- }
- });
- }
- return result[0];
- }
-
- /**
- * @param result
- * @param e
- */
- protected static void handleCreateExecutableException(Object[] result, Throwable e) {
- Logger.logException(e);
- result[0] = null;
-
- }
-
- /**
- * @param element
- * @param classAttribute
- * @return Object
- * @throws CoreException
- */
- static Object createExecutableExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
-
- Object obj = null;
-
- String singleton = element.getAttribute(ATT_SINGLETON);
- String method = element.getAttribute(ATT_METHOD);
- if (TRUE.equalsIgnoreCase(singleton) && method != null) {
- try {
- String name = element.getAttribute(ATT_CLASS);
- Class cls = element.getDeclaringExtension().getDeclaringPluginDescriptor().getPluginClassLoader().loadClass(name);
- Method mtd = cls.getMethod(method, new Class[]{});
-
- obj = mtd.invoke(null, null);
- }
- catch (ClassNotFoundException e) {
- obj = null;
- }
- catch (NoSuchMethodException e) {
- obj = null;
- }
- catch (IllegalAccessException e) {
- obj = null;
- }
- catch (InvocationTargetException e) {
- obj = null;
- }
- }
- else {
- obj = element.createExecutableExtension(classAttribute);
- }
-
- return obj;
- }
-
- /**
- * Reads the contributions from the registry for the provided workbench
- * part and the provided extension point ID.
- * @param id
- * @param tag
- * @param extensionPoint
- */
- protected void readContributions(String[] ids, String tag, String extensionPoint) {
- cache = null;
- targetIDs = Arrays.asList(ids);
- targetContributionTag = tag;
- IPluginRegistry registry = Platform.getPluginRegistry();
- readRegistry(registry, PLUGIN_ID, extensionPoint);
- }
-
- /**
- * Returns the name of the part ID attribute that is expected
- * in the target extension.
- * @param element
- * @return String
- */
- protected String getTargetID(IConfigurationElement element) {
- String value = element.getAttribute(ATT_TARGET_ID);
- return value != null ? value : "???"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- */
- protected boolean readElement(IConfigurationElement element) {
- String tag = element.getName();
- if (tag.equals(targetContributionTag)) {
- String id = getTargetID(element);
- if (id == null || !targetIDs.contains(id)) {
- // This is not of interest to us - don't go deeper
- return true;
- }
- }
- else if (tag.equals(TAG_TRANSFER)) {
- if (cache == null)
- cache = new ArrayList();
- cache.add(element);
- return true; // just cache the element - don't go into it
- }
- else if (tag.equals(TAG_DROP_ACTION)) {
- if (cache == null)
- cache = new ArrayList();
- //cache.add(createActionDescriptor(element));
- cache.add(element);
- return true; // just cache the action - don't go into
- }
- else {
- return false;
- }
-
- readElementChildren(element);
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ConfigurationPointCalculator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ConfigurationPointCalculator.java
deleted file mode 100644
index d912623d96..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ConfigurationPointCalculator.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.part.MultiPageEditorSite;
-
-public class ConfigurationPointCalculator {
- public static final String DESIGN = ".design"; //$NON-NLS-1$
- public static final String SOURCE = ".source"; //$NON-NLS-1$
-
- public static String[] getConfigurationPoints(IEditorPart part, String contentType, String subContext, Class rootClass) {
- ConfigurationPointCalculator calculator = new ConfigurationPointCalculator();
- calculator.setContentType(contentType);
- calculator.setPart(part);
- calculator.setRootClass(rootClass);
- calculator.setSubContext(subContext);
- return calculator.getConfigurationPoints();
- }
-
- protected String fContentType = null;
- protected IEditorPart fPart = null;
-
- protected Class fRootClass = null;
- protected String fSubContext = null;
-
- /**
- *
- */
- public ConfigurationPointCalculator() {
- super();
- }
-
- public String[] getConfigurationPoints() {
- List points = new ArrayList(2);
-
- IEditorSite site = fPart.getEditorSite();
- String id = site.getId();
- if (id != null && id.length() > 0 && !id.equals(fRootClass.getName()))
- points.add(id);
-
- if (site instanceof MultiPageEditorSite) {
- String multipageID = ((MultiPageEditorSite) site).getMultiPageEditor().getSite().getId();
- if (!points.contains(multipageID))
- points.add(multipageID);
- String sourcePageID = ((MultiPageEditorSite) site).getMultiPageEditor().getSite().getId() + ".source"; //$NON-NLS-1$
- if (!points.contains(sourcePageID))
- points.add(sourcePageID);
- }
- if (site instanceof MultiPageEditorSite) {
- String multipageClassName = ((MultiPageEditorSite) site).getMultiPageEditor().getClass().getName();
- if (!points.contains(multipageClassName))
- points.add(multipageClassName);
- }
- Class editorClass = fPart.getClass();
- while (editorClass != null && fRootClass != null && !editorClass.equals(fRootClass)) {
- if (!points.contains(editorClass.getName()))
- points.add(editorClass.getName());
- editorClass = editorClass.getSuperclass();
- }
- if (fContentType != null && !points.contains(fContentType))
- points.add(fContentType);
- if (!points.contains(fRootClass.getName()))
- points.add(fRootClass.getName());
- return (String[]) points.toArray(new String[0]);
- }
-
- /**
- * @return Returns the contentType.
- */
- public String getContentType() {
- return fContentType;
- }
-
- /**
- * @return Returns the part.
- */
- public IEditorPart getPart() {
- return fPart;
- }
-
- /**
- * @return Returns the rootClass.
- */
- public Class getRootClass() {
- return fRootClass;
- }
-
- /**
- * @return Returns the subContext.
- */
- public String getSubContext() {
- return fSubContext;
- }
-
- /**
- * @param contentType The contentType to set.
- */
- public void setContentType(String contentType) {
- fContentType = contentType;
- }
-
- /**
- * @param part The part to set.
- */
- public void setPart(IEditorPart part) {
- fPart = part;
- }
-
- /**
- * @param rootClass The rootClass to set.
- */
- public void setRootClass(Class rootClass) {
- fRootClass = rootClass;
- }
-
- /**
- * @param subContext The subContext to set.
- */
- public void setSubContext(String subContext) {
- fSubContext = subContext;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ExtensionsPlugin.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ExtensionsPlugin.java
deleted file mode 100644
index 4cab6fcbf2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ExtensionsPlugin.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Plugin;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class ExtensionsPlugin extends Plugin {
- //The shared instance.
- private static ExtensionsPlugin plugin;
- //Resource bundle.
- private ResourceBundle resourceBundle;
-
- /**
- * The constructor.
- */
- public ExtensionsPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- plugin = this;
- try {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.sse.ui.extensions.ExtensionsPluginResources"); //$NON-NLS-1$
- }
- catch (MissingResourceException x) {
- resourceBundle = null;
- }
- }
-
- /**
- * Returns the shared instance.
- */
- public static ExtensionsPlugin getDefault() {
- return plugin;
- }
-
- /**
- * Returns the workspace instance.
- */
- public static IWorkspace getWorkspace() {
- return ResourcesPlugin.getWorkspace();
- }
-
- /**
- * Returns the string from the plugin's resource bundle,
- * or 'key' if not found.
- */
- public static String getResourceString(String key) {
- ResourceBundle bundle = ExtensionsPlugin.getDefault().getResourceBundle();
- try {
- return bundle.getString(key);
- }
- catch (MissingResourceException e) {
- return key;
- }
- }
-
- /**
- * Returns the plugin's resource bundle,
- */
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ISelfValidateEditAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ISelfValidateEditAction.java
deleted file mode 100644
index 73dafdeb67..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/ISelfValidateEditAction.java
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions;
-
-
-
-/**
- * This is a marker interface to control ValidateEdit call
- * Usually framework calls IExtendedSimpleEditor#validateEdit()
- * before calling IExtendedEditorAction's run() method.
- * However, if the action implements this interface,
- * framework won't call validateEdit() method.
- *
- * The action should call validateEdit() at their own
- * appropriate timing.
- */
-public interface ISelfValidateEditAction {
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/Logger.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/Logger.java
deleted file mode 100644
index 1b8d248dc3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/Logger.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Status;
-
-/**
- * Small convenience class to log messages to plugin's log file and also, if desired,
- * the console. This class should only be used by classes in this plugin. Other
- * plugins should make their own copy, with appropriate ID.
- */
-public class Logger {
- private static Plugin fPlugin = ExtensionsPlugin.getDefault();
- private static final String fPluginId = fPlugin.getDescriptor().getUniqueIdentifier();
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
-
- public static final int OK = IStatus.OK; // 0
- public static final int INFO = IStatus.INFO; // 1
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int ERROR = IStatus.ERROR; // 4
-
- public static final int OK_DEBUG = 200 + OK;
- public static final int INFO_DEBUG = 200 + INFO;
- public static final int WARNING_DEBUG = 200 + WARNING;
- public static final int ERROR_DEBUG = 200 + ERROR;
-
- /**
- * Adds message to log.
- * @param level severity level of the message (OK, INFO, WARNING, ERROR, OK_DEBUG, INFO_DEBUG, WARNING_DEBUG, ERROR_DEBUG)
- * @param message text to add to the log
- * @param exception exception thrown
- */
- protected static void _log(int level, String message, Throwable exception) {
- if (level == OK_DEBUG || level == INFO_DEBUG || level == WARNING_DEBUG || level == ERROR_DEBUG) {
- if (!isDebugging())
- return;
- }
-
- int severity = IStatus.OK;
- switch (level) {
- case INFO_DEBUG :
- case INFO :
- severity = IStatus.INFO;
- break;
- case WARNING_DEBUG :
- case WARNING :
- severity = IStatus.WARNING;
- break;
- case ERROR_DEBUG :
- case ERROR :
- severity = IStatus.ERROR;
- }
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(severity, fPluginId, severity, message, exception);
- fPlugin.getLog().log(statusObj);
- }
-
- /**
- * Prints message to log if category matches /debug/tracefilter option.
- * @param message text to print
- * @param category category of the message, to be compared with /debug/tracefilter
- */
- protected static void _trace(String category, String message, Throwable exception) {
- if (isTracing(category)) {
- message = (message != null) ? message : "null"; //$NON-NLS-1$
- Status statusObj = new Status(IStatus.OK, fPluginId, IStatus.OK, message, exception);
- fPlugin.getLog().log(statusObj);
- }
- }
-
- /**
- * @return true if the plugin for this logger is debugging
- */
- public static boolean isDebugging() {
- return fPlugin.isDebugging();
- }
-
- /**
- * Determines if currently tracing a category
- * @param category
- * @return true if tracing category, false otherwise
- */
- public static boolean isTracing(String category) {
- if (!isDebugging())
- return false;
-
- String traceFilter = Platform.getDebugOption(fPluginId + TRACEFILTER_LOCATION);
- if (traceFilter != null) {
- StringTokenizer tokenizer = new StringTokenizer(traceFilter, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String cat = tokenizer.nextToken().trim();
- if (category.equals(cat)) {
- return true;
- }
- }
- }
- return false;
- }
-
- public static void log(int level, String message) {
- _log(level, message, null);
- }
-
- public static void log(int level, String message, Throwable exception) {
- _log(level, message, exception);
- }
-
- public static void logException(String message, Throwable exception) {
- _log(ERROR, message, exception);
- }
-
- public static void logException(Throwable exception) {
- _log(ERROR, exception.getMessage(), exception);
- }
-
- public static void traceException(String category, String message, Throwable exception) {
- _trace(category, message, exception);
- }
-
- public static void traceException(String category, Throwable exception) {
- _trace(category, exception.getMessage(), exception);
- }
-
- public static void trace(String category, String message) {
- _trace(category, message, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointConstants.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointConstants.java
deleted file mode 100644
index bf0a9a4641..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointConstants.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.breakpoint;
-
-/**
- * @author pavery
- */
-public interface IBreakpointConstants {
- String ATTR_HIDDEN = "hidden"; //$NON-NLS-1$
- String RESOURCE_PATH = "org.eclipse.wst.sse.ui.extensions.breakpoint.path"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointProvider.java
deleted file mode 100644
index 0c63cd055c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IBreakpointProvider.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.breakpoint;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorInput;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * Interface to provide breakpoint creation
- */
-public interface IBreakpointProvider {
-
- /**
- * Adds breakpoint to specified position
- *
- * @param doc
- * w3c DOM Document object or <code>null</code> if called
- * from a non-DOM based editor plugin
- * @param idoc
- * IDocument object
- * @param input
- * current editor input, not necessarily an IFileEditorInput or
- * linked to a resource in any way
- * @param node
- * current caret node or <code>null</code> if called from a
- * non-DOM based editor plugin
- * @param lineNumber
- * current line number
- * @param offset
- * current caret offset
- * @throws CoreException
- * @return IStatus the status after being asked to add a breakpoint. The
- * Severity of ERROR should only be used if the location
- * information is both valid for a breakpoint and one could not be
- * added.
- */
- IStatus addBreakpoint(Document doc, IDocument idoc, IEditorInput input, Node node, int lineNumber, int offset) throws CoreException;
-
- /**
- * Set SourceEditingTextTools object
- *
- * @param tool
- * SourceEditingTextTools object
- */
- void setSourceEditingTextTools(SourceEditingTextTools tool);
-
- /**
- * Returns corresponding resource from editor input
- *
- * @param input
- * @return IResource
- */
- IResource getResource(IEditorInput input);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IExtendedStorageEditorInput.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IExtendedStorageEditorInput.java
deleted file mode 100644
index d29351aa9d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/IExtendedStorageEditorInput.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.breakpoint;
-
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.texteditor.IElementStateListener;
-
-public interface IExtendedStorageEditorInput extends IStorageEditorInput {
- /**
- * Adds the given element state listener to this input.
- * Has no effect if an identical listener is already registered.
- * Typically used by the IDocumentProvider to register itself for change notification.
- *
- * @param listener the listener
- */
- void addElementStateListener(IElementStateListener listener);
-
- /**
- * Removes the given element state listener from this input.
- * Has no affect if an identical listener is not registered.
- *
- * @param listener the listener
- */
- void removeElementStateListener(IElementStateListener listener);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NodeLocation.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NodeLocation.java
deleted file mode 100644
index 29069038b4..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NodeLocation.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.breakpoint;
-
-
-public interface NodeLocation {
- /**
- * Returns the document end offset of the end tag, -1 of there is no end tag
- * @return
- */
- int getEndTagEndOffset();
-
- /**
- * Returns the document start offset of the end tag, -1 of there is no end tag
- * @return
- */
- int getEndTagStartOffset();
-
- /**
- * Returns the document end offset of the start tag, -1 of there is no start tag
- * @return
- */
- int getStartTagEndOffset();
-
- /**
- * Returns the document start offset of the start tag, -1 of there is no start tag
- * @return
- */
- int getStartTagStartOffset();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NullSourceEditingTextTools.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NullSourceEditingTextTools.java
deleted file mode 100644
index d0155eb461..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/NullSourceEditingTextTools.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.breakpoint;
-
-import org.eclipse.core.resources.IMarker;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-public class NullSourceEditingTextTools implements SourceEditingTextTools {
- private static NullSourceEditingTextTools instance;
- public static final String ID = "sourceeditingtexttools"; //$NON-NLS-1$
-
- private NullSourceEditingTextTools() {
- super();
- }
-
- /* (non-Javadoc)
- */
- public Document getDOMDocument(IMarker marker) {
- return null;
- }
-
- /**
- * @return
- */
- public synchronized static SourceEditingTextTools getInstance() {
- if (instance == null)
- instance = new NullSourceEditingTextTools();
- return instance;
- }
-
- /* (non-Javadoc)
- */
- public NodeLocation getNodeLocation(Node node) {
- return null;
- }
-
- /* (non-Javadoc)
- */
- public String getPageLanguage(Node node) {
- return null;
- }
-
- /* (non-Javadoc)
- */
- public int getStartOffset(Node node) {
- return 0;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/SourceEditingTextTools.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/SourceEditingTextTools.java
deleted file mode 100644
index 238f7ad29a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/breakpoint/SourceEditingTextTools.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.breakpoint;
-
-
-
-import org.eclipse.core.resources.IMarker;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * Interface to provide convenient functions for a plugin
- * which doesn't want to depends on sed.editor or sed.model plugins,
- * but needs some information which the sed functions provide
- * as a convenience to clients
- */
-public interface SourceEditingTextTools {
-
- /**
- * Returns start offset of given Node
- * @param node w3c <code>Node</code> object to check
- * @return int start offset or -1 for error
- */
- int getStartOffset(Node node);
-
-
- /**
- * Returns w3c DOM document for a given marker
- * @param marker marker object to check
- * @return Document w3c DOM document object or <code>null</code>
- * if corresponding document does not exist
- */
- Document getDOMDocument(IMarker marker);
-
- /**
- * Returns a NodeLocation object describing the position information
- * of the Node's start and end tags. Returns null for unsupported
- * Node types (Nodes which are not Elements or in a supported Document).
- * @param node
- * @return
- */
- NodeLocation getNodeLocation(Node node);
-
- /**
- * Returns the current server-side page language for the Document
- * of the given Node.
- * @return
- */
- String getPageLanguage(Node node);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/openon/IOpenOn.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/openon/IOpenOn.java
deleted file mode 100644
index 3233ee8068..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/openon/IOpenOn.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.openon;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-
-/**
- * Interface for open on navigation
- * @author amywu
- */
-public interface IOpenOn {
- /**
- * @deprecated use getOpenRegion(IDocument, int) instead TODO remove in C5
- */
- public IRegion getOpenOnRegion(ITextViewer viewer, int offset);
-
- /**
- * @deprecated use openOn(IDocument, IRegion) instead TODO remove in C5
- */
- public void openOn(ITextViewer viewer, IRegion region);
-
- /**
- * Returns the entire region relevant to the current offset where an openable
- * source region is found. null if offset does not contain an openable source.
- * @param document IDocument
- * @param offset int
- * @return IRegion entire region of openable source
- */
- public IRegion getOpenOnRegion(IDocument document, int offset);
-
- /**
- * Opens the file/source relevant to region if possible.
- * @param viewer ITextViewer
- * @param region Region to examine
- */
- public void openOn(IDocument document, IRegion region);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckAction.java
deleted file mode 100644
index 5f5909b6a3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckAction.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-
-import org.eclipse.ui.texteditor.IUpdate;
-
-/**
- * ISpellCheckAction
- */
-public interface SpellCheckAction extends IUpdate {
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckElement.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckElement.java
deleted file mode 100644
index 0281cc9e5b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckElement.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-
-/**
- * IElement
- */
-public interface SpellCheckElement {
- boolean isSpellError();
-
- String getString();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckException.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckException.java
deleted file mode 100644
index a667854f55..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckException.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * SpellCheckException
- */
-public abstract class SpellCheckException extends Exception {
-
- public SpellCheckException(String msg) {
- super(msg);
- }
-
- /**
- * @return org.eclipse.core.runtime.IStatus
- */
- public abstract IStatus getStatus();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckOptionDialog.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckOptionDialog.java
deleted file mode 100644
index fa7b8f8790..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckOptionDialog.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-
-import org.eclipse.swt.widgets.Shell;
-
-/**
- * ISpellCheckOptionDialog
- */
-public interface SpellCheckOptionDialog {
- void open(Shell shell);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckProvider.java
deleted file mode 100644
index b183524ca8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckProvider.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-/**
- * Interface to provide spellcheck
- */
-public interface SpellCheckProvider {
- SpellCheckAction createSpellCheckAction();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionListener.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionListener.java
deleted file mode 100644
index aee9576edc..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionListener.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-
-/**
- * ISpellCheckSelectinListener
- */
-public interface SpellCheckSelectionListener {
- void selectionChanged();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionManager.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionManager.java
deleted file mode 100644
index edbeb56ec9..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckSelectionManager.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-
-/**
- * SpellCheckSelectionManager
- */
-public interface SpellCheckSelectionManager {
- void addSpellCheckSelectionListener(SpellCheckSelectionListener listener);
-
- void removeSpellCheckSelectionListener(SpellCheckSelectionListener listener);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckTarget.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckTarget.java
deleted file mode 100644
index b28ccef095..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellCheckTarget.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-
-
-/**
- * ISpellCheckTarget
- */
-public interface SpellCheckTarget {
- void setSpellChecker(SpellChecker checker);
-
- void setTextEditor(ITextEditor editor);
-
- boolean canPerformSpellCheck();
-
- boolean canPerformIgnore();
-
- boolean canPerformIgnoreAll();
-
- boolean canPerformChange();
-
- boolean canPerformChangeAll();
-
- SpellCheckElement getAndSelectNextMisspelledElement(boolean init) throws SpellCheckException;
-
- SpellCheckOptionDialog getOptionDialog();
-
- void replaceSelection(String text, Shell shell) throws SpellCheckException;
-
- int findAndSelect(int start, String find);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label);
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester);
-
- SpellCheckSelectionManager getSpellCheckSelectionManager();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellChecker.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellChecker.java
deleted file mode 100644
index 56b73dbaf2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/extensions/spellcheck/SpellChecker.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.extensions.spellcheck;
-
-
-
-/**
- * ISpellChecker
- */
-public interface SpellChecker {
-
- // User Dictionary
- void addWord(String word) throws SpellCheckException;
-
- void deleteWord(String word) throws SpellCheckException;
-
- String[] getUserWords() throws SpellCheckException;
-
- // Spell Check
- SpellCheckElement[] createSingleWords(String text) throws SpellCheckException;
-
- SpellCheckElement verifySpell(SpellCheckElement element) throws SpellCheckException;
-
- String[] getCandidates(SpellCheckElement element) throws SpellCheckException;
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/ContentAssistUtils.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/ContentAssistUtils.java
deleted file mode 100644
index f79e09d04a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/ContentAssistUtils.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.contentassist;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.StructuredTextViewer;
-
-
-/**
- * @author pavery
- *
- */
-public class ContentAssistUtils {
-
- /**
- * Returns the closest IndexedRegion for the offset and viewer allowing for
- * differences between viewer offsets and model positions.
- * note: this method returns an IndexedRegion for read only
- * @param viewer the viewer whose document is used to compute the proposals
- * @param documentOffset an offset within the document for which completions should be computed
- * @return an IndexedRegion
- */
- public static IndexedRegion getNodeAt(StructuredTextViewer viewer, int documentOffset) {
-
- if (viewer == null)
- return null;
-
- IndexedRegion node = null;
- IModelManagerPlugin mmp = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- IModelManager mm = mmp.getModelManager();
- IStructuredModel model = null;
- if (mm != null)
- model = mm.getExistingModelForRead(viewer.getDocument());
- try {
- if (model != null) {
- int lastOffset = documentOffset;
- node = model.getIndexedRegion(documentOffset);
- while (node == null && lastOffset >= 0) {
- lastOffset--;
- node = model.getIndexedRegion(lastOffset);
- }
- }
- }
- finally {
- if (model != null)
- model.releaseFromRead();
- }
- return node;
- }
-
- /**
- * Returns the closest IStructuredDocumentRegion for the offest and viewer.
- * @param viewer
- * @param documentOffset
- * @return the closest IStructuredDocumentRegion for the offest and viewer.
- */
- public static IStructuredDocumentRegion getStructuredDocumentRegion(StructuredTextViewer viewer, int documentOffset) {
- IStructuredDocumentRegion sdRegion = null;
- if (viewer == null || viewer.getDocument() == null)
- return null;
-
- int lastOffset = documentOffset;
- IStructuredDocument doc = (IStructuredDocument) viewer.getDocument();
- sdRegion = doc.getRegionAtCharacterOffset(documentOffset);
- while (sdRegion == null && lastOffset >= 0) {
- lastOffset--;
- sdRegion = doc.getRegionAtCharacterOffset(lastOffset);
- }
- return sdRegion;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CustomCompletionProposal.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CustomCompletionProposal.java
deleted file mode 100644
index f9c38bfc6a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/CustomCompletionProposal.java
+++ /dev/null
@@ -1,296 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.contentassist;
-
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.CompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.ui.contentassist.IRelevanceCompletionProposal;
-
-
-/**
- * An implementation of ICompletionProposal whose values can be
- * read after creation.
- */
-public class CustomCompletionProposal implements ICompletionProposal, ICompletionProposalExtension, ICompletionProposalExtension2, IRelevanceCompletionProposal {
-
- protected CompletionProposal fProposal = null;
- protected String fReplacementString = null;
- protected int fReplacementOffset = 0;
- protected int fReplacementLength = 0;
- protected int fCursorPosition = 0;
- protected Image fImage;
- protected String fDisplayString;
- protected IContextInformation fContextInformation;
- protected String fAdditionalProposalInfo;
- protected int fRelevance = IRelevanceConstants.R_NONE;
- protected int fOriginalReplacementLength;
- private boolean fUpdateLengthOnValidate;
-
- public CustomCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo) {
-
- fProposal = new CompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo);
- fReplacementString = replacementString;
- fReplacementOffset = replacementOffset;
- fReplacementLength = replacementLength;
- fCursorPosition = cursorPosition;
- fImage = image;
- fDisplayString = displayString;
- fContextInformation = contextInformation;
- fAdditionalProposalInfo = additionalProposalInfo;
- }
-
- // constructor with relevance
- public CustomCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance) {
-
- fProposal = new CompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo);
- fReplacementString = replacementString;
- fReplacementOffset = replacementOffset;
- fReplacementLength = replacementLength;
- fCursorPosition = cursorPosition;
- fImage = image;
- fDisplayString = displayString;
- fContextInformation = contextInformation;
- fAdditionalProposalInfo = additionalProposalInfo;
- fRelevance = relevance;
- }
-
- /**
- * Constructor with relevance and replacement length update flag.
- *
- * If the <code>updateReplacementLengthOnValidate</code> flag is true, then when the user types,
- * the replacement length will be incremented by the number of new characters inserted from the
- * original position. Otherwise the replacement length will not change on validate.
- *
- * ex.
- *
- * <tag |name="attr"> - the replacement length is 4
- * <tag i|name="attr"> - the replacement length is now 5
- * <tag id|name="attr"> - the replacement length is now 6
- * <tag |name="attr"> - the replacementlength is now 4 again
- * <tag |name="attr"> - the replacment length remains 4
- *
- */
- public CustomCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, Image image, String displayString, IContextInformation contextInformation, String additionalProposalInfo, int relevance, boolean updateReplacementLengthOnValidate) {
-
- fProposal = new CompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition, image, displayString, contextInformation, additionalProposalInfo);
- fReplacementString = replacementString;
- fReplacementOffset = replacementOffset;
- fReplacementLength = replacementLength;
- fCursorPosition = cursorPosition;
- fImage = image;
- fDisplayString = displayString;
- fContextInformation = contextInformation;
- fAdditionalProposalInfo = additionalProposalInfo;
- fRelevance = relevance;
- fUpdateLengthOnValidate = updateReplacementLengthOnValidate;
- fOriginalReplacementLength = fReplacementLength;
- }
-
- public CustomCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition) {
-
- fProposal = new CompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition);
- fReplacementString = replacementString;
- fReplacementOffset = replacementOffset;
- fReplacementLength = replacementLength;
- fCursorPosition = cursorPosition;
- }
-
- // constructor with relevance
- public CustomCompletionProposal(String replacementString, int replacementOffset, int replacementLength, int cursorPosition, int relevance) {
-
- fProposal = new CompletionProposal(replacementString, replacementOffset, replacementLength, cursorPosition);
- fReplacementString = replacementString;
- fReplacementOffset = replacementOffset;
- fReplacementLength = replacementLength;
- fCursorPosition = cursorPosition;
- fRelevance = relevance;
- }
-
- public void apply(IDocument document) {
- fProposal.apply(document);
- }
-
- public String getAdditionalProposalInfo() {
- return fProposal.getAdditionalProposalInfo();
- }
-
- public IContextInformation getContextInformation() {
- return fProposal.getContextInformation();
- }
-
- public String getDisplayString() {
- return fProposal.getDisplayString();
- }
-
- public Image getImage() {
- return fProposal.getImage();
- }
-
- public Point getSelection(IDocument document) {
- return fProposal.getSelection(document);
- }
-
- public int getReplacementOffset() {
- return fReplacementOffset;
- }
-
- public int getReplacementLength() {
- return fReplacementLength;
- }
-
- public String getReplacementString() {
- return fReplacementString;
- }
-
- public int getCursorPosition() {
- return fCursorPosition;
- }
-
- public int getRelevance() {
- return fRelevance;
- }
-
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDocument document = viewer.getDocument();
- // CMVC 252634 to compensate for "invisible" initial region in StructuredTextEditorViewer
- // should be "0" in other editors, and not effect this calculation
- int caretOffset = viewer.getTextWidget().getCaretOffset() + viewer.getVisibleRegion().getOffset();
- if (caretOffset == getReplacementOffset()) {
- apply(document);
- }
- else {
- // replace the text without affecting the caret Position as this causes the cursor to move on its own
- try {
- int endOffsetOfChanges = getReplacementString().length() + getReplacementOffset();
- // Insert the portion of the new text that comes after the current caret position
- if (endOffsetOfChanges >= caretOffset) {
- int postCaretReplacementLength = getReplacementOffset() + getReplacementLength() - caretOffset;
- int preCaretReplacementLength = getReplacementString().length() - (endOffsetOfChanges - caretOffset);
- if (postCaretReplacementLength < 0) {
- if (Debug.displayWarnings) {
- System.out.println("** postCaretReplacementLength was negative: " + postCaretReplacementLength); //$NON-NLS-1$
- }
- // This is just a quick fix while I figure out what replacement length is supposed to be
- // in each case, otherwise we'll get negative replacment length sometimes
- postCaretReplacementLength = 0;
- }
- document.replace(caretOffset, postCaretReplacementLength, getReplacementString().substring(preCaretReplacementLength));
- }
- // Insert the portion of the new text that comes before the current caret position
- // Done second since offsets would change for the post text otherwise
- // Outright insertions are handled here
- if (caretOffset > getReplacementOffset()) {
- int preCaretTextLength = caretOffset - getReplacementOffset();
- document.replace(getReplacementOffset(), preCaretTextLength, getReplacementString().substring(0, preCaretTextLength));
- }
- }
- catch (BadLocationException x) {
- apply(document);
- }
- catch (StringIndexOutOfBoundsException e) {
- apply(document);
- }
- }
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer, boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /**
- * borrowed from JavaCompletionProposal
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#validate(org.eclipse.jface.text.IDocument, int, org.eclipse.jface.text.DocumentEvent)
- */
- public boolean validate(IDocument document, int offset, DocumentEvent event) {
- if (offset < fReplacementOffset)
- return false;
- boolean validated = startsWith(document, offset, fDisplayString);
- // CMVC 269884
- if (fUpdateLengthOnValidate) {
- int delta = offset - fReplacementOffset;
- if (delta > 0)
- fReplacementLength = delta + fOriginalReplacementLength;
- }
- return validated;
- }
-
- // code is borrowed from JavaCompletionProposal
- protected boolean startsWith(IDocument document, int offset, String word) {
- int wordLength = word == null ? 0 : word.length();
- if (offset > fReplacementOffset + wordLength)
- return false;
-
- try {
- int length = offset - fReplacementOffset;
- String start = document.get(fReplacementOffset, length);
- return word.substring(0, length).equalsIgnoreCase(start);
- }
- catch (BadLocationException x) {
- }
-
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#apply(org.eclipse.jface.text.IDocument, char, int)
- */
- public void apply(IDocument document, char trigger, int offset) {
- // we currently don't do anything special for which character
- // selected the proposal, and where the cursor offset is
- // but we might in the future...
- fProposal.apply(document);
- // we want to ContextInformationPresenter.updatePresentation() here
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getContextInformationPosition()
- */
- public int getContextInformationPosition() {
- return getCursorPosition();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#getTriggerCharacters()
- */
- public char[] getTriggerCharacters() {
- // we currently don't pay attention to which charaters select the proposal
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension#isValidFor(org.eclipse.jface.text.IDocument, int)
- */
- public boolean isValidFor(IDocument document, int offset) {
- return validate(document, offset, null);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/IRelevanceConstants.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/IRelevanceConstants.java
deleted file mode 100644
index 9cf181e48e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/contentassist/IRelevanceConstants.java
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.contentassist;
-
-public interface IRelevanceConstants {
- int R_NONE = 0;
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/ContributedProcessorDescriptor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/ContributedProcessorDescriptor.java
deleted file mode 100644
index 2e25b70450..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/ContributedProcessorDescriptor.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.correction;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-
-public class ContributedProcessorDescriptor {
- private static final String CLASS = "class"; //$NON-NLS-1$
-
- private IConfigurationElement fConfigurationElement;
- private Object fProcessorInstance;
-
- public ContributedProcessorDescriptor(IConfigurationElement element) {
- fConfigurationElement = element;
- fProcessorInstance = null;
- }
-
- public Object getProcessor() throws CoreException {
- if (fProcessorInstance == null && fConfigurationElement != null) {
- fProcessorInstance = fConfigurationElement.createExecutableExtension(CLASS);
- }
- return fProcessorInstance;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickAssistProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickAssistProcessor.java
deleted file mode 100644
index e8ede2e342..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickAssistProcessor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.correction;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.ui.StructuredTextViewer;
-
-
-public interface IQuickAssistProcessor {
- /**
- * Returns true if the processor can assist at the given offset. This test
- * should be an optimistic guess and be extremly cheap.
- */
- boolean canAssist(StructuredTextViewer viewer, int offset);
-
- /**
- * Collects proposals for assistant at the given offset.
- */
- ICompletionProposal[] getProposals(StructuredTextViewer viewer, int offset) throws CoreException;
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickFixProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickFixProcessor.java
deleted file mode 100644
index 386adbe66a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/IQuickFixProcessor.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.correction;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.source.Annotation;
-
-public interface IQuickFixProcessor {
- /**
- * Returns true if the processor can fix the given problem. This test
- * should be an optimistic guess and be extremly cheap.
- */
- boolean canFix(Annotation annnotation);
-
- /**
- * Collects proposals for fixing the given problem.
- */
- ICompletionProposal[] getProposals(Annotation annnotation) throws CoreException;
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/NoModificationCompletionProposal.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/NoModificationCompletionProposal.java
deleted file mode 100644
index 121b2d3118..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/NoModificationCompletionProposal.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.correction;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class NoModificationCompletionProposal implements ICompletionProposal {
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
- */
- public void apply(IDocument document) {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
- */
- public Point getSelection(IDocument document) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return ResourceHandler.getString("NoModificationCompletionProposal.0"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/StructuredCorrectionProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/StructuredCorrectionProcessor.java
deleted file mode 100644
index b8260df848..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/correction/StructuredCorrectionProcessor.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.correction;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.ui.StructuredTextViewer;
-
-
-public class StructuredCorrectionProcessor implements IContentAssistProcessor {
- protected IQuickFixProcessor fQuickFixProcessor;
- protected IQuickAssistProcessor fQuickAssistProcessor;
- protected IAnnotationModel fAnnotationModel;
-
- public StructuredCorrectionProcessor(ITextEditor editor) {
- IEditorInput input = ((IEditorPart) editor).getEditorInput();
- IAnnotationModel annotationModel = editor.getDocumentProvider().getAnnotationModel(input);
-
- fAnnotationModel = annotationModel;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- ArrayList proposals = new ArrayList();
-
- if (viewer instanceof StructuredTextViewer) {
- addQuickFixProposals((StructuredTextViewer) viewer, proposals, documentOffset);
-
- if (proposals.isEmpty()) {
- addQuickAssistProposals((StructuredTextViewer) viewer, proposals, documentOffset);
- }
- }
-
- if (proposals.isEmpty())
- proposals.add(new NoModificationCompletionProposal());
-
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- return null;
- }
-
- protected void addQuickFixProposals(StructuredTextViewer viewer, ArrayList proposals, int documentOffset) {
- ArrayList problems = new ArrayList();
- Iterator iter = fAnnotationModel.getAnnotationIterator();
- while (iter.hasNext()) {
- Annotation annotation = (Annotation) iter.next();
- Position pos = fAnnotationModel.getPosition(annotation);
- if (documentOffset >= pos.offset && documentOffset <= pos.offset + pos.length) {
- IQuickFixProcessor processor = getQuickFixProcessor();
- if (processor != null && processor.canFix(annotation)) {
- try {
- ICompletionProposal[] res = processor.getProposals(annotation);
- if (res != null) {
- for (int k = 0; k < res.length; k++) {
- proposals.add(res[k]);
- }
- }
- }
- catch (CoreException e) {
- throw new SourceEditingRuntimeException();
- }
- }
- }
- }
- }
-
- protected void addQuickAssistProposals(StructuredTextViewer viewer, ArrayList proposals, int documentOffset) {
- try {
- IQuickAssistProcessor processor = getQuickAssistProcessor();
- if (processor != null && processor.canAssist(viewer, documentOffset)) {
- ICompletionProposal[] res = processor.getProposals(viewer, documentOffset);
- if (res != null) {
- for (int k = 0; k < res.length; k++) {
- proposals.add(res[k]);
- }
- }
- }
- }
- catch (Exception e) {
- throw new SourceEditingRuntimeException();
- }
- }
-
- protected IQuickFixProcessor getQuickFixProcessor() {
- return null;
- }
-
- protected IQuickAssistProcessor getQuickAssistProcessor() {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/BreakpointRulerAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/BreakpointRulerAction.java
deleted file mode 100644
index fec19cda7b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/BreakpointRulerAction.java
+++ /dev/null
@@ -1,344 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.debug;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IBreakpointManager;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.IPartService;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.texteditor.MarkerAnnotation;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.ModelPlugin;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.IBreakpointProvider;
-import org.eclipse.wst.sse.ui.internal.extension.BreakpointProviderBuilder;
-
-
-public abstract class BreakpointRulerAction extends Action implements IUpdate {
-
- protected class MouseUpdater implements MouseListener {
- public void mouseDoubleClick(MouseEvent e) {
- // do nothing (here)
- }
-
- public void mouseDown(MouseEvent e) {
- update();
- }
-
- public void mouseUp(MouseEvent e) {
- // do nothing
- }
- }
-
- public static final String getFileExtension(IEditorInput input) {
- IPath path = null;
- if (input instanceof IStorageEditorInput) {
- try {
- path = ((IStorageEditorInput) input).getStorage().getFullPath();
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- if (path != null) {
- return path.getFileExtension();
- }
- String name = input.getName();
- int index = name.lastIndexOf('.');
- if (index == -1)
- return null;
- if (index == (name.length() - 1))
- return ""; //$NON-NLS-1$
- return name.substring(index + 1);
- }
-
- public static final IResource getResource(IEditorInput input) {
- IResource resource = null;
-
- if (input instanceof IFileEditorInput)
- resource = ((IFileEditorInput) input).getFile();
- if (resource == null)
- resource = (IResource) input.getAdapter(IFile.class);
- if (resource == null)
- resource = (IResource) input.getAdapter(IResource.class);
-
- IEditorPart editorPart = null;
- if (resource == null) {
- IWorkbench workbench = EditorPlugin.getDefault().getWorkbench();
- if (workbench != null) {
- IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
- if (window != null) {
- IPartService service = window.getPartService();
- if (service != null) {
- Object part = service.getActivePart();
- if (part != null && part instanceof IEditorPart) {
- editorPart = (IEditorPart) part;
- if (editorPart != null) {
- IStructuredModel model = null;
- ITextEditor textEditor = null;
- try {
- if (editorPart instanceof ITextEditor) {
- textEditor = (ITextEditor) editorPart;
- }
- if (textEditor == null) {
- textEditor = (ITextEditor) editorPart.getAdapter(ITextEditor.class);
- }
- if (textEditor != null) {
- IDocument textDocument = textEditor.getDocumentProvider().getDocument(input);
- IModelManager mgr = ModelPlugin.getDefault().getModelManager();
- model = mgr.getExistingModelForRead(textDocument);
- resource = BreakpointProviderBuilder.getInstance().getResource(input, model.getContentTypeIdentifier(), getFileExtension(input));
- }
- else {
- IBreakpointProvider[] providers = BreakpointProviderBuilder.getInstance().getBreakpointProviders(editorPart, null, getFileExtension(input));
- for (int i = 0; i < providers.length && resource == null; i++) {
- resource = providers[i].getResource(input);
- }
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- finally {
- model.releaseFromRead();
- }
- }
-
- }
- }
- }
-
- }
- }
- return resource;
- }
-
- protected MouseListener fMouseListener = null;
-
- protected IVerticalRulerInfo fRulerInfo = null;
- protected ITextEditor fTextEditor = null;
-
- public BreakpointRulerAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
- super();
- fTextEditor = editor;
- fRulerInfo = rulerInfo;
- fMouseListener = new MouseUpdater();
- rulerInfo.getControl().addMouseListener(fMouseListener);
- }
-
- /**
- * Returns the <code>AbstractMarkerAnnotationModel</code> of the
- * editor's input.
- *
- * @return the marker annotation model
- */
- protected AbstractMarkerAnnotationModel getAnnotationModel() {
- IDocumentProvider provider = fTextEditor.getDocumentProvider();
- IAnnotationModel model = provider.getAnnotationModel(fTextEditor.getEditorInput());
- if (model instanceof AbstractMarkerAnnotationModel)
- return (AbstractMarkerAnnotationModel) model;
- return null;
- }
-
- protected IBreakpoint[] getBreakpoints(IMarker[] markers) {
- IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
- List breakpoints = new ArrayList(markers.length);
- for (int i = 0; i < markers.length; i++) {
- IBreakpoint breakpoint = manager.getBreakpoint(markers[i]);
- if(breakpoint != null) {
- breakpoints.add(breakpoint);
- }
- }
- return (IBreakpoint[]) breakpoints.toArray(new IBreakpoint[0]);
- }
-
- /**
- * Returns the <code>IDocument</code> of the editor's input.
- *
- * @return the document of the editor's input
- */
- protected IDocument getDocument() {
- IDocumentProvider provider = fTextEditor.getDocumentProvider();
- return provider.getDocument(fTextEditor.getEditorInput());
- }
-
- /**
- * Returns all markers which include the ruler's line of activity.
- *
- * @return an array of markers which include the ruler's line of activity
- */
- protected IMarker[] getMarkers() {
- List markers = new ArrayList();
-
- IResource resource = getResource();
- IDocument document = getDocument();
- AbstractMarkerAnnotationModel annotationModel = getAnnotationModel();
-
- if (resource != null && annotationModel != null && resource.exists()) {
- try {
- IMarker[] allMarkers = resource.findMarkers(IBreakpoint.BREAKPOINT_MARKER, true, IResource.DEPTH_ZERO);
- if (allMarkers != null) {
- for (int i = 0; i < allMarkers.length; i++) {
- if (includesRulerLine(annotationModel.getMarkerPosition(allMarkers[i]), document)) {
- markers.add(allMarkers[i]);
- }
- }
- }
- }
- catch (CoreException x) {
- //
- }
- }
-
- return (IMarker[]) markers.toArray(new IMarker[0]);
- }
-
- protected IResource getResource() {
- IEditorInput input = getTextEditor().getEditorInput();
- IResource resource = getResource(input);
- return resource;
- }
-
- /**
- * @return Returns the rulerInfo.
- */
- public IVerticalRulerInfo getRulerInfo() {
- return fRulerInfo;
- }
-
- /**
- * @return Returns the textEditor.
- */
- public ITextEditor getTextEditor() {
- return fTextEditor;
- }
-
- /**
- * @deprecated - no longer used
- * @param lineNumber
- * @return
- */
- protected boolean hasBreakpoints(int lineNumber) {
- IAnnotationModel model = getTextEditor().getDocumentProvider().getAnnotationModel(getTextEditor().getEditorInput());
- List markers = new ArrayList();
- Iterator it = model.getAnnotationIterator();
- while (it.hasNext()) {
- Annotation a = (Annotation) it.next();
- if (a instanceof MarkerAnnotation) {
- int line = MarkerUtilities.getLineNumber(((MarkerAnnotation) a).getMarker());
- if (line == lineNumber)
- markers.add(((MarkerAnnotation) a).getMarker());
- }
- }
-
- boolean enableThisAction = false;
- IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
- IBreakpoint[] breakpoints = manager.getBreakpoints();
- for (int i = 0; !enableThisAction && i < breakpoints.length; i++) {
- IBreakpoint breakpoint = breakpoints[i];
- if (!breakpoint.getMarker().getResource().equals(getResource()))
- continue;
- if (!markers.contains(breakpoint.getMarker()))
- continue;
- enableThisAction = true;
- }
- return enableThisAction;
- }
-
- protected boolean hasMarkers() {
- IResource resource = getResource();
- IDocument document = getDocument();
- AbstractMarkerAnnotationModel model = getAnnotationModel();
-
- if (resource != null && model != null && resource.exists()) {
- try {
- IMarker[] allMarkers = resource.findMarkers(IBreakpoint.LINE_BREAKPOINT_MARKER, true, IResource.DEPTH_ZERO);
- if (allMarkers != null) {
- for (int i = 0; i < allMarkers.length; i++) {
- if (includesRulerLine(model.getMarkerPosition(allMarkers[i]), document)) {
- return true;
- }
- }
- }
- }
- catch (CoreException x) {
- //
- }
- }
- return false;
- }
-
- /**
- * Checks whether a position includes the ruler's line of activity.
- *
- * @param position
- * the position to be checked
- * @param document
- * the document the position refers to
- * @return <code>true</code> if the line is included by the given
- * position
- */
- protected boolean includesRulerLine(Position position, IDocument document) {
-
- if (position != null) {
- try {
- int markerLine = document.getLineOfOffset(position.getOffset());
- int line = getRulerInfo().getLineOfLastMouseButtonActivity();
- if (line == markerLine)
- return true;
- // commented because of "1GEUOZ9: ITPJUI:ALL - Confusing UI
- // for
- // multiline Bookmarks and Tasks"
- // return (markerLine <= line && line <=
- // document.getLineOfOffset(position.getOffset() +
- // position.getLength()));
- }
- catch (BadLocationException x) {
- //
- }
- }
-
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/EditBreakpointAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/EditBreakpointAction.java
deleted file mode 100644
index 9c41423f35..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/EditBreakpointAction.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.debug;
-
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.dialogs.PropertyDialogAction;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * ToggleBreakpointAction
- */
-public class EditBreakpointAction extends BreakpointRulerAction {
- protected IBreakpoint[] breakpoints = null;
-
- /**
- * @param editor
- * @param rulerInfo
- */
- public EditBreakpointAction(ITextEditor editor, IVerticalRuler rulerInfo) {
- super(editor, rulerInfo);
- setText(ResourceHandler.getString("EditBreakpointAction.0")); //$NON-NLS-1$
- }
-
- public void run() {
- PropertyDialogAction action = new PropertyDialogAction(getTextEditor().getEditorSite().getShell(), new ISelectionProvider() {
- public void addSelectionChangedListener(ISelectionChangedListener listener) {
- // do nothing
- }
-
- public ISelection getSelection() {
- return new StructuredSelection(breakpoints);
- }
-
- public void removeSelectionChangedListener(ISelectionChangedListener listener) {
- // do nothing
- }
-
- public void setSelection(ISelection selection) {
- // do nothing
- }
- });
- action.run();
- }
-
- public void update() {
- boolean enableThisAction = hasMarkers();
- setEnabled(enableThisAction);
- breakpoints = getBreakpoints(getMarkers());
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java
deleted file mode 100644
index c35137ab55..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ManageBreakpointAction.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.debug;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.jface.text.source.IVerticalRuler;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * ManageBreakpointAction - Enables and Disables
- */
-public class ManageBreakpointAction extends BreakpointRulerAction {
-
- protected IBreakpoint[] breakpoints = null;
- private boolean doEnable = true;
-
- /**
- * @param editor
- * @param rulerInfo
- */
- public ManageBreakpointAction(ITextEditor editor, IVerticalRuler rulerInfo) {
- super(editor, rulerInfo);
- setEnabled(true);
- }
-
- /**
- *
- */
- protected void disableBreakpoints(IBreakpoint[] breakpoints) {
- for (int i = 0; i < breakpoints.length; i++) {
- try {
- breakpoints[i].setEnabled(false);
- }
- catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- protected void enableBreakpoints(IBreakpoint[] breakpoints) {
- for (int i = 0; i < breakpoints.length; i++) {
- try {
- breakpoints[i].setEnabled(true);
- }
- catch (CoreException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
-
- public void run() {
- if (doEnable)
- enableBreakpoints(breakpoints);
- else
- disableBreakpoints(breakpoints);
- }
-
- public void update() {
- // doEnable means "enable" instead of "disable"
- doEnable = true;
- breakpoints = getBreakpoints(getMarkers());
- for (int i = 0; doEnable && i < breakpoints.length; i++) {
- IBreakpoint breakpoint = breakpoints[i];
- try {
- if (breakpoint.isEnabled()) {
- doEnable = false;
- }
- }
- catch (CoreException e) {
- Logger.logException("breakpoint not responding to isEnabled: " + breakpoint, e); //$NON-NLS-1$
- }
- }
- setEnabled(breakpoints != null && breakpoints.length > 0);
- if (doEnable)
- setText(ResourceHandler.getString("ManageBreakpointAction.0")); //$NON-NLS-1$
- else
- setText(ResourceHandler.getString("ManageBreakpointAction.1")); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ToggleBreakpointAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ToggleBreakpointAction.java
deleted file mode 100644
index 920fcc7483..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/debug/ToggleBreakpointAction.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.debug;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.MultiStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.debug.core.DebugPlugin;
-import org.eclipse.debug.core.IBreakpointManager;
-import org.eclipse.debug.core.model.IBreakpoint;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.IVerticalRulerInfo;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extension.IExtendedMarkupEditor;
-import org.eclipse.wst.sse.ui.extension.IExtendedSimpleEditor;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.IBreakpointProvider;
-import org.eclipse.wst.sse.ui.internal.extension.BreakpointProviderBuilder;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-
-/**
- * ToggleBreakpointAction
- */
-public class ToggleBreakpointAction extends BreakpointRulerAction {
- /**
- * @param editor
- * @param rulerInfo
- */
- public ToggleBreakpointAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
- super(editor, rulerInfo);
- setText(ResourceHandler.getString("ToggleBreakpointAction.0")); //$NON-NLS-1$
- }
-
- protected boolean createBreakpoints(int lineNumber) {
- // Note: we'll always allow processing to continue, even
- // for a "read only" IStorageEditorInput, for the ActiveScript
- // debugger. But this means sometimes the ActiveScript provider
- // might get an input from CVS or something that is not related
- // to debugging.
-
- ITextEditor editor = getTextEditor();
- IEditorInput input = editor.getEditorInput();
- IDocument document = editor.getDocumentProvider().getDocument(input);
- if (document == null)
- return false;
-
- IModelManager mgr = ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager();
- IStructuredModel model = mgr.getExistingModelForRead(document);
- String contentType = null;
- if (model != null) {
- contentType = model.getContentTypeIdentifier();
- model.releaseFromRead();
- }
- IBreakpointProvider[] providers = BreakpointProviderBuilder.getInstance().getBreakpointProviders(editor, contentType, getFileExtension(input));
-
- Document doc = null;
- Node node = null;
- if (editor instanceof IExtendedMarkupEditor) {
- doc = ((IExtendedMarkupEditor) editor).getDOMDocument();
- node = ((IExtendedMarkupEditor) editor).getCaretNode();
- }
-
- int pos = -1;
- if (editor instanceof IExtendedSimpleEditor) {
- pos = ((IExtendedSimpleEditor) editor).getCaretPosition();
- }
-
- final int n = providers.length;
- List errors = new ArrayList(0);
- for (int i = 0; i < n; i++) {
- try {
- if (Debug.debugBreakpoints)
- System.out.println(providers[i].getClass().getName() + " adding breakpoint to line " + lineNumber); //$NON-NLS-1$
- IStatus status = providers[i].addBreakpoint(doc, document, input, node, lineNumber, pos);
- if(status != null && !status.isOK()) {
- errors.add(status);
- }
- }
- catch (CoreException e) {
- errors.add(e.getStatus());
- }
- catch (Throwable t) {
- Logger.logException("exception while adding breakpoint", t); //$NON-NLS-1$
- }
- }
-
- if(errors.size() > 0) {
- Shell shell = editor.getSite().getShell();
- MultiStatus allStatus = new MultiStatus(EditorPlugin.ID, IStatus.INFO, (IStatus[]) errors.toArray(new IStatus[0]), ResourceHandler.getResourceBundle().getString("ManageBreakpoints.error.adding.message1"),null); //$NON-NLS-1$
- // show for conditions more severe than INFO or when no breakpoints were created
- if(allStatus.getSeverity() > IStatus.INFO || getBreakpoints(getMarkers()).length < 1) {
- ErrorDialog.openError(shell, ResourceHandler.getResourceBundle().getString("ManageBreakpoints.error.adding.title1"), ResourceHandler.getResourceBundle().getString("ManageBreakpoints.error.adding.message1"), allStatus); //$NON-NLS-1$ //$NON-NLS-2$
- return false;
- }
- }
- return true;
- }
-
- protected void removeBreakpoints(int lineNumber) {
- IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
- IBreakpoint[] breakpoints = getBreakpoints(getMarkers());
- for (int i = 0; i < breakpoints.length; i++) {
- try {
- breakpoints[i].getMarker().delete();
- breakpointManager.removeBreakpoint(breakpoints[i], true);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- }
-
- public void run() {
- int lineNumber = fRulerInfo.getLineOfLastMouseButtonActivity() + 1;
- boolean doAdd = !hasMarkers();
- if (doAdd)
- createBreakpoints(lineNumber);
- else
- removeBreakpoints(lineNumber);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- ITextEditor editor = getTextEditor();
- IEditorInput input = editor.getEditorInput();
- IDocument document = editor.getDocumentProvider().getDocument(input);
- if (document != null) {
- IModelManager mgr = ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager();
- IStructuredModel model = mgr.getExistingModelForRead(document);
- String contentType = null;
- if (model != null) {
- contentType = model.getContentTypeIdentifier();
- model.releaseFromRead();
- }
- setEnabled(BreakpointProviderBuilder.getInstance().isAvailable(contentType, getFileExtension(input)));
- }
- else {
- setEnabled(false);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImageHelper.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImageHelper.java
deleted file mode 100644
index 9caf277fc2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImageHelper.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-
-
-/**
- * Helper class to handle images provided by this plug-in.
- *
- * NOTE: For internal use only. For images used externally, please use the
- * Shared***ImageHelper class instead.
- *
- * @author amywu
- */
-public class EditorPluginImageHelper {
- private final String PLUGINID = EditorPlugin.ID;
- private static EditorPluginImageHelper instance = null;
-
- // save a descriptor for each image
- private HashMap fImageDescRegistry = null;
-
- /**
- * Gets the instance.
- *
- * @return Returns a EditorPluginImageHelper
- */
- public synchronized static EditorPluginImageHelper getInstance() {
- if (instance == null)
- instance = new EditorPluginImageHelper();
- return instance;
- }
-
- /**
- * Retrieves the image associated with resource from the image registry.
- * If the image cannot be retrieved, attempt to find and load the image at
- * the location specified in resource.
- *
- * @param resource
- * the image to retrieve
- * @return Image the image associated with resource or null if one could
- * not be found
- */
- public Image getImage(String resource) {
- Image image = getImageRegistry().get(resource);
- if (image == null) {
- // create an image
- image = createImage(resource);
- }
- return image;
- }
-
- /**
- * Retrieves the image descriptor associated with resource from the image
- * descriptor registry. If the image descriptor cannot be retrieved,
- * attempt to find and load the image descriptor at the location specified
- * in resource.
- *
- * @param resource
- * the image descriptor to retrieve
- * @return ImageDescriptor the image descriptor assocated with resource or
- * the default "missing" image descriptor if one could not be
- * found
- */
- public ImageDescriptor getImageDescriptor(String resource) {
- ImageDescriptor imageDescriptor = null;
- Object o = getImageDescriptorRegistry().get(resource);
- if (o == null) {
- //create a descriptor
- imageDescriptor = createImageDescriptor(resource);
- }
- else {
- imageDescriptor = (ImageDescriptor) o;
- }
- return imageDescriptor;
- }
-
- /**
- * Returns the image descriptor registry for this plugin.
- *
- * @return HashMap - image descriptor registry for this plugin
- */
- private HashMap getImageDescriptorRegistry() {
- if (fImageDescRegistry == null)
- fImageDescRegistry = new HashMap();
- return fImageDescRegistry;
- }
-
- /**
- * Returns the image registry for this plugin.
- *
- * @return ImageRegistry - image registry for this plugin
- */
- private ImageRegistry getImageRegistry() {
- return JFaceResources.getImageRegistry();
- }
-
- /**
- * Creates an image from the given resource and adds the image to the
- * image registry.
- *
- * @param resource
- * @return Image
- */
- private Image createImage(String resource) {
- ImageDescriptor desc = getImageDescriptor(resource);
- Image image = null;
-
- if (desc != null) {
- image = desc.createImage();
- getImageRegistry().put(resource, image);
- }
- return image;
- }
-
- /**
- * Creates an image descriptor from the given imageFilePath and adds the
- * image descriptor to the image descriptor registry. If an image
- * descriptor could not be created, the default "missing" image descriptor
- * is returned but not added to the image descriptor registry.
- *
- * @param imageFilePath
- * @return ImageDescriptor image descriptor for imageFilePath or default
- * "missing" image descriptor if resource could not be found
- */
- private ImageDescriptor createImageDescriptor(String imageFilePath) {
- ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(PLUGINID, imageFilePath);
- if (imageDescriptor != null) {
- getImageDescriptorRegistry().put(imageFilePath, imageDescriptor);
- }
- else {
- imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
- }
-
- return imageDescriptor;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImages.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImages.java
deleted file mode 100644
index 3f17c57b3d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/EditorPluginImages.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-/**
- * Bundle of most images used by the Source Editor plug-in.
- */
-public class EditorPluginImages {
- public static final String IMG_DLCL_COLLAPSEALL = "icons/full/dlcl16/collapseall.gif"; //$NON-NLS-1$
- public static final String IMG_ELCL_COLLAPSEALL = "icons/full/elcl16/collapseall.gif"; //$NON-NLS-1$
- public static final String IMG_DLCL_DELETE = "icons/full/dlcl16/delete.gif"; //$NON-NLS-1$
- public static final String IMG_ELCL_DELETE = "icons/full/elcl16/delete.gif"; //$NON-NLS-1$
- public static final String IMG_DLCL_SYNCED = "icons/full/dlcl16/synced.gif"; //$NON-NLS-1$
- public static final String IMG_ELCL_SYNCED = "icons/full/elcl16/synced.gif"; //$NON-NLS-1$
-
- public static final String IMG_CTOOL16_SPELLCHECK = "icons/full/ctool16/spellcheck.gif;"; //$NON-NLS-1$
- public static final String IMG_DTOOL16_SPELLCHECK = "icons/full/dtool16/spellcheck.gif;"; //$NON-NLS-1$
- public static final String IMG_ETOOL16_SPELLCHECK = "icons/full/etool16/spellcheck.gif;"; //$NON-NLS-1$
-
- public static final String IMG_OBJ_PREFERENCES = "icons/full/obj16/preferences.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_PROP_PS = "icons/full/obj16/prop_ps.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_OCC_MATCH = "icons/full/obj16/occ_match.gif"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTML2TextReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTML2TextReader.java
deleted file mode 100644
index 3e54fd8c4b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTML2TextReader.java
+++ /dev/null
@@ -1,308 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-
-
-import java.io.IOException;
-import java.io.PushbackReader;
-import java.io.Reader;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-
-/**
- * Copied from org.eclipse.jdt.internal.ui.text.HTML2TextReader
- * Modifications were made to add br/ tag
- */
-/**
- * Reads the text contents from a reader of HTML contents and translates
- * the tags or cut them out.
- */
-public class HTML2TextReader extends SubstitutionTextReader {
-
-
-
- private static final String LINE_DELIM = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
- private static final Map fgEntityLookup;
- private static final Set fgTags;
-
- static {
-
- fgTags = new HashSet();
- fgTags.add("b"); //$NON-NLS-1$
- fgTags.add("br"); //$NON-NLS-1$
- fgTags.add("br/");//$NON-NLS-1$
- fgTags.add("h5"); //$NON-NLS-1$
- fgTags.add("p"); //$NON-NLS-1$
- fgTags.add("dl"); //$NON-NLS-1$
- fgTags.add("dt"); //$NON-NLS-1$
- fgTags.add("dd"); //$NON-NLS-1$
- fgTags.add("li"); //$NON-NLS-1$
- fgTags.add("ul"); //$NON-NLS-1$
- fgTags.add("pre"); //$NON-NLS-1$
-
- fgEntityLookup = new HashMap(7);
- fgEntityLookup.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("circ", "^"); //$NON-NLS-1$ //$NON-NLS-2$
- fgEntityLookup.put("tilde", "~"); //$NON-NLS-2$ //$NON-NLS-1$
- fgEntityLookup.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private int fCounter = 0;
- private TextPresentation fTextPresentation;
- private int fBold = 0;
- private int fStartOffset = -1;
- private boolean fInParagraph = false;
- private boolean fIsPreformattedText = false;
-
- /**
- * Transforms the html text from the reader to formatted text.
- * @param presentation If not <code>null</code>, formattings will be applied to
- * the presentation.
- */
- public HTML2TextReader(Reader reader, TextPresentation presentation) {
- super(new PushbackReader(reader));
- fTextPresentation = presentation;
- }
-
- public int read() throws IOException {
- int c = super.read();
- if (c != -1)
- ++fCounter;
- return c;
- }
-
- protected void startBold() {
- if (fBold == 0)
- fStartOffset = fCounter;
- ++fBold;
- }
-
- protected void startPreformattedText() {
- fIsPreformattedText = true;
- setSkipWhitespace(false);
- }
-
- protected void stopPreformattedText() {
- fIsPreformattedText = false;
- setSkipWhitespace(true);
- }
-
- protected void stopBold() {
- --fBold;
- if (fBold == 0) {
- if (fTextPresentation != null) {
- fTextPresentation.addStyleRange(new StyleRange(fStartOffset, fCounter - fStartOffset, null, null, SWT.BOLD));
- }
- fStartOffset = -1;
- }
- }
-
- /**
- * @see SubstitutionTextReader#computeSubstitution(char)
- */
- protected String computeSubstitution(int c) throws IOException {
-
- if (c == '<')
- return processHTMLTag();
- else if (c == '&')
- return processEntity();
- else if (fIsPreformattedText)
- return processPreformattedText(c);
-
- return null;
- }
-
- private String html2Text(String html) {
-
- String tag = html;
- if ('/' == tag.charAt(0))
- tag = tag.substring(1);
-
- if (!fgTags.contains(tag))
- return EMPTY_STRING;
-
- if ("pre".equals(html)) { //$NON-NLS-1$
- startPreformattedText();
- return EMPTY_STRING;
- }
-
- if ("/pre".equals(html)) { //$NON-NLS-1$
- stopPreformattedText();
- return EMPTY_STRING;
- }
-
- if (fIsPreformattedText)
- return EMPTY_STRING;
-
- if ("b".equals(html)) { //$NON-NLS-1$
- startBold();
- return EMPTY_STRING;
- }
-
- if ("h5".equals(html) || "dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
- startBold();
- return EMPTY_STRING;
- }
-
- if ("dl".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- if ("dd".equals(html)) //$NON-NLS-1$
- return "\t"; //$NON-NLS-1$
-
- if ("li".equals(html)) //$NON-NLS-1$
- return LINE_DELIM + "\t" + "- "; //$NON-NLS-1$ //$NON-NLS-2$
-
- if ("/b".equals(html)) { //$NON-NLS-1$
- stopBold();
- return EMPTY_STRING;
- }
-
- if ("p".equals(html)) { //$NON-NLS-1$
- fInParagraph = true;
- return LINE_DELIM;
- }
-
- if ("br".equals(html) || "br/".equals(html)) //$NON-NLS-1$ //$NON-NLS-2$
- return LINE_DELIM;
-
- if ("/p".equals(html)) { //$NON-NLS-1$
- boolean inParagraph = fInParagraph;
- fInParagraph = false;
- return inParagraph ? EMPTY_STRING : LINE_DELIM;
- }
-
- if ("/h5".equals(html) || "/dt".equals(html)) { //$NON-NLS-1$ //$NON-NLS-2$
- stopBold();
- return LINE_DELIM;
- }
-
- if ("/dd".equals(html)) //$NON-NLS-1$
- return LINE_DELIM;
-
- return EMPTY_STRING;
- }
-
- /*
- * A '<' has been read. Process a html tag
- */
- private String processHTMLTag() throws IOException {
-
- StringBuffer buf = new StringBuffer();
- int ch;
- do {
-
- ch = nextChar();
-
- while (ch != -1 && ch != '>') {
- buf.append(Character.toLowerCase((char) ch));
- ch = nextChar();
- if (ch == '"') {
- buf.append(Character.toLowerCase((char) ch));
- ch = nextChar();
- while (ch != -1 && ch != '"') {
- buf.append(Character.toLowerCase((char) ch));
- ch = nextChar();
- }
- }
- if (ch == '<') {
- unread(ch);
- return '<' + buf.toString();
- }
- }
-
- if (ch == -1)
- return null;
-
- int tagLen = buf.length();
- // needs special treatment for comments
- if ((tagLen >= 3 && "!--".equals(buf.substring(0, 3))) //$NON-NLS-1$
- && !(tagLen >= 5 && "--!".equals(buf.substring(tagLen - 3)))) { //$NON-NLS-1$
- // unfinished comment
- buf.append(ch);
- }
- else {
- break;
- }
- }
- while (true);
-
- return html2Text(buf.toString());
- }
-
- private String processPreformattedText(int c) {
- if (c == '\r' || c == '\n')
- fCounter++;
- return null;
- }
-
-
- private void unread(int ch) throws IOException {
- ((PushbackReader) getReader()).unread(ch);
- }
-
- protected String entity2Text(String symbol) {
- if (symbol.length() > 1 && symbol.charAt(0) == '#') {
- int ch;
- try {
- if (symbol.charAt(1) == 'x') {
- ch = Integer.parseInt(symbol.substring(2), 16);
- }
- else {
- ch = Integer.parseInt(symbol.substring(1), 10);
- }
- return EMPTY_STRING + (char) ch;
- }
- catch (NumberFormatException e) {
- }
- }
- else {
- String str = (String) fgEntityLookup.get(symbol);
- if (str != null) {
- return str;
- }
- }
- return "&" + symbol; // not found //$NON-NLS-1$
- }
-
- /*
- * A '&' has been read. Process a entity
- */
- private String processEntity() throws IOException {
- StringBuffer buf = new StringBuffer();
- int ch = nextChar();
- while (Character.isLetterOrDigit((char) ch) || ch == '#') {
- buf.append((char) ch);
- ch = nextChar();
- }
-
- if (ch == ';')
- return entity2Text(buf.toString());
-
- buf.insert(0, '&');
- if (ch != -1)
- buf.append((char) ch);
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTMLTextPresenter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTMLTextPresenter.java
deleted file mode 100644
index 66c8516cbf..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/HTMLTextPresenter.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-
-
-import java.io.IOException;
-import java.io.Reader;
-import java.io.StringReader;
-import java.util.Iterator;
-
-import org.eclipse.jface.text.DefaultInformationControl;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-/**
- * Copied from org.eclipse.jdt.internal.ui.text.HTMLTextPresenter
- * Modifications were made to use sed Logger to log exception, and the ellipses
- * constant
- */
-public class HTMLTextPresenter implements DefaultInformationControl.IInformationPresenter {
-
- private static final String LINE_DELIM = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
- private static final String ELLIPSES = "..."; //$NON-NLS-1$
-
- private int fCounter;
- private boolean fEnforceUpperLineLimit;
-
- public HTMLTextPresenter(boolean enforceUpperLineLimit) {
- super();
- fEnforceUpperLineLimit = enforceUpperLineLimit;
- }
-
- public HTMLTextPresenter() {
- this(true);
- }
-
- protected Reader createReader(String hoverInfo, TextPresentation presentation) {
- return new HTML2TextReader(new StringReader(hoverInfo), presentation);
- }
-
- protected void adaptTextPresentation(TextPresentation presentation, int offset, int insertLength) {
-
- int yoursStart = offset;
- int yoursEnd = offset + insertLength - 1;
- yoursEnd = Math.max(yoursStart, yoursEnd);
-
- Iterator e = presentation.getAllStyleRangeIterator();
- while (e.hasNext()) {
-
- StyleRange range = (StyleRange) e.next();
-
- int myStart = range.start;
- int myEnd = range.start + range.length - 1;
- myEnd = Math.max(myStart, myEnd);
-
- if (myEnd < yoursStart)
- continue;
-
- if (myStart < yoursStart)
- range.length += insertLength;
- else
- range.start += insertLength;
- }
- }
-
- private void append(StringBuffer buffer, String string, TextPresentation presentation) {
-
- int length = string.length();
- buffer.append(string);
-
- if (presentation != null)
- adaptTextPresentation(presentation, fCounter, length);
-
- fCounter += length;
- }
-
- private String getIndent(String line) {
- int length = line.length();
-
- int i = 0;
- while (i < length && Character.isWhitespace(line.charAt(i)))
- ++i;
-
- return (i == length ? line : line.substring(0, i)) + " "; //$NON-NLS-1$
- }
-
- /*
- * @see IHoverInformationPresenter#updatePresentation(Display display, String, TextPresentation, int, int)
- */
- public String updatePresentation(Display display, String hoverInfo, TextPresentation presentation, int maxWidth, int maxHeight) {
-
- if (hoverInfo == null)
- return null;
-
- GC gc = new GC(display);
- try {
-
- StringBuffer buffer = new StringBuffer();
- int maxNumberOfLines = Math.round(maxHeight / gc.getFontMetrics().getHeight());
-
- fCounter = 0;
- LineBreakingReader reader = new LineBreakingReader(createReader(hoverInfo, presentation), gc, maxWidth);
-
- boolean lastLineFormatted = false;
- String lastLineIndent = null;
-
- String line = reader.readLine();
- boolean lineFormatted = reader.isFormattedLine();
- boolean firstLineProcessed = false;
-
- while (line != null) {
-
- if (fEnforceUpperLineLimit && maxNumberOfLines <= 0)
- break;
-
- if (firstLineProcessed) {
- if (!lastLineFormatted)
- append(buffer, LINE_DELIM, null);
- else {
- append(buffer, LINE_DELIM, presentation);
- if (lastLineIndent != null)
- append(buffer, lastLineIndent, presentation);
- }
- }
-
- append(buffer, line, null);
- firstLineProcessed = true;
-
- lastLineFormatted = lineFormatted;
- if (!lineFormatted)
- lastLineIndent = null;
- else if (lastLineIndent == null)
- lastLineIndent = getIndent(line);
-
- line = reader.readLine();
- lineFormatted = reader.isFormattedLine();
-
- maxNumberOfLines--;
- }
-
- if (line != null) {
- append(buffer, LINE_DELIM, lineFormatted ? presentation : null);
- append(buffer, ELLIPSES, presentation); //$NON-NLS-1$
- }
-
- return trim(buffer, presentation);
-
- }
- catch (IOException e) {
- Logger.logException(e); // log exception
- return null;
-
- }
- finally {
- gc.dispose();
- }
- }
-
- private String trim(StringBuffer buffer, TextPresentation presentation) {
-
- int length = buffer.length();
-
- int end = length - 1;
- while (end >= 0 && Character.isWhitespace(buffer.charAt(end)))
- --end;
-
- if (end == -1)
- return ""; //$NON-NLS-1$
-
- if (end < length - 1)
- buffer.delete(end + 1, length);
- else
- end = length;
-
- int start = 0;
- while (start < end && Character.isWhitespace(buffer.charAt(start)))
- ++start;
-
- buffer.delete(0, start);
- presentation.setResultWindow(new Region(start, buffer.length()));
- return buffer.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/IHelpContextIds.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/IHelpContextIds.java
deleted file mode 100644
index 6ba088f15f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/IHelpContextIds.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-import org.eclipse.wst.sse.ui.EditorPlugin;
-
-/**
- * Help context ids for the Source Editor.
- * <p>
- * This interface contains constants only; it is not intended to be implemented.
- * </p>
- *
- */
-public interface IHelpContextIds {
- // org.eclipse.wst.sse.ui.
- public static final String PREFIX = EditorPlugin.ID + "."; //$NON-NLS-1$
-
- // Structured Text Editor Preference Page
- // Appearance
- public static final String PREFSTE_APPEARANCE_HELPID = PREFIX + "sted0001"; //$NON-NLS-1$
- // Hovers
- public static final String PREFSTE_HOVERS_HELPID = PREFIX + "sted0002"; //$NON-NLS-1$
- // Navigation
- public static final String PREFSTE_NAVIGATION_HELPID = PREFIX + "sted0003"; //$NON-NLS-1$
-
- // Web and XML Preference Page
- // Task Tags
- public static final String PREFWEBX_TASKTAGS_HELPID = PREFIX + "webx0000"; //$NON-NLS-1$
- // Read-Only Text Style
- public static final String PREFWEBX_READONLY_HELPID = PREFIX + "webx0001"; //$NON-NLS-1$
-
- // Source Editor View
- public static final String XML_SOURCE_VIEW_HELPID = PREFIX + "xmlm2000"; //$NON-NLS-1$
-
- // Abstract Source Editor Context Menu
- // Content Assist
- public static final String CONTMNU_CONTENTASSIST_HELPID = PREFIX + "xmlm1010"; //$NON-NLS-1$
-
- // commented out till new infopop ids have been confirmed
- // Format Document
-// public static final String CONTMNU_FORMAT_DOC_HELPID = PREFIX + "xmlm1030"; //$NON-NLS-1$
- // Format Active Elements
-// public static final String CONTMNU_FORMAT_ELEMENTS_HELPID = PREFIX + "xmlm1040"; //$NON-NLS-1$
- // Cleanup Document
-// public static final String CONTMNU_CLEANUP_DOC_HELPID = PREFIX + "xmlm1050"; //$NON-NLS-1$
- // Preferences TODO infopop needed
- // Properties TODO infopop needed
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/LineBreakingReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/LineBreakingReader.java
deleted file mode 100644
index 896c70cefd..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/LineBreakingReader.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.Reader;
-import java.text.BreakIterator;
-
-import org.eclipse.swt.graphics.GC;
-
-/**
- * Copied from org.eclipse.jdt.internal.ui.text.LineBreakingReader
- * No modifications were made
- */
-/*
- * Not a real reader. Could change if requested
- */
-public class LineBreakingReader {
-
-
- private BufferedReader fReader;
- private GC fGC;
- private int fMaxWidth;
-
- private String fLine;
- private int fOffset;
-
- private BreakIterator fLineBreakIterator;
-
- /**
- * Creates a reader that breaks an input text to fit in a given width.
- * @param reader Reader of the input text
- * @param gc The graphic context that defines the currently used font sizes
- * @param maxLineWidth The max width (pixes) where the text has to fit in
- */
- public LineBreakingReader(Reader reader, GC gc, int maxLineWidth) {
- fReader = new BufferedReader(reader);
- fGC = gc;
- fMaxWidth = maxLineWidth;
- fOffset = 0;
- fLine = null;
- fLineBreakIterator = BreakIterator.getLineInstance();
- }
-
- public boolean isFormattedLine() {
- return fLine != null;
- }
-
- /**
- * Reads the next line. The lengths of the line will not exceed the gived maximum
- * width.
- */
- public String readLine() throws IOException {
- if (fLine == null) {
- String line = fReader.readLine();
- if (line == null)
- return null;
-
- int lineLen = fGC.textExtent(line).x;
- if (lineLen < fMaxWidth) {
- return line;
- }
- fLine = line;
- fLineBreakIterator.setText(line);
- fOffset = 0;
- }
- int breakOffset = findNextBreakOffset(fOffset);
- String res;
- if (breakOffset != BreakIterator.DONE) {
- res = fLine.substring(fOffset, breakOffset);
- fOffset = findWordBegin(breakOffset);
- if (fOffset == fLine.length()) {
- fLine = null;
- }
- }
- else {
- res = fLine.substring(fOffset);
- fLine = null;
- }
- return res;
- }
-
- private int findNextBreakOffset(int currOffset) {
- int currWidth = 0;
- int nextOffset = fLineBreakIterator.following(currOffset);
- while (nextOffset != BreakIterator.DONE) {
- String word = fLine.substring(currOffset, nextOffset);
- int wordWidth = fGC.textExtent(word).x;
- int nextWidth = wordWidth + currWidth;
- if (nextWidth > fMaxWidth) {
- if (currWidth > 0) {
- return currOffset;
- }
- else {
- return nextOffset;
- }
- }
- currWidth = nextWidth;
- currOffset = nextOffset;
- nextOffset = fLineBreakIterator.next();
- }
- return nextOffset;
- }
-
- private int findWordBegin(int idx) {
- while (idx < fLine.length() && Character.isWhitespace(fLine.charAt(idx))) {
- idx++;
- }
- return idx;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SingleCharReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SingleCharReader.java
deleted file mode 100644
index ede4ad9cc3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SingleCharReader.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * Copied from org.eclipse.jdt.internal.corext.javadoc.SingleCharReader
- * Also copied in contentassist.html.javascript.tmpcopied.SingleCharReader
- * No modifications were made
- */
-public abstract class SingleCharReader extends Reader {
-
- /**
- * @see Reader#read()
- */
- public abstract int read() throws IOException;
-
- /**
- * @see Reader#read(char[],int,int)
- */
- public int read(char cbuf[], int off, int len) throws IOException {
- int end = off + len;
- for (int i = off; i < end; i++) {
- int ch = read();
- if (ch == -1) {
- if (i == off) {
- return -1;
- }
- else {
- return i - off;
- }
- }
- cbuf[i] = (char) ch;
- }
- return len;
- }
-
- /**
- * @see Reader#ready()
- */
- public boolean ready() throws IOException {
- return true;
- }
-
- /**
- * Gets the content as a String
- */
- public String getString() throws IOException {
- StringBuffer buf = new StringBuffer();
- int ch;
- while ((ch = read()) != -1) {
- buf.append((char) ch);
- }
- return buf.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SubstitutionTextReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SubstitutionTextReader.java
deleted file mode 100644
index 8fc516eed8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editor/SubstitutionTextReader.java
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editor;
-
-
-
-import java.io.IOException;
-import java.io.Reader;
-
-/**
- * Copied from org.eclipse.jdt.internal.ui.text.SubstitutionTextReader
- * Also copied in contentassist.html.javascript.tmpcopied.SubstitutionTextReader
- * Modifications were made to read() to allow whitespaces
- */
-/**
- * Reads the text contents from a reader and computes for each character
- * a potential substitution. The substitution may eat more characters than
- * only the one passed into the computation routine.
- */
-public abstract class SubstitutionTextReader extends SingleCharReader {
-
- protected static final String LINE_DELIM = System.getProperty("line.separator", "\n"); //$NON-NLS-1$ //$NON-NLS-2$
-
- private Reader fReader;
- private boolean fWasWhiteSpace;
- private int fCharAfterWhiteSpace;
-
- /**
- * Tells whether white space characters are skipped.
- */
- private boolean fSkipWhiteSpace = true;
-
- private boolean fReadFromBuffer;
- private StringBuffer fBuffer;
- private int fIndex;
-
-
- protected SubstitutionTextReader(Reader reader) {
- fReader = reader;
- fBuffer = new StringBuffer();
- fIndex = 0;
- fReadFromBuffer = false;
- fCharAfterWhiteSpace = -1;
- fWasWhiteSpace = true;
- }
-
- /**
- * Implement to compute the substitution for the given character and
- * if necessary subsequent characters. Use <code>nextChar</code>
- * to read subsequent characters.
- */
- protected abstract String computeSubstitution(int c) throws IOException;
-
- /**
- * Returns the internal reader.
- */
- protected Reader getReader() {
- return fReader;
- }
-
- /**
- * Returns the next character.
- */
- protected int nextChar() throws IOException {
- fReadFromBuffer = (fBuffer.length() > 0);
- if (fReadFromBuffer) {
- char ch = fBuffer.charAt(fIndex++);
- if (fIndex >= fBuffer.length()) {
- fBuffer.setLength(0);
- fIndex = 0;
- }
- return ch;
- }
- else {
- int ch = fCharAfterWhiteSpace;
- if (ch == -1) {
- ch = fReader.read();
- }
- if (fSkipWhiteSpace && Character.isWhitespace((char) ch)) {
- do {
- ch = fReader.read();
- }
- while (Character.isWhitespace((char) ch));
- if (ch != -1) {
- fCharAfterWhiteSpace = ch;
- return ' ';
- }
- }
- else {
- fCharAfterWhiteSpace = -1;
- }
- return ch;
- }
- }
-
- /**
- * @see Reader#read()
- */
- public int read() throws IOException {
- int c;
- do {
-
- c = nextChar();
- while (!fReadFromBuffer) {
- String s = computeSubstitution(c);
- if (s == null)
- break;
- if (s.length() > 0)
- fBuffer.insert(0, s);
- c = nextChar();
- }
-
- }
- while (fSkipWhiteSpace && fWasWhiteSpace && ((c == ' ') && !fReadFromBuffer)); // AFW - if whitespace is from buffer, then it should be read
- fWasWhiteSpace = ((c == ' ' && !fReadFromBuffer) || c == '\r' || c == '\n'); // AFW - if whitespace is from buffer, then it should be read
- return c;
- }
-
- /**
- * @see Reader#ready()
- */
- public boolean ready() throws IOException {
- return fReader.ready();
- }
-
- /**
- * @see Reader#close()
- */
- public void close() throws IOException {
- fReader.close();
- }
-
- /**
- * @see Reader#reset()
- */
- public void reset() throws IOException {
- fReader.reset();
- fWasWhiteSpace = true;
- fCharAfterWhiteSpace = -1;
- fBuffer.setLength(0);
- fIndex = 0;
- }
-
- protected final void setSkipWhitespace(boolean state) {
- fSkipWhiteSpace = state;
- }
-
- protected final boolean isSkippingWhitespace() {
- return fSkipWhiteSpace;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/StructuredTextEditorViewer.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/StructuredTextEditorViewer.java
deleted file mode 100644
index 8a91b3372e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/StructuredTextEditorViewer.java
+++ /dev/null
@@ -1,512 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editorviewer;
-
-
-
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorActionBarContributor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorSite;
-import org.eclipse.ui.IKeyBindingService;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IViewSite;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchPartSite;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.view.events.INodeSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-import org.eclipse.wst.sse.ui.views.contentoutline.StructuredTextEditorContentOutlinePage;
-import org.w3c.dom.Attr;
-
-
-/**
- * TODO remove in C5 or earlier
- * @deprecated use the StructuredTextViewer directly if only using for read-only mode.
- * otherwise, use the StructuredTextEditorViewer in qev plugin
- * (removing in C5 or earlier)
- */
-public class StructuredTextEditorViewer extends Viewer {
-
- protected void hook2(IEditorPart editor) {
- if (fHighlightRangeListener == null)
- fHighlightRangeListener = new NodeRangeSelectionListener();
-
- fContentOutlinePage = ((IContentOutlinePage) editor.getAdapter(IContentOutlinePage.class));
- if (fContentOutlinePage != null && fContentOutlinePage instanceof StructuredTextEditorContentOutlinePage) {
- ((StructuredTextEditorContentOutlinePage) fContentOutlinePage).getViewerSelectionManager().addNodeSelectionListener(fHighlightRangeListener);
-
- if (!fContentOutlinePage.getSelection().isEmpty() && fContentOutlinePage.getSelection() instanceof IStructuredSelection) {
- getTextEditor().showHighlightRangeOnly(true);
- Object[] nodes = ((IStructuredSelection) fContentOutlinePage.getSelection()).toArray();
- IndexedRegion startNode = (IndexedRegion) nodes[0];
- IndexedRegion endNode = (IndexedRegion) nodes[nodes.length - 1];
-
- if (startNode instanceof Attr)
- startNode = (IndexedRegion) ((Attr) startNode).getOwnerElement();
- if (endNode instanceof Attr)
- endNode = (IndexedRegion) ((Attr) endNode).getOwnerElement();
-
- int start = startNode.getStartOffset();
- int end = endNode.getEndOffset();
- getTextEditor().resetHighlightRange();
- getTextEditor().setHighlightRange(start, end - start, true);
-
- IDocument document = getTextEditor().getDocumentProvider().getDocument(getEditorInput());
- if (document instanceof IStructuredDocument) {
- ((IStructuredDocument) document).makeReadOnly(start, end - start);
- refresh();
- }
-
- }
- }
- }
-
- protected StructuredTextEditor fTextEditor = null;
- protected IContentOutlinePage fContentOutlinePage = null;
-
- private String fDefaultContentTypeID = null;
- protected INodeSelectionListener fHighlightRangeListener = null;
-
- private Composite parent = null;
- protected Composite container = null;
-
- protected boolean fEditable = true;
- protected IEditorInput fInput = null;
- protected int fStyle = SWT.NONE;
-
- /**
- * Unhooks the editor when in follow mode and the target editing part is
- * disposed.
- */
- protected class UnhookOnDisposeListener implements DisposeListener {
- public void widgetDisposed(DisposeEvent e) {
- unhook();
- }
- }
-
- /**
- * Sets the editor's highlighting text range to the text range indicated by the
- * selected Nodes.
- */
- protected class NodeRangeSelectionListener implements INodeSelectionListener {
- public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
- if (!event.getSelectedNodes().isEmpty()) {
- IndexedRegion startNode = (IndexedRegion) event.getSelectedNodes().get(0);
- IndexedRegion endNode = (IndexedRegion) event.getSelectedNodes().get(event.getSelectedNodes().size() - 1);
-
- if (startNode instanceof Attr)
- startNode = (IndexedRegion) ((Attr) startNode).getOwnerElement();
- if (endNode instanceof Attr)
- endNode = (IndexedRegion) ((Attr) endNode).getOwnerElement();
-
- int start = startNode.getStartOffset();
- int end = endNode.getEndOffset();
-
- getTextEditor().resetHighlightRange();
- getTextEditor().setHighlightRange(start, end - start, true);
- }
- else {
- getTextEditor().resetHighlightRange();
- }
- }
- }
-
- public static class ViewEditorInput implements IEditorInput {
-
- private IStructuredModel fStructuredModel = null;
-
- public ViewEditorInput(IStructuredModel model) {
- super();
- fStructuredModel = model;
- }
-
- public boolean exists() {
- return fStructuredModel != null;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- if (exists())
- return fStructuredModel.getId();
- return "org.eclipse.wst.sse.ui.internal-view"; //$NON-NLS-1$
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public String getToolTipText() {
- return getStructuredModel().getBaseLocation();
- }
-
- public Object getAdapter(Class arg0) {
- return null;
- }
-
- public IStructuredModel getStructuredModel() {
- return fStructuredModel;
- }
-
- public void setStructuredModel(IStructuredModel structuredModel) {
- fStructuredModel = structuredModel;
- }
- }
-
- public static class ViewerEditorSite implements IEditorSite {
-
- protected IWorkbenchPartSite fSite = null;
-
- public ViewerEditorSite(IWorkbenchPartSite site) {
- fSite = site;
- }
-
- public IEditorActionBarContributor getActionBarContributor() {
- return null;
- }
-
- public IKeyBindingService getKeyBindingService() {
- return fSite.getKeyBindingService();
- }
-
- public String getId() {
- return fSite.getId();
- }
-
- public String getPluginId() {
- return fSite.getPluginId();
- }
-
- public String getRegisteredName() {
- return fSite.getRegisteredName();
- }
-
- public void registerContextMenu(String menuId, MenuManager menuManager, ISelectionProvider selectionProvider) {
- fSite.registerContextMenu(menuId, menuManager, selectionProvider);
- }
-
- public void registerContextMenu(MenuManager menuManager, ISelectionProvider selectionProvider) {
- fSite.registerContextMenu(menuManager, selectionProvider);
- }
-
- public IWorkbenchPage getPage() {
- return fSite.getPage();
- }
-
- public ISelectionProvider getSelectionProvider() {
- return fSite.getSelectionProvider();
- }
-
- public Shell getShell() {
- return fSite.getShell();
- }
-
- public IWorkbenchWindow getWorkbenchWindow() {
- return fSite.getWorkbenchWindow();
- }
-
- public void setSelectionProvider(ISelectionProvider provider) {
- }
-
- /**
- * @see org.eclipse.ui.IEditorSite#getActionBars()
- */
- public IActionBars getActionBars() {
- if (fSite instanceof IViewSite)
- return ((IViewSite) fSite).getActionBars();
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- // TODO Auto-generated method stub
- return null;
- }
-
- }
-
- /**
- * Method StructuredTextEditorViewer.
- * @param parent
- */
- public StructuredTextEditorViewer(Composite parent) {
- this(parent, SWT.NONE);
- }
-
- /**
- * Method StructuredTextEditorViewer.
- * @param parent
- * @param style
- */
- public StructuredTextEditorViewer(Composite parent, int style) {
- super();
- this.parent = parent;
- fTextEditor = createTextEditor();
- fStyle = style;
- }
-
- /**
- * Method StructuredTextEditorViewer.
- * @param parent
- * @param style
- * @param editor
- */
- public StructuredTextEditorViewer(Composite parent, int style, StructuredTextEditor editor) {
- super();
- this.parent = parent;
- fTextEditor = editor;
- fStyle = style;
- }
-
- protected StructuredTextEditor createTextEditor() {
- StructuredTextEditor editor = new StructuredTextEditor();
- return editor;
- }
-
- /**
- * If possible, retrieves the IEditorPart's StructuredTextEditorContentOutlinePage
- * and displays the text content indicated by its Selection
- * @param editor
- */
- public void followSelection(IEditorPart editor) {
- setInput(editor.getEditorInput());
- hook(editor);
- }
-
- public void followSelection2(IEditorPart editor) {
- setInput(editor.getEditorInput());
- hook2(editor);
- }
-
- /**
- * @see org.eclipse.jface.viewers.Viewer#getControl()
- */
- public Control getControl() {
- return container;
- }
-
- public String getDefaultContentTypeID() {
- return fDefaultContentTypeID;
- }
-
- public IEditorInput getEditorInput() {
- return fInput;
- }
-
- /**
- * @see org.eclipse.jface.viewers.IInputProvider#getInput()
- */
- public Object getInput() {
- return getEditorInput();
- }
-
- /**
- * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
- */
- public ISelection getSelection() {
- return getTextEditor().getTextViewer().getSelection();
- }
-
- /**
- * Returns the textEditor.
- * @return StructuredTextEditor
- */
- public StructuredTextEditor getTextEditor() {
- return fTextEditor;
- }
-
- protected void hook(IEditorPart editor) {
- if (fHighlightRangeListener == null)
- fHighlightRangeListener = new NodeRangeSelectionListener();
-
- fContentOutlinePage = ((IContentOutlinePage) editor.getAdapter(IContentOutlinePage.class));
- if (fContentOutlinePage != null && fContentOutlinePage instanceof StructuredTextEditorContentOutlinePage) {
- ((StructuredTextEditorContentOutlinePage) fContentOutlinePage).getViewerSelectionManager().addNodeSelectionListener(fHighlightRangeListener);
-
- if (!fContentOutlinePage.getSelection().isEmpty() && fContentOutlinePage.getSelection() instanceof IStructuredSelection) {
- getTextEditor().showHighlightRangeOnly(true);
- Object[] nodes = ((IStructuredSelection) fContentOutlinePage.getSelection()).toArray();
- IndexedRegion startNode = (IndexedRegion) nodes[0];
- IndexedRegion endNode = (IndexedRegion) nodes[nodes.length - 1];
-
- if (startNode instanceof Attr)
- startNode = (IndexedRegion) ((Attr) startNode).getOwnerElement();
- if (endNode instanceof Attr)
- endNode = (IndexedRegion) ((Attr) endNode).getOwnerElement();
-
- int start = startNode.getStartOffset();
- int end = endNode.getEndOffset();
- getTextEditor().resetHighlightRange();
- getTextEditor().setHighlightRange(start, end - start, true);
- }
- }
- }
-
- /**
- * Method init, for testing.
- * @param site
- */
- public void init(IWorkbenchPartSite site, IEditorInput input) {
- try {
- // setInput(input);
- // getTextEditor().init(new ViewerEditorSite(site), getEditorInput());
- getTextEditor().init(new ViewerEditorSite(site), input);
- }
- catch (PartInitException e) {
- e.printStackTrace();
- }
- container = new Composite(parent, fStyle);
- FillLayout fill = new FillLayout();
- container.setLayout(fill);
-
- getTextEditor().createPartControl(container);
- // part of the specific DnD support, even though it is itself an IEditorPart
- // TODO: 5.1W3 - should update the StructuredTextEditor to handle this functionality itself
- getTextEditor().setEditorPart(getTextEditor());
- getTextEditor().getTextViewer().getTextWidget().addDisposeListener(new UnhookOnDisposeListener());
- }
-
- /**
- * @see org.eclipse.jface.viewers.Viewer#refresh()
- */
- public void refresh() {
- getTextEditor().getTextViewer().refresh();
- }
-
- /**
- * Sets the documentProvider.
- * @param documentProvider The documentProvider to set
- */
- public void setDocumentProvider(IDocumentProvider documentProvider) {
- getTextEditor().initializeDocumentProvider(documentProvider);
- }
-
- public void setEditable(boolean editable) {
- fEditable = editable;
- }
-
- /**
- * Sets the viewer's input - expects a IStructuredModel or IEditorInput
- * @see org.eclipse.jface.viewers.Viewer#setInput(Object)
- */
- public void setInput(Object input) {
- // getTextEditor().getTextViewer().getTextWidget().setEnabled(input != null);
- unhook();
- if (input instanceof IStructuredModel) {
- fInput = new ViewEditorInput((IStructuredModel) input);
- getTextEditor().setInput(fInput);
- updateEditor();
- }
- else if (input instanceof IEditorInput) {
- // if (input instanceof IFileEditorInput) {
- // setDocumentProvider(FileModelProvider.getInstance());
- // }
- fInput = (IEditorInput) input;
- getTextEditor().setInput(fInput);
- updateEditor();
- }
- else
- throw new UnsupportedOperationException("setInput: unsupported type"); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.viewers.Viewer#setSelection(ISelection, boolean)
- */
- public void setSelection(ISelection selection, boolean reveal) {
- getTextEditor().getTextViewer().setSelection(selection, reveal);
- }
-
- /**
- * @deprecated - leave for users
- *
- * Show content from the beginning of the line on which the offset
- * "start" is located for "length" number of characters.
- */
- public void show(int start, int length) {
- getTextEditor().showHighlightRangeOnly(true);
- getTextEditor().resetHighlightRange();
- getTextEditor().setHighlightRange(start, length, true);
- }
-
- /**
- * @deprecated - leave for users
- *
- * Show all content.
- */
- public void showAll() {
- getTextEditor().resetHighlightRange();
- getTextEditor().showHighlightRangeOnly(false);
- }
-
- /**
- * cease showing just the current selection in the StructuredTextEditorContentOutlinePage
- */
- public void stopFollowingSelection() {
- unhook();
- }
-
- protected void unhook() {
- if (fContentOutlinePage != null && fContentOutlinePage instanceof StructuredTextEditorContentOutlinePage) {
- ((StructuredTextEditorContentOutlinePage) fContentOutlinePage).getViewerSelectionManager().removeNodeSelectionListener(fHighlightRangeListener);
- if (getTextEditor().getTextViewer() != null) {
- showAll();
- }
- fContentOutlinePage = null;
- }
- }
-
- protected void updateEditor() {
- if (getTextEditor().getTextViewer() != null && fInput != null) {
- getTextEditor().getTextViewer().setEditable(fEditable);
- }
- }
-
- public void dispose() {
- getTextEditor().dispose();
- }
-
- /**
- * @param string
- */
- public void setDefaultContentTypeID(String string) {
- fDefaultContentTypeID = string;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/TextStorageEditorInput.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/TextStorageEditorInput.java
deleted file mode 100644
index 07610d7e7f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/editorviewer/TextStorageEditorInput.java
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.editorviewer;
-
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.wst.sse.core.util.DocumentInputStream;
-
-/**
- * TODO remove in C5 or earlier
- * @deprecated removing in C5 or earlier
- */
-public class TextStorageEditorInput implements IStorageEditorInput {
-
- private class TextStorage implements IStorage {
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- public InputStream getContents() throws CoreException {
- return new DocumentInputStream(fDocument);
- }
-
- public IPath getFullPath() {
- return fPath;
- }
-
- public String getName() {
- return getFullPath().toString();
- }
-
- public boolean isReadOnly() {
- return false;
- }
- }
-
- protected IDocument fDocument;
- protected IPath fPath;
- protected TextStorage fStorage;
-
-
- public TextStorageEditorInput(String path) {
- super();
- fPath = new Path(path);
- fStorage = new TextStorage();
- fDocument = new Document();
- }
-
- public boolean exists() {
- return true;
- }
-
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- public IDocument getDocument() {
- return fDocument;
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return fStorage.getName();
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public IStorage getStorage() throws CoreException {
- return fStorage;
- }
-
- public String getToolTipText() {
- return getName();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ActionDescriptor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ActionDescriptor.java
deleted file mode 100644
index f265437311..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ActionDescriptor.java
+++ /dev/null
@@ -1,383 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.extension;
-
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extension.IActionValidator;
-
-
-/**
- * When 'action' tag is found in the registry, an object of this
- * class is created. It creates the appropriate action object
- * and captures information that is later used to add this action
- * object into menu/tool bar. This class is reused for
- * global (workbench) menu/tool bar, popup menu actions,
- * as well as view's pulldown and local tool bar.
- */
-public class ActionDescriptor {
-
- private ActionContributionItem item;
- private String id;
- private String menuPath;
- private String menuGroup;
- private String toolbarPath;
- private String toolbarGroup;
- private String popupmenuPath;
- private String popupmenuGroup;
-
- public static final String ATT_ID = "id"; //$NON-NLS-1$
- public static final String ATT_DEFINITION_ID = "definitionId"; //$NON-NLS-1$
- public static final String ATT_HELP_CONTEXT_ID = "helpContextId"; //$NON-NLS-1$
- public static final String ATT_LABEL = "label"; //$NON-NLS-1$
- public static final String ATT_STATE = "state"; //$NON-NLS-1$
- public static final String ATT_DESCRIPTION = "description"; //$NON-NLS-1$
- public static final String ATT_TOOLTIP = "tooltip"; //$NON-NLS-1$
- public static final String ATT_MENUBAR_PATH = "menubarPath"; //$NON-NLS-1$
- public static final String ATT_TOOLBAR_PATH = "toolbarPath"; //$NON-NLS-1$
- public static final String ATT_POPUPMENU_PATH = "popupmenuPath"; //$NON-NLS-1$
- public static final String ATT_ICON = "icon"; //$NON-NLS-1$
- public static final String ATT_HOVERICON = "hoverIcon"; //$NON-NLS-1$
- public static final String ATT_DISABLEDICON = "disabledIcon"; //$NON-NLS-1$
- public static final String ATT_CLASS = "class"; //$NON-NLS-1$
- public static final String ATT_ACCELERATOR = "accelerator"; //$NON-NLS-1$
-
- /**
- * Creates a new descriptor with the targetType
- */
- public ActionDescriptor(IConfigurationElement actionElement) throws CoreException {
-
- // Calculate menu and toolbar paths.
- String mpath = actionElement.getAttribute(ATT_MENUBAR_PATH);
- String mgroup = null;
- if (mpath != null) {
- int loc = mpath.lastIndexOf('/');
- if (loc != -1) {
- mgroup = mpath.substring(loc + 1);
- mpath = mpath.substring(0, loc);
- }
- else {
- mgroup = mpath;
- mpath = null;
- }
- }
- menuPath = mpath;
- menuGroup = mgroup;
-
- String ppath = actionElement.getAttribute(ATT_POPUPMENU_PATH);
- String pgroup = null;
- if (ppath != null) {
- int loc = ppath.lastIndexOf('/');
- if (loc != -1) {
- pgroup = ppath.substring(loc + 1);
- ppath = ppath.substring(0, loc);
- }
- else {
- pgroup = ppath;
- ppath = null;
- }
- }
- popupmenuPath = ppath;
- popupmenuGroup = pgroup;
-
- String tpath = actionElement.getAttribute(ATT_TOOLBAR_PATH);
- String tgroup = null;
- if (tpath != null) {
- int loc = tpath.lastIndexOf('/');
- if (loc != -1) {
- tgroup = tpath.substring(loc + 1);
- tpath = tpath.substring(0, loc);
- }
- else {
- tgroup = tpath;
- tpath = null;
- }
- }
- toolbarPath = tpath;
- toolbarGroup = tgroup;
-
- // Create action.
- IAction action = createAction(actionElement);
- if (action == null)
- return;
-
- String label = actionElement.getAttribute(ATT_LABEL);
- if (label != null)
- action.setText(label);
-
- id = actionElement.getAttribute(ATT_ID);
- if (id == null) {
- id = actionElement.getAttribute(ATT_CLASS);
- }
- if (id != null)
- action.setId(id);
-
- String defId = actionElement.getAttribute(ATT_DEFINITION_ID);
- if (defId != null && defId.length() != 0) {
- action.setActionDefinitionId(defId);
- }
-
- String tooltip = actionElement.getAttribute(ATT_TOOLTIP);
- if (tooltip != null)
- action.setToolTipText(tooltip);
-
- String helpContextId = actionElement.getAttribute(ATT_HELP_CONTEXT_ID);
- if (helpContextId != null) {
- String fullID = helpContextId;
- if (helpContextId.indexOf(".") == -1) //$NON-NLS-1$
- // For backward compatibility we auto qualify the id if it is not qualified)
- fullID = actionElement.getDeclaringExtension().getDeclaringPluginDescriptor().getUniqueIdentifier() + "." + helpContextId; //$NON-NLS-1$
- WorkbenchHelp.setHelp(action, fullID);
- }
-
- String description = actionElement.getAttribute(ATT_DESCRIPTION);
- if (description != null)
- action.setDescription(description);
-
- String state = actionElement.getAttribute(ATT_STATE);
- if (state != null) {
- action.setChecked(state.equals("true")); //$NON-NLS-1$
- }
-
- String icon = actionElement.getAttribute(ATT_ICON);
- if (icon != null) {
- action.setImageDescriptor(ImageUtil.getImageDescriptorFromExtension(actionElement.getDeclaringExtension(), icon));
- }
-
- String hoverIcon = actionElement.getAttribute(ATT_HOVERICON);
- if (hoverIcon != null) {
- action.setHoverImageDescriptor(ImageUtil.getImageDescriptorFromExtension(actionElement.getDeclaringExtension(), hoverIcon));
- }
-
- String disabledIcon = actionElement.getAttribute(ATT_DISABLEDICON);
- if (disabledIcon != null) {
- action.setDisabledImageDescriptor(ImageUtil.getImageDescriptorFromExtension(actionElement.getDeclaringExtension(), disabledIcon));
- }
-
- String accelerator = actionElement.getAttribute(ATT_ACCELERATOR);
- if (accelerator != null)
- processAccelerator(action, accelerator);
-
- item = new ActionContributionItem(action);
- }
-
- /**
- */
- private IAction createAction(IConfigurationElement actionElement) {
-
- Object action = createExtension(actionElement, ATT_CLASS);
- if (action == null)
- return null;
- if (action instanceof IActionValidator) {
- if (!((IActionValidator) action).isValidAction())
- return null;
- }
- return (action instanceof IAction ? (IAction) ExtendedEditorActionProxy.newInstance(action) : null);
- }
-
- /**
- * Creates an extension. If the extension plugin has not
- * been loaded a busy cursor will be activated during the duration of
- * the load.
- *
- * @param element the config element defining the extension
- * @param classAttribute the name of the attribute carrying the class
- * @returns the extension object if successful. If an error occurs when createing
- * executable extension, the exception is logged, and null returned.
- */
- public static Object createExtension(final IConfigurationElement element, final String classAttribute) {
- final Object[] result = new Object[1];
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- try {
- result[0] = element.createExecutableExtension(classAttribute);
- }
- catch (Throwable e) {
- // catch and log ANY exception from extension point
- handleCreateExecutableException(result, e);
- }
- }
- else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- result[0] = element.createExecutableExtension(classAttribute);
- }
- catch (Throwable e) {
- // catch and log ANY exception from extension point
- handleCreateExecutableException(result, e);
- }
- }
- });
- }
- return result[0];
- }
-
- private static void handleCreateExecutableException(final Object[] result, Throwable e) {
- Logger.logException(e);
- result[0] = null;
- }
-
- /**
- * Returns the IContributionItem object held in this descriptor.
- */
- public IContributionItem getContributionItem() {
- return item;
- }
-
- /**
- * Returns the action object held in this descriptor.
- */
- public IAction getAction() {
- return (item != null ? item.getAction() : null);
- }
-
- /**
- * Returns action's id as defined in the registry.
- */
- public String getId() {
- return id;
- }
-
- /**
- * Returns named slot (group) in the menu where this action
- * should be added.
- */
- public String getMenuGroup() {
- return menuGroup;
- }
-
- /**
- * Returns menu path where this action should be added. If null,
- * the action will not be added into the menu.
- */
-
- public String getMenuPath() {
- return menuPath;
- }
-
- /**
- * Returns named slot (group) in the popup menu where this action
- * should be added.
- */
- public String getPopupMenuGroup() {
- return popupmenuGroup;
- }
-
- /**
- * Returns popup menu path where this action should be added. If null,
- * the action will not be added into the popup menu.
- */
-
- public String getPopupMenuPath() {
- return popupmenuPath;
- }
-
- /**
- * Returns the named slot (group) in the tool bar where this
- * action should be added.
- */
-
- public String getToolbarGroup() {
- return toolbarGroup;
- }
-
- /**
- * Returns path in the tool bar where this action should be added.
- * If null, action will not be added to the tool bar.
- */
- public String getToolbarPath() {
- return toolbarPath;
- }
-
- /**
- * For debugging only.
- */
- public String toString() {
- return "ActionDescriptor(" + id + ")"; //$NON-NLS-2$//$NON-NLS-1$
- }
-
- /**
- * Process the accelerator definition. If it is a number
- * then process the code directly - if not then parse it
- * and create the code
- */
- private void processAccelerator(IAction action, String acceleratorText) {
-
- if (acceleratorText.length() == 0)
- return;
-
- //Is it a numeric definition?
- if (Character.isDigit(acceleratorText.charAt(0))) {
- try {
- action.setAccelerator(Integer.valueOf(acceleratorText).intValue());
- }
- catch (NumberFormatException exception) {
- Logger.log(Logger.ERROR, "Invalid accelerator declaration: " + id); //$NON-NLS-1$
- }
- }
- else
- action.setAccelerator(convertAccelerator(acceleratorText));
- }
-
- /**
- * Parses the given accelerator text, and converts it to an accelerator key code.
- *
- * @param acceleratorText the accelerator text
- * @result the SWT key code, or 0 if there is no accelerator
- */
- private int convertAccelerator(String acceleratorText) {
- int accelerator = 0;
- StringTokenizer stok = new StringTokenizer(acceleratorText, "+"); //$NON-NLS-1$
-
- int keyCode = -1;
-
- boolean hasMoreTokens = stok.hasMoreTokens();
- while (hasMoreTokens) {
- String token = stok.nextToken();
- hasMoreTokens = stok.hasMoreTokens();
- // Every token except the last must be one of the modifiers
- // Ctrl, Shift, or Alt.
- if (hasMoreTokens) {
- int modifier = Action.findModifier(token);
- if (modifier != 0) {
- accelerator |= modifier;
- }
- else { //Leave if there are none
- return 0;
- }
- }
- else {
- keyCode = Action.findKeyCode(token);
- }
- }
- if (keyCode != -1) {
- accelerator |= keyCode;
- }
- return accelerator;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/BreakpointProviderBuilder.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/BreakpointProviderBuilder.java
deleted file mode 100644
index 2a84bc3938..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/BreakpointProviderBuilder.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.extension;
-
-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 java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.IBreakpointProvider;
-import org.eclipse.wst.sse.ui.extensions.breakpoint.SourceEditingTextTools;
-
-
-/**
- * Reads breakpoint extension registory and returns breakpoint provider
- * instances
- */
-public class BreakpointProviderBuilder extends RegistryReader {
-
- private static final String ATT_CLASS = "class"; //$NON-NLS-1$
- //private static final String ATT_ID = "id"; //$NON-NLS-1$
- private static final String ATT_CONTENT_TYPES = "contentTypes"; //$NON-NLS-1$
- private static final String ATT_EXTENSIONS = "extensions"; //$NON-NLS-1$
- private static BreakpointProviderBuilder instance;
- private static final String PL_BREAKPOINT = "breakpoint"; //$NON-NLS-1$
-
- private static final String PLUGIN_ID = "org.eclipse.wst.sse.ui.extensions"; //$NON-NLS-1$
-
- private static final String TAG_BREAKPOINT_CONTRIBUTION = "breakpointContribution"; //$NON-NLS-1$
- private static final String TAG_PROVIDER = "provider"; //$NON-NLS-1$
-
- /*
- * Creates an executable extension. @param element the config element
- * defining the extension @param classAttribute the name of the attribute
- * carrying the class @return the extension object @throws CoreException
- */
- static Object createExecutableExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
- return element.createExecutableExtension(classAttribute);
- }
-
- /**
- * Creates an extension. If the extension plugin has not been loaded a
- * busy cursor will be activated during the duration of the load.
- *
- * @param element
- * the config element defining the extension
- * @param classAttribute
- * the name of the attribute carrying the class
- * @return the extension object
- * @throws CoreException
- */
- public static Object createExtension(final IConfigurationElement element, final String classAttribute) {
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- final Object[] result = new Object[1];
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- try {
- result[0] = createExecutableExtension(element, classAttribute);
- }
- catch (Throwable e) {
- handleCreateExecutableException(result, e);
- }
- }
- else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- result[0] = createExecutableExtension(element, classAttribute);
- }
- catch (CoreException e) {
- handleCreateExecutableException(result, e);
- }
- }
- });
-
- }
- return result[0];
- }
-
- /**
- * returns singleton instance of BreakpointProviderBuilder
- *
- * @return BreakpointProviderBuilder
- */
- public synchronized static BreakpointProviderBuilder getInstance() {
- if (instance == null) {
- instance = new BreakpointProviderBuilder();
- }
- return instance;
- }
-
- /**
- * @param result
- * @param e
- */
- private static void handleCreateExecutableException(Object[] result, Throwable e) {
- Logger.logException(e);
- result[0] = null;
-
- }
-
- protected List cache;
- private Map map = new HashMap();
-
- protected String targetContributionTag;
-
- /*
- * Constructor
- */
- private BreakpointProviderBuilder() {
- super();
- }
-
- /*
- * Creates a breakpoint provider object to given element @param element
- * configuration element object @return IBreakpointProvider
- */
- protected IBreakpointProvider createBreakpointProvider(IConfigurationElement element) {
- Object obj = createExtension(element, ATT_CLASS);
- if (obj == null)
- return null;
- return (obj instanceof IBreakpointProvider) ? (IBreakpointProvider) obj : null;
- }
-
- /*
- * Creates an array of breakpoint providers matching the given key to the
- * value of the IConfigurationElement attribute "attrName" @return
- * IBreakpointProvider[]
- */
- protected IBreakpointProvider[] createBreakpointProviders(String attrName, String key) {
- if (cache == null)
- return new IBreakpointProvider[0];
-
- final int num = cache.size();
- if (num == 0)
- return new IBreakpointProvider[0];
-
- IBreakpointProvider[] bp = new IBreakpointProvider[num];
- int j = 0;
- for (int i = 0; i < num; i++) {
- Object obj = cache.get(i);
- if (!(obj instanceof IConfigurationElement))
- continue;
-
- IConfigurationElement element = (IConfigurationElement) obj;
- if (!TAG_PROVIDER.equals(element.getName()))
- continue;
-
- boolean doCreate = false;
-
- String attrValues = element.getAttribute(attrName);
-
- if (attrValues != null) {
- StringTokenizer tokenizer = new StringTokenizer(attrValues, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String type = tokenizer.nextToken();
- if (type.trim().equalsIgnoreCase(key.trim())) {
- doCreate = true;
- break;
- }
- }
- }
-
- if (doCreate) {
- IBreakpointProvider b = createBreakpointProvider(element);
- if (b != null) {
- bp[j] = b;
- j++;
- }
- }
- }
-
- IBreakpointProvider[] bp2 = new IBreakpointProvider[j];
- for (int i = 0; i < j; i++) {
- bp2[i] = bp[i];
- }
-
- return bp2;
- }
-
- /*
- * Returns a matching array of extension points matching this key. Doesn't
- * cause instantiation of providers. @return IBreakpointProvider[]
- */
- protected IConfigurationElement[] findElements(String key) {
- initCache();
-
- //Jens Lukowski: fixed bug: cache is null when no provider is found
- if (cache == null || cache.size() == 0)
- return new IConfigurationElement[0];
-
- int num = cache.size();
- List elements = new ArrayList(1);
- for (int i = 0; i < num; i++) {
- Object obj = cache.get(i);
- if (!(obj instanceof IConfigurationElement))
- continue;
-
- IConfigurationElement element = (IConfigurationElement) obj;
- if (!TAG_PROVIDER.equals(element.getName()))
- continue;
-
- boolean add = false;
- String types = element.getAttribute(ATT_CONTENT_TYPES);
- String exts = element.getAttribute(ATT_EXTENSIONS);
-
- if (types == null && exts == null) {
- add = true;
- }
-
- if (!add && types != null) {
- StringTokenizer tokenizer = new StringTokenizer(types, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String type = tokenizer.nextToken();
- if (type.trim().equals(key.trim())) {
- add = true;
- break;
- }
- }
- }
-
- if (!add && exts != null) {
- StringTokenizer tokenizer = new StringTokenizer(exts, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String ext = tokenizer.nextToken();
- if (ext.trim().equals(key.trim())) {
- add = true;
- break;
- }
- }
- }
-
- if (add) {
- elements.add(element);
- }
- }
- return (IConfigurationElement[]) elements.toArray(new IConfigurationElement[0]);
- }
-
- /**
- * Returns an array of breakpoint providers for a specified content type
- * handler
- *
- * @param handler
- * a content type handler
- * @param ext
- * file extension
- * @return IBreakpointProvider[]
- */
- public IBreakpointProvider[] getBreakpointProviders(IEditorPart editorpart, String contentType, String ext) {
- initCache();
-
- // Get breakpoint providers for this content type handler
- IBreakpointProvider[] ps1 = new IBreakpointProvider[0];
- if (contentType != null) {
- ps1 = (IBreakpointProvider[]) map.get(contentType);
- if (ps1 == null) {
- ps1 = createBreakpointProviders(ATT_CONTENT_TYPES, contentType);
- if (ps1 != null) {
- map.put(contentType, ps1);
- }
- }
- }
-
- // Get breakpoint providers for this extension
- IBreakpointProvider[] ps2 = new IBreakpointProvider[0];
- if (ext != null) {
- ps2 = (IBreakpointProvider[]) map.get(ext);
- if (ps2 == null) {
- ps2 = createBreakpointProviders(ATT_EXTENSIONS, ext);
- if (ps2 != null) {
- map.put(ext, ps2);
- }
- }
- }
-
- // create single hash set to remove duplication
- Set s = new HashSet();
- for (int i = 0; i < ps1.length; i++) {
- s.add(ps1[i]);
- }
- for (int i = 0; i < ps2.length; i++) {
- s.add(ps2[i]);
- }
-
- // create IBreakpointProvider[] to return
- IBreakpointProvider[] providers = new IBreakpointProvider[s.size()];
- Iterator itr = s.iterator();
- int i = 0;
- SourceEditingTextTools tools = null;
- if (editorpart != null && itr.hasNext())
- tools = (SourceEditingTextTools) editorpart.getAdapter(SourceEditingTextTools.class);
- while (itr.hasNext()) {
- providers[i] = (IBreakpointProvider) itr.next();
- providers[i].setSourceEditingTextTools(tools);
- i++;
- }
- return providers;
- }
-
- /**
- * Returns corresponding resource from given parameters
- *
- * @param input
- * @param handler
- * @param ext
- * @return IResource
- */
- public IResource getResource(IEditorInput input, String contentType, String ext) {
- IBreakpointProvider[] providers = getBreakpointProviders(null, contentType, ext);
- IResource res = null;
- for (int i = 0; i < providers.length; i++) {
- res = providers[i].getResource(input);
- if (res != null) {
- break;
- }
- }
- return res;
- }
-
- private void initCache() {
- if (cache == null) {
- readContributions(TAG_BREAKPOINT_CONTRIBUTION, PL_BREAKPOINT);
- }
- }
-
- /**
- * Returns an array of breakpoint providers for a specified content type
- * handler
- *
- * @param handler
- * a content type handler
- * @param ext
- * file extension
- * @return boolean
- */
- public boolean isAvailable(String contentType, String ext) {
- boolean available = findElements(ext).length > 0;
- if (!available && contentType != null)
- available = findElements(contentType).length > 0;
- return available;
- }
-
- /**
- * Reads the contributions from the registry for the provided workbench
- * part and the provided extension point ID.
- *
- * @param tag
- * @param extensionPoint
- */
- protected void readContributions(String tag, String extensionPoint) {
- cache = null;
- targetContributionTag = tag;
- IPluginRegistry registry = Platform.getPluginRegistry();
- readRegistry(registry, PLUGIN_ID, extensionPoint);
- }
-
- /*
- */
- protected boolean readElement(IConfigurationElement element) {
- String tag = element.getName();
- if (tag.equals(targetContributionTag)) {
- readElementChildren(element);
- return true;
- }
- else if (tag.equals(TAG_PROVIDER)) {
- if (cache == null)
- cache = new ArrayList();
- cache.add(element);
- return true; // just cache the element - don't go into it
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java
deleted file mode 100644
index 10a375d3ea..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/DropActionProxy.java
+++ /dev/null
@@ -1,165 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.extension;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extension.IExtendedSimpleEditor;
-import org.eclipse.wst.sse.ui.extensions.ISelfValidateEditAction;
-
-
-/**
- */
-public class DropActionProxy implements InvocationHandler {
- public static Object newInstance(Object obj) {
- Object instance = null;
- try {
- Set set = new HashSet();
- Class clazz = obj.getClass();
- while (clazz != null) {
- Class[] interfaces = clazz.getInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- set.add(interfaces[i]);
- }
- clazz = clazz.getSuperclass();
- }
- Class[] classes = new Class[set.size()];
- Iterator itr = set.iterator();
- int i = 0;
- while (itr.hasNext()) {
- classes[i] = (Class) itr.next();
- i++;
- }
- instance = Proxy.newProxyInstance(obj.getClass().getClassLoader(), classes, new DropActionProxy(obj));
- }
- catch (Error e) {
- Logger.logException("Exception while proxying a drop action", e); //$NON-NLS-1$
- instance = obj;
- }
- return instance;
- }
-
- private IExtendedSimpleEditor editor = null;
- private IStructuredModel fRecorder;
- private Object obj;
-
- private DropActionProxy(Object obj) {
- this.obj = obj;
- }
-
- private void beginRecording() {
- IDocument document = null;
- if (editor != null) {
- document = editor.getDocument();
- if (document != null)
- fRecorder = getModelManager().getExistingModelForEdit(document);
- // Prepare for Undo
- if (fRecorder != null) {
- StructuredTextUndoManager um = fRecorder.getUndoManager();
- if (um != null) {
- if (this.obj instanceof IAction)
- um.beginRecording(this, ((IAction) this.obj).getText(), ((IAction) this.obj).getDescription());
- else
- um.beginRecording(this);
- }
- }
- }
- }
-
- private void endRecording() {
- if (fRecorder != null) {
- StructuredTextUndoManager um = fRecorder.getUndoManager();
- if (um != null)
- um.endRecording(this);
- fRecorder.releaseFromEdit();
- fRecorder = null;
- }
- }
-
- /**
- *
- */
- private IModelManager getModelManager() {
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- /**
- * @see java.lang.reflect.InvocationHandler#invoke(Object, Method,
- * Object[])
- */
- public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
- Object result;
- String name = m.getName();
- try {
- if (name.equals("equals")) { //$NON-NLS-1$
- // Workaround for JDK's bug 4652876
- // "equals" always returns false even if both InvocationHandler
- // class
- // hold the same objects
- // See
- // http://developer.java.sun.com/developer/bugParade/bugs/4652876.html
- // This problem is in the IBM SDK 1.3.1
- // but I don't see the bug in Sun's JDK 1.4.1 (beta)
- Object arg = args[0];
- return (proxy.getClass() == arg.getClass() && equals(Proxy.getInvocationHandler(arg))) ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equals("run")) { //$NON-NLS-1$
- if (args[1] instanceof IExtendedSimpleEditor) {
- editor = (IExtendedSimpleEditor) args[1];
- }
- beginRecording();
- if ((editor != null) && !(obj instanceof ISelfValidateEditAction)) {
- IStatus status = editor.validateEdit(getDisplay().getActiveShell());
- if (!status.isOK()) {
- return null;
- }
- }
- }
- result = m.invoke(obj, args);
- }
- catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- catch (Exception e) {
- throw new RuntimeException(e.getMessage());
- }
- finally {
- if (name.equals("run")) { //$NON-NLS-1$
- endRecording();
- }
- }
- return result;
- }
-
- private Display getDisplay() {
- return PlatformUI.getWorkbench().getDisplay();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ExtendedEditorActionProxy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ExtendedEditorActionProxy.java
deleted file mode 100644
index 51c7b43bca..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ExtendedEditorActionProxy.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.extension;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.ui.extension.IExtendedSimpleEditor;
-import org.eclipse.wst.sse.ui.extensions.ISelfValidateEditAction;
-
-
-/**
- * Begins and ends UndoManager recording around run() and runWithEvent(...)
- */
-public class ExtendedEditorActionProxy implements InvocationHandler {
- public static Object newInstance(Object obj) {
- Set set = new HashSet();
- Class clazz = obj.getClass();
- while (clazz != null) {
- Class[] interfaces = clazz.getInterfaces();
- for (int i = 0; i < interfaces.length; i++) {
- set.add(interfaces[i]);
- }
- clazz = clazz.getSuperclass();
- }
- Class[] classes = new Class[set.size()];
- Iterator itr = set.iterator();
- int i = 0;
- while (itr.hasNext()) {
- classes[i] = (Class) itr.next();
- i++;
- }
- return Proxy.newProxyInstance(obj.getClass().getClassLoader(), classes, new ExtendedEditorActionProxy(obj));
- }
-
- private IExtendedSimpleEditor editor = null;
- private IStructuredModel fRecorder;
- private Object obj;
-
- private ExtendedEditorActionProxy(Object obj) {
- this.obj = obj;
- }
-
- private void beginRecording() {
- IDocument document = null;
- if (editor != null) {
- document = editor.getDocument();
- if (document != null)
- fRecorder = getModelManager().getExistingModelForEdit(document);
- // Prepare for Undo
- if (fRecorder != null) {
- StructuredTextUndoManager um = fRecorder.getUndoManager();
- if (um != null)
- um.beginRecording(this, ((IAction) this.obj).getText(), ((IAction) this.obj).getDescription());
- }
- }
- }
-
- private void endRecording() {
- if (fRecorder != null) {
- StructuredTextUndoManager um = fRecorder.getUndoManager();
- if (um != null)
- um.endRecording(this);
- fRecorder.releaseFromEdit();
- fRecorder = null;
- }
- }
-
- /**
- *
- */
- private IModelManager getModelManager() {
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- /**
- * @see java.lang.reflect.InvocationHandler#invoke(Object, Method,
- * Object[])
- */
- public Object invoke(Object proxy, Method m, Object[] args) throws Throwable {
- Object result;
- String name = m.getName();
- try {
- if (name.equals("equals")) { //$NON-NLS-1$
- // Workaround for JDK's bug 4652876
- // "equals" always returns false even if both InvocationHandler
- // class
- // hold the same objects
- // See
- // http://developer.java.sun.com/developer/bugParade/bugs/4652876.html
- // This problem is in the IBM SDK 1.3.1
- // but I don't see the bug in Sun's JDK 1.4.1 (beta)
- Object arg = args[0];
- return (proxy.getClass() == arg.getClass() && equals(Proxy.getInvocationHandler(arg))) ? Boolean.TRUE : Boolean.FALSE;
- }
- else if (name.equals("runWithEvent") || name.equals("run")) { //$NON-NLS-1$ //$NON-NLS-2$
- beginRecording();
- if ((editor != null) && !(this.obj instanceof ISelfValidateEditAction)) {
- IStatus status = editor.validateEdit(getDisplay().getActiveShell());
- if (!status.isOK()) {
- return null;
- }
- }
- }
- else if (name.equals("setActiveExtendedEditor")) { //$NON-NLS-1$
- if (args[0] instanceof IExtendedSimpleEditor) {
- editor = (IExtendedSimpleEditor) args[0];
- }
- }
- result = m.invoke(this.obj, args);
- }
- catch (InvocationTargetException e) {
- throw e.getTargetException();
- }
- catch (Exception e) {
- throw new RuntimeException(e.getMessage());
- }
- finally {
- if (name.equals("runWithEvent") || name.equals("run")) { //$NON-NLS-1$ //$NON-NLS-2$
- endRecording();
- }
- }
- return result;
- }
-
- private Display getDisplay() {
- return PlatformUI.getWorkbench().getDisplay();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ImageUtil.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ImageUtil.java
deleted file mode 100644
index 635b66e8f6..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/ImageUtil.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.extension;
-
-
-
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.jface.resource.ImageDescriptor;
-
-public class ImageUtil {
-
-
- /**
- * Convenience Method.
- * Returns an ImageDescriptor whose path, relative to the plugin containing
- * the <code>extension</code> is <code>subdirectoryAndFilename</code>.
- * If there isn't any value associated with the name then <code>null
- * </code> is returned.
- *
- * This method is convenience and only intended for use by the workbench because it
- * explicitly uses the workbench's registry for caching/retrieving images from other
- * extensions -- other plugins must user their own registry.
- * This convenience method is subject to removal.
- *
- * Note:
- * subdirectoryAndFilename must not have any leading "." or path separators / or \
- * ISV's should use icons/mysample.gif and not ./icons/mysample.gif
- *
- * Note:
- * This consults the plugin for extension and obtains its installation location.
- * all requested images are assumed to be in a directory below and relative to that
- * plugins installation directory.
- */
- public static ImageDescriptor getImageDescriptorFromExtension(IExtension extension, String subdirectoryAndFilename) {
- return getImageDescriptorFromPlugin(extension.getDeclaringPluginDescriptor(), subdirectoryAndFilename);
- }
-
- /**
- * Convenience Method.
- * Return an ImageDescriptor whose path relative to the plugin described
- * by <code>pluginDescriptor</code> is <code>subdirectoryAndFilename</code>.
- * Returns <code>null</code>if no image could be found.
- *
- * This method is convenience and only intended for use by the workbench because it
- * explicitly uses the workbench's registry for caching/retrieving images from other
- * extensions -- other plugins must user their own registry.
- * This convenience method is subject to removal.
- *
- * Note:
- * subdirectoryAndFilename must not have any leading "." or path separators / or \
- * ISV's should use icons/mysample.gif and not ./icons/mysample.gif
- *
- * Note:
- * This consults the plugin for extension and obtains its installation location.
- * all requested images are assumed to be in a directory below and relative to that
- * plugins installation directory.
- */
- public static ImageDescriptor getImageDescriptorFromPlugin(IPluginDescriptor pluginDescriptor, String subdirectoryAndFilename) {
-
- URL path = pluginDescriptor.getInstallURL();
- URL fullPathString = null;
- try {
- fullPathString = new URL(path, subdirectoryAndFilename);
- return ImageDescriptor.createFromURL(fullPathString);
- }
- catch (MalformedURLException e) {
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/RegistryReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/RegistryReader.java
deleted file mode 100644
index 6e13fdfa49..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/extension/RegistryReader.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.extension;
-
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.util.Sorter;
-
-
-/**
- * Template implementation of a registry reader that creates objects
- * representing registry contents. Typically, an extension
- * contains one element, but this reader handles multiple
- * elements per extension.
- *
- * To start reading the extensions from the registry for an
- * extension point, call the method <code>readRegistry</code>.
- *
- * To read children of an IConfigurationElement, call the
- * method <code>readElementChildren</code> from your implementation
- * of the method <code>readElement</code>, as it will not be
- * done by default.
- */
-public abstract class RegistryReader {
-
-
- protected static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
-
- /**
- * The constructor.
- */
- protected RegistryReader() {
- }
-
- /**
- * This method extracts description as a subelement of
- * the given element.
- * @return description string if defined, or empty string
- * if not.
- */
- protected String getDescription(IConfigurationElement config) {
- IConfigurationElement[] children = config.getChildren(TAG_DESCRIPTION);
- if (children.length >= 1) {
- return children[0].getValue();
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Logs the error in the workbench log using the provided
- * text and the information in the configuration element.
- */
- protected void logError(IConfigurationElement element, String text) {
- IExtension extension = element.getDeclaringExtension();
- IPluginDescriptor descriptor = extension.getDeclaringPluginDescriptor();
- StringBuffer buf = new StringBuffer();
- buf.append("Plugin " + descriptor.getUniqueIdentifier() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-2$//$NON-NLS-1$
- buf.append("\n" + text); //$NON-NLS-1$
- Logger.log(Logger.ERROR, buf.toString());
- }
-
- /**
- * Logs a very common registry error when a required attribute is missing.
- */
- protected void logMissingAttribute(IConfigurationElement element, String attributeName) {
- logError(element, "Required attribute '" + attributeName + "' not defined"); //$NON-NLS-2$//$NON-NLS-1$
- }
-
- /**
- * Logs a registry error when the configuration element is unknown.
- */
- protected void logUnknownElement(IConfigurationElement element) {
- logError(element, "Unknown extension tag found: " + element.getName()); //$NON-NLS-1$
- }
-
- /**
- * Apply a reproducable order to the list of extensions
- * provided, such that the order will not change as
- * extensions are added or removed.
- */
- protected IExtension[] orderExtensions(IExtension[] extensions) {
- // By default, the order is based on plugin id sorted
- // in ascending order. The order for a plugin providing
- // more than one extension for an extension point is
- // dependent in the order listed in the XML file.
- Sorter sorter = new Sorter() {
- public boolean compare(Object extension1, Object extension2) {
- String s1 = ((IExtension) extension1).getDeclaringPluginDescriptor().getUniqueIdentifier().toUpperCase();
- String s2 = ((IExtension) extension2).getDeclaringPluginDescriptor().getUniqueIdentifier().toUpperCase();
- //Return true if elementTwo is 'greater than' elementOne
- return s2.compareTo(s1) > 0;
- }
- };
-
- Object[] sorted = sorter.sort(extensions);
- IExtension[] sortedExtension = new IExtension[sorted.length];
- System.arraycopy(sorted, 0, sortedExtension, 0, sorted.length);
- return sortedExtension;
- }
-
- /**
- * Implement this method to read element's attributes.
- * If children should also be read, then implementor
- * is responsible for calling <code>readElementChildren</code>.
- * Implementor is also responsible for logging missing
- * attributes.
- *
- * @return true if element was recognized, false if not.
- */
- protected abstract boolean readElement(IConfigurationElement element);
-
- /**
- * Read the element's children. This is called by
- * the subclass' readElement method when it wants
- * to read the children of the element.
- */
- protected void readElementChildren(IConfigurationElement element) {
- readElements(element.getChildren());
- }
-
- /**
- * Read each element one at a time by calling the
- * subclass implementation of <code>readElement</code>.
- *
- * Logs an error if the element was not recognized.
- */
- protected void readElements(IConfigurationElement[] elements) {
- for (int i = 0; i < elements.length; i++) {
- if (!readElement(elements[i]))
- logUnknownElement(elements[i]);
- }
- }
-
- /**
- * Read one extension by looping through its
- * configuration elements.
- */
- protected void readExtension(IExtension extension) {
- readElements(extension.getConfigurationElements());
- }
-
- /**
- * Start the registry reading process using the
- * supplied plugin ID and extension point.
- */
- protected void readRegistry(IPluginRegistry registry, String pluginId, String extensionPoint) {
- IExtensionPoint point = registry.getExtensionPoint(pluginId, extensionPoint);
- if (point != null) {
- IExtension[] extensions = point.getExtensions();
- extensions = orderExtensions(extensions);
- for (int i = 0; i < extensions.length; i++)
- readExtension(extensions[i]);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/ExternalFileEditorInput.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/ExternalFileEditorInput.java
deleted file mode 100644
index 8dc057b0d5..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/ExternalFileEditorInput.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.openon;
-
-import java.io.File;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.editors.text.ILocationProvider;
-
-/**
- * EditorInput for external files.
- * Copied from org.eclipse.ui.internal.editors.text.JavaFileEditorInput
- */
-public class ExternalFileEditorInput implements IEditorInput, ILocationProvider {
-
- private File fFile;
-
- public ExternalFileEditorInput(File file) {
- super();
- fFile= file;
- }
- /*
- * @see org.eclipse.ui.IEditorInput#exists()
- */
- public boolean exists() {
- return fFile.exists();
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getName()
- */
- public String getName() {
- return fFile.getName();
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getPersistable()
- */
- public IPersistableElement getPersistable() {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IEditorInput#getToolTipText()
- */
- public String getToolTipText() {
- return fFile.getAbsolutePath();
- }
-
- /*
- * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
- */
- public Object getAdapter(Class adapter) {
- if (ILocationProvider.class.equals(adapter))
- return this;
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- /*
- * @see org.eclipse.ui.editors.text.ILocationProvider#getPath(java.lang.Object)
- */
- public IPath getPath(Object element) {
- if (element instanceof ExternalFileEditorInput) {
- ExternalFileEditorInput input= (ExternalFileEditorInput) element;
- return new Path(input.fFile.getAbsolutePath());
- }
- return null;
- }
-
- /*
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object o) {
- if (o == this)
- return true;
-
- if (o instanceof ExternalFileEditorInput) {
- ExternalFileEditorInput input = (ExternalFileEditorInput) o;
- return fFile.equals(input.fFile);
- }
-
- return false;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fFile.hashCode();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenFileHyperlinkTracker.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenFileHyperlinkTracker.java
deleted file mode 100644
index 690c5f062b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenFileHyperlinkTracker.java
+++ /dev/null
@@ -1,682 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.openon;
-
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceConverter;
-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.IRegion;
-import org.eclipse.jface.text.ITextInputListener;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITextViewerExtension5;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.FocusListener;
-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.MouseMoveListener;
-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.GC;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extensions.openon.IOpenOn;
-import org.eclipse.wst.sse.ui.openon.OpenOnProvider;
-import org.eclipse.wst.sse.ui.util.EditorUtility;
-
-
-/*
- * Link mode.
- */
-public class OpenFileHyperlinkTracker implements KeyListener, MouseListener, MouseMoveListener, FocusListener, PaintListener, IPropertyChangeListener, IDocumentListener, ITextInputListener {
-
- /** The session is active. */
- private boolean fActive;
-
- /** The currently active style range. */
- private IRegion fActiveRegion;
- /** The currently active style range as position. */
- private Position fRememberedPosition;
- /** The hand cursor. */
- private Cursor fCursor;
-
- /** The link color. */
- private Color fColor;
- /** The key modifier mask. */
- private int fKeyModifierMask;
-
- /** The text viewer this hyperlink tracker is associated with */
- private ITextViewer fTextViewer;
- /** The preference store */
- private IPreferenceStore fPreferenceStore;
- /** Preference key for hyperlink underline color */
- private String fLinkColorKey;
- /** Preference key for browser-like links to be enabled */
- private String fBrowserLikeLinksKeyModifierKey;
- /** @deprecated use fBrowserLinkLinksKeyModifierKey instead */
- private String fBrowserLikeLinksKeyModifierMaskKey;
-
- /**
- *
- */
- public OpenFileHyperlinkTracker(ITextViewer textViewer) {
- fTextViewer = textViewer;
- }
-
- public void deactivate() {
- deactivate(false);
- }
-
- public void deactivate(boolean redrawAll) {
- if (!fActive)
- return;
-
- repairRepresentation(redrawAll);
- fActive = false;
- }
-
- public void install(IPreferenceStore store) {
- fPreferenceStore = store;
- ITextViewer textViewer = getTextViewer();
- if (textViewer == null)
- return;
-
- StyledText text = textViewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
- updateColor(textViewer);
-
- textViewer.addTextInputListener(this);
-
- IDocument document = textViewer.getDocument();
- if (document != null)
- document.addDocumentListener(this);
-
- text.addKeyListener(this);
- text.addMouseListener(this);
- text.addMouseMoveListener(this);
- text.addFocusListener(this);
- text.addPaintListener(this);
-
- updateKeyModifierMask();
-
- fPreferenceStore.addPropertyChangeListener(this);
- }
-
- private void updateKeyModifierMask() {
- String modifiers = getNewPreferenceStore().getString(fBrowserLikeLinksKeyModifierKey);
- fKeyModifierMask = computeStateMask(modifiers);
- }
-
- private int computeStateMask(String modifiers) {
- if (modifiers == null)
- return -1;
-
- if (modifiers.length() == 0)
- return SWT.NONE;
-
- int stateMask = 0;
- StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
- while (modifierTokenizer.hasMoreTokens()) {
- int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
- if (modifier == 0 || (stateMask & modifier) == modifier)
- return -1;
- stateMask = stateMask | modifier;
- }
- return stateMask;
- }
-
- public void uninstall() {
- if (fCursor != null) {
- fCursor.dispose();
- fCursor = null;
- }
-
- ITextViewer textViewer = getTextViewer();
- if (textViewer == null)
- return;
-
- textViewer.removeTextInputListener(this);
-
- IDocument document = textViewer.getDocument();
- if (document != null)
- document.removeDocumentListener(this);
-
- IPreferenceStore preferenceStore = getNewPreferenceStore();
- if (preferenceStore != null)
- preferenceStore.removePropertyChangeListener(this);
-
- StyledText text = textViewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
- text.removeKeyListener(this);
- text.removeMouseListener(this);
- text.removeMouseMoveListener(this);
- text.removeFocusListener(this);
- text.removePaintListener(this);
- }
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(fLinkColorKey)) {
- ITextViewer viewer = getTextViewer();
- if (viewer != null)
- updateColor(viewer);
- }
- else if (event.getProperty().equals(fBrowserLikeLinksKeyModifierKey)) {
- updateKeyModifierMask();
- }
- }
-
- private void updateColor(ITextViewer viewer) {
- StyledText text = viewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
- Display display = text.getDisplay();
- fColor = createColor(getNewPreferenceStore(), fLinkColorKey, display);
- }
-
- /**
- * Creates a color from the information stored in the given preference
- * store. Returns <code>null</code> if there is no such information
- * available.
- */
- 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);
- }
-
- return EditorUtility.getColor(rgb);
- }
-
- private void repairRepresentation() {
- repairRepresentation(false);
- }
-
- private void repairRepresentation(boolean redrawAll) {
-
- if (fActiveRegion == null)
- return;
-
- int offset = fActiveRegion.getOffset();
- int length = fActiveRegion.getLength();
- fActiveRegion = null;
-
- ITextViewer viewer = getTextViewer();
- if (viewer != null) {
-
- resetCursor(viewer);
-
- // Remove underline
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
- offset = extension.modelOffset2WidgetOffset(offset);
- }
- else {
- offset -= viewer.getVisibleRegion().getOffset();
- }
- try {
- StyledText text = viewer.getTextWidget();
-
- // need clearBackground to be true for paint event to be fired
- text.redrawRange(offset, length, true);
- }
- catch (IllegalArgumentException x) {
- Logger.logException(x);
- }
- }
- }
-
- private void highlightRegion(ITextViewer viewer, IRegion region) {
-
- if (region.equals(fActiveRegion))
- return;
-
- repairRepresentation();
-
- StyledText text = viewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
-
- // Underline
- int offset = 0;
- int length = 0;
- if (viewer instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
- IRegion widgetRange = extension.modelRange2WidgetRange(new Region(region.getOffset(), region.getLength()));
- if (widgetRange == null)
- return;
-
- offset = widgetRange.getOffset();
- length = widgetRange.getLength();
-
- }
- else {
- offset = region.getOffset() - viewer.getVisibleRegion().getOffset();
- length = region.getLength();
- }
- // need clearBackground to be true for paint event to be fired
- text.redrawRange(offset, length, true);
-
- fActiveRegion = region;
- }
-
- private void activateCursor(ITextViewer viewer) {
- StyledText text = viewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
- Display display = text.getDisplay();
- if (fCursor == null)
- fCursor = new Cursor(display, SWT.CURSOR_HAND);
- text.setCursor(fCursor);
- }
-
- private void resetCursor(ITextViewer viewer) {
- StyledText text = viewer.getTextWidget();
- if (text != null && !text.isDisposed())
- text.setCursor(null);
-
- if (fCursor != null) {
- fCursor.dispose();
- fCursor = null;
- }
- }
-
- /*
- * @see org.eclipse.swt.events.KeyListener#keyPressed(org.eclipse.swt.events.KeyEvent)
- */
- public void keyPressed(KeyEvent event) {
-
- if (fActive) {
- deactivate();
- return;
- }
-
- if (event.keyCode != fKeyModifierMask) {
- deactivate();
- return;
- }
-
- fActive = true;
-
- // removed for #25871
- //
- // ISourceViewer viewer= getSourceViewer();
- // if (viewer == null)
- // return;
- //
- // IRegion region= getCurrentTextRegion(viewer);
- // if (region == null)
- // return;
- //
- // highlightRegion(viewer, region);
- // activateCursor(viewer);
- }
-
- /*
- * @see org.eclipse.swt.events.KeyListener#keyReleased(org.eclipse.swt.events.KeyEvent)
- */
- public void keyReleased(KeyEvent event) {
-
- if (!fActive)
- return;
-
- deactivate();
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDoubleClick(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseDown(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseDown(MouseEvent event) {
-
- if (!fActive)
- return;
-
- if (event.stateMask != fKeyModifierMask) {
- deactivate();
- return;
- }
-
- if (event.button != 1) {
- deactivate();
- return;
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseListener#mouseUp(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseUp(MouseEvent e) {
-
- if (!fActive)
- return;
-
- if (e.button != 1) {
- deactivate();
- return;
- }
-
- boolean wasActive = fCursor != null;
- IRegion previousRegion = fActiveRegion;
-
- deactivate();
-
- if (wasActive) {
- IOpenOn openOn = OpenOnProvider.getInstance().getOpenOn(getTextViewer().getDocument(), previousRegion.getOffset());
- if (openOn != null) {
- openOn.openOn(getTextViewer().getDocument(), previousRegion);
- }
- }
- }
-
- /*
- * @see org.eclipse.swt.events.MouseMoveListener#mouseMove(org.eclipse.swt.events.MouseEvent)
- */
- public void mouseMove(MouseEvent event) {
-
- if (event.widget instanceof Control && !((Control) event.widget).isFocusControl()) {
- deactivate();
- return;
- }
-
- if (!fActive) {
- if (event.stateMask != fKeyModifierMask)
- return;
- // modifier was already pressed
- fActive = true;
- }
-
- ITextViewer viewer = getTextViewer();
- if (viewer == null) {
- deactivate();
- return;
- }
-
- StyledText text = viewer.getTextWidget();
- if (text == null || text.isDisposed()) {
- deactivate();
- return;
- }
-
- if ((event.stateMask & SWT.BUTTON1) != 0 && text.getSelectionCount() != 0) {
- deactivate();
- return;
- }
-
- IRegion region = null;
- int offset = getCurrentTextOffset();
- IOpenOn openOn = OpenOnProvider.getInstance().getOpenOn(getTextViewer().getDocument(), offset);
- if (openOn != null) {
- region = openOn.getOpenOnRegion(getTextViewer().getDocument(), offset);
- }
- if (region == null || region.getLength() == 0) {
- repairRepresentation();
- return;
- }
-
- highlightRegion(viewer, region);
- activateCursor(viewer);
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusGained(org.eclipse.swt.events.FocusEvent)
- */
- public void focusGained(FocusEvent e) {
- }
-
- /*
- * @see org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt.events.FocusEvent)
- */
- public void focusLost(FocusEvent event) {
- deactivate();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentAboutToBeChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- if (fActive && fActiveRegion != null) {
- fRememberedPosition = new Position(fActiveRegion.getOffset(), fActiveRegion.getLength());
- try {
- event.getDocument().addPosition(fRememberedPosition);
- }
- catch (BadLocationException x) {
- fRememberedPosition = null;
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentListener#documentChanged(org.eclipse.jface.text.DocumentEvent)
- */
- public void documentChanged(DocumentEvent event) {
- if (fRememberedPosition != null) {
- if (!fRememberedPosition.isDeleted()) {
-
- event.getDocument().removePosition(fRememberedPosition);
- fActiveRegion = new Region(fRememberedPosition.getOffset(), fRememberedPosition.getLength());
- fRememberedPosition = null;
-
- ITextViewer viewer = getTextViewer();
- if (viewer != null) {
- StyledText widget = viewer.getTextWidget();
- if (widget != null && !widget.isDisposed()) {
- widget.getDisplay().asyncExec(new Runnable() {
- public void run() {
- deactivate();
- }
- });
- }
- }
-
- }
- else {
- fActiveRegion = null;
- fRememberedPosition = null;
- deactivate();
- }
- }
- }
-
- /*
- * @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)
- return;
- deactivate();
- oldInput.removeDocumentListener(this);
- }
-
- /*
- * @see org.eclipse.jface.text.ITextInputListener#inputDocumentChanged(org.eclipse.jface.text.IDocument,
- * org.eclipse.jface.text.IDocument)
- */
- public void inputDocumentChanged(IDocument oldInput, IDocument newInput) {
- if (newInput == null)
- return;
- newInput.addDocumentListener(this);
- }
-
- /*
- * @see PaintListener#paintControl(PaintEvent)
- */
- public void paintControl(PaintEvent event) {
- if (fActiveRegion == null)
- return;
-
- ITextViewer viewer = getTextViewer();
- if (viewer == null)
- return;
-
- StyledText text = viewer.getTextWidget();
- if (text == null || text.isDisposed())
- return;
-
-
- int offset = 0;
- int length = 0;
-
- if (viewer instanceof ITextViewerExtension5) {
-
- ITextViewerExtension5 extension = (ITextViewerExtension5) viewer;
- IRegion widgetRange = extension.modelRange2WidgetRange(new Region(offset, length));
- if (widgetRange == null)
- return;
-
- offset = widgetRange.getOffset();
- length = widgetRange.getLength();
-
- }
- else {
-
- IRegion region = viewer.getVisibleRegion();
- if (!includes(region, fActiveRegion))
- return;
-
- offset = fActiveRegion.getOffset() - region.getOffset();
- length = fActiveRegion.getLength();
- }
-
- // support for bidi
- Point minLocation = getMinimumLocation(text, offset, length);
- Point maxLocation = getMaximumLocation(text, offset, length);
-
- int x1 = minLocation.x;
- int x2 = minLocation.x + maxLocation.x - minLocation.x - 1;
- int y = minLocation.y + text.getLineHeight() - 1;
-
- GC gc = event.gc;
- if (fColor != null && !fColor.isDisposed())
- gc.setForeground(fColor);
- gc.drawLine(x1, y, x2, y);
- }
-
- private boolean includes(IRegion region, IRegion position) {
- return position.getOffset() >= region.getOffset() && position.getOffset() + position.getLength() <= region.getOffset() + region.getLength();
- }
-
- private Point getMinimumLocation(StyledText text, int offset, int length) {
- Point minLocation = new Point(Integer.MAX_VALUE, Integer.MAX_VALUE);
-
- for (int i = 0; i <= length; i++) {
- Point location = text.getLocationAtOffset(offset + i);
-
- if (location.x < minLocation.x)
- minLocation.x = location.x;
- if (location.y < minLocation.y)
- minLocation.y = location.y;
- }
-
- return minLocation;
- }
-
- private Point getMaximumLocation(StyledText text, int offset, int length) {
- Point maxLocation = new Point(Integer.MIN_VALUE, Integer.MIN_VALUE);
-
- for (int i = 0; i <= length; i++) {
- Point location = text.getLocationAtOffset(offset + i);
-
- if (location.x > maxLocation.x)
- maxLocation.x = location.x;
- if (location.y > maxLocation.y)
- maxLocation.y = location.y;
- }
-
- return maxLocation;
- }
-
- private ITextViewer getTextViewer() {
- return fTextViewer;
- }
-
- private IPreferenceStore getNewPreferenceStore() {
- return fPreferenceStore;
- }
-
- /**
- * @deprecated browserLikeLinksKeyModiferMaskKey is deprecated and not needed. use 2-arg setHyperlinkPreferenceKeys instead
- */
- public void setHyperlinkPreferenceKeys(String linkColorKey, String browserLinkLinksKeyModifierKey, String browserLikeLinksKeyModiferMaskKey) {
- fLinkColorKey = linkColorKey;
- fBrowserLikeLinksKeyModifierKey = browserLinkLinksKeyModifierKey;
- fBrowserLikeLinksKeyModifierMaskKey = browserLikeLinksKeyModiferMaskKey;
- }
-
- public void setHyperlinkPreferenceKeys(String linkColorKey, String browserLinkLinksKeyModifierKey) {
- fLinkColorKey = linkColorKey;
- fBrowserLikeLinksKeyModifierKey = browserLinkLinksKeyModifierKey;
- }
-
- private int getCurrentTextOffset() {
- try {
- StyledText text = getTextViewer().getTextWidget();
- if (text == null || text.isDisposed())
- return -1;
-
- Display display = text.getDisplay();
- Point absolutePosition = display.getCursorLocation();
- Point relativePosition = text.toControl(absolutePosition);
-
- int widgetOffset = text.getOffsetAtLocation(relativePosition);
- if (getTextViewer() instanceof ITextViewerExtension5) {
- ITextViewerExtension5 extension = (ITextViewerExtension5) getTextViewer();
- return extension.widgetOffset2ModelOffset(widgetOffset);
- }
- else {
- return widgetOffset + getTextViewer().getVisibleRegion().getOffset();
- }
-
- }
- catch (IllegalArgumentException e) {
- return -1;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnAction.java
deleted file mode 100644
index 1f64cfd81b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnAction.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.openon;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.extensions.openon.IOpenOn;
-import org.eclipse.wst.sse.ui.openon.OpenOnProvider;
-
-
-/**
- * Determines the appropriate IOpenFileAction to call based on current partition.
- */
-public class OpenOnAction extends TextEditorAction {
- public OpenOnAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- BusyIndicator.showWhile(getTextEditor().getEditorSite().getShell().getDisplay(), new Runnable() {
- public void run() {
- ITextEditor editor = getTextEditor();
-
- // figure out current offset
- int offset = -1;
- if (editor instanceof StructuredTextEditor) {
- offset = ((StructuredTextEditor) editor).getCaretPosition();
- } else {
- if (editor.getSelectionProvider() != null) {
- ISelection sel = editor.getSelectionProvider().getSelection();
- if (sel instanceof ITextSelection) {
- offset = ((ITextSelection)sel).getOffset();
- }
- }
- }
- IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
- IOpenOn openOn = OpenOnProvider.getInstance().getOpenOn(document, offset);
- if (openOn != null) {
- openOn.openOn(document, new Region(offset, 0));
- }
- }
- });
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnBuilder.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnBuilder.java
deleted file mode 100644
index 5c56d12788..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnBuilder.java
+++ /dev/null
@@ -1,255 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.openon;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.ui.internal.extension.RegistryReader;
-
-
-/**
- * Reads extensions for open on extension point, org.eclipse.wst.sse.ui.extensions.openon
- */
-public class OpenOnBuilder extends RegistryReader {
- // extension point ID
- public static final String PL_OPENON = "openon"; //$NON-NLS-1$
-
- public static final String PLUGIN_ID = "org.eclipse.wst.sse.ui.extensions"; //$NON-NLS-1$
-
- public static final String TAG_OPENON = "openon"; //$NON-NLS-1$
- public static final String TAG_CONTENT_TYPE_IDENTIFIER = "contenttypeidentifier"; //$NON-NLS-1$
- public static final String TAG_PARTITION_TYPE = "partitiontype"; //$NON-NLS-1$
-
- public static final String ATT_ID = "id"; //$NON-NLS-1$
- public static final String ATT_CLASS = "class"; //$NON-NLS-1$
-
- protected String targetContributionTag;
-
- private static OpenOnBuilder fInstance;
-
- private List fOpenOnDefs = null;
- private OpenOnDefinition fCurrentOpenOnDefinition = null;
- private String fCurrentContentType;
-
- /**
- * returns singleton instance of OpenOnBuilder
- *
- * @return OpenOnBuilder
- */
- public synchronized static OpenOnBuilder getInstance() {
- if (fInstance == null) {
- fInstance = new OpenOnBuilder();
- }
- return fInstance;
- }
-
- /**
- * Returns the name of the part ID attribute that is expected
- * in the target extension.
- *
- * @param element
- * @return String
- */
- protected String getId(IConfigurationElement element) {
- String value = element.getAttribute(ATT_ID);
- return value;
- }
-
- protected String getOpenOnClass(IConfigurationElement element) {
- String value = element.getAttribute(ATT_CLASS);
- return value;
- }
-
- /**
- * Processes element which should be a configuration element specifying an
- * open on object. Creates a new open on definition object and adds it to the
- * list of open on definition objects
- *
- * @param element openon configuration element
- */
- private void processOpenOnTag(IConfigurationElement element) {
- String theId = getId(element);
- String theClass = getOpenOnClass(element);
-
- if (theId != null && theClass != null) {
- // start building new OpenOnDefinition
- fCurrentOpenOnDefinition = new OpenOnDefinition(theId, theClass, element);
-
- // create a new list of open on definitions if it hasnt been created yet
- if (fOpenOnDefs == null) {
- fOpenOnDefs = new ArrayList();
- }
- fOpenOnDefs.add(fCurrentOpenOnDefinition);
- }
- else {
- fCurrentOpenOnDefinition = null;
- }
- }
-
- /**
- * Processes element which should be a configuration element specifying a content
- * type for the current open on tag. Assumes that there is a valid current open
- * on definition object.
- *
- * @param element contenttypeidentifier configuration element
- */
- private void processContentTypeTag(IConfigurationElement element) {
- // add to current openOnDefinition
- String theId = getId(element);
-
- if (theId != null) {
- fCurrentContentType = theId;
- fCurrentOpenOnDefinition.addContentTypeId(fCurrentContentType);
- }
- else {
- fCurrentContentType = null;
- }
- }
-
- /**
- * Processes element which should be a configuration element specifying a partition
- * type for the current open on/content type tag. Assumes that there is a valid
- * current open on/content type tag.
- *
- * @param element partitiontype configuration element
- */
- private void processPartitionTypeTag(IConfigurationElement element) {
- // add to current openOnDefinition/contentType
- String theId = getId(element);
-
- if (theId != null) {
- fCurrentOpenOnDefinition.addPartitionType(fCurrentContentType, theId);
- }
- }
-
- /* (non-Javadoc)
- */
- protected boolean readElement(IConfigurationElement element) {
- String tag = element.getName();
-
- if (tag.equals(targetContributionTag)) {
- processOpenOnTag(element);
-
- // make sure processing of current open on tag resulted in a current open on definition
- // before continue reading the children
- if (fCurrentOpenOnDefinition != null) {
- readElementChildren(element);
- }
- return true;
- }
- else if (tag.equals(TAG_CONTENT_TYPE_IDENTIFIER)) {
- processContentTypeTag(element);
-
- // make sure processing of current content type resulted in a valid content type
- // before reading the children
- if (fCurrentContentType != null) {
- readElementChildren(element);
- }
- return true;
- }
- else if (tag.equals(TAG_PARTITION_TYPE)) {
- processPartitionTypeTag(element);
- return true;
- }
-
- return false;
- }
-
- private void initCache() {
- if (fOpenOnDefs == null) {
- readContributions(TAG_OPENON, PL_OPENON);
- }
- }
-
- /**
- * Reads the contributions from the registry for the provided workbench
- * part and the provided extension point ID.
- * @param tag
- * @param extensionPoint
- */
- protected void readContributions(String tag, String extensionPoint) {
- targetContributionTag = tag;
- IPluginRegistry registry = Platform.getPluginRegistry();
- readRegistry(registry, PLUGIN_ID, extensionPoint);
- }
-
- /**
- * Returns all the open on definition objects
- * @return
- */
- public OpenOnDefinition[] getOpenOnDefinitions() {
- initCache();
- if( fOpenOnDefs == null )
- fOpenOnDefs = new ArrayList();
- return (OpenOnDefinition[]) fOpenOnDefs.toArray(new OpenOnDefinition[fOpenOnDefs.size()]);
- }
-
- /**
- * Returns all the open on definition objects valid for contentType/partitionType
- * @param contentType
- * @param partitionType
- * @return if either contentType or partitionType is null, null is returned
- */
- public OpenOnDefinition[] getOpenOnDefinitions(String contentType, String partitionType) {
- if (contentType == null || partitionType == null) {
- // should not be able to define an openon without a content type
- // but if it were possible then would need to search all openon definitions for
- // definitions with empty contentType list
- return null;
- }
-
- // entire list of openon definition objects
- OpenOnDefinition[] allDefs = getOpenOnDefinitions();
- // current list of open on definitions valid for contentType/partitionType
- List defs = new ArrayList();
- // default definitions that should be added to end of list of open on definitions
- List lastDefs = new ArrayList();
-
- for (int i = 0; i < allDefs.length; ++i) {
- // for each one check if it contains contentType
- List partitions = (List) allDefs[i].getContentTypes().get(contentType);
- if (partitions != null) {
- // this openon definition is valid for all partition types for this content type
- if (partitions.isEmpty()) {
- // this will be added to end of list because this is considered a default openon
- lastDefs.add(allDefs[i]);
- }
- else {
- // examine the partition types of this openon
- int j = 0; // current index in list of partitions
- boolean added = false; // openon has been added to list
- while (j < partitions.size() && !added) {
- // this openon definition applies to partitionType so add to list of valid openons
- if (partitionType.equals(partitions.get(j))) {
- defs.add(allDefs[i]);
- added = true;
- }
- else {
- // continue checking to see if this openon definition is valid for current partitionType
- ++j;
- }
- }
- }
- }
- }
- // append the default openon definitions
- defs.addAll(lastDefs);
-
- // return the list
- return (OpenOnDefinition[]) defs.toArray(new OpenOnDefinition[defs.size()]);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnDefinition.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnDefinition.java
deleted file mode 100644
index b0de98622c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/openon/OpenOnDefinition.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.openon;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extensions.openon.IOpenOn;
-
-
-/**
- * Open on definition object
- * @author amywu
- */
-public class OpenOnDefinition {
- private String fId = null;
- private String fClassName = null;
-
- // a hash map of content type Ids (String) that points to lists of parition types (List of Strings)
- // contentTypeId -> List(paritionType, paritionType, partitionType, ...)
- // contentTypeId2 -> List(partitionType, partitionType, ...)
- // ...
- private HashMap fContentTypes = null;
-
- private IConfigurationElement fConfigurationElement = null;
-
- /**
- * @param id
- * @param class1
- * @param configurationElement
- */
- public OpenOnDefinition(String id, String class1, IConfigurationElement configurationElement) {
- super();
- fId = id;
- fClassName = class1;
- fConfigurationElement = configurationElement;
- fContentTypes = new HashMap();
- }
-
- public void addContentTypeId(String contentTypeId) {
- if (!fContentTypes.containsKey(contentTypeId))
- fContentTypes.put(contentTypeId, new ArrayList());
- }
-
- public void addPartitionType(String contentTypeId, String partitionType) {
- if (!fContentTypes.containsKey(contentTypeId))
- fContentTypes.put(contentTypeId, new ArrayList());
-
- List partitionList = (List) fContentTypes.get(contentTypeId);
- partitionList.add(partitionType);
- }
-
- /**
- * @return Returns the fClass.
- */
- public String getClassName() {
- return fClassName;
- }
-
- /**
- * @return Returns the fConfigurationElement.
- */
- public IConfigurationElement getConfigurationElement() {
- return fConfigurationElement;
- }
-
- /**
- * @return Returns the fContentTypes.
- */
- public HashMap getContentTypes() {
- return fContentTypes;
- }
-
- /**
- * @return Returns the fId.
- */
- public String getId() {
- return fId;
- }
-
- /**
- * @return IOpenOn for this definition
- */
- public IOpenOn createOpenOn() {
- IOpenOn openOn = null;
-
- if (getClassName() != null) {
- openOn = (IOpenOn) createExtension(OpenOnBuilder.ATT_CLASS);
- }
-
- return openOn;
- }
-
- /**
- * Creates an extension. If the extension plugin has not
- * been loaded a busy cursor will be activated during the duration of
- * the load.
- * @param propertyName
- * @return Object
- */
- private Object createExtension(String propertyName) {
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- final IConfigurationElement element = getConfigurationElement();
- final String name = propertyName;
-
- final Object[] result = new Object[1];
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- try {
- return element.createExecutableExtension(name);
- }
- catch (CoreException e) {
- handleCreateExecutableException(result, e);
- }
- }
- else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- result[0] = element.createExecutableExtension(name);
- }
- catch (Throwable e) {
- handleCreateExecutableException(result, e);
- }
- }
- });
- }
- return result[0];
- }
-
- /**
- * @param result
- * @param e
- */
- private void handleCreateExecutableException(Object[] result, Throwable e) {
- Logger.logException("Unable to create open on: " + getId(), e); //$NON-NLS-1$
- e.printStackTrace();
- result[0] = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/OverlayPreferenceStore.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/OverlayPreferenceStore.java
deleted file mode 100644
index f817375959..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/OverlayPreferenceStore.java
+++ /dev/null
@@ -1,487 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferenceStore;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-
-/**
- * An overlaying preference store.
- * copied from JDT
- */
-public class OverlayPreferenceStore implements IPreferenceStore {
-
-
- public static final class TypeDescriptor {
- private TypeDescriptor() {
- }
- }
-
- public static final TypeDescriptor BOOLEAN= new TypeDescriptor();
- public static final TypeDescriptor DOUBLE= new TypeDescriptor();
- public static final TypeDescriptor FLOAT= new TypeDescriptor();
- public static final TypeDescriptor INT= new TypeDescriptor();
- public static final TypeDescriptor LONG= new TypeDescriptor();
- public static final TypeDescriptor STRING= new TypeDescriptor();
-
- public static class OverlayKey {
-
- TypeDescriptor fDescriptor;
- String fKey;
-
- public OverlayKey(TypeDescriptor descriptor, String key) {
- fDescriptor= descriptor;
- fKey= key;
- }
- }
-
- private class PropertyListener implements IPropertyChangeListener {
-
- /*
- * @see IPropertyChangeListener#propertyChange(PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- OverlayKey key= findOverlayKey(event.getProperty());
- if (key != null)
- propagateProperty(fParent, key, fStore);
- }
- }
-
-
- private IPreferenceStore fParent;
- private IPreferenceStore fStore;
- private OverlayKey[] fOverlayKeys;
-
- private PropertyListener fPropertyListener;
- private boolean fLoaded;
-
-
- public OverlayPreferenceStore(IPreferenceStore parent, OverlayKey[] overlayKeys) {
- fParent= parent;
- fOverlayKeys= overlayKeys;
- fStore= new PreferenceStore();
- }
-
- private OverlayKey findOverlayKey(String key) {
- for (int i= 0; i < fOverlayKeys.length; i++) {
- if (fOverlayKeys[i].fKey.equals(key))
- return fOverlayKeys[i];
- }
- return null;
- }
-
- private boolean covers(String key) {
- return (findOverlayKey(key) != null);
- }
-
- private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
-
- if (orgin.isDefault(key.fKey)) {
- if (!target.isDefault(key.fKey))
- target.setToDefault(key.fKey);
- return;
- }
-
- TypeDescriptor d= key.fDescriptor;
- if (BOOLEAN == d) {
-
- boolean originValue= orgin.getBoolean(key.fKey);
- boolean targetValue= target.getBoolean(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (DOUBLE == d) {
-
- double originValue= orgin.getDouble(key.fKey);
- double targetValue= target.getDouble(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (FLOAT == d) {
-
- float originValue= orgin.getFloat(key.fKey);
- float targetValue= target.getFloat(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (INT == d) {
-
- int originValue= orgin.getInt(key.fKey);
- int targetValue= target.getInt(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (LONG == d) {
-
- long originValue= orgin.getLong(key.fKey);
- long targetValue= target.getLong(key.fKey);
- if (targetValue != originValue)
- target.setValue(key.fKey, originValue);
-
- } else if (STRING == d) {
-
- String originValue= orgin.getString(key.fKey);
- String targetValue= target.getString(key.fKey);
- if (targetValue != null && originValue != null && !targetValue.equals(originValue))
- target.setValue(key.fKey, originValue);
-
- }
- }
-
- public void propagate() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- propagateProperty(fStore, fOverlayKeys[i], fParent);
- }
-
- private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) {
- TypeDescriptor d= key.fDescriptor;
- if (BOOLEAN == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, true);
- target.setValue(key.fKey, orgin.getBoolean(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey));
-
- } else if (DOUBLE == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1.0D);
- target.setValue(key.fKey, orgin.getDouble(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey));
-
- } else if (FLOAT == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1.0F);
- target.setValue(key.fKey, orgin.getFloat(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey));
-
- } else if (INT == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1);
- target.setValue(key.fKey, orgin.getInt(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey));
-
- } else if (LONG == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, 1L);
- target.setValue(key.fKey, orgin.getLong(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey));
-
- } else if (STRING == d) {
-
- if (forceInitialization)
- target.setValue(key.fKey, "1"); //$NON-NLS-1$
- target.setValue(key.fKey, orgin.getString(key.fKey));
- target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
-
- }
- }
-
- public void load() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- loadProperty(fParent, fOverlayKeys[i], fStore, true);
-
- fLoaded= true;
-
- }
-
- public void loadDefaults() {
- for (int i= 0; i < fOverlayKeys.length; i++)
- setToDefault(fOverlayKeys[i].fKey);
- }
-
- public void start() {
- if (fPropertyListener == null) {
- fPropertyListener= new PropertyListener();
- fParent.addPropertyChangeListener(fPropertyListener);
- }
- }
-
- public void stop() {
- if (fPropertyListener != null) {
- fParent.removePropertyChangeListener(fPropertyListener);
- fPropertyListener= null;
- }
- }
-
- /*
- * @see IPreferenceStore#addPropertyChangeListener(IPropertyChangeListener)
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- fStore.addPropertyChangeListener(listener);
- }
-
- /*
- * @see IPreferenceStore#removePropertyChangeListener(IPropertyChangeListener)
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- fStore.removePropertyChangeListener(listener);
- }
-
- /*
- * @see IPreferenceStore#firePropertyChangeEvent(String, Object, Object)
- */
- public void firePropertyChangeEvent(String name, Object oldValue, Object newValue) {
- fStore.firePropertyChangeEvent(name, oldValue, newValue);
- }
-
- /*
- * @see IPreferenceStore#contains(String)
- */
- public boolean contains(String name) {
- return fStore.contains(name);
- }
-
- /*
- * @see IPreferenceStore#getBoolean(String)
- */
- public boolean getBoolean(String name) {
- return fStore.getBoolean(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultBoolean(String)
- */
- public boolean getDefaultBoolean(String name) {
- return fStore.getDefaultBoolean(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultDouble(String)
- */
- public double getDefaultDouble(String name) {
- return fStore.getDefaultDouble(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultFloat(String)
- */
- public float getDefaultFloat(String name) {
- return fStore.getDefaultFloat(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultInt(String)
- */
- public int getDefaultInt(String name) {
- return fStore.getDefaultInt(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultLong(String)
- */
- public long getDefaultLong(String name) {
- return fStore.getDefaultLong(name);
- }
-
- /*
- * @see IPreferenceStore#getDefaultString(String)
- */
- public String getDefaultString(String name) {
- return fStore.getDefaultString(name);
- }
-
- /*
- * @see IPreferenceStore#getDouble(String)
- */
- public double getDouble(String name) {
- return fStore.getDouble(name);
- }
-
- /*
- * @see IPreferenceStore#getFloat(String)
- */
- public float getFloat(String name) {
- return fStore.getFloat(name);
- }
-
- /*
- * @see IPreferenceStore#getInt(String)
- */
- public int getInt(String name) {
- return fStore.getInt(name);
- }
-
- /*
- * @see IPreferenceStore#getLong(String)
- */
- public long getLong(String name) {
- return fStore.getLong(name);
- }
-
- /*
- * @see IPreferenceStore#getString(String)
- */
- public String getString(String name) {
- return fStore.getString(name);
- }
-
- /*
- * @see IPreferenceStore#isDefault(String)
- */
- public boolean isDefault(String name) {
- return fStore.isDefault(name);
- }
-
- /*
- * @see IPreferenceStore#needsSaving()
- */
- public boolean needsSaving() {
- return fStore.needsSaving();
- }
-
- /*
- * @see IPreferenceStore#putValue(String, String)
- */
- public void putValue(String name, String value) {
- if (covers(name))
- fStore.putValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, double)
- */
- public void setDefault(String name, double value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, float)
- */
- public void setDefault(String name, float value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, int)
- */
- public void setDefault(String name, int value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, long)
- */
- public void setDefault(String name, long value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, String)
- */
- public void setDefault(String name, String value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setDefault(String, boolean)
- */
- public void setDefault(String name, boolean value) {
- if (covers(name))
- fStore.setDefault(name, value);
- }
-
- /*
- * @see IPreferenceStore#setToDefault(String)
- */
- public void setToDefault(String name) {
- fStore.setToDefault(name);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, double)
- */
- public void setValue(String name, double value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, float)
- */
- public void setValue(String name, float value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, int)
- */
- public void setValue(String name, int value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, long)
- */
- public void setValue(String name, long value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, String)
- */
- public void setValue(String name, String value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /*
- * @see IPreferenceStore#setValue(String, boolean)
- */
- public void setValue(String name, boolean value) {
- if (covers(name))
- fStore.setValue(name, value);
- }
-
- /**
- * The keys to add to the list of overlay keys.
- * <p>
- * Note: This method must be called before {@link #load()} is called.
- * </p>
- *
- * @param keys
- * @since 3.0
- */
- public void addKeys(OverlayKey[] keys) {
- Assert.isTrue(!fLoaded);
- Assert.isNotNull(keys);
-
- int overlayKeysLength= fOverlayKeys.length;
- OverlayKey[] result= new OverlayKey[keys.length + overlayKeysLength];
-
- for (int i= 0, length= overlayKeysLength; i < length; i++)
- result[i]= fOverlayKeys[i];
-
- for (int i= 0, length= keys.length; i < length; i++)
- result[overlayKeysLength + i]= keys[i];
-
- fOverlayKeys= result;
-
- if (fLoaded)
- load();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/TabFolderLayout.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/TabFolderLayout.java
deleted file mode 100644
index 8d5b0294d8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/preferences/TabFolderLayout.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.preferences;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Layout;
-
-/**
- * Copied from JDT
- * @author pavery
- */
-public class TabFolderLayout extends Layout {
-
- protected Point computeSize(Composite composite, int wHint, int hHint, boolean flushCache) {
- if (wHint != SWT.DEFAULT && hHint != SWT.DEFAULT)
- return new Point(wHint, hHint);
-
- Control[] children = composite.getChildren();
- int count = children.length;
- int maxWidth = 0, maxHeight = 0;
- for (int i = 0; i < count; i++) {
- Control child = children[i];
- Point pt = child.computeSize(SWT.DEFAULT, SWT.DEFAULT, flushCache);
- maxWidth = Math.max(maxWidth, pt.x);
- maxHeight = Math.max(maxHeight, pt.y);
- }
-
- if (wHint != SWT.DEFAULT)
- maxWidth = wHint;
- if (hHint != SWT.DEFAULT)
- maxHeight = hHint;
-
- return new Point(maxWidth, maxHeight);
-
- }
-
- protected void layout(Composite composite, boolean flushCache) {
- Rectangle rect = composite.getClientArea();
-
- Control[] children = composite.getChildren();
- for (int i = 0; i < children.length; i++) {
- children[i].setBounds(rect);
- }
- }
-}
-
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java
deleted file mode 100644
index ef74fac787..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/AbstractStructuredTextReconcilingStrategy.java
+++ /dev/null
@@ -1,488 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcileResult;
-import org.eclipse.jface.text.reconciler.IReconcileStep;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension;
-import org.eclipse.jface.text.source.IAnnotationModel;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.IReleasable;
-import org.eclipse.wst.sse.ui.ITemporaryAnnotation;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.StructuredTextReconciler;
-import org.eclipse.wst.sse.ui.util.Assert;
-
-
-/**
- * A base ReconcilingStrategy. Subclasses must implement createReconcileSteps().
- *
- * @author pavery
- */
-public abstract class AbstractStructuredTextReconcilingStrategy implements IReconcilingStrategy, IReconcilingStrategyExtension, IReleasable, IStructuredReconcilingStrategy {
-
- protected IReconcileStep fFirstStep = null;
- protected IProgressMonitor fProgressMonitor = null;
- protected ITextEditor fTextEditor = null;
- protected IDocument fDocument = null;
-
- protected boolean fAlreadyRemovedAllThisRun = false;
-
- /**
- * Creates a new strategy. The editor parameter is for access to the annotation model.
- *
- * @param editor
- */
- public AbstractStructuredTextReconcilingStrategy(ITextEditor editor) {
- fTextEditor = editor;
- init();
- }
-
- /**
- * This is where you should create the steps for this strategy
- */
- abstract public void createReconcileSteps();
-
- public void init() {
- createReconcileSteps();
- }
-
- /**
- * Gets partition types from all steps in this strategy.
- *
- * @return parition types from all steps
- */
- public String[] getPartitionTypes() {
- if (fFirstStep instanceof IStructuredReconcileStep)
- return ((IStructuredReconcileStep) fFirstStep).getPartitionTypes();
- return new String[0];
- }
-
- /**
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
- */
- public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion) {
-
- // external files may be null
- if (isCanceled() || fFirstStep == null)
- return;
-
- reconcile(dirtyRegion, subRegion, false);
- }
-
- /**
- * Like IReconcileStep.reconcile(DirtyRegion dirtyRegion, IRegion subRegion) but also aware of the fact that the reconciler is running a processAll()
- * operation, and short circuits removal and reconcile calls accordingly.
- *
- * @param dirtyRegion
- * @param refreshAll
- * @param subRegion
- * @see IStructuredReconcilingStrategy#reconcile(DirtyRegion, IRegion, boolean)
- */
- public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion, boolean refreshAll) {
-
- // external files may be null
- if (isCanceled() || fFirstStep == null)
- return;
-
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(dirtyRegion.getOffset());
- if (sdRegion == null)
- return;
-
- TemporaryAnnotation[] annotationsToRemove = new TemporaryAnnotation[0];
- IReconcileResult[] annotationsToAdd = new IReconcileResult[0];
- IStructuredReconcileStep structuredStep = (IStructuredReconcileStep) fFirstStep;
- if (!refreshAll) {
- // regular reconcile
- annotationsToRemove = getAnnotationsToRemove(dirtyRegion);
- annotationsToAdd = structuredStep.reconcile(dirtyRegion, subRegion);
- fAlreadyRemovedAllThisRun = false;
- }
- else {
- // the entire document is being reconciled (strategies may be called multiple times)
- if (!fAlreadyRemovedAllThisRun) {
- annotationsToRemove = getAllAnnotationsToRemove();
- fAlreadyRemovedAllThisRun = true;
- }
- annotationsToAdd = structuredStep.reconcile(dirtyRegion, subRegion, true);
- }
- smartProcess(annotationsToRemove, annotationsToAdd);
- }
-
- /**
- * @return
- */
- protected boolean isCanceled() {
- if (Logger.isTracing(StructuredTextReconciler.TRACE_FILTER) && (fProgressMonitor != null && fProgressMonitor.isCanceled()))
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "** STRATEGY CANCELED **:" + this.getClass().getName()); //$NON-NLS-1$
- return fProgressMonitor != null && fProgressMonitor.isCanceled();
- }
-
- /**
- * pa_TODO make adding/removing smarter... Check if the annotation is already there, if it is, no need to remove or add again.
- * this will avoid a lot of flickering behavior...
- *
- * @param annotationsToRemove
- * @param annotationsToAdd
- */
-
- protected void smartProcess(TemporaryAnnotation[] annotationsToRemove, IReconcileResult[] annotationsToAdd) {
- // we should be doing a check like this during annotation creation (if possible)
- // might be too much work
-
- // TemporaryAnnotation tempRemoval = null;
- // TemporaryAnnotation tempAddition = null;
- // for(int i=0; i<annotationsToRemove.length; i++) {
- // tempRemoval = annotationsToRemove[i];
- // boolean isInAdditions = false;
- // for(int j=0; j<annotationsToAdd.length; j++) {
- // // do i need instance of check here?
- // tempAddition = (TemporaryAnnotation)annotationsToAdd[j];
- // if(tempRemoval.equals(tempAddition)) {
- // isInAdditions = true;
- // break;
- // }
- // }
- // //isInAdditions > means we should just ignore this annotation
- //
- // // add the rest of additions (that weren't in removals)
- // }
-
- removeAnnotations(annotationsToRemove);
- process(annotationsToAdd);
- }
-
- /**
- * Process the results from the reconcile steps in this strategy.
- *
- * @param results
- */
- private void process(final IReconcileResult[] results) {
- if (Logger.isTracing(StructuredTextReconciler.TRACE_FILTER))
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] > STARTING PROCESS METHOD with (" + results.length + ") results"); //$NON-NLS-1$ //$NON-NLS-2$
-
- if (results == null)
- return;
-
- for (int i = 0; i < results.length; i++) {
- if (isCanceled()) {
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] >** PROCESS (adding) WAS CANCELLED **"); //$NON-NLS-1$
- return;
- }
- addResultToAnnotationModel(results[i]);
- }
- // tracing --------------------------------------------------------------------
- if (Logger.isTracing(StructuredTextReconciler.TRACE_FILTER)) {
- StringBuffer traceString = new StringBuffer();
- for (int j = 0; j < results.length; j++)
- traceString.append("\n (+) :" + results[j] + ":\n"); //$NON-NLS-1$ //$NON-NLS-2$
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] > PROCESSING (" + results.length + ") results in AbstractStructuredTextReconcilingStrategy " + traceString); //$NON-NLS-1$ //$NON-NLS-2$
- }
- //------------------------------------------------------------------------------
- }
-
- /**
- * This is where we add results to the annotationModel, doing any special "extra" processing.
- */
- protected void addResultToAnnotationModel(IReconcileResult result) {
- if (!(result instanceof TemporaryAnnotation))
- return;
-
- TemporaryAnnotation tempAnnotation = (TemporaryAnnotation) result;
- getAnnotationModel().addAnnotation(tempAnnotation, tempAnnotation.getPosition());
- }
-
- private void removeAnnotations(TemporaryAnnotation[] annotationsToRemove) {
- IAnnotationModel annotationModel = getAnnotationModel();
- for (int i = 0; i < annotationsToRemove.length; i++) {
- if (isCanceled()) {
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] >** REMOVAL WAS CANCELLED **"); //$NON-NLS-1$
- return;
- }
- annotationModel.removeAnnotation(annotationsToRemove[i]);
- }
- // tracing --------------------------------------------------------------------
- if (Logger.isTracing(StructuredTextReconciler.TRACE_FILTER)) {
- StringBuffer traceString = new StringBuffer();
- for (int i = 0; i < annotationsToRemove.length; i++)
- traceString.append("\n (-) :" + annotationsToRemove[i] + ":\n"); //$NON-NLS-1$ //$NON-NLS-2$
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] > REMOVED (" + annotationsToRemove.length + ") annotations in AbstractStructuredTextReconcilingStrategy :" + traceString); //$NON-NLS-1$ //$NON-NLS-2$
- }
- //------------------------------------------------------------------------------
- }
-
- protected TemporaryAnnotation[] getAnnotationsToRemove(DirtyRegion dr) {
- IStructuredDocumentRegion[] sdRegions = getStructuredDocumentRegions(dr);
- List remove = new ArrayList();
- IAnnotationModel annotationModel = getAnnotationModel();
- Iterator i = annotationModel.getAnnotationIterator();
- while (i.hasNext()) {
- Object obj = i.next();
- if (!(obj instanceof TemporaryAnnotation))
- continue;
-
- TemporaryAnnotation annotation = (TemporaryAnnotation) obj;
- IReconcileAnnotationKey key = (IReconcileAnnotationKey) annotation.getKey();
-
- // first check if this annotation is still relevant for the current partition
- if (sdRegions.length > 0) {
- if (!partitionsMatch(key, annotation.getPosition().offset, sdRegions[0])) {
- remove.add(annotation);
- continue;
- }
- }
-
- // then if this strategy knows how to add/remove this partition type
- if (canHandlePartition(key.getPartitionType()) && containsStep(key.getStep())) {
- if (key.getScope() == IReconcileAnnotationKey.PARTIAL && overlaps(annotation.getPosition(), sdRegions)) {
- remove.add(annotation);
- }
- else if (key.getScope() == IReconcileAnnotationKey.TOTAL) {
- remove.add(annotation);
- }
- }
- }
- return (TemporaryAnnotation[]) remove.toArray(new TemporaryAnnotation[remove.size()]);
- }
-
- /**
- * Remove ALL temporary annotations that this strategy can handle.
- */
- protected TemporaryAnnotation[] getAllAnnotationsToRemove() {
- List removals = new ArrayList();
- IAnnotationModel annotationModel = getAnnotationModel();
- Iterator i = annotationModel.getAnnotationIterator();
- while (i.hasNext()) {
- Object obj = i.next();
- if (!(obj instanceof ITemporaryAnnotation))
- continue;
-
- ITemporaryAnnotation annotation = (ITemporaryAnnotation) obj;
- IReconcileAnnotationKey key = (IReconcileAnnotationKey) annotation.getKey();
- // then if this strategy knows how to add/remove this partition type
- if (canHandlePartition(key.getPartitionType()) && containsStep(key.getStep()))
- removals.add(annotation);
- }
- return (TemporaryAnnotation[]) removals.toArray(new TemporaryAnnotation[removals.size()]);
- }
-
- /**
- * Returns the appropriate (first) IStructuredDocumentRegion for the given dirtyRegion.
- *
- * @param dirtyRegion
- * @return the appropriate StructuredDocumentRegion for the given dirtyRegion.
- */
- private IStructuredDocumentRegion getStructuredDocumentRegion(int offset) {
- IStructuredDocumentRegion sdRegion = null;
- if (fDocument instanceof IStructuredDocument) {
- sdRegion = ((IStructuredDocument) fDocument).getRegionAtCharacterOffset(offset);
- }
- return sdRegion;
- }
-
- private IStructuredDocumentRegion[] getStructuredDocumentRegions(DirtyRegion dr) {
- int offset = dr.getOffset();
- int end = offset + dr.getLength();
- List regions = new ArrayList();
- IStructuredDocumentRegion r = getStructuredDocumentRegion(offset);
- while (r != null && r.getStartOffset() <= end) {
- regions.add(r);
- r = r.getNext();
- }
- return (IStructuredDocumentRegion[]) regions.toArray(new IStructuredDocumentRegion[regions.size()]);
- }
-
- /**
- * @param partition
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#reconcile(org.eclipse.jface.text.IRegion)
- */
- public void reconcile(IRegion partition) {
- // not used, we use - reconcile(DirtyRegion dirtyRegion, IRegion subRegion)
- }
-
- /**
- * Calls release() on all the steps in this strategy.
- */
- public void release() {
- // release steps (each step calls release on the next)
- if (fFirstStep != null && fFirstStep instanceof IReleasable)
- ((IReleasable) fFirstStep).release();
- fFirstStep = null;
- }
-
- /**
- * Set the document for this strategy.
- *
- * @param document
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
- */
- public void setDocument(IDocument document) {
-
- // remove all old annotations since it's a new document
- removeAnnotations(getAllAnnotationsToRemove());
-
- if (document == null)
- release();
- fDocument = document;
- if (fFirstStep != null)
- fFirstStep.setInputModel(new DocumentAdapter(document));
- }
-
- /**
- * @param step
- * @return
- */
- protected boolean containsStep(IReconcileStep step) {
- if (fFirstStep instanceof IStructuredReconcileStep)
- return ((IStructuredReconcileStep) fFirstStep).isSiblingStep(step);
- return false;
- }
-
- /**
- * Checks to make sure that the annotation key (partition type for which it was originally added) matches the current document partition at that offset. This can occur when the character you just typed caused the previous (or subsequent) partition type to change.
- *
- * @param key
- * @param sdRegion
- * @return the partition type for this annotation matches the current document partition type
- */
- private boolean partitionsMatch(IReconcileAnnotationKey key, int annotationPos, IStructuredDocumentRegion sdRegion) {
- String keyPartitionType = key.getPartitionType();
- IDocumentPartitioner p = getPartitioner(sdRegion);
- String partitionType = p.getPartition(annotationPos).getType();
- return keyPartitionType.equals(partitionType);
- }
-
- /**
- * pa_TODO - should be temporary until we figure out a way to send in partition with "reconcile()" call
- *
- * @param sdRegion
- */
- protected IDocumentPartitioner getPartitioner(IStructuredDocumentRegion sdRegion) {
- Assert.isNotNull(fDocument, "document was null when partitioning information was sought"); //$NON-NLS-1$
- IStructuredModel sModel = ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager().getExistingModelForRead(fDocument);
- IDocumentPartitioner partitioner = sModel.getStructuredDocument().getDocumentPartitioner();
- sModel.releaseFromRead();
- return partitioner;
- }
-
- /**
- * @param object
- * @return if this strategy is responisble for adding this type of key
- */
- protected boolean canHandlePartition(String partition) {
- String[] haystack = getPartitionTypes();
- for (int i = 0; i < haystack.length; i++) {
- if (haystack[i].equals(partition))
- return true;
- }
- return false;
- }
-
- /**
- * Checks if this position overlaps any of the StructuredDocument regions' correstponding IndexedRegion.
- *
- * @param pos
- * @param sdRegions
- * @return true if the position overlaps any of the regions, otherwise false.
- */
- protected boolean overlaps(Position pos, IStructuredDocumentRegion[] sdRegions) {
- int start = -1;
- int end = -1;
- for (int i = 0; i < sdRegions.length; i++) {
- IndexedRegion corresponding = getCorrespondingNode(sdRegions[i]);
- if (start == -1 || start > corresponding.getStartOffset())
- start = corresponding.getStartOffset();
- if (end == -1 || end < corresponding.getEndOffset())
- end = corresponding.getEndOffset();
- }
- //System.out.println("checking overlap: [node:" + start + ":" + end + " pos:" + pos.getOffset() + ":" + pos.getLength() + "> " + pos.overlapsWith(start, end - start));
- return pos.overlapsWith(start, end - start);
- }
-
- /**
- * Returns the corresponding node for the StructuredDocumentRegion.
- *
- * @param sdRegion
- * @return the corresponding node for sdRegion
- */
- protected IndexedRegion getCorrespondingNode(IStructuredDocumentRegion sdRegion) {
- IStructuredModel sModel = ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager().getExistingModelForRead(fDocument);
- IndexedRegion xmlNode = sModel.getIndexedRegion(sdRegion.getStart());
- sModel.releaseFromRead();
- return xmlNode;
- }
-
- protected IAnnotationModel getAnnotationModel() {
- return fTextEditor.getDocumentProvider().getAnnotationModel(fTextEditor.getEditorInput());
- }
-
- /**
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#initialReconcile()
- */
- public void initialReconcile() {
- // do nothing
- }
-
- /**
- * @param monitor
- * @see org.eclipse.jface.text.reconciler.IReconcilingStrategyExtension#setProgressMonitor(org.eclipse.core.runtime.IProgressMonitor)
- */
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor = monitor;
- if (fFirstStep != null)
- fFirstStep.setProgressMonitor(fProgressMonitor);
- }
-
- /**
- * The IFile that this strategy is operating on (the file input for the TextEditor)
- *
- * @return the IFile that this strategy is operating on
- */
- protected IFile getFile() {
- if (fTextEditor == null)
- return null;
- IEditorInput input = fTextEditor.getEditorInput();
- if (!(input instanceof IFileEditorInput))
- return null;
- return ((IFileEditorInput) input).getFile();
- }
-
- /**
- * Resets any specially set for an operation such as processAll() from the reconciler.
- */
- public void reset() {
- fAlreadyRemovedAllThisRun = false;
- if (fFirstStep instanceof IStructuredReconcileStep)
- ((IStructuredReconcileStep) fFirstStep).reset();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentAdapter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentAdapter.java
deleted file mode 100644
index 879bbf3965..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/DocumentAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.reconciler.IReconcilableModel;
-
-/**
- * Adapts an <code>IDocument</code> to a <code>IReconcilableModel</code>.
- *
- * @since 3.0
- */
-public class DocumentAdapter implements IReconcilableModel {
-
- private IDocument fDocument;
-
- /**
- * Creates a text model adapter for the given document.
- *
- * @param document
- */
- public DocumentAdapter(IDocument document) {
- fDocument= document;
- }
-
- /**
- * Returns this model's document.
- *
- * @return the model's input document
- */
- public IDocument getDocument() {
- return fDocument;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileAnnotationKey.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileAnnotationKey.java
deleted file mode 100644
index cfff3a89eb..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileAnnotationKey.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import org.eclipse.jface.text.reconciler.IReconcileStep;
-
-/**
- * Defines an annotation key that the <code>AbstractStructuredTextReconcilingStrategy</code>
- * knows how to remove appropriately.
- *
- * @author pavery
- */
-public interface IReconcileAnnotationKey {
- static final int TOTAL = 0;
- static final int PARTIAL = 1;
-
- String getPartitionType();
-
- IReconcileStep getStep();
-
- int getScope();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileStepAdapter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileStepAdapter.java
deleted file mode 100644
index 7d90ab19af..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IReconcileStepAdapter.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.reconciler.IReconcileResult;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.ui.IReleasable;
-
-
-/**
- * This interface is for reconcile steps that need to "work" off of
- * StructuredDocument events, as well as the ReconcilerThread.
- */
-public interface IReconcileStepAdapter extends INodeAdapter, IReleasable {
-
- /**
- * Marks a node for reconciling.
- * @param o
- */
- void markForReconciling(Object o);
-
- /**
- * Reconcile call seeded with an indexedNode.
- *
- * @param monitor
- * @param xmlNode
- * @return
- */
- IReconcileResult[] reconcile(IProgressMonitor monitor, IndexedRegion indexedNode);
-
- /**
- * Partition types for which this step can add annootations.
- *
- * @return partition types for which this step can add annootations.
- */
- String[] getPartitionTypes();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcileStep.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcileStep.java
deleted file mode 100644
index dc63461eed..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcileStep.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcileResult;
-import org.eclipse.jface.text.reconciler.IReconcileStep;
-
-/**
- * @author pavery
- *
- * Interface for a step in StructuredTextReconciler framework.
- */
-public interface IStructuredReconcileStep extends IReconcileStep {
- /**
- * Partitions for which this step can add/remove annotions
- * @return an array of the partitions for which this step can add/remove annotions
- */
- String[] getPartitionTypes();
-
- /**
- * Returns the scope for which this step adds annotations.
- * @return the scope for which this step adds annotations
- */
- int getScope();
-
- /**
- * Adds awareness that the Reconciler is reconciling the entire document this call.
- *
- * @param dirtyRegion
- * @param subRegion
- * @param refreshAll
- * @return
- */
- IReconcileResult[] reconcile(DirtyRegion dirtyRegion, IRegion subRegion, boolean refreshAll);
-
- /**
- * Used to reset the state of the Strategy. For example: any flags that need to be reset after
- * a long running operation like processAll().
- */
- void reset();
-
- /**
- * Tells you if the step is equal to this step or any of the sibling steps.
- *
- * @return
- */
- boolean isSiblingStep(IReconcileStep step);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcilingStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcilingStrategy.java
deleted file mode 100644
index 5c1acfc869..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/IStructuredReconcilingStrategy.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
-
-
-/**
- * Interface for structured reconciling strategies.
- *
- * @author pavery
- */
-public interface IStructuredReconcilingStrategy extends IReconcilingStrategy {
- /**
- * Adds awareness that the reconciler is processing the entire document via refreshAll flag.
- *
- * @param dirtyRegion
- * @param subRegion
- * @param refreshAll
- */
- public void reconcile(DirtyRegion dirtyRegion, IRegion subRegion, boolean refreshAll);
-
- /**
- * Used to reset the state of the Strategy. For example: any flags that need to be reset after
- * a long running operation like processAll().
- */
- public void reset();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/ReconcileAnnotationKey.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/ReconcileAnnotationKey.java
deleted file mode 100644
index 493ad3926c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/ReconcileAnnotationKey.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import org.eclipse.jface.text.reconciler.IReconcileStep;
-
-
-/**
- * Implementation of <code>IReconcileAnnotationKey</code>
- * note: clients should use the method StructuredReconcileStep#createKey(String partitionType, int scope)
- *
- * @author pavery
- */
-public class ReconcileAnnotationKey implements IReconcileAnnotationKey {
-
- private IReconcileStep fReconcileStep = null;
- private String fPartitionType = null;
- private int fScope;
-
- public ReconcileAnnotationKey(IReconcileStep step, String partitionType, int scope) {
- fReconcileStep = step;
- fPartitionType = partitionType;
- fScope = scope;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.xml.reconcile.IReconcileAnnotationKey#getId()
- */
- public String getPartitionType() {
- return fPartitionType;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.xml.reconcile.IReconcileAnnotationKey#getScope()
- */
- public int getScope() {
- return fScope;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.xml.reconcile.IReconcileAnnotationKey#getStep()
- */
- public IReconcileStep getStep() {
- return fReconcileStep;
- }
-
- public String toString() {
- return this.getClass() + "\r\nid: " + fPartitionType + "\nscope: " + fScope; //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java
deleted file mode 100644
index 08ad0b47fd..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/StructuredReconcileStep.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.reconciler.AbstractReconcileStep;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcilableModel;
-import org.eclipse.jface.text.reconciler.IReconcileResult;
-import org.eclipse.jface.text.reconciler.IReconcileStep;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner;
-import org.eclipse.wst.sse.ui.IReleasable;
-
-
-/**
- * ReconcileStep that knows about the annotation that it adds to the AnnotationModel.
- * It knows how to create an annotation key (for smart removal later)
- * It knows the partition types on which it can operate.
- * It knows the scope on which it operates (for short circuiting)
- * It knows if the Reconciler is reconciling the entire document.
- *
- * Clients must subclass this class.
- *
- * @author pavery
- */
-public abstract class StructuredReconcileStep extends AbstractReconcileStep implements IStructuredReconcileStep, IReleasable {
-
- protected final IReconcileResult[] EMPTY_RECONCILE_RESULT_SET = new IReconcileResult[0];
- private IStructuredReconcileStep fNextStructuredStep = null;
- private HashSet fPartitionTypes = null;
- private IModelManager fModelManager = null;
-
- // these limits are safetys for "runaway" validation cases
- // should be used to safeguard potentially dangerous loops or potentially long annotations
- // (since the painter seems to affect performance when painting long annotations)
- public static final int ELEMENT_ERROR_LIMIT = 100;
- public static final int ANNOTATION_LENGTH_LIMIT = 100;
-
- /**
- * Flag so that TOTAL scope steps are only called once during a batch reconcile.
- * reset() should be called after the batch reconcile.
- */
- private boolean fAlreadyRanGlobalReconcile = false;
- /**
- * It's possible for a partial step to get called on the same area twice (as w/ a full document reconcile)
- * this list keeps track of area already covered. Should be reset() after the "batch" of reconciling is finished.
- * */
- private List fPartialRangesCovered = null;
-
- public abstract int getScope();
-
- public StructuredReconcileStep() {
- super();
- fPartitionTypes = new HashSet();
- fPartialRangesCovered = new ArrayList();
- }
-
- public StructuredReconcileStep(IReconcileStep step) {
- super(step);
- if (step instanceof IStructuredReconcileStep)
- fNextStructuredStep = (IStructuredReconcileStep) step;
-
- fPartitionTypes = new HashSet();
- fPartialRangesCovered = new ArrayList();
- }
-
- /**
- * Like IReconcileStep.reconcile() except takes into consideration if the strategy may be called
- * multiple times in this same "run" (ie. a processAll() call from the StructuredTextReconciler)
- */
- public final IReconcileResult[] reconcile(DirtyRegion dirtyRegion, IRegion subRegion, boolean refreshAll) {
- IReconcileResult[] result = EMPTY_RECONCILE_RESULT_SET;
-
- if (!refreshAll) {
- result = reconcileModel(dirtyRegion, subRegion);
- fAlreadyRanGlobalReconcile = false;
- }
- else if (getScope() == IReconcileAnnotationKey.TOTAL && !fAlreadyRanGlobalReconcile) {
- result = reconcileModel(dirtyRegion, subRegion);
- fAlreadyRanGlobalReconcile = true;
- }
- else if (getScope() == IReconcileAnnotationKey.PARTIAL) {
- if (!isInPartiallyCheckedRanges(dirtyRegion)) {
- result = reconcileModel(dirtyRegion, subRegion);
- }
- }
-
- if (!isLastStep()) {
- ((IReconcileStep) fNextStructuredStep).setInputModel(getModel());
- IReconcileResult[] nextResult = fNextStructuredStep.reconcile(dirtyRegion, subRegion, refreshAll);
- return merge(result, convertToInputModel(nextResult));
- }
- return result;
- }
-
- /**
- * @param dirtyRegion
- * @return
- */
- private boolean isInPartiallyCheckedRanges(DirtyRegion dirtyRegion) {
- // pa_TODO reconciler performance, this can be bad
- Iterator it = fPartialRangesCovered.iterator();
- Position p = null;
- while (it.hasNext()) {
- p = (Position) it.next();
- if (p.overlapsWith(dirtyRegion.getOffset(), dirtyRegion.getLength()))
- return true;
- }
-
- // add new range that has been covered
- IStructuredModel sm = getModelManager().getExistingModelForRead(getDocument());
- IndexedRegion indexed = sm.getIndexedRegion(dirtyRegion.getOffset());
- sm.releaseFromRead();
- if (indexed != null)
- fPartialRangesCovered.add(new Position(indexed.getStartOffset(), indexed.getEndOffset() - indexed.getStartOffset()));
- return false;
- }
-
- /**
- * Removes duplicates.
- * @param results1
- * @param results2
- * @return
- */
- protected IReconcileResult[] merge(IReconcileResult[] results1, IReconcileResult[] results2) {
- if (results1 == null)
- return results2;
- if (results2 == null)
- return results1;
-
- List results = new ArrayList();
- results.addAll(Arrays.asList(results1));
- for (int i = 0; i < results2.length; i++) {
- // pa_TODO: could be bad for performance
- if (!results.contains(results2[i]))
- results.add(results2[i]);
- }
-
- return (IReconcileResult[]) results.toArray(new IReconcileResult[results.size()]);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.reconciler.AbstractReconcileStep#reconcileModel(org.eclipse.jface.text.reconciler.DirtyRegion, org.eclipse.jface.text.IRegion)
- */
- protected IReconcileResult[] reconcileModel(DirtyRegion dirtyRegion, IRegion subRegion) {
- return EMPTY_RECONCILE_RESULT_SET;
- }
-
- /*
- * @see org.eclipse.text.reconcilerpipe.AbstractReconcilePipeParticipant#getModel()
- */
- public IReconcilableModel getModel() {
- return getInputModel();
- }
-
- protected IDocument getDocument() {
- IDocument doc = null;
- IReconcilableModel rModel = getModel();
- if (rModel instanceof DocumentAdapter) {
- doc = ((DocumentAdapter) rModel).getDocument();
- }
- return doc;
- }
-
- protected IStructuredDocument getStructuredDocument() {
- IStructuredDocument sDoc = null;
- IDocument doc = getDocument();
- if (doc instanceof IStructuredDocument)
- sDoc = (IStructuredDocument) getDocument();
- return sDoc;
- }
-
- /**
- * Avoid excessive calls to Platform.getPlugin(ModelPlugin.ID)
- * @return sse model manager
- */
- protected IModelManager getModelManager() {
- if (fModelManager == null)
- fModelManager = ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager();
- return fModelManager;
- }
-
- protected IDocumentPartitioner getPartitioner() {
- return getDocument().getDocumentPartitioner();
- }
-
- public String getPartitionType(int offset) {
- ITypedRegion tr = getPartitioner().getPartition(offset);
- return (tr != null) ? tr.getType() : StructuredTextPartitioner.ST_UNKNOWN_PARTITION;
- }
-
- public IReconcileAnnotationKey createKey(IStructuredDocumentRegion sdRegion, int scope) {
- ITypedRegion tr = sdRegion.getParentDocument().getDocumentPartitioner().getPartition(sdRegion.getStartOffset());
- String partitionType = (tr != null) ? tr.getType() : StructuredTextPartitioner.ST_UNKNOWN_PARTITION;
- return createKey(partitionType, scope);
- }
-
- /**
- * Clients should use this method to create annotation keys as it registers the key for removal later.
- *
- * @param partitionType
- * @param scope
- * @return
- */
- public IReconcileAnnotationKey createKey(String partitionType, int scope) {
- fPartitionTypes.add(partitionType);
- return new ReconcileAnnotationKey(this, partitionType, scope);
- }
-
- public String[] getPartitionTypes() {
- // using hash set to automatically get rid of dupes
- HashSet tempResults = new HashSet();
- // add these partition types
- tempResults.addAll(fPartitionTypes);
- // add next step's partition types
- if (fNextStructuredStep != null) {
- String[] nextResults = fNextStructuredStep.getPartitionTypes();
- for (int i = 0; i < nextResults.length; i++)
- tempResults.add(nextResults[i]);
- }
- return (String[]) tempResults.toArray(new String[tempResults.size()]);
- }
-
- /**
- * Release resources used by the step here as needed.
- * Be sure to call super.release() when you override this method as to propagate the release through all steps.
- */
- public void release() {
- if (fNextStructuredStep != null && fNextStructuredStep instanceof IReleasable)
- ((IReleasable) fNextStructuredStep).release();
- fNextStructuredStep = null;
- fModelManager = null;
- }
-
- public void reset() {
- fAlreadyRanGlobalReconcile = false;
- fPartialRangesCovered.clear();
-
- if (!isLastStep())
- fNextStructuredStep.reset();
- }
-
- /**
- * If step passed in is found somewhere in the chain of steps.
- *
- * @return true if step passed in is found somewhere in the chain of steps, else false
- */
- public boolean isSiblingStep(IReconcileStep step) {
- if (step == null)
- return false;
- else if (step.equals(this))
- return true;
- else if (isLastStep())
- return false;
- else
- return fNextStructuredStep.isSiblingStep(step);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/TemporaryAnnotation.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/TemporaryAnnotation.java
deleted file mode 100644
index f743279d67..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/TemporaryAnnotation.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile;
-
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.reconciler.IReconcileResult;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.wst.sse.ui.ITemporaryAnnotation;
-
-
-/**
- * An implementation of ITemporaryAnnotation
- *
- * @ @author pavery
- */
-public class TemporaryAnnotation extends Annotation implements ITemporaryAnnotation, IReconcileResult {
-
- // remember to change these if it changes in the extension point
- // may need a different home for them in the future, but they're here for now
- public final static String ANNOT_ERROR = "org.eclipse.wst.sse.ui.temp.error"; //$NON-NLS-1$
- public final static String ANNOT_WARNING = "org.eclipse.wst.sse.ui.temp.warning"; //$NON-NLS-1$
- public final static String ANNOT_INFO = "org.eclipse.wst.sse.ui.temp.info"; //$NON-NLS-1$
-
- public final static String ANNOT_BOOKMARK = "org.eclipse.ui.workbench.texteditor.bookmark"; //$NON-NLS-1$
- public final static String ANNOT_TASK = "org.eclipse.ui.workbench.texteditor.task"; //$NON-NLS-1$
-
- // pa_TODO what should the ID be for this?
- public final static String ANNOT_SEARCH = Annotation.TYPE_UNKNOWN;
- public final static String ANNOT_UNKNOWN = Annotation.TYPE_UNKNOWN;
-
- private int fProblemID;
- private Object fAdditionalFixInfo = null;
-
- private Object fKey = null;
- private Position fPosition = null;
-
- public TemporaryAnnotation(Position p, String type, String message, IReconcileAnnotationKey key) {
- super();
- fPosition = p;
- setType(type);
- fKey = key;
- setText(message);
- }
-
- public TemporaryAnnotation(Position p, String type, String message, IReconcileAnnotationKey key, int problemId) {
- super();
- fPosition = p;
- fKey = key;
- setType(type);
- setText(message);
- fProblemID = problemId;
- }
-
- /* (non-Javadoc)
- */
- public String getDescription() {
- return getText();
- }
-
- public Object getKey() {
- return fKey;
- }
-
- public Position getPosition() {
- return fPosition;
- }
-
- public String toString() {
- return "" + fPosition.getOffset() + ':' + fPosition.getLength() + ": " + getText(); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * @deprecated use getText instead TODO remove in C5
- */
- public String getMessage() {
- return getText();
- }
-
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.source.Annotation#isPersistent()
- */
- public boolean isPersistent() {
- return false;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- public boolean equals(Object obj) {
- // this check doesn't take into consideration that annotation positions that change from a text edit before it
- // we should be checking if the annotation is still on the same line, and the distance from the start of the line is the same
- if(obj instanceof TemporaryAnnotation) {
- TemporaryAnnotation ta = (TemporaryAnnotation) obj;
- return ta.getText().equals(this.getText()) && ta.getPosition().equals(this.getPosition());
- }
- return super.equals(obj);
- }
-
- /**
- * @return Returns the problemID.
- */
- public int getProblemID() {
- return fProblemID;
- }
-
- /**
- * Sets additional information useful to fixing this problem.
- * @param an Object that contains additional info on how to fix this problem
- */
- public void setAdditionalFixInfo(Object info) {
- fAdditionalFixInfo = info;
- }
-
- /**
- * Additional info required to fix this problem.
- * @return an Object that contains additional info on how to fix this problem, or null if there is none
- */
- public Object getAdditionalFixInfo() {
- return fAdditionalFixInfo;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalHelper.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalHelper.java
deleted file mode 100644
index 07fdbd92bf..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalHelper.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile.validator;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.validation.IHelper;
-
-
-public class IncrementalHelper implements IHelper {
- private IProject fProject;
-
- public IncrementalHelper(IDocument sourceDocument, IProject project) {
- super();
- fProject = project;
- }
-
- public String getTargetObjectName(Object object) {
- if (object == null)
- return null;
- if (object instanceof IResource)
- return getPortableName((IResource) object);
- return object.toString();
- }
-
- public IFile getFileFromFilename(String filename) {
- IResource res = getProject().findMember(filename, true); // true means include phantom resources
- if (res instanceof IFile) {
- return (IFile) res;
- }
- return null;
- }
-
- public IProject getProject() {
- return fProject;
- }
-
- public String getPortableName(IResource resource) {
- return resource.getProjectRelativePath().toString();
- }
-
- public Object loadModel(String symbolicName) {
- return null;
- }
-
- public Object loadModel(String symbolicName, Object[] parms) {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalReporter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalReporter.java
deleted file mode 100644
index 5a531f1f6e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/IncrementalReporter.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile.validator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.validation.IMessage;
-import org.eclipse.wst.validation.IMessageAccess;
-import org.eclipse.wst.validation.IReporter;
-import org.eclipse.wst.validation.IValidator;
-
-/**
- * Right now we'll only use one reporter per validator.
- */
-public class IncrementalReporter implements IReporter {
- private HashMap messages = new HashMap();
- private IProgressMonitor fProgressMonitor;
-
- public IncrementalReporter(IProgressMonitor progressMonitor) {
- super();
- fProgressMonitor = progressMonitor;
- }
-
- public void addMessage(IValidator validator, IMessage message) {
- Object existingValue = messages.get(validator);
- if (existingValue != null) {
- ((List) existingValue).add(message);
- }
- else {
- List newValue = new ArrayList(1);
- newValue.add(message);
- messages.put(validator, newValue);
- }
- }
-
- public void displaySubtask(IValidator validator, IMessage message) {
- if ((message == null) || (message.equals(""))) { //$NON-NLS-1$
- return;
- }
- if (fProgressMonitor != null) {
- fProgressMonitor.subTask(message.getText(validator.getClass().getClassLoader()));
- }
- }
-
- public IMessageAccess getMessageAccess() {
- // we may want to use this eventually
- return null;
- }
-
- public HashMap getMessages() {
- return messages;
- }
-
- public boolean isCancelled() {
- if (fProgressMonitor == null)
- return false;
- return fProgressMonitor.isCanceled();
- }
-
- public void removeAllMessages(IValidator validator) {
- messages.clear();
- }
-
- public void removeAllMessages(IValidator validator, Object object) {
- removeAllMessages(validator);
- }
-
- // group names are unsupported
- public void removeMessageSubset(IValidator validator, Object obj, String groupName) {
- removeAllMessages(validator);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java
deleted file mode 100644
index fae0a2bcfc..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ReconcileStepForValidator.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile.validator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcileResult;
-import org.eclipse.jface.text.reconciler.IReconcileStep;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.util.URIResolver;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.StructuredTextReconciler;
-import org.eclipse.wst.sse.ui.internal.reconcile.IReconcileAnnotationKey;
-import org.eclipse.wst.sse.ui.internal.reconcile.StructuredReconcileStep;
-import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-import org.eclipse.wst.validation.FileDelta;
-import org.eclipse.wst.validation.IFileDelta;
-import org.eclipse.wst.validation.IHelper;
-import org.eclipse.wst.validation.IMessage;
-import org.eclipse.wst.validation.IValidator;
-import org.eclipse.wst.validation.SeverityEnum;
-
-
-/**
- * A reconcile step for an IValidator for reconcile.
- * Used the reconcile framework to create TemporaryAnnotations from the validator messages.
- *
- * @author pavery
- */
-public class ReconcileStepForValidator extends StructuredReconcileStep {
-
- private final IReconcileResult[] EMPTY_RECONCILE_RESULT_SET = new IReconcileResult[0];
- private IValidator validator = null;
- private int scope = -1;
- private IHelper helper = null;
- private IncrementalReporter reporter = null;
-
-
- public ReconcileStepForValidator(IValidator v, int scope) {
- super();
- this.validator = v;
- this.scope = scope;
- }
-
- public ReconcileStepForValidator(IValidator v, IReconcileStep step, int scope) {
- super(step);
- this.validator = v;
- this.scope = scope;
- }
-
- protected IReconcileResult[] reconcileModel(DirtyRegion dirtyRegion, IRegion subRegion) {
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] > reconciling model in VALIDATOR step w/ dirty region: " + dirtyRegion.getText()); //$NON-NLS-1$
-
- // pa_TODO need to use dirty region if Validators can ever handle partial file validation
- IReconcileResult[] results = this.EMPTY_RECONCILE_RESULT_SET;
- if (dirtyRegion != null) {
- try {
- results = validate();
- }
- catch (Exception ex) {
- Logger.logException("EXEPTION IN RECONCILE STEP FOR VALIDATOR", ex); //$NON-NLS-1$
- }
- }
-
- Logger.trace(StructuredTextReconciler.TRACE_FILTER, "[trace reconciler] > VALIDATOR step done"); //$NON-NLS-1$
-
- return results;
- }
-
- public void initialReconcile() {
- // do nothing
- }
-
- protected IReconcileResult[] validate() {
- IReconcileResult[] results = this.EMPTY_RECONCILE_RESULT_SET;
-
- IProject project = getProject();
- IFile file = getFile(project);
-
- if(file != null) {
- try {
- IHelper helper = getHelper(project);
- IncrementalReporter reporter = getReporter();
-
- IFileDelta fullDelta = new FileDelta(file.getFullPath().toString(), IFileDelta.CHANGED);
- this.validator.validate(helper, reporter, new IFileDelta[]{fullDelta});
-
- results = createAnnotations(reporter.getMessages());
- reporter.getMessages().clear();
-
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- return results;
- }
-
- private IFile getFile(IProject project) {
-
- IFile file = null;
- if(project != null) {
-
- IDocument doc = getDocument();
- // document may be null inbetween model/document swap
- if(doc != null) {
- IStructuredModel model = null;
- try {
- model = getModelManager().getExistingModelForRead(doc);
- file = project.getWorkspace().getRoot().getFileForLocation(new Path(model.getBaseLocation()));
- }
- finally {
- if(model != null)
- model.releaseFromRead();
- }
- }
- }
- return file;
- }
-
- private IProject getProject() {
-
- URIResolver resolver = null;
- IDocument doc = getDocument();
-
- if(doc != null) {
- IStructuredModel model = getModelManager().getExistingModelForRead(doc);
- try {
- if(model != null)
- resolver = model.getResolver();
- }
- finally {
- if(model != null)
- model.releaseFromRead();
- }
- }
- return (resolver != null) ? resolver.getProject() : null;
- }
-
- /**
- * Converts a map of IValidatorForReconcile to List to annotations based on those messages
- * @param messages
- * @return
- */
- protected IReconcileResult[] createAnnotations(HashMap messages) {
- List annotations = new ArrayList();
- Iterator keys = messages.keySet().iterator();
-
- while (keys.hasNext() && !isCanceled()) {
- IValidator validator = (IValidator) keys.next();
- List messageList = (List) messages.get(validator);
- for (int i = 0; i < messageList.size(); i++) {
- IMessage validationMessage = (IMessage) messageList.get(i);
- int offset = validationMessage.getOffset();
-
- if (offset < 0)
- continue;
-
- String messageText = null;
- try {
- messageText = validationMessage.getText(validator.getClass().getClassLoader());
- }
- catch (Throwable t) {
- Logger.logException("exception reporting message from validator", t); //$NON-NLS-1$
- continue;
- }
- String type = TemporaryAnnotation.ANNOT_INFO;
- switch (validationMessage.getSeverity()) {
- case SeverityEnum.HIGH_SEVERITY :
- type = TemporaryAnnotation.ANNOT_ERROR;
- break;
- case SeverityEnum.NORMAL_SEVERITY :
- type = TemporaryAnnotation.ANNOT_WARNING;
- break;
- case SeverityEnum.LOW_SEVERITY :
- type = TemporaryAnnotation.ANNOT_WARNING;
- break;
- case SeverityEnum.ERROR_AND_WARNING :
- type = TemporaryAnnotation.ANNOT_WARNING;
- break;
- }
- Position p = new Position(offset, validationMessage.getLength());
- IReconcileAnnotationKey key = createKey(getPartitionType(offset), IReconcileAnnotationKey.TOTAL);
- annotations.add(new TemporaryAnnotation(p, type, messageText, key));
- }
- }
- return (IReconcileResult[]) annotations.toArray(new IReconcileResult[annotations.size()]);
- }
-
- public int getScope() {
- return this.scope;
- }
-
- private IHelper getHelper(IProject project) {
- if (this.helper == null)
- this.helper = new IncrementalHelper(getStructuredDocument(), project);
- return this.helper;
- }
-
- private IncrementalReporter getReporter() {
- if (this.reporter == null)
- this.reporter = new IncrementalReporter(getProgressMonitor());
- return this.reporter;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer debugString = new StringBuffer("ValidatorStep: "); //$NON-NLS-1$
- if(this.validator != null)
- debugString.append(this.validator.getClass().toString());
- return debugString.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorBuilder.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorBuilder.java
deleted file mode 100644
index 5455cf6703..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorBuilder.java
+++ /dev/null
@@ -1,143 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile.validator;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.extension.RegistryReader;
-
-
-/**
- * Based off of TransferBuilder.
- * Reads the extension point for org.eclipse.wst.sse.ui.extensions.reconcileValidator
- *
- * @author pavery
- */
-public class ValidatorBuilder extends RegistryReader {
-
- public static final String TRACE_FILTER = "reconcile_validator"; //$NON-NLS-1$
- protected String targetID;
- protected String targetContributionTag;
-
- // extension point ID
- public static final String PL_RECONCILE_VALIDATOR = "reconcileValidator"; //$NON-NLS-1$
-
- public static final String PLUGIN_ID = "org.eclipse.wst.sse.ui.extensions"; //$NON-NLS-1$
-
- public static final String TAG_VALIDATOR = "validator"; //$NON-NLS-1$
- public static final String TAG_CONTENT_TYPE_IDENTIFIER = "contentTypeIdentifier"; //$NON-NLS-1$
- public static final String TAG_PARTITION_TYPE = "partitionType"; //$NON-NLS-1$
-
- public static final String ATT_ID = "id"; //$NON-NLS-1$
- public static final String ATT_CLASS = "class"; //$NON-NLS-1$
- public static final String ATT_SCOPE = "scope"; //$NON-NLS-1$
-
- public static final String TRUE = "true"; //$NON-NLS-1$
-
- public static final ValidatorMetaData[] EMTPY_VMD_ARRAY = new ValidatorMetaData[0];
- private ValidatorMetaData fCurrentVMD = null;
- private List fVmds = new ArrayList();
- private String fCurrentCTID;
-
- /**
- * @param editorId
- * @return Transfer[]
- */
- public ValidatorMetaData[] getValidatorMetaData(String editorId) {
- readContributions(editorId, TAG_VALIDATOR, PL_RECONCILE_VALIDATOR);
- return (ValidatorMetaData[]) fVmds.toArray(new ValidatorMetaData[fVmds.size()]);
- }
-
- /**
- * Reads the contributions from the registry for the provided workbench
- * part and the provided extension point ID.
- * @param id
- * @param tag
- * @param extensionPoint
- */
- protected void readContributions(String id, String tag, String extensionPoint) {
- targetID = id;
- targetContributionTag = tag;
- IPluginRegistry registry = Platform.getPluginRegistry();
- readRegistry(registry, PLUGIN_ID, extensionPoint);
- }
-
- /**
- * Returns the name of the part ID attribute that is expected
- * in the target extension.
- *
- * @param element
- * @return String
- */
- protected String getID(IConfigurationElement element) {
- String value = element.getAttribute(ATT_ID);
- return value != null ? value : "???"; //$NON-NLS-1$
- }
-
- protected String getValidatorClass(IConfigurationElement element) {
- String value = element.getAttribute(ATT_CLASS);
- return value != null ? value : "???"; //$NON-NLS-1$
- }
-
- protected String getValidatorScope(IConfigurationElement element) {
- String value = element.getAttribute(ATT_SCOPE);
- return value != null ? value : "???"; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- */
- protected boolean readElement(IConfigurationElement element) {
- String tag = element.getName();
- //ie. targetContributionTag == validator
- if (tag.equals(targetContributionTag)) {
- String vId = getID(element);
- String vClass = getValidatorClass(element);
- String vScope = getValidatorScope(element);
-
- if (vId == null) {
- // This is not of interest to us - don't go deeper
- return true;
- }
- // start building a VMD
- fCurrentVMD = new ValidatorMetaData(element, vId, vClass, vScope);
- fVmds.add(fCurrentVMD);
-
- if(Logger.isTracing(ValidatorBuilder.TRACE_FILTER))
- System.out.println("added reconcile validator: " + vId + ":" + vClass + ":" + vScope); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
- else if (tag.equals(TAG_CONTENT_TYPE_IDENTIFIER)) {
- // add to current VMD
- fCurrentCTID = getID(element);
- fCurrentVMD.addContentTypeId(fCurrentCTID);
- }
- else if (tag.equals(TAG_PARTITION_TYPE)) {
- // add to current VMD
- String partitionType = getID(element);
- fCurrentVMD.addParitionType(fCurrentCTID, partitionType);
-
- return true;
- }
- else {
- return false;
- }
-
- readElementChildren(element);
- return true;
- }
-}
-
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java
deleted file mode 100644
index 1a8ced12bf..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorMetaData.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile.validator;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.reconcile.IReconcileAnnotationKey;
-import org.eclipse.wst.validation.IValidator;
-
-
-/**
- * Object that holds information relevant to the creation of a
- * validator for the reconciling framework.
- *
- * @author pavery
- */
-public class ValidatorMetaData {
- private String fId = null;
- private String fClass = null;
- private String fScope = null;
- private IConfigurationElement fConfigurationElement = null;
-
- // a hash map of content type Ids (String) that points to lists of parition types (List of Strings)
- // contentTypeId -> List(paritionType, paritionType, partitionType, ...)
- // contentTypeId2 -> List(partitionType, partitionType, ...)
- // ...
- private HashMap fMatrix = null;
-
- public ValidatorMetaData(IConfigurationElement element, String vId, String vClass, String vScope) {
- fId = vId;
- fClass = vClass;
- fScope = vScope;
- fConfigurationElement = element;
-
- fMatrix = new HashMap();
- }
-
- public void addContentTypeId(String contentTypeId) {
- if (!fMatrix.containsKey(contentTypeId))
- fMatrix.put(contentTypeId, new ArrayList());
- }
-
- public void addParitionType(String contentTypeId, String partitionType) {
- if (!fMatrix.containsKey(contentTypeId))
- fMatrix.put(contentTypeId, new ArrayList());
-
- List partitionList = (List) fMatrix.get(contentTypeId);
- partitionList.add(partitionType);
- }
-
- public boolean canHandleContentType(String contentType) {
- return fMatrix.containsKey(contentType);
- }
-
- public boolean canHandleParitionType(String contentType, String paritionType) {
- if (fMatrix.containsKey(contentType)) {
- List partitions = (List) fMatrix.get(contentType);
- for (int i = 0; i < partitions.size(); i++) {
- if (paritionType.equals(partitions.get(i)))
- return true;
- }
- }
- return false;
- }
-
- public String getValidatorId() {
- return fId;
- }
-
- public String getValidatorClass() {
- return fClass;
- }
-
- public int getValidatorScope() {
- return fScope.equalsIgnoreCase("total") ? IReconcileAnnotationKey.TOTAL : IReconcileAnnotationKey.PARTIAL; //$NON-NLS-1$
- }
-
- public IConfigurationElement getConfigurationElement() {
- return fConfigurationElement;
- }
-
- /**
- * @param element
- * @return Transfer
- */
- public IValidator createValidator() {
- Object obj = null;
- obj = createExtension();
- if (obj == null)
- return null;
- return (obj instanceof IValidator) ? (IValidator) obj : null;
- }
-
- /**
- * Creates an extension. If the extension plugin has not
- * been loaded a busy cursor will be activated during the duration of
- * the load.
- * @param element
- * @param classAttribute
- * @return Object
- * @throws CoreException
- */
- public Object createExtension() {
- // If plugin has been loaded create extension.
- // Otherwise, show busy cursor then create extension.
- final IConfigurationElement element = getConfigurationElement();
- //final String classAttribute = getValidatorClass();
-
- final Object[] result = new Object[1];
- IPluginDescriptor plugin = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- if (plugin.isPluginActivated()) {
- try {
- return createExecutableExtension(element, "class"/*classAttribute*/); //$NON-NLS-1$
- }
- catch (CoreException e) {
- handleCreateExecutableException(result, e);
- }
- }
- else {
- BusyIndicator.showWhile(null, new Runnable() {
- public void run() {
- try {
- result[0] = createExecutableExtension(element, "class"/*classAttribute*/); //$NON-NLS-1$
- }
- catch (Throwable e) {
- handleCreateExecutableException(result, e);
- }
- }
- });
- }
- return result[0];
- }
-
- /**
- * @param result
- * @param e
- */
- void handleCreateExecutableException(Object[] result, Throwable e) {
- Logger.logException(e);
- e.printStackTrace();
- result[0] = null;
- }
-
- /**
- * @param element
- * @param classAttribute
- * @return Object
- * @throws CoreException
- */
- Object createExecutableExtension(final IConfigurationElement element, final String classAttribute) throws CoreException {
- Object obj = null;
- obj = element.createExecutableExtension(classAttribute);
- return obj;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer debugString = new StringBuffer("ValidatorMetaData:"); //$NON-NLS-1$
- if(fId != null)
- debugString.append(" [id:"+fId+"]"); //$NON-NLS-1$ //$NON-NLS-2$
- return debugString.toString();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java
deleted file mode 100644
index cd6312ff99..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/reconcile/validator/ValidatorStrategy.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.reconcile.validator;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.reconciler.DirtyRegion;
-import org.eclipse.jface.text.reconciler.IReconcileResult;
-import org.eclipse.jface.text.reconciler.IReconcileStep;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.ui.internal.reconcile.AbstractStructuredTextReconcilingStrategy;
-import org.eclipse.wst.sse.ui.internal.reconcile.DocumentAdapter;
-import org.eclipse.wst.sse.ui.internal.reconcile.IStructuredReconcileStep;
-import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-import org.eclipse.wst.validation.IValidator;
-
-
-/**
- * Special validator strategy.
- * Runs validator steps contributed via reconcileValidator extension point
- *
- * @author pavery
- */
-public class ValidatorStrategy extends AbstractStructuredTextReconcilingStrategy {
-
- private List fMetaData = null;
- private String fContentType = null;
- private HashMap fIdToStepMap = null;
-
- public ValidatorStrategy(ITextEditor editor, String contentType) {
- super(editor);
- fMetaData = new ArrayList();
- fContentType = contentType;
- fIdToStepMap = new HashMap();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.reconcile.AbstractStructuredTextReconcilingStrategy#createReconcileSteps()
- */
- public void createReconcileSteps() {
- // do nothing, steps are created
- }
-
- public void addValidatorMetaData(ValidatorMetaData vmd) {
- fMetaData.add(vmd);
- }
-
- public boolean canValidatePartition(String partitionType) {
- ValidatorMetaData vmd = null;
- for (int i = 0; i < fMetaData.size(); i++) {
- vmd = (ValidatorMetaData) fMetaData.get(i);
- if (vmd.canHandleParitionType(getContentType(), partitionType))
- return true;
- }
- return false;
- }
-
- public String getContentType() {
- return fContentType;
- }
-
- public void reconcile(ITypedRegion tr, DirtyRegion dr, boolean refreshAll) {
-
- // for external files, this can be null
- if (getFile() != null) {
-
- String partitionType = tr.getType();
- if (canValidatePartition(partitionType)) {
- ValidatorMetaData vmd = null;
-
- //TemporaryAnnotation[]
- List annotationsToRemove = new ArrayList();
- //IReconcileResult[]
- List annotationsToAdd = new ArrayList();
- for (int i = 0; i < fMetaData.size(); i++) {
- vmd = (ValidatorMetaData) fMetaData.get(i);
- if (vmd.canHandleParitionType(getContentType(), partitionType)) {
- // get step for partition type
- Object o = fIdToStepMap.get(vmd.getValidatorId());
- ReconcileStepForValidator validatorStep = null;
- if (o != null) {
- validatorStep = (ReconcileStepForValidator) o;
- }
- else {
- // if doesn't exist, create one
- IValidator validator = vmd.createValidator();
- validatorStep = new ReconcileStepForValidator(validator, vmd.getValidatorScope());
- validatorStep.setInputModel(new DocumentAdapter(fDocument));
-
- fIdToStepMap.put(vmd.getValidatorId(), validatorStep);
- }
- ////////////////////////////////////////////////////////////////////////////
- // this logic copied from AbstractStructuredTextReconcilingStrategy
-
- if (!refreshAll) {
- // regular reconcile
- annotationsToRemove.addAll(Arrays.asList(getAnnotationsToRemove(dr)));
- annotationsToAdd.addAll(Arrays.asList(validatorStep.reconcile(dr, dr, refreshAll)));
- fAlreadyRemovedAllThisRun = false;
- }
- else {
- // the entire document is being reconciled (strategies may be called multiple times)
- if (!fAlreadyRemovedAllThisRun) {
- annotationsToRemove.addAll(Arrays.asList(getAllAnnotationsToRemove()));
- fAlreadyRemovedAllThisRun = true;
- }
- annotationsToAdd.addAll(Arrays.asList(validatorStep.reconcile(dr, dr, true)));
- }
- //smartProcess(annotationsToRemove, annotationsToAdd);
- /////////////////////////////////////////////////////////////////////////////
- }
- // remove/add if there is anything to remove/add
- if(annotationsToRemove.size() + annotationsToAdd.size() > 0)
- smartProcess((TemporaryAnnotation[])annotationsToRemove.toArray(new TemporaryAnnotation[annotationsToRemove.size()]),
- (IReconcileResult[])annotationsToAdd.toArray(new IReconcileResult[annotationsToAdd.size()]));
- }
- }
- }
- }
-
- /*
- * so that removal will work properly
- */
- public String[] getPartitionTypes() {
- List partitionTypes = new ArrayList();
- Iterator keys = fIdToStepMap.keySet().iterator();
- String key = null;
- while (keys.hasNext()) {
- key = (String) keys.next();
- IStructuredReconcileStep step = (IStructuredReconcileStep) fIdToStepMap.get(key);
- partitionTypes.addAll(Arrays.asList(step.getPartitionTypes()));
- }
- return (String[]) partitionTypes.toArray(new String[partitionTypes.size()]);
- }
-
- /*
- * so that removal will work properly
- */
- protected boolean containsStep(IReconcileStep step) {
- return step != null ? fIdToStepMap.values().contains(step) : false;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.reconcile.AbstractStructuredTextReconcilingStrategy#setDocument(org.eclipse.jface.text.IDocument)
- */
- public void setDocument(IDocument document) {
-
- super.setDocument(document);
- // validator steps are in "fIdToStepMap" (as opposed to fFirstStep > next step etc...)
- Iterator it = fIdToStepMap.values().iterator();
- IReconcileStep step = null;
- while(it.hasNext()) {
- step = (IReconcileStep)it.next();
- step.setInputModel(new DocumentAdapter(document));
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java
deleted file mode 100644
index bb4b99e5ad..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicFindOccurrencesAction.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-
-
-/**
- * <p>
- * Finds occurrences of a specified region type w/ region text in an IStructuredDocument.
- * Clients must implement getPartitionTypes() and getRegionTypes() to indicate which partition
- * types and region types it can operate on.
- * </p>
- *
- * <p>
- * Clients should override <code>getSearchQuery()</code> in order to provide their own type of
- * "search" (eg. searching for XML start tags, searching for Java elements, etc...)
- * </p>
- *
- * @author pavery
- */
-public class BasicFindOccurrencesAction extends TextEditorAction {
-
- private IFile file = null;
- private IStructuredDocument document = null;
- private String matchText = null;
- private String matchRegionType = null;
-
- public BasicFindOccurrencesAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- public void run() {
-
- if(this.document != null && this.matchText != null && this.matchRegionType != null)
- NewSearchUI.runQuery(getSearchQuery());
-
- unconfigure();
- }
-
- /**
- * Clients should override to provide their own search for the file.
- *
- */
- public ISearchQuery getSearchQuery() {
- return new OccurrencesSearchQuery(this.file, this.document, this.matchText, this.matchRegionType);
- }
-
- /**
- * Enables and initialzies the action, or disables.
- * @see org.eclipse.ui.texteditor.TextEditorAction#update()
- */
- public void update() {
-
- super.update();
-
- // determine if action should be enabled or not
- StructuredTextEditor editor = (StructuredTextEditor) getTextEditor();
- IStructuredDocumentRegion sdRegion = editor.getSelectedDocumentRegion();
- if (sdRegion != null) {
-
- ITextRegion r = editor.getSelectedTextRegion(sdRegion);
- if (r != null) {
-
- String type = r.getType();
- if (enabledForRegionType(type)) {
- configure(editor, sdRegion, r, type);
- setEnabled(true);
- }
- else {
- unconfigure();
- setEnabled(false);
- }
- }
- }
- }
-
- /**
- * @param editor
- * @param sdRegion
- * @param r
- * @param type
- */
- private void configure(StructuredTextEditor editor, IStructuredDocumentRegion sdRegion, ITextRegion r, String type) {
-
- this.file = editor.getFileInEditor();
- this.document = (IStructuredDocument)editor.getDocument();
- this.matchText = sdRegion.getText(r);
- this.matchRegionType = type;
- }
-
- private void unconfigure() {
-
- this.file = null;
- this.document = null;
- }
-
- /**
- * @param partitionType
- * @return <code>true</code> if this action can operate on this type of partition, otherwise <code>false</code>.
- */
- public boolean enabledForParitition(String partitionType) {
-
- String[] accept = getPartitionTypes();
- for (int i = 0; i < accept.length; i++) {
- if (partitionType.equals(accept[i]))
- return true;
- }
- return false;
- }
-
- /**
- * @param regionType
- * @return <code>true</code> if this action can operate on this region type (ITextRegion), otherwise false.
- */
- public boolean enabledForRegionType(String regionType) {
-
- String[] accept = getRegionTypes();
- for (int i = 0; i < accept.length; i++) {
- if (regionType.equals(accept[i]))
- return true;
- }
- return false;
- }
-
- /**
- * Clients should override this to enable find occurrences on certain partition(s).
- */
- protected String[] getPartitionTypes() {
- return new String[0];
- }
-
- /**
- * Clients should override this to enable find occurrences on different region type(s).
- */
- protected String[] getRegionTypes() {
- return new String[0];
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchLabelProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchLabelProvider.java
deleted file mode 100644
index 1dfa4a7975..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchLabelProvider.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-
-
-
-/**
- * Basic label provider that just provides an image and default text.
- *
- * @author pavery
- */
-public class BasicSearchLabelProvider implements ILabelProvider {
-
- public Image getImage(Object element) {
- return EditorPluginImageHelper.getInstance().getImage(EditorPluginImages.IMG_OBJ_OCC_MATCH);
- }
-
- public String getText(Object element) {
-
- StringBuffer text = new StringBuffer();
- if (element instanceof Match) {
- Match m = (Match)element;
-
- IMarker marker = (IMarker)m.getElement();
- if(marker.exists()) {
- String resultText = ""; //$NON-NLS-1$
- try {
- resultText = (String)marker.getAttribute(IMarker.MESSAGE);
- } catch (CoreException e) {
- Logger.logException(e);
- }
- text.append(resultText);
- }
- }
- else {
- text.append(element.toString());
- }
- return text.toString();
- }
-
- public void addListener(ILabelProviderListener listener) {
- // do nothing
- }
-
- public void dispose() {
- // do nothing
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- // do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchQuery.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchQuery.java
deleted file mode 100644
index 6024c78440..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/BasicSearchQuery.java
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.texteditor.MarkerUtilities;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-/**
- * @author pavery
- */
-public class BasicSearchQuery implements ISearchQuery {
-
- /** attribute to identify markers added by find occurrences */
- public static final String ATTR_OCCURRENCES_MARKER = "occurrences_marker"; //$NON-NLS-1$
-
- private static int LINE_LENGTH_LIMIT = 200;
-
- /** the file we're searching **/
- private IFile file = null;
- /** occurrence search matches **/
- private List matches = null;
-
- public BasicSearchQuery(IFile file) {
- this.file = file;
- this.matches = new ArrayList();
- }
-
- /*
- * public to avoid synthetic method access from inner class
- */
- public IFile getFile() {
- return this.file;
- }
-
- /**
- * @see org.eclipse.search.ui.ISearchQuery#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- public IStatus run(IProgressMonitor monitor) {
-
- // get rid of the old markers
- deleteOccurrencesMarkers();
-
- IStatus status = Status.OK_STATUS;
- try {
- // pa_TODO use scheduling rules
- ResourcesPlugin.getWorkspace().run(getRunnable(), monitor);
- }
- catch (Exception e){
- status = new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.OK, "", null); //$NON-NLS-1$
- }
- return status;
- }
-
- private void deleteOccurrencesMarkers() {
-
- final List removals = new ArrayList();
- try {
- // clear all old find occurrences markers
- IMarker[] searchMarkers = file.findMarkers(NewSearchUI.SEARCH_MARKER, false, IResource.DEPTH_ZERO);
- for (int i = 0; i < searchMarkers.length; i++) {
- Object o = searchMarkers[i].getAttribute(BasicSearchQuery.ATTR_OCCURRENCES_MARKER);
- if(o != null && ((Boolean)o).booleanValue() == true)
- removals.add(searchMarkers[i]);
-
- }
-
- if(removals.size() > 0) {
- IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
- public void run(IProgressMonitor monitor) throws CoreException {
- for(int i=0; i < removals.size(); i++)
- ((IMarker)removals.get(i)).delete();
- }
- };
- ResourcesPlugin.getWorkspace().run(runnable, null);
- }
- } catch (CoreException e) {
- Logger.logException(e);
- }
- }
-
- /**
- * Clients must supply their own runnable that should call <code>addMatch(IStructuredDocument document, int matchStart, int matchEnd)</code>
- * for all the matches it finds. It's in a runnable so search markers show up for a file in a live editor.
- *
- * @return
- */
- protected IWorkspaceRunnable getRunnable() {
- return null;
- }
-
- /**
- * @see org.eclipse.search.ui.ISearchQuery#getLabel()
- */
- public String getLabel() {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * used in search result display labels
- * @return
- */
- protected String getSearchText() {
- return ""; //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.search.ui.ISearchQuery#canRerun()
- */
- public boolean canRerun() {
- return false;
- }
-
- /**
- * @see org.eclipse.search.ui.ISearchQuery#canRunInBackground()
- */
- public boolean canRunInBackground() {
- return false;
- }
-
- /**
- * @see org.eclipse.search.ui.ISearchQuery#getSearchResult()
- */
- public ISearchResult getSearchResult() {
- return null;
- }
-
- public void addMatch(IStructuredDocument document, int matchStart, int matchEnd) {
-
- try {
- int lineNumber = document.getLineOfOffset(matchStart);
- int lineStart = document.getLineOffset(lineNumber);
- int lineLength = document.getLineLength(lineNumber);
-
- String searchResultString = document.get().substring(lineStart, lineStart + lineLength).trim();
-
- // create search marker (so annotations show up in editor)
- IMarker marker = createSearchMarker(matchStart, matchEnd, lineNumber, searchResultString);
-
- addMatch(new Match(marker, Match.UNIT_LINE, matchStart, matchStart + matchEnd));
-
- } catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
-
- private void addMatch(Match match) {
- if(match != null)
- this.matches.add(match);
- }
-
- public Match[] getMatches() {
- return (Match[])this.matches.toArray(new Match[this.matches.size()]);
- }
-
- protected IMarker createSearchMarker(int matchStart, int matchEnd, int lineNumber, String searchResultString) {
-
- IMarker marker = null;
- try {
- if(getFile() != null) {
-
- marker = getFile().createMarker(NewSearchUI.SEARCH_MARKER);
- HashMap attributes = new HashMap(6);
-
- MarkerUtilities.setCharStart(attributes, matchStart);
- MarkerUtilities.setCharEnd(attributes, matchEnd);
- MarkerUtilities.setLineNumber(attributes, lineNumber);
-
- // this might be bad if line of text is VERY long?
- if(searchResultString.length() > LINE_LENGTH_LIMIT)
- searchResultString = searchResultString.substring(0, LINE_LENGTH_LIMIT) + "..."; //$NON-NLS-1$
- MarkerUtilities.setMessage(attributes, searchResultString);
-
- // so we can remove them later
- attributes.put(ATTR_OCCURRENCES_MARKER, new Boolean(true));
-
- marker.setAttributes(attributes);
- }
- } catch (CoreException e) {
- Logger.logException(e);
- }
- return marker;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java
deleted file mode 100644
index 5921271c5d..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/FindOccurrencesActionProvider.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.search.ui.NewSearchUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.util.PlatformStatusLineUtil;
-
-
-
-/**
- * Performs the appropriate FindOccurrences action call based on selection.
- * Clients can add actions for different partitions via <code>addAction(BasicFindOccurrencesAction action)</code>
- *
- * @author pavery
- */
-public class FindOccurrencesActionProvider extends TextEditorAction {
-
- private List actions = null;
-
- public FindOccurrencesActionProvider(ResourceBundle bundle, String prefix, ITextEditor editor) {
-
- super(bundle, prefix, editor);
- }
-
- public void addAction(BasicFindOccurrencesAction action) {
-
- getActions().add(action);
- }
-
-
- /**
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
-
- BasicFindOccurrencesAction action = getActionForCurrentSelection();
- String errorMessage = ResourceHandler.getString("FindOccurrencesActionProvider.0"); //$NON-NLS-1$
- if (action != null) {
- action.update();
- if(action.isEnabled()) {
- // first of all activate the view
- NewSearchUI.activateSearchResultView();
-
- // run the action
- action.run();
-
- // clear status message
- PlatformStatusLineUtil.clearStatusLine();
- }
- else {
- PlatformStatusLineUtil.displayErrorMessage(errorMessage);
- PlatformStatusLineUtil.addOneTimeClearListener();
- }
- }
- else {
- PlatformStatusLineUtil.displayErrorMessage(errorMessage);
- PlatformStatusLineUtil.addOneTimeClearListener();
- }
- }
-
- /**
- * @see org.eclipse.ui.texteditor.TextEditorAction#update()
- */
- public void update() {
-
- super.update();
- // clear status message
- PlatformStatusLineUtil.clearStatusLine();
- }
-
- /**
- * @see org.eclipse.jface.action.Action#isEnabled()
- */
- public boolean isEnabled() {
- // always enabled
- return true;
- }
-
- private BasicFindOccurrencesAction getActionForCurrentSelection() {
-
- // check if we have an action that's enabled on the current partition
- ITypedRegion tr = getPartition();
- String partition = tr != null ? tr.getType() : ""; //$NON-NLS-1$
-
- Iterator it = getActions().iterator();
- BasicFindOccurrencesAction action = null;
- while (it.hasNext()) {
- action = (BasicFindOccurrencesAction) it.next();
- // we just choose the first action that can handle the partition
- if (action.enabledForParitition(partition))
- return action;
- }
- return null;
- }
-
- private ITypedRegion getPartition() {
- ITextSelection sel = getTextSelection();
- if (sel != null) {
- ITypedRegion region = getDocument().getDocumentPartitioner().getPartition(sel.getOffset());
- return region;
- }
- return null;
- }
-
- private IDocument getDocument() {
- return getTextEditor().getDocumentProvider().getDocument(getTextEditor().getEditorInput());
- }
-
- private ITextSelection getTextSelection() {
- ISelection selection = getTextEditor().getSelectionProvider().getSelection();
- if (selection instanceof ITextSelection && !selection.isEmpty()) {
- ITextSelection textSel = (ITextSelection) selection;
- return textSel;
- }
- return null;
- }
-
- private List getActions() {
- if (this.actions == null)
- this.actions = new ArrayList();
- return this.actions;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesContentProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesContentProvider.java
deleted file mode 100644
index 0b38611b09..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesContentProvider.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-
-/**
- * @author pavery
- */
-public class OccurrencesContentProvider implements IStructuredContentProvider {
-
- protected final Object[] EMPTY_ARRAY= new Object[0];
- private TableViewer tableViewer = null;
- private OccurrencesSearchResult result = null;
-
-
- /**
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- */
- public Object[] getElements(Object inputElement) {
-
- this.result = (OccurrencesSearchResult)inputElement;
- return this.result.getMatches();
- }
-
- public void elementsChanged(Object[] objects) {
-
- // only add what's not already added...
- if(this.tableViewer != null) {
- if(this.result != null && this.result.getMatches().length > 0) {
- this.tableViewer.add(this.result.getMatches());
- }
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.IContentProvider#dispose()
- */
- public void dispose() {
- // do nothing
- }
-
- public void clear() {
-
- if(this.tableViewer != null)
- this.tableViewer.refresh();
- }
-
- /**
- * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, java.lang.Object, java.lang.Object)
- */
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
-
- if(viewer instanceof TableViewer)
- this.tableViewer= (TableViewer)viewer;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchQuery.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchQuery.java
deleted file mode 100644
index b12c2d128a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchQuery.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import java.text.MessageFormat;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.search.ui.ISearchResult;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * Basic ISearchQuery that finds matches of region type and region text.
- *
- * @author pavery
- */
-public class OccurrencesSearchQuery extends BasicSearchQuery {
-
- /**
- * We need a runnable so that the search markers show up in the live document.
- */
- private class FindRegions implements IWorkspaceRunnable {
-
- private IStructuredDocument findRegionsDocument = null;
- private String matchRegionType = null;
- private String matchName = null;
-
- public FindRegions(IStructuredDocument document, String matchText, String matchRegionType) {
- this.findRegionsDocument = document;
- this.matchName = matchText;
- this.matchRegionType = matchRegionType;
- }
-
- public void run(IProgressMonitor monitor) throws CoreException {
- findOccurrences(monitor);
- }
-
- private void findOccurrences(IProgressMonitor monitor) {
-
- if (!isCanceled(monitor)) {
-
- int matchStart = -1;
- int matchEnd = -1;
- String findRegionText = ""; //$NON-NLS-1$
- String findResultText = ""; //$NON-NLS-1$
- String lineText = ""; //$NON-NLS-1$
-
- ITextRegion r = null;
- ITextRegionList regions = null;
- IStructuredDocumentRegion current = this.findRegionsDocument.getFirstStructuredDocumentRegion();
-
- // this is the main loop that iterates the document
- while (current != null && !isCanceled(monitor)) {
- regions = current.getRegions();
- for (int i = 0; i < regions.size() && !isCanceled(monitor); i++) {
-
- r = regions.get(i);
-
- // maybe this is the equals check where some valid matches are failing (like searching on end tag)
- if (r.getType().equals(this.matchRegionType) && current.getText(r).equals(this.matchName)) {
-
- findRegionText = current.getText(r);
-
- // region found
- matchStart = current.getStartOffset(r);
- matchEnd = matchStart + findRegionText.trim().length();
-
- addMatch(this.findRegionsDocument, matchStart, matchEnd);
- }
- }
- current = current.getNext();
- }
- }
- }
-
- private boolean isCanceled(IProgressMonitor monitor) {
- return monitor != null && monitor.isCanceled();
- }
- }
- // end inner class FindRegions
-
-
- private IStructuredDocument document = null;
- private String regionText = null;
- private String regionType = null;
-
- public OccurrencesSearchQuery(IFile file, IStructuredDocument document, String regionText, String regionType) {
- super(file);
- this.document = document;
- this.regionText = regionText;
- this.regionType = regionType;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.search.BasicSearchQuery#getRunnable()
- */
- protected IWorkspaceRunnable getRunnable() {
- return new FindRegions(this.document, this.regionText, this.regionType);
- }
-
- public String getLabel() {
- String label = ResourceHandler.getString("OccurrencesSearchQuery.0"); //$NON-NLS-1$
- String[] args = {getSearchText(), getOccurrencesCountText(), getFilename()};
- return MessageFormat.format(label, args);
- }
-
- /**
- * @return
- */
- private String getOccurrencesCountText() {
- String count = "";
- // pa_TODO dynamically change count
- return count;
- }
-
- private String getFilename() {
- String filename = ResourceHandler.getString("OccurrencesSearchQuery.2"); //$NON-NLS-1$ "file"
- if(getFile() != null)
- filename = getFile().getName().toString();
- return filename;
- }
-
- protected String getSearchText() {
- return this.regionText;
- }
-
- public boolean canRerun() {
- return false;
- }
-
- public boolean canRunInBackground() {
- // pa_TODO investigate what is required to do this safely
- return false;
- }
-
- public ISearchResult getSearchResult() {
- return new OccurrencesSearchResult(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchResult.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchResult.java
deleted file mode 100644
index e55f0e09da..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchResult.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.search.ui.ISearchQuery;
-import org.eclipse.search.ui.text.AbstractTextSearchResult;
-import org.eclipse.search.ui.text.IEditorMatchAdapter;
-import org.eclipse.search.ui.text.IFileMatchAdapter;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-
-
-/**
- * @author pavery
- */
-public class OccurrencesSearchResult extends AbstractTextSearchResult implements IEditorMatchAdapter, IFileMatchAdapter {
-
- private ISearchQuery query = null;
- private final Match[] NO_MATCHES = new Match[0];
-
- public OccurrencesSearchResult(ISearchQuery query) {
- this.query = query;
- }
-
- public IEditorMatchAdapter getEditorMatchAdapter() {
- return this;
- }
-
- public IFileMatchAdapter getFileMatchAdapter() {
- return this;
- }
-
- /**
- * This label shows up in the search history
- */
- public String getLabel() {
- return getQuery().getLabel();
- }
-
- public String getTooltip() {
- return getLabel();
- }
-
- public ImageDescriptor getImageDescriptor() {
- return EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_OBJ_OCC_MATCH);
- }
-
- public ISearchQuery getQuery() {
- return this.query;
- }
-
- public Match[] getMatches() {
- return ((OccurrencesSearchQuery)getQuery()).getMatches();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.search.ui.text.IEditorMatchAdapter#isShownInEditor(org.eclipse.search.ui.text.Match, org.eclipse.ui.IEditorPart)
- */
- public boolean isShownInEditor(Match match, IEditorPart editor) {
- return true;
- }
-
- /**
- * @see org.eclipse.search.ui.text.IEditorMatchAdapter#computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult, org.eclipse.ui.IEditorPart)
- */
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IEditorPart editor) {
-
- IEditorInput editorInput= editor.getEditorInput();
- if (editorInput instanceof IFileEditorInput) {
- IFileEditorInput fileEditorInput= (IFileEditorInput) editorInput;
- return computeContainedMatches(result, fileEditorInput.getFile());
- }
- return this.NO_MATCHES;
- }
-
- /**
- * @see org.eclipse.search.ui.text.IFileMatchAdapter#computeContainedMatches(org.eclipse.search.ui.text.AbstractTextSearchResult, org.eclipse.core.resources.IFile)
- */
- public Match[] computeContainedMatches(AbstractTextSearchResult result, IFile file) {
- return getMatches();
- }
-
- /**
- * @see org.eclipse.search.ui.text.IFileMatchAdapter#getFile(java.lang.Object)
- */
- public IFile getFile(Object element) {
- // return the file for the match
- IFile file = null;
- //System.out.println("get file for:"+element);
- if(element instanceof IMarker) {
- IResource r = ((IMarker)element).getResource();
- if(r instanceof IFile) {
- file = (IFile)r;
- }
- }
- return file;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchViewPage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchViewPage.java
deleted file mode 100644
index 831982f284..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/search/OccurrencesSearchViewPage.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.search;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.search.ui.text.AbstractTextSearchViewPage;
-import org.eclipse.search.ui.text.Match;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.ide.IGotoMarker;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-
-
-/**
- * Base page for Occurrences in file search results.
- *
- * @author pavery
- */
-public class OccurrencesSearchViewPage extends AbstractTextSearchViewPage {
-
- private OccurrencesContentProvider contentProvider = null;
-
- public OccurrencesSearchViewPage() {
- super(AbstractTextSearchViewPage.FLAG_LAYOUT_FLAT);
- }
-
- /**
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#elementsChanged(java.lang.Object[])
- */
- protected void elementsChanged(Object[] objects) {
- if(this.contentProvider != null)
- this.contentProvider.elementsChanged(objects);
- }
-
- /**
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#clear()
- */
- protected void clear() {
- if(this.contentProvider != null)
- this.contentProvider.clear();
- }
-
- /**
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTreeViewer(org.eclipse.jface.viewers.TreeViewer)
- */
- protected void configureTreeViewer(TreeViewer viewer) {
- // not supported at the moment
- }
-
- /**
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#configureTableViewer(org.eclipse.jface.viewers.TableViewer)
- */
- protected void configureTableViewer(TableViewer viewer) {
-
- // pa_TODO need sorter?
- viewer.setLabelProvider(new BasicSearchLabelProvider());
- this.contentProvider = new OccurrencesContentProvider();
- viewer.setContentProvider(this.contentProvider);
- }
-
- /**
- * @see org.eclipse.search.ui.text.AbstractTextSearchViewPage#showMatch(org.eclipse.search.ui.text.Match, int, int)
- */
- protected void showMatch(Match match, int currentOffset, int currentLength) throws PartInitException {
- Object o = match.getElement();
- if(o instanceof IMarker) {
- show((IMarker)o);
- }
- }
-
- private void show(IMarker marker) {
- IResource resource = marker.getResource();
- if (resource == null || !resource.exists())
- return;
-
- IEditorPart editor = getActivePage().getActiveEditor();
- if(editor != null) {
- IGotoMarker gotoMarker = (IGotoMarker) editor.getAdapter(IGotoMarker.class);
- if (gotoMarker != null)
- gotoMarker.gotoMarker(marker);
- }
- }
-
- private IWorkbenchPage getActivePage() {
- IWorkbench workbench = ((AbstractUIPlugin) Platform.getPlugin(EditorPlugin.ID)).getWorkbench();
- IWorkbenchWindow window = workbench.getActiveWorkbenchWindow();
- if (window == null)
- return null;
- return workbench.getActiveWorkbenchWindow().getActivePage();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java
deleted file mode 100644
index 3aecec15b9..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/SelectionHistory.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.selection;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class SelectionHistory {
-
- private List fHistory;
- private ITextEditor fEditor;
- private ISelectionChangedListener fSelectionListener;
- private int fSelectionChangeListenerCounter;
- private StructureSelectHistoryAction fHistoryAction;
-
- public SelectionHistory(ITextEditor editor) {
- Assert.isNotNull(editor);
- fEditor = editor;
- fHistory = new ArrayList(3);
- fSelectionListener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if (fSelectionChangeListenerCounter == 0)
- flush();
- }
- };
- fEditor.getSelectionProvider().addSelectionChangedListener(fSelectionListener);
- }
-
- public void setHistoryAction(StructureSelectHistoryAction action) {
- Assert.isNotNull(action);
- fHistoryAction = action;
- }
-
- public boolean isEmpty() {
- return fHistory.isEmpty();
- }
-
- public void remember(IRegion region) {
- fHistory.add(region);
- fHistoryAction.update();
- }
-
- public IRegion getLast() {
- if (isEmpty())
- return null;
- int size = fHistory.size();
- IRegion result = (IRegion) fHistory.remove(size - 1);
- fHistoryAction.update();
- return result;
- }
-
- public void flush() {
- if (fHistory.isEmpty())
- return;
- fHistory.clear();
- fHistoryAction.update();
- }
-
- public void ignoreSelectionChanges() {
- fSelectionChangeListenerCounter++;
- }
-
- public void listenToSelectionChanges() {
- fSelectionChangeListenerCounter--;
- }
-
- public void dispose() {
- fEditor.getSelectionProvider().removeSelectionChangedListener(fSelectionListener);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java
deleted file mode 100644
index e0f05f0846..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectAction.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.selection;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.StructuredTextViewer;
-import org.w3c.dom.Node;
-
-
-public abstract class StructureSelectAction extends Action {
- protected StructuredTextEditor fEditor = null;
- protected SelectionHistory fHistory;
- protected IStructuredModel fModel = null;
- protected StructuredTextViewer fViewer = null;
-
- public StructureSelectAction(StructuredTextEditor editor, SelectionHistory history) {
- super();
-
- Assert.isNotNull(editor);
- Assert.isNotNull(history);
- fEditor = editor;
- fHistory = history;
- fViewer = editor.getTextViewer();
- fModel = editor.getModel();
- Assert.isNotNull(fViewer);
- Assert.isNotNull(fModel);
- }
-
- public void run() {
- Region currentRegion = new Region(fViewer.getSelectedRange().x, fViewer.getSelectedRange().y);
- if (currentRegion.getLength() == fViewer.getDocument().getLength())
- return;
-
- IndexedRegion cursorIndexedRegion = getCursorIndexedRegion();
- if (cursorIndexedRegion instanceof Node) {
- Node cursorNode = (Node) cursorIndexedRegion;
-
- // use parent node for empty text node
- if (cursorNode.getNodeType() == Node.TEXT_NODE && cursorNode.getNodeValue().trim().length() == 0) {
- cursorNode = cursorNode.getParentNode();
-
- if (cursorNode instanceof IndexedRegion)
- cursorIndexedRegion = (IndexedRegion) cursorNode;
- }
-
- Region cursorNodeRegion = new Region(cursorIndexedRegion.getStartOffset(), cursorIndexedRegion.getEndOffset() - cursorIndexedRegion.getStartOffset());
-
- Region newRegion = null;
- if (cursorNodeRegion.getOffset() >= currentRegion.getOffset() &&
- cursorNodeRegion.getOffset() <= currentRegion.getOffset() + currentRegion.getLength() &&
- cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentRegion.getOffset() &&
- cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentRegion.getOffset() + currentRegion.getLength())
- newRegion = getNewSelectionRegion(cursorNode, currentRegion);
- else
- newRegion = cursorNodeRegion;
-
- if (newRegion != null) {
- fHistory.remember(currentRegion);
- try {
- fHistory.ignoreSelectionChanges();
- fEditor.selectAndReveal(newRegion.getOffset(), newRegion.getLength());
- }
- finally {
- fHistory.listenToSelectionChanges();
- }
- }
- }
- }
-
- protected IndexedRegion getIndexedRegion(int offset) {
- IndexedRegion indexedRegion = null;
-
- int lastOffset = offset;
- indexedRegion = fModel.getIndexedRegion(lastOffset);
- while (indexedRegion == null && lastOffset >= 0) {
- lastOffset--;
- indexedRegion = fModel.getIndexedRegion(lastOffset);
- }
-
- return indexedRegion;
- }
-
- abstract protected IndexedRegion getCursorIndexedRegion();
-
- abstract protected Region getNewSelectionRegion(Node node, Region region);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java
deleted file mode 100644
index 71acad0fd7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectEnclosingAction.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.selection;
-
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.w3c.dom.Node;
-
-
-public class StructureSelectEnclosingAction extends StructureSelectAction {
- public StructureSelectEnclosingAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
- setText(ResourceHandler.getString("StructureSelectEnclosing.label")); //$NON-NLS-1$
- setToolTipText(ResourceHandler.getString("StructureSelectEnclosing.tooltip")); //$NON-NLS-1$
- setDescription(ResourceHandler.getString("StructureSelectEnclosing.description")); //$NON-NLS-1$
- }
-
- protected IndexedRegion getCursorIndexedRegion() {
- return getIndexedRegion(fViewer.getSelectedRange().x);
- }
-
- protected Region getNewSelectionRegion(Node node, Region region) {
- Region newRegion = null;
-
- Node newNode = node.getParentNode();
-
- if (newNode instanceof IndexedRegion) {
- IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
- newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
- }
-
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java
deleted file mode 100644
index 91fc1c9bfc..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectHistoryAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.selection;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.w3c.dom.Node;
-
-
-public class StructureSelectHistoryAction extends StructureSelectAction implements IUpdate {
- public StructureSelectHistoryAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
- setText(ResourceHandler.getString("StructureSelectHistory.label")); //$NON-NLS-1$
- setToolTipText(ResourceHandler.getString("StructureSelectHistory.tooltip")); //$NON-NLS-1$
- setDescription(ResourceHandler.getString("StructureSelectHistory.description")); //$NON-NLS-1$
-
- update();
- }
-
- public void update() {
- setEnabled(!fHistory.isEmpty());
- }
-
- public void run() {
- IRegion old = fHistory.getLast();
- if (old != null) {
- try {
- fHistory.ignoreSelectionChanges();
- fEditor.selectAndReveal(old.getOffset(), old.getLength());
- }
- finally {
- fHistory.listenToSelectionChanges();
- }
- }
- }
-
- protected IndexedRegion getCursorIndexedRegion() {
- return null;
- }
-
- protected Region getNewSelectionRegion(Node node, Region region) {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java
deleted file mode 100644
index 5e22cb197c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectNextAction.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.selection;
-
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.w3c.dom.Node;
-
-
-public class StructureSelectNextAction extends StructureSelectAction {
- public StructureSelectNextAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
- setText(ResourceHandler.getString("StructureSelectNext.label")); //$NON-NLS-1$
- setToolTipText(ResourceHandler.getString("StructureSelectNext.tooltip")); //$NON-NLS-1$
- setDescription(ResourceHandler.getString("StructureSelectNext.description")); //$NON-NLS-1$
- }
-
- protected IndexedRegion getCursorIndexedRegion() {
- int offset = fViewer.getSelectedRange().x + fViewer.getSelectedRange().y - 1;
-
- if (offset < 0)
- offset = 0;
-
- return getIndexedRegion(offset);
- }
-
- protected Region getNewSelectionRegion(Node node, Region region) {
- Region newRegion = null;
-
- Node newNode = node.getNextSibling();
- if (newNode == null) {
- newNode = node.getParentNode();
-
- if (newNode instanceof IndexedRegion) {
- IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
- newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
- }
- }
- else {
- if (newNode instanceof IndexedRegion) {
- IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
- newRegion = new Region(region.getOffset(), newIndexedRegion.getEndOffset() - region.getOffset());
-
- if (newNode.getNodeType() == Node.TEXT_NODE)
- newRegion = getNewSelectionRegion(newNode, newRegion);
- }
- }
-
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java
deleted file mode 100644
index a11cf6274f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/selection/StructureSelectPreviousAction.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.selection;
-
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.IndexedRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.w3c.dom.Node;
-
-
-public class StructureSelectPreviousAction extends StructureSelectAction {
- public StructureSelectPreviousAction(StructuredTextEditor editor, SelectionHistory history) {
- super(editor, history);
- setText(ResourceHandler.getString("StructureSelectPrevious.label")); //$NON-NLS-1$
- setToolTipText(ResourceHandler.getString("StructureSelectPrevious.tooltip")); //$NON-NLS-1$
- setDescription(ResourceHandler.getString("StructureSelectPrevious.description")); //$NON-NLS-1$
- }
-
- protected IndexedRegion getCursorIndexedRegion() {
- return getIndexedRegion(fViewer.getSelectedRange().x);
- }
-
- protected Region getNewSelectionRegion(Node node, Region region) {
- Region newRegion = null;
-
- Node newNode = node.getPreviousSibling();
- if (newNode == null) {
- newNode = node.getParentNode();
-
- if (newNode instanceof IndexedRegion) {
- IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
- newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
- }
- }
- else {
- if (newNode instanceof IndexedRegion) {
- IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
- newRegion = new Region(newIndexedRegion.getStartOffset(), region.getOffset() + region.getLength() - newIndexedRegion.getStartOffset());
-
- if (newNode.getNodeType() == Node.TEXT_NODE)
- newRegion = getNewSelectionRegion(newNode, newRegion);
- }
- }
-
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/taginfo/DebugInfoHoverProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/taginfo/DebugInfoHoverProcessor.java
deleted file mode 100644
index 26205c8297..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/taginfo/DebugInfoHoverProcessor.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.taginfo;
-
-
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-
-/**
- * Provides debug hover help
- *
- * @author amywu
- * @see org.eclipse.jface.text.ITextHover
- */
-public class DebugInfoHoverProcessor implements ITextHover {
- public static final String TRACEFILTER = "debuginfohover"; // $NON-NLS-1$ //$NON-NLS-1$
- private static final String EDITOR_PLUGIN_ID = "org.eclipse.wst.sse.ui"; // $NON-NLS-1$ //$NON-NLS-1$
- protected IPreferenceStore fPreferenceStore = null;
-
- public DebugInfoHoverProcessor() {
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
- */
- public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
- if ((hoverRegion == null) || (viewer == null) || (viewer.getDocument() == null))
- return null;
-
- String displayText = null;
- int offset = hoverRegion.getOffset();
-
- ITypedRegion region = viewer.getDocument().getDocumentPartitioner().getPartition(offset);
- if (region != null) {
- displayText = region.getType();
- }
-
- return displayText;
- }
-
- /**
- * @deprecated if enabled flag is false, dont call getHoverInfo in the first place if true, use getHoverInfo(ITextViewer, int)
- */
- public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion, boolean enabled) {
- if (enabled)
- return getHoverInfo(viewer, hoverRegion);
- else
- return null;
- }
-
- /**
- * Returns the region to hover the text over based on the offset.
- * @param textViewer
- * @param offset
- *
- * @return IRegion region to hover over if offset is
- * not over invalid whitespace. otherwise, returns <code>null</code>
- *
- * @see ITextHover#getHoverRegion(ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- if ((textViewer == null) || (textViewer.getDocument() == null))
- return null;
-
- ITypedRegion region = textViewer.getDocument().getDocumentPartitioner().getPartition(offset);
- return region;
- }
-
- /**
- * @deprecated if enabled flag is false, dont call getHoverRegion in the first place if true, use getHoverRegion(ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset, boolean enabled) {
- if (enabled)
- return getHoverRegion(textViewer, offset);
- else
- return null;
- }
-
- /**
- * @deprecated hover processor no longer preference store-dependent
- */
- protected IPreferenceStore getPreferenceStore() {
- if (fPreferenceStore == null) {
- fPreferenceStore = ((AbstractUIPlugin) Platform.getPlugin(EDITOR_PLUGIN_ID)).getPreferenceStore();
- }
- return fPreferenceStore;
- }
-
- /**
- * @deprecated this method will not longer be used once other deprecated methods are removed
- */
- private IModelManager getModelManager() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- /**
- * @deprecated hover processor should not be preference store-dependent
- */
- protected boolean isHoverHelpEnabled(ITextViewer viewer) {
- // returning false because this method is deprecated
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/ui/StructuredTextAnnotationImageProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/ui/StructuredTextAnnotationImageProvider.java
deleted file mode 100644
index cc38978614..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/ui/StructuredTextAnnotationImageProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.ui;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.texteditor.IAnnotationImageProvider;
-
-/**
- * Image provider for structured text editor annotations.
- *
- * @author pavery
- */
-public class StructuredTextAnnotationImageProvider implements IAnnotationImageProvider {
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getManagedImage(org.eclipse.jface.text.source.Annotation)
- */
- public Image getManagedImage(Annotation annotation) {
- // future return different types of managed images as JDT does
- // eg. overlay icon images, "grayed" images, quick fixable, etc...
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptorId(org.eclipse.jface.text.source.Annotation)
- */
- public String getImageDescriptorId(Annotation annotation) {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.texteditor.IAnnotationImageProvider#getImageDescriptor(java.lang.String)
- */
- public ImageDescriptor getImageDescriptor(String imageDescritporId) {
- return null;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCommandImpl.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCommandImpl.java
deleted file mode 100644
index 73935517f2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCommandImpl.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.undo;
-
-
-
-import org.eclipse.emf.common.command.AbstractCommand;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.StructuredTextCommand;
-
-public class StructuredTextCommandImpl extends AbstractCommand implements StructuredTextCommand {
-
- protected IStructuredDocument fStructuredDocument = null; // needed for updating the text
- protected String fTextDeleted = null;
- protected String fTextInserted = null;
- protected int fTextStart = -1;
- protected int fTextEnd = -1;
-
- public StructuredTextCommandImpl(IStructuredDocument structuredDocument) {
- super();
-
- fStructuredDocument = structuredDocument; // needed for updating the text
- }
-
- public void execute() {
- }
-
- /**
- * getTextDeleted method comment.
- */
- public java.lang.String getTextDeleted() {
- return fTextDeleted;
- }
-
- /**
- * textEnd is the same as (textStart + textInserted.length())
- */
- public int getTextEnd() {
- return fTextEnd;
- }
-
- /**
- * getTextInserted method comment.
- */
- public java.lang.String getTextInserted() {
- return fTextInserted;
- }
-
- /**
- * getTextStart method comment.
- */
- public int getTextStart() {
- return fTextStart;
- }
-
- protected boolean prepare() {
- return true;
- }
-
- public void redo() {
- if (fStructuredDocument != null)
- fStructuredDocument.replaceText(this, fTextStart, fTextDeleted.length(), fTextInserted);
- }
-
- /**
- * setTextDeleted method comment.
- */
- public void setTextDeleted(java.lang.String textDeleted) {
- fTextDeleted = textDeleted;
- }
-
- /**
- * setTextEnd method comment.
- */
- public void setTextEnd(int textEnd) {
- fTextEnd = textEnd;
- }
-
- /**
- * setTextInserted method comment.
- */
- public void setTextInserted(java.lang.String textInserted) {
- fTextInserted = textInserted;
- }
-
- /**
- * setTextStart method comment.
- */
- public void setTextStart(int textStart) {
- fTextStart = textStart;
- }
-
- public void undo() {
- if (fStructuredDocument != null)
- fStructuredDocument.replaceText(this, fTextStart, fTextInserted.length(), fTextDeleted);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCompoundCommandImpl.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCompoundCommandImpl.java
deleted file mode 100644
index cb86703b08..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/internal/undo/StructuredTextCompoundCommandImpl.java
+++ /dev/null
@@ -1,221 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.internal.undo;
-
-
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.wst.sse.core.undo.CommandCursorPosition;
-
-
-public class StructuredTextCompoundCommandImpl extends CompoundCommand implements CommandCursorPosition {
-
- protected int fUndoCursorPosition = -1;
- protected int fRedoCursorPosition = -1;
- protected int fUndoSelectionLength = 0;
- protected int fRedoSelectionLength = 0;
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- */
- public StructuredTextCompoundCommandImpl() {
- super();
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param resultIndex int
- */
- public StructuredTextCompoundCommandImpl(int resultIndex) {
- super(resultIndex);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param resultIndex int
- * @param label java.lang.String
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label) {
- super(resultIndex, label);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param resultIndex int
- * @param label java.lang.String
- * @param description java.lang.String
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label, String description) {
- super(resultIndex, label, description);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param resultIndex int
- * @param label java.lang.String
- * @param description java.lang.String
- * @param commandList java.util.List
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label, String description, java.util.List commandList) {
- super(resultIndex, label, description, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param resultIndex int
- * @param label java.lang.String
- * @param commandList java.util.List
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, String label, java.util.List commandList) {
- super(resultIndex, label, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param resultIndex int
- * @param commandList java.util.List
- */
- public StructuredTextCompoundCommandImpl(int resultIndex, java.util.List commandList) {
- super(resultIndex, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param label java.lang.String
- */
- public StructuredTextCompoundCommandImpl(String label) {
- super(label);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param label java.lang.String
- * @param description java.lang.String
- */
- public StructuredTextCompoundCommandImpl(String label, String description) {
- super(label, description);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param label java.lang.String
- * @param description java.lang.String
- * @param commandList java.util.List
- */
- public StructuredTextCompoundCommandImpl(String label, String description, java.util.List commandList) {
- super(label, description, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param label java.lang.String
- * @param commandList java.util.List
- */
- public StructuredTextCompoundCommandImpl(String label, java.util.List commandList) {
- super(label, commandList);
- }
-
- /**
- * StructuredTextCompoundCommandImpl constructor comment.
- * @param commandList java.util.List
- */
- public StructuredTextCompoundCommandImpl(java.util.List commandList) {
- super(commandList);
- }
-
- /**
- * Returns the cursor position to be set to after this command is redone.
- * @return int
- */
- public int getRedoCursorPosition() {
- int cursorPosition = -1;
-
- if (fRedoCursorPosition != -1)
- cursorPosition = fRedoCursorPosition;
- else if (!commandList.isEmpty()) {
- int commandListSize = commandList.size();
- Command lastCommand = (Command) commandList.get(commandListSize - 1);
-
- if (lastCommand instanceof CommandCursorPosition)
- cursorPosition = ((CommandCursorPosition) lastCommand).getRedoCursorPosition();
- }
-
- return cursorPosition;
- }
-
- /**
- * Returns the length of text to be selected after this command is redone.
- * @return int
- */
- public int getRedoSelectionLength() {
- return fRedoSelectionLength;
- }
-
- /**
- * Returns the cursor position to be set to after this command is undone.
- * @return int
- */
- public int getUndoCursorPosition() {
- int cursorPosition = -1;
-
- if (fUndoCursorPosition != -1)
- cursorPosition = fUndoCursorPosition;
- else if (!commandList.isEmpty()) {
- // never used
- //int commandListSize = commandList.size();
- Command firstCommand = (Command) commandList.get(0);
-
- if (firstCommand instanceof CommandCursorPosition)
- cursorPosition = ((CommandCursorPosition) firstCommand).getUndoCursorPosition();
- }
-
- return cursorPosition;
- }
-
- /**
- * Returns the length of text to be selected after this command is undone.
- * @return int
- */
- public int getUndoSelectionLength() {
- return fUndoSelectionLength;
- }
-
- /**
- * Sets the cursor position to be used after this command is redone.
- */
- public void setRedoCursorPosition(int cursorPosition) {
- fRedoCursorPosition = cursorPosition;
- }
-
- /**
- * Sets the length of text to be selected after this command is redone.
- */
- public void setRedoSelectionLength(int selectionLength) {
- fRedoSelectionLength = selectionLength;
- }
-
- /**
- * Sets the cursor position to be used after this command is undone.
- */
- public void setUndoCursorPosition(int cursorPosition) {
- fUndoCursorPosition = cursorPosition;
- }
-
- /**
- * Sets the length of text to be selected after this command is undone.
- */
- public void setUndoSelectionLength(int selectionLength) {
- fUndoSelectionLength = selectionLength;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/nls/ResourceHandler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/nls/ResourceHandler.java
deleted file mode 100644
index 792129b0c2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/nls/ResourceHandler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.nls;
-
-
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class ResourceHandler {
-
-
- private static ResourceBundle fgResourceBundle;
-
- /**
- * Returns the resource bundle used by all classes in this Project
- */
- public static ResourceBundle getResourceBundle() {
- try {
- return ResourceBundle.getBundle("Editing");//$NON-NLS-1$
- }
- catch (MissingResourceException e) {
- // does nothing - this method will return null and
- // getString(String) will return the key
- // it was called with
- e.printStackTrace();
- }
- return null;
- }
-
- public static String getString(String key) {
- if (fgResourceBundle == null) {
- fgResourceBundle = getResourceBundle();
- }
-
- if (fgResourceBundle != null) {
- try {
- return fgResourceBundle.getString(key);
- }
- catch (MissingResourceException e) {
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- return "!" + key + "!";//$NON-NLS-2$//$NON-NLS-1$
- }
- }
-
- public static String getString(String key, Object[] args) {
-
- try {
- return MessageFormat.format(getString(key), args);
- }
- catch (IllegalArgumentException e) {
- return getString(key);
- }
-
- }
-
- public static String getString(String key, Object[] args, int x) {
-
- return getString(key);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/AbstractOpenOn.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/AbstractOpenOn.java
deleted file mode 100644
index 638239974e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/AbstractOpenOn.java
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.openon;
-
-import java.io.File;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.program.Program;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IEditorRegistry;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.util.PathHelper;
-import org.eclipse.wst.sse.core.util.URIResolver;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extensions.openon.IOpenOn;
-import org.eclipse.wst.sse.ui.internal.openon.ExternalFileEditorInput;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.util.PlatformStatusLineUtil;
-
-
-/**
- * This action class retrieves the link/file selected by the cursor and
- * attempts to open the link/file in the default editor or web browser
- */
-abstract public class AbstractOpenOn implements IOpenOn {
- protected final String FILE_PROTOCOL = "file:/";//$NON-NLS-1$
- private final String HTTP_PROTOCOL = "http://";//$NON-NLS-1$
- protected final String CANNOT_OPEN = ResourceHandler.getString("AbstractOpenOn.0"); //$NON-NLS-1$
- private IDocument fDocument; // document currention associated with open on
-
- /**
- * Opens the appropriate editor for fileString
- * @param fileString
- */
- protected void openFileInEditor(String fileString) {
- IEditorPart editor = null;
- if (fileString != null) {
- // open web browser if this is a web address
- String temp = fileString.toLowerCase();
- if (temp.startsWith(HTTP_PROTOCOL)) {
- Program.launch(fileString); // launches web browser/executable associated with uri
- return;
- }
- // chop off the file protocol
- if (temp.startsWith(FILE_PROTOCOL)) {
- fileString = fileString.substring(FILE_PROTOCOL.length());
- }
-
- // try to locate the file in the workspace and return an IFile if found
- IFile file = getFile(fileString);
- if (file != null) {
- // file exists in workspace
- editor = openFileInEditor(file);
- } else {
- // file does not exist in workspace
- editor = openExternalFile(fileString);
- }
- }
- // no editor was opened
- if (editor == null) {
- openFileFailed();
- }
- }
-
- /**
- * Returns an IFile from the given uri if possible, null if cannot find file from uri.
- * @param fileString file system path
- * @return returns IFile if fileString exists in the workspace
- */
- protected IFile getFile(String fileString) {
- if (fileString != null) {
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(new Path(fileString));
- for (int i = 0; i < files.length; i++)
- if (files[i].exists())
- return files[i];
- }
- return null;
- }
-
- /**
- * Opens the IFile, input in its default editor, if possible, and returns the editor
- * opened.
- * Possible reasons for failure: input cannot be found, input does not exist in
- * workbench, editor cannot be opened.
- *
- * @return IEditorPart editor opened or null if input == null or does not exist,
- * external editor was opened, editor could not be opened
- */
- protected IEditorPart openFileInEditor(IFile input) {
- if (input != null && input.exists()) {
- try {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- return IDE.openEditor(page, input, true);
- }
- catch (PartInitException pie) {
- Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);
- }
- }
- return null;
- }
-
- /**
- * Try to open the external file, fileString in its default editor
- * @param fileString
- * @return IEditorPart editor opened or null if editor could not be opened
- */
- protected IEditorPart openExternalFile(String fileString) {
- // file does not exist in workspace so try to open using system editor
- File file = new File(fileString);
- IEditorInput input = new ExternalFileEditorInput(file);
- String editorId = getEditorId(fileString);
-
- try {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- return page.openEditor(input, editorId, true);
- }
- catch (PartInitException pie) {
- Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);
- }
- return null;
- }
-
- /**
- * Determines the editor associated with the given file name
- * @param filename
- * @return editor id of the editor associated with the given file name
- */
- private String getEditorId(String filename) {
- IWorkbench workbench= PlatformUI.getWorkbench();
- IEditorRegistry editorRegistry= workbench.getEditorRegistry();
- IEditorDescriptor descriptor= editorRegistry.getDefaultEditor(filename);
- if (descriptor != null)
- return descriptor.getId();
- return EditorsUI.DEFAULT_TEXT_EDITOR_ID;
- }
-
- /**
- * Notifies user that open on selection action could not successfully open
- * the selection (writes message on status bar and beeps)
- */
- protected void openFileFailed() {
- PlatformStatusLineUtil.displayErrorMessage(CANNOT_OPEN);
- PlatformStatusLineUtil.addOneTimeClearListener();
- }
-
- /**
- * @deprecated this method has moved up to DefaultOpenOnHTML - TODO remove in C5
- */
- protected String resolveURI(String uriString) {
- // future_TODO: should use the new common extensible URI resolver when clients start implementing it
- String resolvedURI = uriString;
-
- if (uriString != null) {
- IStructuredModel sModel = getModelManager().getExistingModelForRead(getDocument());
- if (sModel != null) {
- URIResolver resolver = sModel.getResolver();
- resolvedURI = resolver != null ? resolver.getLocationByURI(uriString, true) : uriString;
-
- sModel.releaseFromRead();
- }
- // special adjustment for file protocol
- if (uriString.startsWith(FILE_PROTOCOL)) {
- PathHelper.removeLeadingSeparator(resolvedURI);
- }
- }
- return resolvedURI;
- }
-
- protected IModelManager getModelManager() {
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- /**
- * @deprecated use getOpenRegion(IDocument, int) instead TODO remove in C5
- */
- public IRegion getOpenOnRegion(ITextViewer viewer, int offset) {
- if (viewer != null) {
- return getOpenOnRegion(viewer.getDocument(), offset);
- }
- return null;
- }
-
- /**
- * @deprecated use openOn(IDocument, IRegion) instead TODO remove in C5
- */
- public void openOn(ITextViewer viewer, IRegion region) {
- if (viewer != null) {
- openOn(viewer.getDocument(), region);
- }
- }
-
- /**
- * @deprecated use getDocument() instead TODO remove in C5
- */
- public ITextViewer getTextViewer() {
- return null;
- }
-
- /**
- * @deprecated use setDocument instead TODO remove in C5
- */
- public void setTextViewer(ITextViewer viewer) {
- }
-
- /*
- * (non-Javadoc)
- */
- public IRegion getOpenOnRegion(IDocument doc, int offset) {
- IRegion region;
- // set the document for this action
- setDocument(doc);
- region = doGetOpenOnRegion(offset);
- // reset the document back to null for this action
- setDocument(null);
- return region;
- }
-
- /*
- * (non-Javadoc)
- */
- public void openOn(IDocument doc, IRegion region) {
- // set the document for this action
- setDocument(doc);
- // if no region was given this action fails
- if (region == null)
- openFileFailed();
- else
- doOpenOn(region);
- // reset the document back to null for this action
- setDocument(null);
- }
-
- /**
- * Returns the current document associated with open on
- * @return IDocument
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- /**
- * Sets current document associated with open on
- * @param document
- */
- public void setDocument(IDocument document) {
- fDocument = document;
- }
-
- abstract protected IRegion doGetOpenOnRegion(int offset);
-
- abstract protected void doOpenOn(IRegion region);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/OpenOnProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/OpenOnProvider.java
deleted file mode 100644
index e1db1a13db..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/openon/OpenOnProvider.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.openon;
-
-
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.extensions.openon.IOpenOn;
-import org.eclipse.wst.sse.ui.internal.openon.OpenOnBuilder;
-import org.eclipse.wst.sse.ui.internal.openon.OpenOnDefinition;
-
-
-/**
- * Determines the appropriate IOpenOn to call based on current partition.
- */
-public class OpenOnProvider {
- private static OpenOnProvider fInstance;
-
- /**
- * returns singleton instance of OpenOnProvider
- *
- * @return OpenOnProvider
- */
- public synchronized static OpenOnProvider getInstance() {
- if (fInstance == null) {
- fInstance = new OpenOnProvider();
- }
- return fInstance;
- }
-
- /**
- * @deprecated use getOpenOn(IDocument, int) instead TODO remove in C5
- */
- public IOpenOn getOpenOn(ITextViewer viewer, int offset) {
- // determine the current partition
- if (viewer != null) {
- IDocument document = viewer.getDocument();
- return getOpenOn(document, offset);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the appropriate IOpenOn for the current partition
- *
- * @return
- */
- public IOpenOn getOpenOn(IDocument document, int offset) {
- IOpenOn openOn = null;
-
- // determine the current partition
- if (document != null) {
- String contentType = getContentType(document);
- String partitionType = getPartitionType(document, offset);
-
- // query OpenOnBuilder and get the list of open ons for the
- // current partition
- OpenOnDefinition[] defs = OpenOnBuilder.getInstance().getOpenOnDefinitions(contentType, partitionType);
-
- // if more than 1 openon is returned, need to further check
- // which open on is the appropriate one to return
- // for now just returning the first one
- if (defs != null && defs.length > 0) {
- openOn = defs[0].createOpenOn();
- }
- }
-
- return openOn;
- }
-
-
- /**
- * Returns the content type of document
- *
- * @param document -
- * assumes document is not null
- * @return String content type of given document
- */
- protected String getContentType(IDocument document) {
- String type = null;
-
- IModelManager mgr = ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager();
- IStructuredModel model = null;
- try {
- model = mgr.getExistingModelForRead(document);
- if (model != null) {
- type = model.getContentTypeIdentifier();
- }
- }
- finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
- return type;
- }
-
- /**
- * Returns the partition type located at offset in the document
- *
- * @param document -
- * assumes document is not null
- * @param offset
- * @return String partition type
- */
- protected String getPartitionType(IDocument document, int offset) {
- String type = null;
- ITypedRegion region = document.getDocumentPartitioner().getPartition(offset);
- if (region != null) {
- type = region.getType();
- }
-
- return type;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/CommonEditorPreferenceNames.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/CommonEditorPreferenceNames.java
deleted file mode 100644
index 24822036d0..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/CommonEditorPreferenceNames.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences;
-
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-
-/**
- * Editor preferences split out from Model Preferences.
- * Preferences defined in here are dependent on a visual editor.
- */
-public class CommonEditorPreferenceNames {
- // currently can take on 3 different values
- public static final String EDITOR_VALIDATION_METHOD = "editorValidationMethod"; //$NON-NLS-1$
- public static final String EDITOR_VALIDATION_NONE = "validation_none"; //$NON-NLS-1$
- public static final String EDITOR_VALIDATION_WORKBENCH_DEFAULT = "validation_workbench_default"; //$NON-NLS-1$
- public static final String EDITOR_VALIDATION_CONTENT_MODEL = "validation_content_model"; //$NON-NLS-1$
-
- // these 2 preferences are on the StructuredTextEditorPreferencePage annotations tab
- public static final String EVALUATE_TEMPORARY_PROBLEMS = "evaluateTemporaryProblems"; //$NON-NLS-1$
- public static final String SHOW_QUICK_FIXABLES = "showQuickFixables"; //$NON-NLS-1$
-
- public static final String EDITOR_USE_INFERRED_GRAMMAR = "useInferredGrammar"; //$NON-NLS-1$
-
- public static final String CONTENT_ASSIST_SUPPORTED = "contentAssistSupported";//$NON-NLS-1$
-
- /**
- * @deprecated EDITOR_TEXT_HOVER_MODIFIERS contains this information now TODO remove
- */
- public static final String SHOW_HOVER_HELP = "showHoverHelp"; //$NON-NLS-1$
-
- public static final String AUTO_PROPOSE = "autoPropose";//$NON-NLS-1$
- public static final String AUTO_PROPOSE_CODE = "autoProposeCode";//$NON-NLS-1$
- public static final String LT = "<";//$NON-NLS-1$
- public static final String LT_PERCENT = "<%";//$NON-NLS-1$
- public static final String DOT = ".";//$NON-NLS-1$
-
- /** Preference key for matching brackets */
- public final static String MATCHING_BRACKETS = "matchingBrackets"; //$NON-NLS-1$
- /** Preference key for matching brackets color */
- public final static String MATCHING_BRACKETS_COLOR = "matchingBracketsColor"; //$NON-NLS-1$
-
- /**
- * A named preference that controls if browser like links are turned on or off.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- *
- */
- public final static String BROWSER_LIKE_LINKS = "browserLikeLinks"; //$NON-NLS-1$
-
- /**
- * A named preference that controls the key modifier for browser like links.
- * <p>
- * Value is of type <code>String</code>.
- * </p>
- *
- */
- public final static String BROWSER_LIKE_LINKS_KEY_MODIFIER = "browserLikeLinksKeyModifier"; //$NON-NLS-1$
-
- /**
- * @deprecated use BROWSER_LIKE_LINKS_KEY_MODIFIER instead
- */
- public final static String BROWSER_LIKE_LINKS_KEY_MODIFIER_MASK = "browserLikeLinksKeyModifierMask"; //$NON-NLS-1$
-
- /**
- * A named preference that holds the color used for 'linked-mode' underline.
- * <p>
- * Value is of type <code>String</code>. A RGB color value encoded as a string
- * using class <code>PreferenceConverter</code>
- * </p>
- *
- * @see org.eclipse.jface.resource.StringConverter
- * @see org.eclipse.jface.preference.PreferenceConverter
- */
- public final static String LINK_COLOR = "linkColor"; //$NON-NLS-1$
-
- /**
- * A named preference that defines whether hint to make hover sticky should be shown.
- */
- public static final String EDITOR_SHOW_TEXT_HOVER_AFFORDANCE= "showTextHoverAffordance"; //$NON-NLS-1$
-
- /**
- * A named preference that defines the key for the hover modifiers.
- */
- public static final String EDITOR_TEXT_HOVER_MODIFIERS= "hoverModifiers"; //$NON-NLS-1$
-
- /**
- * A named preference that controls whether annotation roll over is used or not.
- * <p>
- * Value is of type <code>Boolean</code>. If <code>true<code> the annotation ruler column
- * uses a roll over to display multiple annotations
- * </p>
- */
- public static final String EDITOR_ANNOTATION_ROLL_OVER= "editor_annotation_roll_over"; //$NON-NLS-1$
-
- /**
- * The key to store customized templates.
- */
- public static final String TEMPLATES_KEY= "org.eclipse.wst.sse.ui.custom_templates"; //$NON-NLS-1$
-
- /** Preference key for error indication */
- public final static String ERROR_INDICATION = "errorIndication"; //$NON-NLS-1$
- /** Preference key for error color */
- public final static String ERROR_INDICATION_COLOR = "errorIndicationColor"; //$NON-NLS-1$
- /** Preference key for warning indication */
- public final static String WARNING_INDICATION = "warningIndication"; //$NON-NLS-1$
- /** Preference key for warning color */
- public final static String WARNING_INDICATION_COLOR = "warningIndicationColor"; //$NON-NLS-1$
- /** Preference key for task indication */
- public final static String TASK_INDICATION = "taskIndication"; //$NON-NLS-1$
- /** Preference key for task color */
- public final static String TASK_INDICATION_COLOR = "taskIndicationColor"; //$NON-NLS-1$
- /** Preference key for bookmark indication */
- public final static String BOOKMARK_INDICATION = "bookmarkIndication"; //$NON-NLS-1$
- /** Preference key for bookmark color */
- public final static String BOOKMARK_INDICATION_COLOR = "bookmarkIndicationColor"; //$NON-NLS-1$
- /** Preference key for search result indication */
- public final static String SEARCH_RESULT_INDICATION = "searchResultIndication"; //$NON-NLS-1$
- /** Preference key for search result color */
- public final static String SEARCH_RESULT_INDICATION_COLOR = "searchResultIndicationColor"; //$NON-NLS-1$
- /** Preference key for unknown annotation indication */
- public final static String UNKNOWN_INDICATION = "unknownIndication"; //$NON-NLS-1$
- /** Preference key for unknown annotation color */
- public final static String UNKNOWN_INDICATION_COLOR = "unknownIndicationColor"; //$NON-NLS-1$
- /** Preference key for error indication in overview ruler */
- public final static String ERROR_INDICATION_IN_OVERVIEW_RULER = "errorIndicationInOverviewRuler"; //$NON-NLS-1$
- /** Preference key for warning indication in overview ruler */
- public final static String WARNING_INDICATION_IN_OVERVIEW_RULER = "warningIndicationInOverViewrRuler"; //$NON-NLS-1$
- /** Preference key for task indication in overview ruler */
- public final static String TASK_INDICATION_IN_OVERVIEW_RULER = "taskIndicationInOverviewRuler"; //$NON-NLS-1$
- /** Preference key for bookmark indication in overview ruler */
- public final static String BOOKMARK_INDICATION_IN_OVERVIEW_RULER = "bookmarkIndicationInOverviewRuler"; //$NON-NLS-1$
- /** Preference key for search result indication in overview ruler */
- public final static String SEARCH_RESULT_INDICATION_IN_OVERVIEW_RULER = "searchResultIndicationInOverviewRuler"; //$NON-NLS-1$
- /** Preference key for unknown annotation indication in overview ruler */
- public final static String UNKNOWN_INDICATION_IN_OVERVIEW_RULER = "unknownIndicationInOverviewRuler"; //$NON-NLS-1$
-
- /**
- * these are preferences that should be inherited from the "embedded preference store"
- * for example: if you ask for th OVERVIEW_RULER preference for JSP, you will automatically
- * get the preference from the HTML preference store.
- */
- String EMBEDDED_CONTENT_TYPE_PREFERENCES[] = {CommonModelPreferenceNames.TAB_WIDTH, CommonModelPreferenceNames.LINE_WIDTH, CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, CommonModelPreferenceNames.INDENT_USING_TABS, CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, AUTO_PROPOSE, AUTO_PROPOSE_CODE, CommonModelPreferenceNames.TAG_NAME_CASE, CommonModelPreferenceNames.ATTR_NAME_CASE,};
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceKeyGenerator.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceKeyGenerator.java
deleted file mode 100644
index 7d7c73b99a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceKeyGenerator.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences;
-
-/**
- * This class is a utility to generate contentType specific keys,
- * for content type sensitive preferences (eg. highlighting).
- *
- * This class is not intended to be used for non content type
- * sensitive prefrences (eg. font style).
- *
- *
- */
-public class PreferenceKeyGenerator {
- public static String generateKey(String key, String contentTypeId) {
- return contentTypeId + "." + key; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceManager.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceManager.java
deleted file mode 100644
index ca42140c57..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/PreferenceManager.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences;
-
-
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.Reader;
-import java.io.Writer;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-import javax.xml.parsers.ParserConfigurationException;
-import javax.xml.transform.OutputKeys;
-import javax.xml.transform.Source;
-import javax.xml.transform.Transformer;
-import javax.xml.transform.TransformerConfigurationException;
-import javax.xml.transform.TransformerException;
-import javax.xml.transform.TransformerFactory;
-import javax.xml.transform.TransformerFactoryConfigurationError;
-import javax.xml.transform.dom.DOMSource;
-import javax.xml.transform.stream.StreamResult;
-
-import org.eclipse.wst.sse.core.preferences.PreferenceChangeListener;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-
-public abstract class PreferenceManager {
- /**
- * The PreferenceRuntimeException is often thrown by methods when
- * a service we use throws a checked exception, but we want to convert and treat
- * as a runtime exception.
- */
- class PreferenceRuntimeException extends RuntimeException {
- private Throwable originalException;
-
- public PreferenceRuntimeException() {
- super();
- }
-
- /**
- * This form of the constructor is used to wrapper another exception.
- */
- public PreferenceRuntimeException(Throwable t) {
- this();
- originalException = t;
- }
-
- public String getMessage() {
- String result = super.getMessage();
- if ((result != null) && (!result.endsWith("."))) //$NON-NLS-1$
- result = result + "."; //$NON-NLS-1$
- if (originalException != null) {
- String embeddedMessage = originalException.getMessage();
- embeddedMessage = originalException.getClass().getName() + ": " + originalException.getMessage(); //$NON-NLS-1$
- // not all exceptions have messages (e.g. many NullPointerException)
- String originalError = ResourceHandler.getString("PreferenceManager.0"); //$NON-NLS-1$
- if (result == null)
- result = ""; //$NON-NLS-1$
- if (embeddedMessage != null)
- result = result + " " + originalError + " " + embeddedMessage; //$NON-NLS-2$//$NON-NLS-1$
- else
- result = result + " " + originalError + " " + originalException.toString(); //$NON-NLS-2$//$NON-NLS-1$
- }
- return result;
- }
-
- public Throwable getOriginalException() {
- return originalException;
- }
-
- public String toString() {
- // we don't put super.toString or getClass to "hide" that it was a
- // SourceEditing exception (otherwise, focus goes on that,
- // instead of original exception.
- String message = getMessage();
- // message should never be null ... but just in case
- return (message != null) ? message : super.toString();
- }
- }
-
- protected class EmptyNodeList implements NodeList {
- protected EmptyNodeList() {
- super();
- }
-
- public int getLength() {
- return 0;
- }
-
- public Node item(int param1) {
- return null;
- }
- }
-
- protected String fileName = null;
- protected Document document = null;
- private List preferenceChangeListeners = new ArrayList(1);
-
- protected Document _getNewDocumentDOM2() {
- Document result = null;
- // settings
- DocumentBuilder builder = getDocumentBuilder();
- result = builder.newDocument();
- Element settings = result.createElement(getRootElementName());
- result.appendChild(settings);
- return result;
-
- }
-
- protected Document _getParsedDocumentDOM2(String filename) {
- Document result = null;
- DocumentBuilder builder = getDocumentBuilder();
- try {
- Reader inputReader = new FileReader(getFilename());
- InputSource inputSource = new InputSource(inputReader);
- result = builder.parse(inputSource);
- }
- catch (FileNotFoundException e) {
- // file not found is "ok" ... it'll be created if we return null
- result = null;
- }
- catch (IOException e) {
- result = null;
- }
- catch (SAXException e) {
- result = null;
- }
-
- return result;
-
- }
-
- public void addPreferenceChangeListener(PreferenceChangeListener l) {
- if (!preferenceChangeListeners.contains(l))
- preferenceChangeListeners.add(l);
- }
-
- /**
- * Returns a new document containing the defaults for this manager.
- * This SHOULD NOT overwrite the actual document stored within this manager,
- * and while a root element MAY BE created by the DOM implementation, it is
- * recommended that subclasses NOT RELY upon it being there.
- * @return org.w3c.dom.Document
- */
- public Document createDefaultPreferences() {
- Document txobj = null;
- txobj = _getNewDocumentDOM2();
- return txobj;
- }
-
- protected void firePreferenceChangeListeners() {
- if (preferenceChangeListeners != null)
- for (int i = 0; i < preferenceChangeListeners.size(); ++i)
- ((PreferenceChangeListener) preferenceChangeListeners.get(i)).preferencesChanged();
- }
-
- /**
- *
- * @return Document
- */
- public Document getDocument() {
- if (document == null)
- load();
- return document;
- }
-
- /****************************************************
- * Takes a single string of the form "a/b/c" and
- * ensures that that structure exists below the
- * head element, down through 'c', and returns a
- * <em>single</em> element 'c'. For multiple
- * elements (such as multiple &lt;macro&gt; elements
- * contained within a single &lt;macros&gt; element,
- * full DOM access is required for searching and
- * child element manipulation.
- ***************************************************/
- public Element getElement(String name) {
- if (document == null)
- load();
- if (document != null)
- return (Element) getNode(getRootElement(), name);
- else
- return null;
- }
-
- protected abstract String getFilename();
-
- protected Node getNamedChild(Node parent, String childName) {
- if (parent == null) {
- return null;
- }
- NodeList childList = parent.getChildNodes();
- for (int i = 0; i < childList.getLength(); i++) {
- if (childList.item(i).getNodeName().equals(childName))
- return childList.item(i);
- }
- return null;
- }
-
- /****************************************************
- * Takes a single string of the form "a/b/c" and
- * ensures that that structure exists below the
- * head element, down through 'c', and returns the
- * element 'c'.
- ***************************************************/
- public Node getNode(Node node, String name) {
- StringTokenizer tokenizer = new StringTokenizer(name, "/"); //$NON-NLS-1$
- String token = null;
- while (tokenizer.hasMoreTokens()) {
- token = tokenizer.nextToken();
- if (getNamedChild(node, token) == null) {
- Document localDocument = node.getOwnerDocument();
- node.appendChild(localDocument.createElement(token));
- }
- node = getNamedChild(node, token);
- }
- return node;
- }
-
- protected Document getParsedDocument(String filename) {
- Document result = null;
- // file name is almost never null,
- // but can be if preferences are being ran
- // outside of a workbench application
- if (filename != null) {
- File existenceTester = new File(filename);
- if (!existenceTester.exists())
- result = null;
- else
- result = _getParsedDocumentDOM2(filename);
- }
- return result;
-
- }
-
- /**
- * Returns the root element of the current document
- * @return org.w3c.dom.Element
- */
- public Node getRootElement() {
- return getRootElement(getDocument());
- }
-
- /**
- * Returns the root element of the current document
- * @return org.w3c.dom.Element
- */
- public Node getRootElement(Document doc) {
- if (doc == null)
- return null;
- Node rootElement = doc.getFirstChild();
- while (rootElement != null && rootElement.getNodeType() != Node.ELEMENT_NODE && !rootElement.getNodeName().equals(getRootElementName())) {
- rootElement = rootElement.getNextSibling();
- }
- return rootElement;
- }
-
- /**
- * The intended name for the root Element of the Document; what is also
- * listed within the DOCTYPE declaration.
- * @return String
- */
- public String getRootElementName() {
- return "settings"; //$NON-NLS-1$
- }
-
- public void load() {
- document = getParsedDocument(getFilename());
-
- if (document == null) {
- document = createDefaultPreferences();
- }
- }
-
- public void removePreferenceChangeListener(PreferenceChangeListener l) {
- preferenceChangeListeners.remove(l);
- }
-
- public void save() {
- if (document == null) {
- document = createDefaultPreferences();
- }
- try {
- // pa_TODO is this still going to be done like this?
- FileWriter output = new FileWriter(getFilename());
- saveDocument(document, output);
- output.flush();
- output.close();
- }
- catch (IOException e) {
- Logger.logException("Program Error: PreferenceManager::save. Exception saving preferences ", e); //$NON-NLS-1$
- throw new PreferenceRuntimeException(e);
- }
- firePreferenceChangeListeners();
- }
-
- public void saveDocument(Document document, Writer writer) throws IOException {
-
- serialize(document, writer);
- }
-
- private void serialize(Document sourceDocument, Writer writer) throws IOException {
- Source domSource = new DOMSource(sourceDocument);
- try {
- Transformer serializer = TransformerFactory.newInstance().newTransformer();
- try {
- serializer.setOutputProperty(OutputKeys.INDENT, "yes"); //$NON-NLS-1$
- serializer.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", "4"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- catch (IllegalArgumentException e) {
- // unsupported properties
- }
- serializer.transform(domSource, new StreamResult(writer));
- }
- catch (TransformerConfigurationException e) {
- throw new IOException(e.getMessage());
- }
- catch (TransformerFactoryConfigurationError e) {
- throw new IOException(e.getMessage());
- }
- catch (TransformerException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- private DocumentBuilder getDocumentBuilder() {
- DocumentBuilder result = null;
- try {
- result = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- }
- catch (ParserConfigurationException e) {
- Logger.logException(e);
- }
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractColorPage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractColorPage.java
deleted file mode 100644
index cdf073d0dd..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractColorPage.java
+++ /dev/null
@@ -1,309 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.preferences.PreferenceManager;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-
-public abstract class AbstractColorPage extends org.eclipse.jface.preference.PreferencePage implements org.eclipse.ui.IWorkbenchPreferencePage {
-
- protected StyledTextColorPicker fPicker = null;
-
- protected Control createContents(Composite parent) {
- // create scrollbars for this preference page when needed
- final ScrolledComposite sc1 = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- sc1.setLayoutData(new GridData(GridData.FILL_BOTH));
- Composite pageComponent = createComposite(sc1, 1);
- sc1.setContent(pageComponent);
-
- Label descLabel = createDescriptionLabel(pageComponent, ResourceHandler.getString("AbstractColorPageDescription")); //$NON-NLS-1$
- Composite coloringComposite = createColoringComposite(pageComponent);
-
- createContentsForPicker(coloringComposite);
-
- GridData gd = (GridData) descLabel.getLayoutData();
- gd.widthHint = (coloringComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT)).x;
- setSize(pageComponent);
- return pageComponent;
- }
-
- /**
- * Creates the coloring group used in createContents
- * This method can be overwritten to set the text of the group
- * or provide an infopop
- */
- protected Composite createColoringComposite(Composite parent) {
- Composite coloringComposite = createComposite(parent, 1);
- return coloringComposite;
- }
-
- /**
- * Creates the StyledTextColorPicker used in createContents
- * This method can be overwritten to set up StyledTextColorPicker
- * differently
- */
- protected void createContentsForPicker(Composite parent) {
- // create the color picker
- fPicker = new StyledTextColorPicker(parent, SWT.NULL);
- GridData data = new GridData(GridData.FILL_BOTH);
- fPicker.setLayoutData(data);
- fPicker.setColorsNode(getColorManager().getRootElement().cloneNode(true));
- fPicker.setDefaultColorsNode(getColorManager().createDefaultPreferences().getDocumentElement());
-
- setupPicker(fPicker);
-
- fPicker.setText(getSampleText());
- }
-
- /**
- * Sets the size of composite to the default value
- */
- protected void setSize(Composite composite) {
- if (composite != null) {
- Point minSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- composite.setSize(minSize);
- // set scrollbar composite's min size so page is expandable but has scrollbars when needed
- if (composite.getParent() instanceof ScrolledComposite) {
- ScrolledComposite sc1 = (ScrolledComposite) composite.getParent();
- sc1.setMinSize(minSize);
- sc1.setExpandHorizontal(true);
- sc1.setExpandVertical(true);
- }
- }
- }
-
- /**
- * Create description label displayed at top of preference page. This
- * method/label is used instead of PreferencePage's description label
- * because the ScrolledComposite contained in this page will not fully
- * work (horizontal scrolling) with PreferencePage's description label.
- */
- protected Label createDescriptionLabel(Composite parent, String description) {
- Label label = new Label(parent, SWT.LEFT | SWT.WRAP);
- label.setText(description);
-
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.grabExcessHorizontalSpace = true;
- label.setLayoutData(data);
-
- return label;
- }
-
- /**
- * Creates composite control and sets the default layout data.
- */
- protected Composite createComposite(Composite parent, int numColumns) {
- Composite composite = new Composite(parent, SWT.NULL);
-
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
- return composite;
- }
-
- /**
- * Creates composite control and sets the default layout data.
- */
-
- protected Group createGroup(Composite parent, int numColumns) {
- Group group = new Group(parent, SWT.NULL);
-
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- group.setLayout(layout);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- group.setLayoutData(data);
-
- return group;
- }
-
- /**
- * Utility method that creates a label instance
- * and sets the default layout data.
- */
- protected Label createLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
- GridData data = new GridData(GridData.FILL);
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- protected Button createPushButton(Composite parent, String label) {
- Button button = new Button(parent, SWT.PUSH);
- button.setText(label);
- GridData data = new GridData(GridData.FILL);
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
- return button;
- }
-
- /**
- * Utility method that creates a text instance
- * and sets the default layout data.
- */
- protected Text createTextField(Composite parent, String text) {
- Text textfield = new Text(parent, SWT.LEFT);
- textfield.setText(text);
- GridData data = new GridData(GridData.FILL);
- data.horizontalAlignment = GridData.FILL;
- textfield.setLayoutData(data);
- return textfield;
- }
-
- public void dispose() {
- super.dispose();
- if (fPicker != null && !fPicker.isDisposed())
- fPicker.releasePickerResources();
- }
-
- protected abstract PreferenceManager getColorManager();
-
- public StyledTextColorPicker getPicker() {
- return fPicker;
- }
-
- public abstract String getSampleText();
-
- protected Node getSetting(String settingName) {
- if (getColorManager().getRootElement() == null)
- return null;
- NodeList settingsList = getColorManager().getRootElement().getChildNodes();
- for (int k = 0; k < settingsList.getLength(); k++) {
- Node setting = settingsList.item(k);
- if (setting.getNodeType() != Node.TEXT_NODE && setting.getNodeName().equals(settingName)) {
- return setting;
- }
- }
- // Hopefully, this only happens if the UI preferences have new settings not reflected in the user's
- // stored Document
- Node namedSetting = null;
- Document defaultDoc = getColorManager().createDefaultPreferences();
- NodeList possibleSettings = defaultDoc.getDocumentElement().getChildNodes();
- for (int i = 0; i < possibleSettings.getLength(); i++) {
- if (possibleSettings.item(i).getNodeName().equals(settingName)) {
- namedSetting = possibleSettings.item(i).cloneNode(true);
- if (getColorManager().getDocument() != null)
- namedSetting = getColorManager().getDocument().importNode(namedSetting, true);
- getColorManager().getRootElement().appendChild(namedSetting);
- break;
- }
- }
- if (namedSetting == null)
- namedSetting = getColorManager().getNode(getColorManager().getDocument(), getColorManager().getRootElementName() + "/" + settingName);//$NON-NLS-1$
- return namedSetting;
- }
-
- /**
- * Initializes this preference page for the given workbench.
- * <p>
- * This method is called automatically as the preference page is being created
- * and initialized. Clients must not call this method.
- * </p>
- *
- * @param workbench the workbench
- */
- public void init(IWorkbench workbench) {
- }
-
- /**
- * Initializes states of the controls using default values
- * in the preference store.
- */
- protected void performDefaults() {
- fPicker.setColorsNode(getColorManager().createDefaultPreferences().getDocumentElement().cloneNode(true));
- fPicker.refresh();
- }
-
- public boolean performOk() {
- // get new
- Node newColors = fPicker.getColorsNode();
- if (newColors != null) {
- // remove old
- Document persistentDocument = getColorManager().getDocument();
- while (persistentDocument.getFirstChild() != null)
- persistentDocument.removeChild(persistentDocument.getFirstChild());
- // add new
- Node persistentColors = newColors.cloneNode(true);
- persistentColors = persistentDocument.importNode(persistentColors, true);
- persistentDocument.appendChild(persistentColors);
- }
-
- getColorManager().save();
- return true;
- }
-
- protected abstract void setupPicker(StyledTextColorPicker picker);
-
- public void setVisible(boolean visible) {
- boolean doShrink = false;
- // limiter, for the really huge fonts
- if (visible) {
- getPicker().refresh();
- int x = Math.min(getControl().getShell().getSize().x, getControl().getDisplay().getClientArea().width * 9 / 10);
- int y = Math.min(getControl().getShell().getSize().y, getControl().getDisplay().getClientArea().height * 9 / 10);
- boolean shrinkWidth = (x != getControl().getShell().getSize().x);
- boolean shrinkHeight = (y != getControl().getShell().getSize().y);
- doShrink = shrinkWidth || shrinkHeight;
- if (doShrink) {
- // modify just the height
- if (shrinkHeight && !shrinkWidth)
- getShell().setBounds(getShell().getLocation().x, 0, getShell().getSize().x, getControl().getDisplay().getClientArea().height);
- // modify just the width
- else if (!shrinkHeight && shrinkWidth)
- getShell().setBounds(0, getShell().getLocation().y, getControl().getDisplay().getClientArea().width, getShell().getSize().y);
- // change the entire shell size to only fill the display, and move it to the origin
- else
- getShell().setBounds(0, 0, getControl().getDisplay().getClientArea().width, getControl().getDisplay().getClientArea().height);
- }
- }
- super.setVisible(visible);
- if (doShrink) {
- getControl().getShell().redraw();
- getControl().getShell().update();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferencePage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferencePage.java
deleted file mode 100644
index 5de72f6d83..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferencePage.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.custom.ScrolledComposite;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * (pa) why is this class abstract if there are no abstract methods?
- */
-public abstract class AbstractPreferencePage extends PreferencePage implements ModifyListener, SelectionListener, IWorkbenchPreferencePage {
-
- protected final static int WIDTH_VALIDATION_LOWER_LIMIT = 0; //$NON-NLS-1$
- protected final static int WIDTH_VALIDATION_UPPER_LIMIT = 999; //$NON-NLS-1$
-
- protected Control createContents(Composite parent) {
- // create scrollbars for this preference page when needed
- final ScrolledComposite sc1 = new ScrolledComposite(parent, SWT.H_SCROLL | SWT.V_SCROLL);
- sc1.setLayoutData(new GridData(GridData.FILL_BOTH));
- Composite composite = createComposite(sc1, 1);
- sc1.setContent(composite);
-
- // assuming 'pageComponent' is the "main page"
- // no real need for line of code below
-
- // not calling setSize for page will result in a blank page, so calling it here initially
- // setSize actually needs to be called after all controls are created, so scrolledComposite
- // has correct minSize
- setSize(composite);
- return composite;
- }
-
- protected void setSize(Composite composite) {
- if (composite != null) {
- Point minSize = composite.computeSize(SWT.DEFAULT, SWT.DEFAULT);
- composite.setSize(minSize);
- // set scrollbar composite's min size so page is expandable but has scrollbars when needed
- if (composite.getParent() instanceof ScrolledComposite) {
- ScrolledComposite sc1 = (ScrolledComposite) composite.getParent();
- sc1.setMinSize(minSize);
- sc1.setExpandHorizontal(true);
- sc1.setExpandVertical(true);
- }
- }
- }
-
- protected Button createCheckBox(Composite group, String label) {
- Button button = new Button(group, SWT.CHECK | SWT.LEFT);
- button.setText(label);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.verticalAlignment = GridData.CENTER;
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
-
- return button;
- }
-
- protected Composite createComposite(Composite parent, int numColumns) {
- Composite composite = new Composite(parent, SWT.NULL);
-
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.horizontalIndent = 0;
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- composite.setLayoutData(data);
-
- return composite;
- }
-
- protected Group createGroup(Composite parent, int numColumns) {
- Group group = new Group(parent, SWT.NULL);
-
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- group.setLayout(layout);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.horizontalIndent = 0;
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- group.setLayoutData(data);
-
- return group;
- }
-
- protected Label createLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
-
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.verticalAlignment = GridData.CENTER;
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
-
- return label;
- }
-
- protected Button createRadioButton(Composite group, String label) {
- Button button = new Button(group, SWT.RADIO);
- button.setText(label);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.verticalAlignment = GridData.CENTER;
- data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
-
- return button;
- }
-
- protected Label createSeparator(Composite parent, int columnSpan) {
- // Create a spacer line
- Label separator = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.verticalAlignment = GridData.CENTER;
- data.horizontalAlignment = GridData.FILL;
- data.horizontalSpan = columnSpan;
-
- separator.setLayoutData(data);
- return separator;
- }
-
- protected Text createTextField(Composite parent) {
- Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
-
- //GridData
- GridData data = new GridData();
- data.verticalAlignment = GridData.CENTER;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- text.setLayoutData(data);
-
- return text;
- }
-
- protected Combo createDropDownBox(Composite parent) {
- Combo comboBox = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
-
- //GridData
- GridData data = new GridData();
- data.verticalAlignment = GridData.CENTER;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- comboBox.setLayoutData(data);
-
- return comboBox;
- }
-
- public void init(IWorkbench workbench) {
- }
-
- protected boolean loadPreferences() {
- BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
- public void run() {
- initializeValues();
- validateValues();
- enableValues();
- }
- });
- return true;
- }
-
- protected boolean savePreferences() {
- BusyIndicator.showWhile(getControl().getDisplay(), new Runnable() {
- public void run() {
- storeValues();
- }
- });
- return true;
- }
-
- protected void performDefaults() {
- super.performDefaults();
- }
-
- public boolean performOk() {
- savePreferences();
- return true;
- }
-
- protected void setInvalidInputMessage(String widthText) {
- String msg = ResourceHandler.getString("4concat", (new Object[]{widthText})); //$NON-NLS-1$ = "''{0}'' is not a valid input"
- setErrorMessage(msg);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
- // If we are called too early, i.e. before the controls are created then return
- // to avoid null pointer exceptions
- if (e.widget != null && e.widget.isDisposed())
- return;
-
- validateValues();
- enableValues();
- }
-
- public void modifyText(ModifyEvent e) {
- // If we are called too early, i.e. before the controls are created then return
- // to avoid null pointer exceptions
- if (e.widget != null && e.widget.isDisposed())
- return;
-
- validateValues();
- enableValues();
- }
-
- protected void initializeValues() {
- }
-
- protected void validateValues() {
- }
-
- protected void enableValues() {
- }
-
- protected void storeValues() {
- EditorPlugin.getDefault().savePluginPreferences();
- }
-
- private IModelManagerPlugin getModelManagerPlugin() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- protected Preferences getModelPreferences() {
- return getModelManagerPlugin().getPluginPreferences();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferenceTab.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferenceTab.java
deleted file mode 100644
index 5ab136557a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/AbstractPreferenceTab.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.FontMetrics;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * Generic preference tab page that contains helpful methods
- * @author amywu
- */
-abstract public class AbstractPreferenceTab implements IPreferenceTab {
- private SelectionListener fCheckBoxListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- Button button = (Button) e.widget;
- fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
- private ModifyListener fNumberFieldListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- numberFieldChanged((Text) e.widget);
- }
- };
- private ModifyListener fTextFieldListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Text text = (Text) e.widget;
- fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
- }
- };
-
- private Map fCheckBoxes = new HashMap();
- private ArrayList fNumberFields = new ArrayList();
- private Map fTextFields = new HashMap();
- private PreferencePage fMainPreferencePage;
- private OverlayPreferenceStore fOverlayStore;
-
- /**
- * @return Returns the fMainPreferencePage.
- */
- protected PreferencePage getMainPreferencePage() {
- return fMainPreferencePage;
- }
- /**
- * @param mainPreferencePage The fMainPreferencePage to set.
- */
- protected void setMainPreferencePage(PreferencePage mainPreferencePage) {
- fMainPreferencePage = mainPreferencePage;
- }
- /**
- * @return Returns the fOverlayStore.
- */
- protected OverlayPreferenceStore getOverlayStore() {
- return fOverlayStore;
- }
- /**
- * @param overlayStore The fOverlayStore to set.
- */
- protected void setOverlayStore(OverlayPreferenceStore overlayStore) {
- fOverlayStore = overlayStore;
- }
-
- protected Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText(label);
-
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent = indentation;
- gd.horizontalSpan = 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- protected Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
- return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
- }
-
- private Text getTextControl(Control[] labelledTextField) {
- return (Text) labelledTextField[1];
- }
-
- /**
- * Returns an array of size 2:
- * - first element is of type <code>Label</code>
- * - second element is of type <code>Text</code>
- * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
- */
- private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
- Label labelControl = new Label(composite, SWT.NONE);
- labelControl.setText(label);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent = indentation;
- labelControl.setLayoutData(gd);
-
- Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.widthHint = convertWidthInCharsToPixels(textControl, textLimit + 1);
- textControl.setLayoutData(gd);
- textControl.setTextLimit(textLimit);
- fTextFields.put(textControl, key);
- if (isNumber) {
- fNumberFields.add(textControl);
- textControl.addModifyListener(fNumberFieldListener);
- }
- else {
- textControl.addModifyListener(fTextFieldListener);
- }
-
- return new Control[]{labelControl, textControl};
- }
-
- private void numberFieldChanged(Text textControl) {
- String number = textControl.getText();
- IStatus status = validatePositiveNumber(number);
- if (!status.matches(IStatus.ERROR))
- fOverlayStore.setValue((String) fTextFields.get(textControl), number);
- updateStatus(status);
- }
-
- private IStatus validatePositiveNumber(String number) {
- StatusInfo status = new StatusInfo();
- if (number.length() == 0) {
- status.setError(ResourceHandler.getString("StructuredTextEditorPreferencePage.37")); //$NON-NLS-1$
- }
- else {
- try {
- int value = Integer.parseInt(number);
- if (value < 0)
- status.setError(number + ResourceHandler.getString("StructuredTextEditorPreferencePage.38")); //$NON-NLS-1$
- }
- catch (NumberFormatException e) {
- status.setError(number + ResourceHandler.getString("StructuredTextEditorPreferencePage.39")); //$NON-NLS-1$
- }
- }
- return status;
- }
-
- protected void initializeFields() {
- Iterator e = fCheckBoxes.keySet().iterator();
- while (e.hasNext()) {
- Button b = (Button) e.next();
- String key = (String) fCheckBoxes.get(b);
- b.setSelection(fOverlayStore.getBoolean(key));
- }
-
- e = fTextFields.keySet().iterator();
- while (e.hasNext()) {
- Text t = (Text) e.next();
- String key = (String) fTextFields.get(t);
- t.setText(fOverlayStore.getString(key));
- }
- }
-
- /**
- * Update status of main preference page
- * @param status
- */
- protected void updateStatus(IStatus status) {
- if (!status.matches(IStatus.ERROR)) {
- for (int i = 0; i < fNumberFields.size(); i++) {
- Text text = (Text) fNumberFields.get(i);
- IStatus s = validatePositiveNumber(text.getText());
- status = s.getSeverity() > status.getSeverity() ? s : status;
- }
- }
-
- fMainPreferencePage.setValid(!status.matches(IStatus.ERROR));
- applyToStatusLine(status);
- }
-
- /**
- * Applies the status to the status line of a dialog page.
- */
- private void applyToStatusLine(IStatus status) {
- String message = status.getMessage();
- switch (status.getSeverity()) {
- case IStatus.OK :
- fMainPreferencePage.setMessage(message, IMessageProvider.NONE);
- fMainPreferencePage.setErrorMessage(null);
- break;
- case IStatus.WARNING :
- fMainPreferencePage.setMessage(message, IMessageProvider.WARNING);
- fMainPreferencePage.setErrorMessage(null);
- break;
- case IStatus.INFO :
- fMainPreferencePage.setMessage(message, IMessageProvider.INFORMATION);
- fMainPreferencePage.setErrorMessage(null);
- break;
- default :
- if (message.length() == 0) {
- message = null;
- }
- fMainPreferencePage.setMessage(null);
- fMainPreferencePage.setErrorMessage(message);
- break;
- }
- }
-
- /**
- * Returns the number of pixels corresponding to the width of the given
- * number of characters. This method was copied from org.eclipse.jface.dialogs.DialogPage
- * <p>
- * @param a control in the page
- * @param chars
- * the number of characters
- * @return the number of pixels
- */
- private int convertWidthInCharsToPixels(Control testControl, int chars) {
- // Compute and store a font metric
- GC gc = new GC(testControl);
- gc.setFont(JFaceResources.getDialogFont());
- FontMetrics fontMetrics = gc.getFontMetrics();
- gc.dispose();
-
- // test for failure to initialize for backward compatibility
- if (fontMetrics == null)
- return 0;
- return Dialog.convertWidthInCharsToPixels(fontMetrics, chars);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorEditor.java
deleted file mode 100644
index 70f8109488..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorEditor.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.ACC;
-import org.eclipse.swt.accessibility.AccessibleControlAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.ColorDialog;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-
-/**
- * A "button" of a certain color determined by the color picker.
- */
-public class ColorEditor {
-
- private Point fExtent;
- private Image fImage;
- private RGB fColorValue;
- private Color fColor;
- private Button fButton;
-
- public ColorEditor(Composite parent) {
-
- fButton = new Button(parent, SWT.PUSH);
- fExtent = computeImageSize(parent);
- fImage = new Image(parent.getDisplay(), fExtent.x, fExtent.y);
-
- GC gc = new GC(fImage);
- gc.setBackground(fButton.getBackground());
- gc.fillRectangle(0, 0, fExtent.x, fExtent.y);
- gc.dispose();
-
- fButton.setImage(fImage);
-
- // bug2541 - associate color value to button's value field
- fButton.getAccessible().addAccessibleControlListener(new AccessibleControlAdapter() {
- /**
- * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getValue(AccessibleControlEvent)
- */
- public void getValue(AccessibleControlEvent e) {
- if (e.childID == ACC.CHILDID_SELF) {
- if (getColorValue() != null)
- e.result = getColorValue().toString();
- else
- e.result = null;
- }
- }
- });
-
- fButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent event) {
- ColorDialog colorDialog = new ColorDialog(fButton.getShell());
- colorDialog.setRGB(fColorValue);
- RGB newColor = colorDialog.open();
- if (newColor != null) {
- fColorValue = newColor;
- updateColorImage();
- }
- }
- });
-
- fButton.addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent event) {
- if (fImage != null) {
- fImage.dispose();
- fImage = null;
- }
- if (fColor != null) {
- fColor.dispose();
- fColor = null;
- }
- }
- });
- }
-
- public RGB getColorValue() {
- return fColorValue;
- }
-
- public void setColorValue(RGB rgb) {
- fColorValue = rgb;
- updateColorImage();
- }
-
- public Button getButton() {
- return fButton;
- }
-
- protected void updateColorImage() {
-
- Display display = fButton.getDisplay();
-
- GC gc = new GC(fImage);
- gc.setForeground(display.getSystemColor(SWT.COLOR_BLACK));
- gc.drawRectangle(0, 2, fExtent.x - 1, fExtent.y - 4);
-
- if (fColor != null)
- fColor.dispose();
-
- fColor = new Color(display, fColorValue);
- gc.setBackground(fColor);
- gc.fillRectangle(1, 3, fExtent.x - 2, fExtent.y - 5);
- gc.dispose();
-
- fButton.setImage(fImage);
- }
-
- protected Point computeImageSize(Control window) {
- GC gc = new GC(window);
- Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
- gc.setFont(f);
- int height = gc.getFontMetrics().getHeight();
- gc.dispose();
- Point p = new Point(height * 3 - 6, height);
- return p;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorHelper.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorHelper.java
deleted file mode 100644
index b0b08a8a8f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorHelper.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-
-
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-public class ColorHelper {
-
- public final static String NAME = "name";//$NON-NLS-1$
- public final static String FOREGROUND = "foreground";//$NON-NLS-1$
- public final static String BACKGROUND = "background";//$NON-NLS-1$
- public final static String BOLD = "bold";//$NON-NLS-1$
-
- /**
- * @return org.eclipse.swt.graphics.RGB
- * @param anRGBString java.lang.String
- */
- public static RGB toRGB(String anRGBString) {
- RGB result = null;
- if (anRGBString.length() > 6 && anRGBString.charAt(0) == '#') {
- int r = 0;
- int g = 0;
- int b = 0;
- try {
- r = Integer.valueOf(anRGBString.substring(1, 3), 16).intValue();
- g = Integer.valueOf(anRGBString.substring(3, 5), 16).intValue();
- b = Integer.valueOf(anRGBString.substring(5, 7), 16).intValue();
- result = new RGB(r, g, b);
- }
- catch (NumberFormatException nfExc) {
- Logger.logException("Could not load highlighting preference for color " + anRGBString, nfExc);//$NON-NLS-1$
- }
- }
- return result;
- }
-
- /**
- * @return java.lang.String
- * @param anRGB org.eclipse.swt.graphics.RGB
- */
- public static String toRGBString(RGB anRGB) {
- if (anRGB == null)
- return "#000000";//$NON-NLS-1$
- String red = Integer.toHexString(anRGB.red);
- while (red.length() < 2)
- red = "0" + red;//$NON-NLS-1$
- String green = Integer.toHexString(anRGB.green);
- while (green.length() < 2)
- green = "0" + green;//$NON-NLS-1$
- String blue = Integer.toHexString(anRGB.blue);
- while (blue.length() < 2)
- blue = "0" + blue;//$NON-NLS-1$
- return "#" + red + green + blue;//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorNames.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorNames.java
deleted file mode 100644
index d22e72b96f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/ColorNames.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-
-
-public interface ColorNames {
-
- String COLORS = "colors"; //$NON-NLS-1$
- String COLOR = "color"; //$NON-NLS-1$
-
- String NAME = "name"; //$NON-NLS-1$
- String FOREGROUND = "foreground"; //$NON-NLS-1$
- String BACKGROUND = "background"; //$NON-NLS-1$
- String BOLD = "bold"; //$NON-NLS-1$
- String ITALIC = "italic"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/EditStructuredTextEditorPreferencesAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/EditStructuredTextEditorPreferencesAction.java
deleted file mode 100644
index ef57e5bad9..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/EditStructuredTextEditorPreferencesAction.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.preference.IPreferenceNode;
-import org.eclipse.jface.preference.PreferenceDialog;
-import org.eclipse.jface.preference.PreferenceManager;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.util.DocumentInputStream;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.extension.ExtendedConfigurationBuilder;
-import org.eclipse.wst.sse.ui.extension.IExtendedEditorAction;
-import org.eclipse.wst.sse.ui.extension.IExtendedSimpleEditor;
-import org.eclipse.wst.sse.ui.extensions.ConfigurationPointCalculator;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * This action displays the preferences relative to the current editor
- * @author amywu
- */
-public class EditStructuredTextEditorPreferencesAction extends Action implements IExtendedEditorAction {
- private final String EXTENSION_TYPE_ID = "preferencepages"; //$NON-NLS-1$
- private final String EXTENSION_ATTRIBUTE_PREFERENCE_IDS = "preferenceids"; //$NON-NLS-1$
- private IExtendedSimpleEditor fEditor;
-
- public EditStructuredTextEditorPreferencesAction() {
- super(ResourceHandler.getString("EditPreferences.label"), EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_OBJ_PREFERENCES)); //$NON-NLS-1$
- }
-
- /**
- * Open the given preference page in a preference dialog.
- *
- * @param shell
- * The shell to open on
- * @param manager
- * The preference manager to use/display in the preference
- * dialog
- * @return Returns <code>true</code> if the user ended the page by
- * pressing OK.
- */
- public boolean showPreferencePage(Shell shell, PreferenceManager manager) {
- final PreferenceDialog dialog = new PreferenceDialog(shell, manager);
- final boolean[] result = new boolean[]{false};
- BusyIndicator.showWhile(shell.getDisplay(), new Runnable() {
- public void run() {
- dialog.create();
- dialog.setMessage(ResourceHandler.getString("EditStructuredTextEditorPreferencesAction.0")); //$NON-NLS-1$
- result[0] = (dialog.open() == Window.OK);
- }
- });
- return result[0];
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- PreferenceManager manager = buildPreferenceManager();
- if (manager != null) {
- showPreferencePage(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), manager);
- }
- }
-
- private IModelManager getModelManager() {
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- /**
- * Return the content type of the current fEditor for this action
- *
- * @return content type identifier of the current fEditor
- */
- private String getContentType() {
- String contentType = null;
-
- IStructuredModel model = getModelManager().getExistingModelForRead(getEditor().getDocument());
- if (model != null) {
- contentType = model.getContentTypeIdentifier();
- model.releaseFromRead();
- }
- if(contentType == null) {
- IContentType type = null;
- try {
- type = Platform.getContentTypeManager().findContentTypeFor(new DocumentInputStream(getEditor().getDocument()), getEditor().getEditorPart().getEditorInput().getName());
- }
- catch (IOException e) {
- // do nothing, shouldn't even be possible
- }
- if(type != null) {
- contentType = type.getId();
- }
- }
- return contentType;
- }
-
- /**
- * Create the preference manager to use to display in the preference
- * dialog
- *
- * @return a preference manager or null if there is no editor/preference
- * page to display
- */
- protected PreferenceManager buildPreferenceManager() {
- if (getEditor() == null) {
- return null;
- }
-
- // gather all preference page ids to display
- String[] ids = buildPreferencePageIds();
-
- // if no preference pages to display, return null
- if (ids.length == 0) {
- return null;
- }
-
- // create a new preference manager for this action/dialog
- PreferenceManager manager = new PreferenceManager();
-
- // get the workbench preference manager
- PreferenceManager platformManager = PlatformUI.getWorkbench().getPreferenceManager();
-
- for (int i = 0; i < ids.length; ++i) {
- final IPreferenceNode targetNode = platformManager.find(ids[i]);
- if (targetNode != null) {
- manager.addToRoot(targetNode);
- }
- }
-
- return manager;
- }
-
- /**
- * Create a list of preference page ids of the preference pages to display
- *
- * @return String[]
- */
- protected String[] buildPreferencePageIds() {
- List prefIds = new ArrayList();
-
- // figure out all preference page ids contributed
- String[] pointIds = null;
- if(getEditor() instanceof IEditorPart) {
- pointIds = ConfigurationPointCalculator.getConfigurationPoints((IEditorPart) getEditor(), getContentType(), ConfigurationPointCalculator.SOURCE, StructuredTextEditor.class);
- }
- else {
- pointIds = ConfigurationPointCalculator.getConfigurationPoints(getEditor().getEditorPart(), getContentType(), ConfigurationPointCalculator.SOURCE, StructuredTextEditor.class);
- }
- ExtendedConfigurationBuilder builder = ExtendedConfigurationBuilder.getInstance();
-
- // go through each configuration point and extract the preference page
- // ids
- // going through configuration points backwards so base fEditor
- // preferences show up first
- for (int i = pointIds.length - 1; i >= 0; --i) {
- IConfigurationElement config = builder.getConfigurationElement(EXTENSION_TYPE_ID, pointIds[i]);
- // get the list of preference page ids from the preferenceids
- // attribute
- if (config != null) {
- String preferenceIdsString = config.getAttribute(EXTENSION_ATTRIBUTE_PREFERENCE_IDS);
- // separate out the list of preference ids
- if (preferenceIdsString != null) {
- StringTokenizer tokenizer = new StringTokenizer(preferenceIdsString, ","); //$NON-NLS-1$
- while (tokenizer.hasMoreTokens()) {
- String prefId = tokenizer.nextToken().trim();
- prefIds.add(prefId);
- }
- }
- }
- }
- return (String[]) prefIds.toArray(new String[prefIds.size()]);
- }
-
- private IExtendedSimpleEditor getEditor() {
- return fEditor;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void setActiveExtendedEditor(IExtendedSimpleEditor targetEditor) {
- fEditor = targetEditor;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean isVisible() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- if (getEditor() == null) {
- setEnabled(false);
- }
- else {
- setEnabled(true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/FilePreferencePage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/FilePreferencePage.java
deleted file mode 100644
index ac23c312b5..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/FilePreferencePage.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-
-
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.wst.sse.ui.internal.preferences.TabFolderLayout;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class FilePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private IPreferenceTab[] fTabs = null;
-
- public void init(IWorkbench desktop) {
- }
-
- protected Control createContents(Composite parent) {
- Composite composite = createComposite(parent, 1);
-
- String description = ResourceHandler.getString("FilePreferencePage.0"); //$NON-NLS-1$
- createLabel(composite, description);
- createLabel(composite, ""); //$NON-NLS-1$
-
- TabFolder folder = new TabFolder(composite, SWT.NONE);
- folder.setLayout(new TabFolderLayout());
- folder.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TabItem taskItem = new TabItem(folder, SWT.NONE);
- IPreferenceTab tasksTab = new TaskTagPreferenceTab();
- taskItem.setText(tasksTab.getTitle());
- Control taskTags = tasksTab.createContents(folder);
- taskItem.setControl(taskTags);
-
- TabItem translucenceItem = new TabItem(folder, SWT.NONE);
- IPreferenceTab translucenceTab = new TranslucencyPreferenceTab();
- translucenceItem.setText(translucenceTab.getTitle());
- Control translucenceControl = translucenceTab.createContents(folder);
- translucenceItem.setControl(translucenceControl);
-
- fTabs = new IPreferenceTab[]{tasksTab, translucenceTab};
-
- return composite;
- }
-
- protected Composite createComposite(Composite parent, int numColumns) {
- Composite composite = new Composite(parent, SWT.NULL);
-
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- composite.setLayout(layout);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.horizontalIndent = 0;
- data.verticalAlignment = GridData.FILL_VERTICAL;
- data.horizontalAlignment = GridData.FILL_HORIZONTAL;
- composite.setLayoutData(data);
-
- return composite;
- }
-
- protected Label createLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
-
- //GridData
- GridData data = new GridData(GridData.FILL);
- data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
- label.setLayoutData(data);
-
- return label;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.PreferencePage#performApply()
- */
- protected void performApply() {
- super.performApply();
- for (int i = 0; i < fTabs.length; i++) {
- fTabs[i].performApply();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- super.performDefaults();
- for (int i = 0; i < fTabs.length; i++) {
- fTabs[i].performDefaults();
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- boolean ok = super.performOk();
- for (int i = 0; i < fTabs.length; i++) {
- fTabs[i].performOk();
- }
- return ok;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/IPreferenceTab.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/IPreferenceTab.java
deleted file mode 100644
index 5e94957759..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/IPreferenceTab.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-
-public interface IPreferenceTab {
-
- Control createContents(Composite tabFolder);
-
- String getTitle();
-
- void performApply();
- void performDefaults();
- void performOk();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/NavigationPreferenceTab.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/NavigationPreferenceTab.java
deleted file mode 100644
index 23a8681b5a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/NavigationPreferenceTab.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import java.text.MessageFormat;
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.preferences.CommonEditorPreferenceNames;
-import org.eclipse.wst.sse.ui.util.EditorUtility;
-
-
-/**
- * Preference page tab that contains Navigation preferences
- * @author amywu
- */
-public class NavigationPreferenceTab extends AbstractPreferenceTab {
- private static final String DELIMITER = "+"; //$NON-NLS-1$
-
- private Text fBrowserLikeLinksKeyModifierText;
- private Button fBrowserLikeLinksCheckBox;
-
- public NavigationPreferenceTab(PreferencePage mainPreferencePage, OverlayPreferenceStore store) {
- Assert.isNotNull(mainPreferencePage);
- Assert.isNotNull(store);
- setMainPreferencePage(mainPreferencePage);
- setOverlayStore(store);
- getOverlayStore().addKeys(createOverlayStoreKeys());
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
- ArrayList overlayKeys = new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CommonEditorPreferenceNames.LINK_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CommonEditorPreferenceNames.BROWSER_LIKE_LINKS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER));
-
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /* (non-Javadoc)
- */
- public Control createContents(Composite tabFolder) {
- Composite composite = new Composite(tabFolder, SWT.NULL);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- composite.setLayout(layout);
-
- String text = ResourceHandler.getString("StructuredTextEditorPreferencePage.7"); //$NON-NLS-1$
- fBrowserLikeLinksCheckBox = addCheckBox(composite, text, CommonEditorPreferenceNames.BROWSER_LIKE_LINKS, 0);
- fBrowserLikeLinksCheckBox.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- boolean state = fBrowserLikeLinksCheckBox.getSelection();
- fBrowserLikeLinksKeyModifierText.setEnabled(state);
- handleBrowserLikeLinksKeyModifierModified();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- // Text field for modifier string
- text = ResourceHandler.getString("StructuredTextEditorPreferencePage.8"); //$NON-NLS-1$
- fBrowserLikeLinksKeyModifierText = addTextField(composite, text, CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER, 20, 0, false);
- fBrowserLikeLinksKeyModifierText.setTextLimit(Text.LIMIT);
-
- if (EditorUtility.computeStateMask(getOverlayStore().getString(CommonEditorPreferenceNames.BROWSER_LIKE_LINKS_KEY_MODIFIER)) == -1) {
- fBrowserLikeLinksKeyModifierText.setText(""); //$NON-NLS-1$
- }
-
- fBrowserLikeLinksKeyModifierText.addKeyListener(new KeyListener() {
- private boolean isModifierCandidate;
-
- public void keyPressed(KeyEvent e) {
- isModifierCandidate = e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
- }
-
- public void keyReleased(KeyEvent e) {
- if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
- String modifierString = fBrowserLikeLinksKeyModifierText.getText();
- Point selection = fBrowserLikeLinksKeyModifierText.getSelection();
- int i = selection.x - 1;
- while (i > -1 && Character.isWhitespace(modifierString.charAt(i))) {
- i--;
- }
- boolean needsPrefixDelimiter = i > -1 && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
-
- i = selection.y;
- while (i < modifierString.length() && Character.isWhitespace(modifierString.charAt(i))) {
- i++;
- }
- boolean needsPostfixDelimiter = i < modifierString.length() && !String.valueOf(modifierString.charAt(i)).equals(DELIMITER);
-
- String insertString;
-
- if (needsPrefixDelimiter && needsPostfixDelimiter)
- insertString = " \\ + " + Action.findModifierString(e.stateMask) + " + "; //$NON-NLS-1$ //$NON-NLS-2$
- else if (needsPrefixDelimiter)
- insertString = "\\ + " + Action.findModifierString(e.stateMask); //$NON-NLS-1$
- else if (needsPostfixDelimiter)
- insertString = "\\ " + Action.findModifierString(e.stateMask) + " + "; //$NON-NLS-1$ //$NON-NLS-2$
- else
- insertString = Action.findModifierString(e.stateMask);
-
- fBrowserLikeLinksKeyModifierText.insert(insertString);
- }
- }
- });
-
- fBrowserLikeLinksKeyModifierText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleBrowserLikeLinksKeyModifierModified();
- }
- });
-
- initializeFields();
-
- WorkbenchHelp.setHelp(composite, IHelpContextIds.PREFSTE_NAVIGATION_HELPID);
- return composite;
- }
-
- /* (non-Javadoc)
- */
- public String getTitle() {
- return ResourceHandler.getString("StructuredTextEditorPreferencePage.34"); //$NON-NLS-1$;
- }
-
- /* (non-Javadoc)
- */
- public void performApply() {
- // all preferences are stored in overlay store so main preference page should handle apply
- }
-
- /* (non-Javadoc)
- */
- public void performDefaults() {
- initializeFields();
- }
-
- /* (non-Javadoc)
- */
- public void performOk() {
- // all preferences are stored in overlay store so main preference page should handle OK
- }
-
- private void handleBrowserLikeLinksKeyModifierModified() {
- IStatus status = new StatusInfo();
-
- String modifiers = fBrowserLikeLinksKeyModifierText.getText();
- int stateMask = EditorUtility.computeStateMask(modifiers);
-
- if (fBrowserLikeLinksCheckBox.getSelection() && (stateMask == -1 || (stateMask & SWT.SHIFT) != 0)) {
- if (stateMask == -1) {
- MessageFormat messageFormat = new MessageFormat(ResourceHandler.getString("NavigationPreferenceTab.0")); //$NON-NLS-1$
- Object[] args = {modifiers};
- String message = messageFormat.format(args);
- status = new StatusInfo(IStatus.ERROR, message);
- }
- else
- status = new StatusInfo(IStatus.ERROR, ResourceHandler.getString("StructuredTextEditorPreferencePage.15")); //$NON-NLS-1$
- }
- updateStatus(status);
- }
-
- /*
- * (non-Javadoc)
- */
- protected void initializeFields() {
- super.initializeFields();
-
- // disable if checkbox is unchecked
- boolean state = fBrowserLikeLinksCheckBox.getSelection();
- fBrowserLikeLinksKeyModifierText.setEnabled(state);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StatusInfo.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StatusInfo.java
deleted file mode 100644
index aec5e50ed4..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StatusInfo.java
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.ui.editors.text.EditorsUI;
-
-/**
- * A settable IStatus.
- * Can be an error, warning, info or ok. For error, info and warning states,
- * a message describes the problem.
- *
- * This class was copied from other StatusInfo classes that are located in internal packages
- */
-class StatusInfo implements IStatus {
-
- /** The message of this status. */
- private String fStatusMessage;
- /** The severity of this status. */
- private int fSeverity;
-
- /**
- * Creates a status set to OK (no message).
- */
- public StatusInfo() {
- this(OK, null);
- }
-
- /**
- * Creates a status with the given severity and message.
- *
- * @param severity the severity of this status: ERROR, WARNING, INFO and OK.
- * @param message the message of this status. Applies only for ERROR,
- * WARNING and INFO.
- */
- public StatusInfo(int severity, String message) {
- fStatusMessage= message;
- fSeverity= severity;
- }
-
- /*
- * @see org.eclipse.core.runtime.IStatus#isOK()
- */
- public boolean isOK() {
- return fSeverity == IStatus.OK;
- }
-
- /**
- * Returns whether this status indicates a warning.
- *
- * @return <code>true</code> if this status has severity
- * {@link IStatus#WARNING} and <code>false</code> otherwise
- */
- public boolean isWarning() {
- return fSeverity == IStatus.WARNING;
- }
-
- /**
- * Returns whether this status indicates an info.
- *
- * @return <code>true</code> if this status has severity
- * {@link IStatus#INFO} and <code>false</code> otherwise
- */
- public boolean isInfo() {
- return fSeverity == IStatus.INFO;
- }
-
- /**
- * Returns whether this status indicates an error.
- *
- * @return <code>true</code> if this status has severity
- * {@link IStatus#ERROR} and <code>false</code> otherwise
- */
- public boolean isError() {
- return fSeverity == IStatus.ERROR;
- }
-
- /*
- * @see IStatus#getMessage()
- */
- public String getMessage() {
- return fStatusMessage;
- }
-
- /**
- * Sets the status to ERROR.
- *
- * @param errorMessage the error message which can be an empty string, but not <code>null</code>
- */
- public void setError(String errorMessage) {
- Assert.isNotNull(errorMessage);
- fStatusMessage= errorMessage;
- fSeverity= IStatus.ERROR;
- }
-
- /**
- * Sets the status to WARNING.
- *
- * @param warningMessage the warning message which can be an empty string, but not <code>null</code>
- */
- public void setWarning(String warningMessage) {
- Assert.isNotNull(warningMessage);
- fStatusMessage= warningMessage;
- fSeverity= IStatus.WARNING;
- }
-
- /**
- * Sets the status to INFO.
- *
- * @param infoMessage the info message which can be an empty string, but not <code>null</code>
- */
- public void setInfo(String infoMessage) {
- Assert.isNotNull(infoMessage);
- fStatusMessage= infoMessage;
- fSeverity= IStatus.INFO;
- }
-
- /**
- * Sets the status to OK.
- */
- public void setOK() {
- fStatusMessage= null;
- fSeverity= IStatus.OK;
- }
-
- /*
- * @see IStatus#matches(int)
- */
- public boolean matches(int severityMask) {
- return (fSeverity & severityMask) != 0;
- }
-
- /**
- * Returns always <code>false</code>.
- *
- * @see IStatus#isMultiStatus()
- */
- public boolean isMultiStatus() {
- return false;
- }
-
- /*
- * @see IStatus#getSeverity()
- */
- public int getSeverity() {
- return fSeverity;
- }
-
- /*
- * @see IStatus#getPlugin()
- */
- public String getPlugin() {
- return EditorsUI.PLUGIN_ID;
- }
-
- /**
- * Returns always <code>null</code>.
- *
- * @see IStatus#getException()
- */
- public Throwable getException() {
- return null;
- }
-
- /**
- * Returns always the error severity.
- *
- * @see IStatus#getCode()
- */
- public int getCode() {
- return fSeverity;
- }
-
- /**
- * Returns always <code>null</code>.
- *
- * @see IStatus#getChildren()
- */
- public IStatus[] getChildren() {
- return new IStatus[0];
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StructuredTextEditorPreferencePage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StructuredTextEditorPreferencePage.java
deleted file mode 100644
index 73c5f6e22f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StructuredTextEditorPreferencePage.java
+++ /dev/null
@@ -1,538 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.debug.internal.ui.actions.StatusInfo;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.DialogPage;
-import org.eclipse.jface.dialogs.IMessageProvider;
-import org.eclipse.jface.preference.PreferenceConverter;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.ACC;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.List;
-import org.eclipse.swt.widgets.TabFolder;
-import org.eclipse.swt.widgets.TabItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AbstractDecoratedTextEditorPreferenceConstants;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
-import org.eclipse.wst.sse.ui.internal.preferences.TabFolderLayout;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.preferences.CommonEditorPreferenceNames;
-
-
-/**
- * Gutted version of JavaEditorPreferencePage
- * @author pavery
- */
-public class StructuredTextEditorPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
- private Map fCheckBoxes = new HashMap();
- private SelectionListener fCheckBoxListener = new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- Button button = (Button) e.widget;
- fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection());
- }
- };
-
- private ArrayList fNumberFields = new ArrayList();
- private ModifyListener fNumberFieldListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- numberFieldChanged((Text) e.widget);
- }
- };
-
- private Map fTextFields = new HashMap();
- private ModifyListener fTextFieldListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- Text text = (Text) e.widget;
- fOverlayStore.setValue((String) fTextFields.get(text), text.getText());
- }
- };
-
- private Map fColorButtons = new HashMap();
- /** Button controlling default setting of the selected reference provider. */
- private Button fSetDefaultButton;
- private OverlayPreferenceStore fOverlayStore;
-
- private final String[][] fAppearanceColorListModel = new String[][]{{ResourceHandler.getString("StructuredTextEditorPreferencePage.1"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR}, {ResourceHandler.getString("StructuredTextEditorPreferencePage.2"), CommonEditorPreferenceNames.MATCHING_BRACKETS_COLOR}, {ResourceHandler.getString("StructuredTextEditorPreferencePage.3"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR}, {ResourceHandler.getString("StructuredTextEditorPreferencePage.4"), AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR}, {ResourceHandler.getString("StructuredTextEditorPreferencePage.5"), CommonEditorPreferenceNames.LINK_COLOR},}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- private List fAppearanceColorList;
- private ColorEditor fAppearanceColorEditor;
- private IPreferenceTab[] fTabs = null;
-
- public StructuredTextEditorPreferencePage() {
- setDescription(ResourceHandler.getString("StructuredTextEditorPreferencePage.6")); //$NON-NLS-1$
- setPreferenceStore(((AbstractUIPlugin)Platform.getPlugin(EditorPlugin.ID)).getPreferenceStore());
-
- fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), createOverlayStoreKeys());
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
- ArrayList overlayKeys = new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CommonEditorPreferenceNames.SHOW_QUICK_FIXABLES));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CommonEditorPreferenceNames.MATCHING_BRACKETS_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CommonEditorPreferenceNames.MATCHING_BRACKETS));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER));
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER_COLOR));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER));
-
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /*
- * @see IWorkbenchPreferencePage#init()
- */
- public void init(IWorkbench workbench) {
- // nothing to do
- }
-
- /*
- * @see PreferencePage#createControl(Composite)
- */
- public void createControl(Composite parent) {
- super.createControl(parent);
- //WorkbenchHelp.setHelp(getControl(), IJavaHelpContextIds.JAVA_EDITOR_PREFERENCE_PAGE);
- }
-
- private void handleAppearanceColorListSelection() {
- int i = fAppearanceColorList.getSelectionIndex();
- String key = fAppearanceColorListModel[i][1];
- RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
- fAppearanceColorEditor.setColorValue(rgb);
- }
-
- private Control createAppearancePage(Composite parent) {
-
- Composite appearanceComposite = new Composite(parent, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- appearanceComposite.setLayout(layout);
-
- String label = ResourceHandler.getString("StructuredTextEditorPreferencePage.16"); //$NON-NLS-1$
- addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH, 3, 0, true);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.17"); //$NON-NLS-1$
- addTextField(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLUMN, 3, 0, true);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.18"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_OVERVIEW_RULER, 0);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.19"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_LINE_NUMBER_RULER, 0);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.20"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, CommonEditorPreferenceNames.MATCHING_BRACKETS, 0);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.21"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE, 0);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.22"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN, 0);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.31"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, CommonEditorPreferenceNames.SHOW_QUICK_FIXABLES, 0);
-
- label = ResourceHandler.getString("StructuredTextEditorPreferencePage.30"); //$NON-NLS-1$
- addCheckBox(appearanceComposite, label, CommonEditorPreferenceNames.EVALUATE_TEMPORARY_PROBLEMS, 0);
-
- Label l = new Label(appearanceComposite, SWT.LEFT);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- gd.heightHint = convertHeightInCharsToPixels(1) / 2;
- l.setLayoutData(gd);
-
- l = new Label(appearanceComposite, SWT.LEFT);
- l.setText(ResourceHandler.getString("StructuredTextEditorPreferencePage.23")); //$NON-NLS-1$
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- gd.horizontalSpan = 2;
- l.setLayoutData(gd);
-
- Composite editorComposite = new Composite(appearanceComposite, SWT.NONE);
- layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- editorComposite.setLayout(layout);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_VERTICAL);
- gd.horizontalSpan = 2;
- editorComposite.setLayoutData(gd);
-
- fAppearanceColorList = new List(editorComposite, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER);
- gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
- gd.heightHint = convertHeightInCharsToPixels(5);
- fAppearanceColorList.setLayoutData(gd);
-
- Composite stylesComposite = new Composite(editorComposite, SWT.NONE);
- layout = new GridLayout();
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- layout.numColumns = 2;
- stylesComposite.setLayout(layout);
- stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- l = new Label(stylesComposite, SWT.LEFT);
- // needs to be made final so label can be set in foregroundcolorbutton's acc listener
- final String buttonLabel = ResourceHandler.getString("StructuredTextEditorPreferencePage.24"); //$NON-NLS-1$
- l.setText(buttonLabel);
- gd = new GridData();
- gd.horizontalAlignment = GridData.BEGINNING;
- l.setLayoutData(gd);
-
- fAppearanceColorEditor = new ColorEditor(stylesComposite);
- Button foregroundColorButton = fAppearanceColorEditor.getButton();
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment = GridData.BEGINNING;
- foregroundColorButton.setLayoutData(gd);
-
- fAppearanceColorList.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- handleAppearanceColorListSelection();
- }
- });
- foregroundColorButton.addSelectionListener(new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- // do nothing
- }
-
- public void widgetSelected(SelectionEvent e) {
- int i = fAppearanceColorList.getSelectionIndex();
- String key = fAppearanceColorListModel[i][1];
-
- PreferenceConverter.setValue(fOverlayStore, key, fAppearanceColorEditor.getColorValue());
- }
- });
-
- // bug2541 - associate color label to button's label field
- foregroundColorButton.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- if (e.childID == ACC.CHILDID_SELF)
- e.result = buttonLabel;
- }
- });
-
- WorkbenchHelp.setHelp(appearanceComposite, IHelpContextIds.PREFSTE_APPEARANCE_HELPID);
- return appearanceComposite;
- }
-
- /*
- * @see PreferencePage#createContents(Composite)
- */
- protected Control createContents(Composite parent) {
- // need to create tabs before loading/starting overlaystore in case tabs also add values
- IPreferenceTab navigationTab = new NavigationPreferenceTab(this, fOverlayStore);
- IPreferenceTab hoversTab = new TextHoverPreferenceTab(this, fOverlayStore);
-
- fOverlayStore.load();
- fOverlayStore.start();
-
- TabFolder folder = new TabFolder(parent, SWT.NONE);
- folder.setLayout(new TabFolderLayout());
- folder.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TabItem item = new TabItem(folder, SWT.NONE);
- item.setText(ResourceHandler.getString("StructuredTextEditorPreferencePage.0")); //$NON-NLS-1$
- item.setControl(createAppearancePage(folder));
-
- item = new TabItem(folder, SWT.NONE);
- item.setText(navigationTab.getTitle());
- item.setControl(navigationTab.createContents(folder));
-
- item = new TabItem(folder, SWT.NONE);
- item.setText(hoversTab.getTitle());
- item.setControl(hoversTab.createContents(folder));
-
- fTabs = new IPreferenceTab[]{navigationTab, hoversTab};
-
- initialize();
-
- Dialog.applyDialogFont(folder);
- return folder;
- }
-
- private void initialize() {
- initializeFields();
-
- for (int i = 0; i < fAppearanceColorListModel.length; i++)
- fAppearanceColorList.add(fAppearanceColorListModel[i][0]);
- fAppearanceColorList.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (fAppearanceColorList != null && !fAppearanceColorList.isDisposed()) {
- fAppearanceColorList.select(0);
- handleAppearanceColorListSelection();
- }
- }
- });
- }
-
- private void initializeFields() {
- Iterator e = fColorButtons.keySet().iterator();
- while (e.hasNext()) {
- ColorEditor c = (ColorEditor) e.next();
- String key = (String) fColorButtons.get(c);
- RGB rgb = PreferenceConverter.getColor(fOverlayStore, key);
- c.setColorValue(rgb);
- }
-
- e = fCheckBoxes.keySet().iterator();
- while (e.hasNext()) {
- Button b = (Button) e.next();
- String key = (String) fCheckBoxes.get(b);
- b.setSelection(fOverlayStore.getBoolean(key));
- }
-
- e = fTextFields.keySet().iterator();
- while (e.hasNext()) {
- Text t = (Text) e.next();
- String key = (String) fTextFields.get(t);
- t.setText(fOverlayStore.getString(key));
- }
- }
-
- private IModelManagerPlugin getModelManagerPlugin() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.preference.PreferencePage#performApply()
- */
- protected void performApply() {
- for (int i = 0; i < fTabs.length; i++) {
- fTabs[i].performApply();
- }
- super.performApply();
- }
-
- /*
- * @see PreferencePage#performOk()
- */
- public boolean performOk() {
- for (int i = 0; i < fTabs.length; i++) {
- fTabs[i].performOk();
- }
-
- fOverlayStore.propagate();
- EditorPlugin.getDefault().savePluginPreferences();
-
- // tab width is also a model-side preference so need to set it
- int tabWidth = getPreferenceStore().getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH);
- getModelManagerPlugin().getPluginPreferences().setValue(CommonModelPreferenceNames.TAB_WIDTH, tabWidth);
- ((Plugin)getModelManagerPlugin()).savePluginPreferences();
-
- return true;
- }
-
- /*
- * @see PreferencePage#performDefaults()
- */
- protected void performDefaults() {
- fOverlayStore.loadDefaults();
-
- initializeFields();
-
- handleAppearanceColorListSelection();
-
- for (int i = 0; i < fTabs.length; i++) {
- fTabs[i].performDefaults();
- }
-
- super.performDefaults();
-
- // there is currently no need for a viewer
- // fPreviewViewer.invalidateTextPresentation();
- }
-
- /*
- * @see DialogPage#dispose()
- */
- public void dispose() {
- if (fOverlayStore != null) {
- fOverlayStore.stop();
- fOverlayStore = null;
- }
-
- super.dispose();
- }
-
- private Button addCheckBox(Composite parent, String label, String key, int indentation) {
- Button checkBox = new Button(parent, SWT.CHECK);
- checkBox.setText(label);
-
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent = indentation;
- gd.horizontalSpan = 2;
- checkBox.setLayoutData(gd);
- checkBox.addSelectionListener(fCheckBoxListener);
-
- fCheckBoxes.put(checkBox, key);
-
- return checkBox;
- }
-
- private Text addTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
- return getTextControl(addLabelledTextField(composite, label, key, textLimit, indentation, isNumber));
- }
-
- private static Text getTextControl(Control[] labelledTextField) {
- return (Text) labelledTextField[1];
- }
-
- /**
- * Returns an array of size 2:
- * - first element is of type <code>Label</code>
- * - second element is of type <code>Text</code>
- * Use <code>getLabelControl</code> and <code>getTextControl</code> to get the 2 controls.
- */
- private Control[] addLabelledTextField(Composite composite, String label, String key, int textLimit, int indentation, boolean isNumber) {
- Label labelControl = new Label(composite, SWT.NONE);
- labelControl.setText(label);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.horizontalIndent = indentation;
- labelControl.setLayoutData(gd);
-
- Text textControl = new Text(composite, SWT.BORDER | SWT.SINGLE);
- gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- gd.widthHint = convertWidthInCharsToPixels(textLimit + 1);
- textControl.setLayoutData(gd);
- textControl.setTextLimit(textLimit);
- fTextFields.put(textControl, key);
- if (isNumber) {
- fNumberFields.add(textControl);
- textControl.addModifyListener(fNumberFieldListener);
- }
- else {
- textControl.addModifyListener(fTextFieldListener);
- }
-
- return new Control[]{labelControl, textControl};
- }
-
- private void numberFieldChanged(Text textControl) {
- String number = textControl.getText();
- IStatus status = validatePositiveNumber(number);
- if (!status.matches(IStatus.ERROR))
- fOverlayStore.setValue((String) fTextFields.get(textControl), number);
- updateStatus(status);
- }
-
- private IStatus validatePositiveNumber(String number) {
- StatusInfo status = new StatusInfo();
- if (number.length() == 0) {
- status.setError(ResourceHandler.getString("StructuredTextEditorPreferencePage.37")); //$NON-NLS-1$
- }
- else {
- try {
- int value = Integer.parseInt(number);
- if (value < 0)
- status.setError(number + ResourceHandler.getString("StructuredTextEditorPreferencePage.38")); //$NON-NLS-1$
- }
- catch (NumberFormatException e) {
- status.setError(number + ResourceHandler.getString("StructuredTextEditorPreferencePage.39")); //$NON-NLS-1$
- }
- }
- return status;
- }
-
- void updateStatus(IStatus status) {
- if (!status.matches(IStatus.ERROR)) {
- for (int i = 0; i < fNumberFields.size(); i++) {
- Text text = (Text) fNumberFields.get(i);
- IStatus s = validatePositiveNumber(text.getText());
- status = s.getSeverity() > status.getSeverity() ? s : status;
- }
- }
-
- setValid(!status.matches(IStatus.ERROR));
- applyToStatusLine(this, status);
- }
-
- /**
- * Applies the status to the status line of a dialog page.
- */
- public void applyToStatusLine(DialogPage page, IStatus status) {
- String message = status.getMessage();
- switch (status.getSeverity()) {
- case IStatus.OK :
- page.setMessage(message, IMessageProvider.NONE);
- page.setErrorMessage(null);
- break;
- case IStatus.WARNING :
- page.setMessage(message, IMessageProvider.WARNING);
- page.setErrorMessage(null);
- break;
- case IStatus.INFO :
- page.setMessage(message, IMessageProvider.INFORMATION);
- page.setErrorMessage(null);
- break;
- default :
- if (message.length() == 0) {
- message = null;
- }
- page.setMessage(null);
- page.setErrorMessage(message);
- break;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StyledTextColorPicker.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StyledTextColorPicker.java
deleted file mode 100644
index bec04729e7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/StyledTextColorPicker.java
+++ /dev/null
@@ -1,1035 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import java.io.CharArrayReader;
-import java.text.Collator;
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.accessibility.ACC;
-import org.eclipse.swt.accessibility.AccessibleAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlAdapter;
-import org.eclipse.swt.accessibility.AccessibleControlEvent;
-import org.eclipse.swt.accessibility.AccessibleControlListener;
-import org.eclipse.swt.accessibility.AccessibleEvent;
-import org.eclipse.swt.custom.BusyIndicator;
-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.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.TraverseEvent;
-import org.eclipse.swt.events.TraverseListener;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.Font;
-import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.swt.graphics.PaletteData;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.ColorDialog;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-
-/**
- * This class is configurable by setting 3 properties: 1) an array of Strings
- * as the styleNames; one unique entry for every style type meant to be
- * configurable by the user 2) a Dictionary of descriptions, mapping the
- * styleNames to unique descriptions - meant for use within the selection
- * ComboBox
- *
- * TODO (pa) this should probably be working off document partitions now (2.1+) 3)
- * a Dictionary mapping parsed ITextRegion contexts (strings) to the locally
- * defined styleNames
- *
- */
-public class StyledTextColorPicker extends Composite {
- protected class DescriptionSorter extends org.eclipse.wst.sse.ui.util.Sorter {
- Collator collator = Collator.getInstance();
-
- public boolean compare(Object elementOne, Object elementTwo) {
- /**
- * Returns true if elementTwo is 'greater than' elementOne This is
- * the 'ordering' method of the sort operation. Each subclass
- * overides this method with the particular implementation of the
- * 'greater than' concept for the objects being sorted.
- */
- return (collator.compare(elementOne.toString(), elementTwo.toString())) < 0;
- }
- }
-
- // names for preference elements ... non-NLS
- public static final String FOREGROUND = "foreground"; //$NON-NLS-1$
- public static final String BACKGROUND = "background"; //$NON-NLS-1$
- public static final String BOLD = "bold"; //$NON-NLS-1$
- public static final String ITALIC = "italic"; //$NON-NLS-1$
- public static final String NAME = "name"; //$NON-NLS-1$
- public static final String COLOR = "color"; //$NON-NLS-1$
- protected StyledText fText = null;
- private IStructuredDocumentRegion fNodes = null;
- /*
- * A DOM Node named "colors" with many children Elements named "color" Each
- * color Element supports 'name', 'bold', 'italic'(future?), 'foreground'
- * and 'background' HTML-style color definitions
- *
- * <colors> <color foreground="#008080" name="TAG_BORDER" bold="false"/>
- */
- protected Node fColorsNode = null;
- // An identical Node holding the default values for use when restoring a
- // <em>single</em> setting; optional.
- protected Node fDefaultColorsNode = null;
- // A RegionParser, which will turn the input into
- // IStructuredDocumentRegion(s) and Regions
- protected RegionParser fParser = null;
- // The list of supported ITextRegion types [Strings]
- protected List fStyleList = null;
- // Dictionary mapping the ITextRegion types above to display strings, for
- // use in the combo box
- protected Dictionary fDescriptions = null;
- // Dictionary mapping the ITextRegion types above to color names, which
- // are, in turn, attributes
- protected Dictionary fContextStyleMap = null;
- protected Combo fStyleCombo = null;
- protected Button fForeground;
- protected Button fBackground;
- protected Button fClearStyle;
- protected Button fBold;
- protected Button fItalic;
- protected Label fForegroundLabel;
- protected Label fBackgroundLabel;
- protected String fInput = ""; //$NON-NLS-1$
- protected Color fDefaultForeground = getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- protected Color fDefaultBackground = getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- protected List usedColors = new ArrayList();
- private static final boolean showItalic = false;
- protected SelectionListener comboListener = new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- int selectedIndex = fStyleCombo.getSelectionIndex();
- String description = selectedIndex >= 0 ? fStyleCombo.getItem(selectedIndex) : null;
- activate(getStyleName(description));
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- };
- protected SelectionListener buttonListener = new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- String namedStyle = getStyleName(fStyleCombo.getItem(fStyleCombo.getSelectionIndex()));
- if (namedStyle == null)
- return;
- if (e.widget == fForeground) {
- String oldValue = toRGBString(getAttribute(namedStyle).getForeground().getRGB());
- String newValue = changeColor(oldValue);
- getStyleElement(namedStyle).setAttribute(FOREGROUND, newValue);
- if (!newValue.equals(oldValue))
- refresh();
- }
- else if (e.widget == fBackground) {
- String oldValue = toRGBString(getAttribute(namedStyle).getBackground().getRGB());
- String newValue = changeColor(oldValue);
- getStyleElement(namedStyle).setAttribute(BACKGROUND, newValue);
- if (!newValue.equals(oldValue))
- refresh();
- }
- else if (e.widget == fClearStyle) {
- clearStyle(getStyleElement(namedStyle));
- refresh();
- }
- else if (e.widget == fBold) {
- String oldValue = getStyleElement(namedStyle).getAttribute(BOLD);
- String newValue = String.valueOf(fBold.getSelection());
- getStyleElement(namedStyle).setAttribute(BOLD, newValue);
- if (!newValue.equals(oldValue))
- refresh();
- }
- else if (showItalic && e.widget == fItalic) {
- String oldValue = getStyleElement(namedStyle).getAttribute(ITALIC);
- String newValue = String.valueOf(fItalic.getSelection());
- getStyleElement(namedStyle).setAttribute(ITALIC, newValue);
- if (!newValue.equals(oldValue))
- refresh();
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- widgetSelected(e);
- }
- };
- // defect 200764 - ACC:display values for color buttons
- protected AccessibleControlListener foregroundAccListener = new AccessibleControlAdapter() {
- /**
- * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getValue(AccessibleControlEvent)
- */
- public void getValue(AccessibleControlEvent e) {
- if (e.childID == ACC.CHILDID_SELF) {
- e.result = getColorButtonValue(fForeground);
- }
- }
- };
- protected AccessibleControlListener backgroundAccListener = new AccessibleControlAdapter() {
- /**
- * @see org.eclipse.swt.accessibility.AccessibleControlAdapter#getValue(AccessibleControlEvent)
- */
- public void getValue(AccessibleControlEvent e) {
- if (e.childID == ACC.CHILDID_SELF) {
- e.result = getColorButtonValue(fBackground);
- }
- }
- };
-
- /**
- * XMLTextColorPicker constructor comment.
- *
- * @param parent
- * org.eclipse.swt.widgets.Composite
- * @param style
- * int
- */
- public StyledTextColorPicker(Composite parent, int style) {
- super(parent, style);
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- setLayout(layout);
- createControls(this);
- }
-
- // activate controls based on the given local color type
- private void activate(String namedStyle) {
- if (namedStyle == null) {
- fForeground.setEnabled(false);
- fBackground.setEnabled(false);
- fClearStyle.setEnabled(false);
- fBold.setEnabled(false);
- if (showItalic)
- fItalic.setEnabled(false);
- fForegroundLabel.setEnabled(false);
- fBackgroundLabel.setEnabled(false);
- }
- else {
- fForeground.setEnabled(true);
- fBackground.setEnabled(true);
- fClearStyle.setEnabled(true);
- fBold.setEnabled(true);
- if (showItalic)
- fItalic.setEnabled(true);
- fForegroundLabel.setEnabled(true);
- fBackgroundLabel.setEnabled(true);
- }
- TextAttribute attribute = getAttribute(namedStyle);
- if (fForeground.getSize().x > 0 && fForeground.getSize().y > 0 && (fForeground.getImage() == null || fForeground.getImage().getImageData() == null || fForeground.getImage().getImageData().getRGBs() == null || fForeground.getImage().getImageData().getRGBs().length < 1 || !fForeground.getImage().getImageData().getRGBs()[0].equals(attribute.getForeground().getRGB()))) {
- if (fForeground.getImage() != null)
- fForeground.getImage().dispose();
- Image foreground = new Image(getDisplay(), new ImageData(fForeground.getSize().x, fForeground.getSize().y, 1, new PaletteData(new RGB[]{attribute.getForeground().getRGB()})));
- fForeground.setImage(foreground);
- }
- if (fBackground.getSize().x > 0 && fBackground.getSize().y > 0 && (fBackground.getImage() == null || fBackground.getImage().getImageData() == null || fBackground.getImage().getImageData().getRGBs() == null || fBackground.getImage().getImageData().getRGBs().length < 1 || !fBackground.getImage().getImageData().getRGBs()[0].equals(attribute.getBackground().getRGB()))) {
- if (fBackground.getImage() != null)
- fBackground.getImage().dispose();
- Image background = new Image(getDisplay(), new ImageData(fBackground.getSize().x, fBackground.getSize().y, 1, new PaletteData(new RGB[]{attribute.getBackground().getRGB()})));
- fBackground.setImage(background);
- }
- fBold.setSelection((attribute.getStyle() & SWT.BOLD) != 0);
- if (showItalic)
- fItalic.setSelection((attribute.getStyle() & SWT.ITALIC) != 0);
- }
-
- protected void applyStyles() {
- if (fText == null || fText.isDisposed() || fInput == null || fInput.length() == 0)
- return;
- // List regions = fParser.getRegions();
- IStructuredDocumentRegion node = fNodes;
- while (node != null) {
- ITextRegionList regions = node.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion currentRegion = regions.get(i);
- // lookup the local coloring type and apply it
- String namedStyle = (String) getContextStyleMap().get(currentRegion.getType());
- if (namedStyle == null)
- continue;
- TextAttribute attribute = getAttribute(namedStyle);
- if (attribute == null)
- continue;
- StyleRange style = new StyleRange(node.getStartOffset(currentRegion), currentRegion.getLength(), attribute.getForeground(), attribute.getBackground(), attribute.getStyle());
- fText.setStyleRange(style);
- }
- node = node.getNext();
- }
- }
-
- private String changeColor(String rgb) {
- return toRGBString(changeColor(toRGB(rgb)));
- }
-
- private RGB changeColor(RGB startValue) {
- ColorDialog colorDlg = new ColorDialog(getShell());
- if (startValue != null)
- colorDlg.setRGB(startValue);
- colorDlg.open();
- RGB newRGB = colorDlg.getRGB();
- if (newRGB != null)
- return newRGB;
- return startValue;
- }
-
- public void clearStyle(Element color) {
- if (color == null)
- return;
- final Element colorToClear = color;
- BusyIndicator.showWhile(getDisplay(), new Runnable() {
- public void run() {
- primClearStyle(colorToClear);
- }
- });
- }
-
- protected void close() {
- releaseColors();
- }
-
- /**
- * Creates an new checkbox instance and sets the default layout data.
- *
- * @param group
- * the composite in which to create the checkbox
- * @param label
- * the string to set into the checkbox
- * @return the new checkbox
- */
- private Button createCheckBox(Composite group, String label) {
- Button button = new Button(group, SWT.CHECK | SWT.CENTER);
- if (label != null)
- button.setText(label);
- GridData data = new GridData(GridData.FILL_BOTH);
- data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_END;
- // data.verticalAlignment = GridData.VERTICAL_ALIGN_FILL;
- button.setLayoutData(data);
- return button;
- }
-
- private Combo createCombo(Composite parent, String[] labels, int selectedItem) {
- Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
- combo.setItems(labels);
- if (selectedItem >= 0)
- combo.select(selectedItem);
- GridData data = new GridData(GridData.FILL_HORIZONTAL);
- data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
- combo.setLayoutData(data);
- return combo;
- }
-
- /**
- * Creates composite control and sets the default layout data.
- */
- private Composite createComposite(Composite parent, int numColumns) {
- Composite composite = new Composite(parent, SWT.NULL);
- //GridLayout
- GridLayout layout = new GridLayout();
- layout.numColumns = numColumns;
- layout.horizontalSpacing = 5;
- layout.makeColumnsEqualWidth = false;
- composite.setLayout(layout);
- //GridData
- GridData data = new GridData(GridData.FILL_VERTICAL);
- data.grabExcessVerticalSpace = false;
- data.verticalAlignment = GridData.VERTICAL_ALIGN_CENTER;
- composite.setLayoutData(data);
- return composite;
- }
-
- protected void createControls(Composite parent) {
- Composite styleRow = createComposite(parent, 3);
- // row 1 - content type label, combo box, restore defaults
- createLabel(styleRow, ResourceHandler.getString("Content_type__UI_")); //$NON-NLS-1$ = "Content type:"
- // Contexts combo box
- fStyleCombo = createCombo(styleRow, new String[0], -1);
- fClearStyle = createPushButton(styleRow, ResourceHandler.getString("Restore_Default_UI_")); //$NON-NLS-1$ = "Restore Default"
- Composite styleRow2;
- if (showItalic)
- styleRow2 = createComposite(parent, 7);
- else
- styleRow2 = createComposite(parent, 6);
- // row 2 - foreground label, button, background label, button, bold,
- // italics?
- fForegroundLabel = createLabel(styleRow2, ResourceHandler.getString("Foreground_UI_")); //$NON-NLS-1$ = "Foreground"
- fForeground = createPushButton(styleRow2, ""); //$NON-NLS-1$
- setAccessible(fForeground, fForegroundLabel.getText());
- fForeground.getAccessible().addAccessibleControlListener(foregroundAccListener); // defect
- // 200764
- // -
- // ACC:display
- // values
- // for
- // color
- // buttons
- Point buttonSize = computeImageSize(parent);
- ((GridData) fForeground.getLayoutData()).widthHint = buttonSize.x;
- ((GridData) fForeground.getLayoutData()).heightHint = buttonSize.y;
- fBackgroundLabel = createLabel(styleRow2, ResourceHandler.getString("Background_UI_")); //$NON-NLS-1$ = "Background"
- fBackground = createPushButton(styleRow2, ""); //$NON-NLS-1$
- setAccessible(fBackground, fBackgroundLabel.getText());
- fBackground.getAccessible().addAccessibleControlListener(backgroundAccListener); // defect
- // 200764
- // -
- // ACC:display
- // values
- // for
- // color
- // buttons
- ((GridData) fBackground.getLayoutData()).widthHint = buttonSize.x;
- ((GridData) fBackground.getLayoutData()).heightHint = buttonSize.y;
- createLabel(styleRow2, ""); //$NON-NLS-1$
- fBold = createCheckBox(styleRow2, ResourceHandler.getString("Bold_UI_")); //$NON-NLS-1$ = "Bold"
- if (showItalic)
- fItalic = createCheckBox(styleRow2, ResourceHandler.getString("Italic")); //$NON-NLS-1$
- // // Defaults checkbox
- fForeground.setEnabled(false);
- fBackground.setEnabled(false);
- fClearStyle.setEnabled(false);
- fBold.setEnabled(false);
- if (showItalic)
- fItalic.setEnabled(false);
- fForegroundLabel.setEnabled(false);
- fBackgroundLabel.setEnabled(false);
- Composite sample = createComposite(parent, 1);
- createLabel(sample, ResourceHandler.getString("Sample_text__UI_")); //$NON-NLS-1$ = "&Sample text:"
- fText = new StyledText(sample, SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER | SWT.READ_ONLY);
- GridData data = new GridData(GridData.FILL_BOTH);
- fText.setLayoutData(data);
- fText.setEditable(false);
- fText.setBackground(fDefaultBackground);
- fText.setFont(JFaceResources.getTextFont());
- fText.addKeyListener(getTextKeyListener());
- fText.addSelectionListener(getTextSelectionListener());
- fText.addMouseListener(getTextMouseListener());
- fText.addTraverseListener(getTraverseListener()); // defect 220377 -
- // Provide tab
- // traversal for
- // fText widget
- setAccessible(fText, ResourceHandler.getString("Sample_text__UI_")); //$NON-NLS-1$ = "&Sample text:"
- fForeground.addSelectionListener(buttonListener);
- fBackground.addSelectionListener(buttonListener);
- fClearStyle.addSelectionListener(buttonListener);
- fBold.addSelectionListener(buttonListener);
- if (showItalic)
- fItalic.addSelectionListener(buttonListener);
- fStyleCombo.addSelectionListener(comboListener);
- parent.addDisposeListener(getDisposeListener());
- }
-
- /**
- * Utility method that creates a label instance and sets the default layout
- * data.
- */
- private Label createLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.LEFT);
- label.setText(text);
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- label.setLayoutData(data);
- return label;
- }
-
- private Button createPushButton(Composite parent, String label) {
- Button button = new Button(parent, SWT.PUSH);
- button.setText(label);
- GridData data = new GridData(GridData.FILL_BOTH);
- // data.horizontalAlignment = GridData.FILL;
- button.setLayoutData(data);
- return button;
- }
-
- /**
- * Specifically set the reporting name of a control for accessibility
- */
- private void setAccessible(Control control, String name) {
- if (control == null)
- return;
- final String n = name;
- control.getAccessible().addAccessibleListener(new AccessibleAdapter() {
- public void getName(AccessibleEvent e) {
- if (e.childID == ACC.CHILDID_SELF)
- e.result = n;
- }
- });
- }
-
- // defect 200764 - ACC:display values for color buttons
- /**
- * @return String - color Button b's current RBG value
- */
- private String getColorButtonValue(Button b) {
- if ((b == null) || (b.getImage() == null) || (b.getImage().getImageData() == null) || (b.getImage().getImageData().getRGBs() == null) || (b.getImage().getImageData().getRGBs()[0] == null))
- return null;
- String val = b.getImage().getImageData().getRGBs()[0].toString();
- return val;
- }
-
- protected TextAttribute getAttribute(String namedStyle) {
- if (namedStyle == null || namedStyle.length() < 1 || fColorsNode == null)
- return new TextAttribute(getDefaultForeground(), getDefaultBackground(), SWT.NORMAL);
- Node colorsElement = (Element) fColorsNode;
- NodeList colors = colorsElement.getChildNodes();
- Element color = null;
- for (int i = 0; i < colors.getLength(); i++) {
- Node tester = colors.item(i);
- if (tester.getNodeType() == Node.ELEMENT_NODE && ((Element) tester).getAttribute(NAME).equals(namedStyle)) {
- color = (Element) tester;
- break;
- }
- }
- if (color == null) {
- // create one
- color = colorsElement.getOwnerDocument().createElement(COLOR);
- color.setAttribute(NAME, namedStyle);
- colorsElement.appendChild(color);
- }
- int fontModifier = SWT.NORMAL;
- if (Boolean.valueOf(color.getAttribute(BOLD)).booleanValue())
- fontModifier = fontModifier | SWT.BOLD;
- if (showItalic && Boolean.valueOf(color.getAttribute(ITALIC)).booleanValue())
- fontModifier = fontModifier | SWT.ITALIC;
- return new TextAttribute(getColor(toRGB(color.getAttribute(FOREGROUND), getDefaultForeground().getRGB())), getColor(toRGB(color.getAttribute(BACKGROUND), getDefaultBackground().getRGB())), fontModifier);
- }
-
- private Color getColor(int r, int g, int b) {
- for (int i = 0; i < usedColors.size(); i++) {
- Color color = (Color) usedColors.get(i);
- if (color.getRed() == r && color.getGreen() == g && color.getBlue() == b)
- return color;
- }
- Color newColor = new Color(getDisplay(), r, g, b);
- usedColors.add(newColor);
- return newColor;
- }
-
- private Color getColor(RGB rgb) {
- return getColor(rgb.red, rgb.green, rgb.blue);
- }
-
- /**
- * @return org.w3c.dom.Node
- */
- public Node getColorsNode() {
- return fColorsNode;
- }
-
- /**
- * @return java.util.Dictionary
- */
- public Dictionary getContextStyleMap() {
- return fContextStyleMap;
- }
-
- /**
- * @return org.eclipse.swt.graphics.Color
- */
- public Color getDefaultBackground() {
- return fDefaultBackground;
- }
-
- /**
- * @return org.w3c.dom.Node
- */
- public Node getDefaultColorsNode() {
- return fDefaultColorsNode;
- }
-
- /**
- * @return org.eclipse.swt.graphics.Color
- */
- public Color getDefaultForeground() {
- return fDefaultForeground;
- }
-
- /**
- * @return java.util.Dictionary
- */
- public Dictionary getDescriptions() {
- return fDescriptions;
- }
-
- private DisposeListener getDisposeListener() {
- return new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- close();
- }
- };
- }
-
- public Font getFont() {
- return fText.getFont();
- }
-
- protected String getNamedStyleAtOffset(int offset) {
- // ensure the offset is clean
- if (offset >= fInput.length())
- return getNamedStyleAtOffset(fInput.length() - 1);
- else if (offset < 0)
- return getNamedStyleAtOffset(0);
- // find the ITextRegion at this offset
- if (fNodes == null)
- return null;
- IStructuredDocumentRegion aNode = fNodes;
- while (aNode != null && !aNode.containsOffset(offset))
- aNode = aNode.getNext();
- if (aNode != null) {
- // find the ITextRegion's Context at this offset
- ITextRegion interest = aNode.getRegionAtCharacterOffset(offset);
- if (interest == null)
- return null;
- if (offset > aNode.getTextEndOffset(interest))
- return null;
- String regionContext = interest.getType();
- if (regionContext == null)
- return null;
- // find the named style (internal/selectable name) for that context
- String namedStyle = (String) getContextStyleMap().get(regionContext);
- if (namedStyle != null) {
- return namedStyle;
- }
- }
- return null;
- }
-
- /**
- */
- public RegionParser getParser() {
- return fParser;
- }
-
- private Element getStyleElement(String namedStyle) {
- if (namedStyle == null || namedStyle.length() < 1)
- return null;
- Element colorsElement = (Element) fColorsNode;
- NodeList colors = colorsElement.getChildNodes();
- Element color = null;
- for (int i = 0; i < colors.getLength(); i++) {
- Node tester = colors.item(i);
- if (tester.getNodeType() == Node.ELEMENT_NODE && ((Element) tester).getAttribute(NAME).equals(namedStyle)) {
- color = (Element) tester;
- break;
- }
- }
- if (color == null) {
- // create one
- color = fColorsNode.getOwnerDocument().createElement(COLOR);
- color.setAttribute(NAME, namedStyle);
- colorsElement.appendChild(color);
- }
- return color;
- }
-
- /**
- * @return String[]
- */
- public List getStyleList() {
- return fStyleList;
- }
-
- private String getStyleName(String description) {
- if (description == null)
- return null;
- String styleName = null;
- java.util.Enumeration keys = getDescriptions().keys();
- while (keys.hasMoreElements()) {
- String test = keys.nextElement().toString();
- if (getDescriptions().get(test).equals(description)) {
- styleName = test;
- break;
- }
- }
- return styleName;
- }
-
- public String getText() {
- return fInput;
- }
-
- private KeyListener getTextKeyListener() {
- return new KeyListener() {
- public void keyPressed(KeyEvent e) {
- if (e.widget instanceof StyledText) {
- int x = ((StyledText) e.widget).getCaretOffset();
- selectColorAtOffset(x);
- }
- }
-
- public void keyReleased(KeyEvent e) {
- if (e.widget instanceof StyledText) {
- int x = ((StyledText) e.widget).getCaretOffset();
- selectColorAtOffset(x);
- }
- }
- };
- }
-
- private MouseListener getTextMouseListener() {
- return new MouseListener() {
- public void mouseDoubleClick(MouseEvent e) {
- }
-
- public void mouseDown(MouseEvent e) {
- }
-
- public void mouseUp(MouseEvent e) {
- if (e.widget instanceof StyledText) {
- int x = ((StyledText) e.widget).getCaretOffset();
- selectColorAtOffset(x);
- }
- }
- };
- }
-
- private SelectionListener getTextSelectionListener() {
- return new SelectionListener() {
- public void widgetDefaultSelected(SelectionEvent e) {
- selectColorAtOffset(e.x);
- if (e.widget instanceof StyledText) {
- ((StyledText) e.widget).setSelection(e.x);
- }
- }
-
- public void widgetDoubleSelected(SelectionEvent e) {
- selectColorAtOffset(e.x);
- if (e.widget instanceof StyledText) {
- ((StyledText) e.widget).setSelection(e.x);
- }
- }
-
- public void widgetSelected(SelectionEvent e) {
- selectColorAtOffset(e.x);
- if (e.widget instanceof StyledText) {
- ((StyledText) e.widget).setSelection(e.x);
- }
- }
- };
- }
-
- // defect 220377 - Provide tab traversal for fText widget
- private TraverseListener getTraverseListener() {
- return new TraverseListener() {
- /**
- * @see org.eclipse.swt.events.TraverseListener#keyTraversed(TraverseEvent)
- */
- public void keyTraversed(TraverseEvent e) {
- if (e.widget instanceof StyledText) {
- if ((e.detail == SWT.TRAVERSE_TAB_NEXT) || (e.detail == SWT.TRAVERSE_TAB_PREVIOUS))
- e.doit = true;
- }
- }
- };
- }
-
- protected void primClearStyle(Element color) {
- // if display is null by the time we execute, we've been disposed
- // already
- if (getDisplay() == null)
- return;
- if (color == null)
- return;
- boolean stylesCleared = false;
- if (fDefaultColorsNode != null) {
- // Look for a default color with the same name
- NodeList defaultColors = fDefaultColorsNode.getChildNodes();
- Element defaultColor = null;
- for (int i = 0; i < defaultColors.getLength(); i++) {
- Node tester = defaultColors.item(i);
- if (tester.getNodeType() == Node.ELEMENT_NODE && ((Element) tester).getAttribute(NAME).equals(color.getAttribute(NAME))) {
- defaultColor = (Element) tester;
- break;
- }
- }
- // If a default color was found, clear the current attributes and
- // copy all of the defaults
- if (defaultColor != null) {
- NamedNodeMap attributes = defaultColor.getAttributes();
- if (attributes != null && attributes.getLength() > 0) {
- NamedNodeMap oldAttributes = color.getAttributes();
- int count = 0;
- int totalAttributes = (oldAttributes == null) ? 0 : oldAttributes.getLength();
- while (oldAttributes.getLength() > 0 && count < totalAttributes) {
- color.removeAttributeNode((Attr) oldAttributes.item(0));
- count++;
- }
- stylesCleared = true;
- for (int i = 0; i < attributes.getLength(); i++) {
- Node attribute = attributes.item(i);
- color.setAttribute(attribute.getNodeName(), attribute.getNodeValue());
- }
- }
- }
- }
- if (!stylesCleared) {
- // restore widget defaults
- color.removeAttribute(ColorNames.FOREGROUND);
- color.removeAttribute(ColorNames.BACKGROUND);
- color.removeAttribute(ColorNames.BOLD);
- color.removeAttribute(ColorNames.ITALIC);
- }
- }
-
- // refresh the GUI after a color change
- public void refresh() {
- fText.setRedraw(false);
- int selectedIndex = fStyleCombo.getSelectionIndex();
- String description = selectedIndex >= 0 ? fStyleCombo.getItem(selectedIndex) : null;
- activate(getStyleName(description));
- // update Font
- fText.setFont(JFaceResources.getTextFont());
- // reapplyStyles
- applyStyles();
- fText.setRedraw(true);
- }
-
- private void releaseColors() {
- java.util.Iterator colors = usedColors.iterator();
- while (colors.hasNext())
- ((Color) colors.next()).dispose();
- }
-
- public void releasePickerResources() {
- if (fForeground != null && !fForeground.isDisposed() && fForeground.getImage() != null)
- fForeground.getImage().dispose();
- if (fBackground != null && !fBackground.isDisposed() && fBackground.getImage() != null)
- fBackground.getImage().dispose();
- }
-
- private void selectColorAtOffset(int offset) {
- String namedStyle = getNamedStyleAtOffset(offset);
- if (namedStyle == null) {
- fStyleCombo.deselectAll();
- activate(null);
- return;
- }
- String description = (String) getDescriptions().get(namedStyle);
- if (description == null)
- return;
- int itemCount = fStyleCombo.getItemCount();
- for (int i = 0; i < itemCount; i++) {
- if (fStyleCombo.getItem(i).equals(description)) {
- fStyleCombo.select(i);
- break;
- }
- }
- activate(namedStyle);
- }
-
- /**
- * @param newColorsNode
- * org.w3c.dom.Node
- */
- public void setColorsNode(Node newColorsNode) {
- fColorsNode = newColorsNode;
- }
-
- /**
- * @param newContextStyleMap
- * java.util.Dictionary
- */
- public void setContextStyleMap(Dictionary newContextStyleMap) {
- fContextStyleMap = newContextStyleMap;
- }
-
- /**
- * @param newDefaultBackground
- * org.eclipse.swt.graphics.Color
- */
- public void setDefaultBackground(Color newDefaultBackground) {
- fDefaultBackground = newDefaultBackground;
- }
-
- /**
- * @param newDefaultColorsNode
- * org.w3c.dom.Node
- */
- public void setDefaultColorsNode(Node newDefaultColorsNode) {
- fDefaultColorsNode = newDefaultColorsNode;
- }
-
- /**
- * @param newDefaultForeground
- * org.eclipse.swt.graphics.Color
- */
- public void setDefaultForeground(Color newDefaultForeground) {
- fDefaultForeground = newDefaultForeground;
- }
-
- /**
- * @param newDescriptions
- * java.util.Dictionary
- */
- public void setDescriptions(Dictionary newDescriptions) {
- fDescriptions = newDescriptions;
- updateStyleList();
- }
-
- public void setFont(Font font) {
- fText.setFont(font);
- fText.redraw();
- }
-
- /**
- * @param newParser
- */
- public void setParser(RegionParser newParser) {
- fParser = newParser;
- }
-
- /**
- * @param newStyleList
- * String[]
- */
- public void setStyleList(List newStyleList) {
- fStyleList = newStyleList;
- updateStyleList();
- }
-
- public void setText(String s) {
- fInput = s;
- getParser().reset(new CharArrayReader(fInput.toCharArray()));
- fNodes = getParser().getDocumentRegions();
- if (Debug.displayInfo)
- System.out.println("Length of input: " //$NON-NLS-1$
- //$NON-NLS-1$
- + s.length() + ", " //$NON-NLS-1$
- + getParser().getRegions().size() + " regions."); //$NON-NLS-1$
- if (fText != null)
- fText.setText(s);
- applyStyles();
- }
-
- /**
- * @return org.eclipse.swt.graphics.RGB
- * @param anRGBString
- * java.lang.String
- */
- private RGB toRGB(String anRGBString) {
- RGB result = null;
- if (anRGBString.length() > 6 && anRGBString.charAt(0) == '#') {
- int r = 0;
- int g = 0;
- int b = 0;
- try {
- r = Integer.valueOf(anRGBString.substring(1, 3), 16).intValue();
- g = Integer.valueOf(anRGBString.substring(3, 5), 16).intValue();
- b = Integer.valueOf(anRGBString.substring(5, 7), 16).intValue();
- result = new RGB(r, g, b);
- }
- catch (NumberFormatException nfExc) {
- Logger.logException("Could not load highlighting preference for color " + anRGBString, nfExc); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- /**
- * @return org.eclipse.swt.graphics.RGB
- * @param anRGBString
- * java.lang.String
- * @param defaultRGB
- * org.eclipse.swt.graphics.RGB
- */
- private RGB toRGB(String anRGBString, RGB defaultRGB) {
- RGB result = toRGB(anRGBString);
- if (result == null)
- return defaultRGB;
- return result;
- }
-
- /**
- * @return java.lang.String
- * @param anRGB
- * org.eclipse.swt.graphics.RGB
- */
- private String toRGBString(RGB anRGB) {
- if (anRGB == null)
- return "#000000"; //$NON-NLS-1$
- String red = Integer.toHexString(anRGB.red);
- while (red.length() < 2)
- red = "0" + red; //$NON-NLS-1$
- String green = Integer.toHexString(anRGB.green);
- while (green.length() < 2)
- green = "0" + green; //$NON-NLS-1$
- String blue = Integer.toHexString(anRGB.blue);
- while (blue.length() < 2)
- blue = "0" + blue; //$NON-NLS-1$
- return "#" + red + green + blue; //$NON-NLS-1$
- }
-
- private void updateStyleList() {
- if (fStyleList == null || fDescriptions == null)
- return;
- String[] descriptions = new String[fStyleList.size()];
- for (int i = 0; i < fStyleList.size(); i++) {
- if (fStyleList.get(i) != null)
- descriptions[i] = (String) getDescriptions().get(fStyleList.get(i));
- else
- descriptions[i] = (String) fStyleList.get(i);
- }
- Object[] sortedObjects = new DescriptionSorter().sort(descriptions);
- String[] sortedDescriptions = new String[descriptions.length];
- for (int i = 0; i < descriptions.length; i++) {
- sortedDescriptions[i] = sortedObjects[i].toString();
- }
- fStyleCombo.setItems(sortedDescriptions);
- fStyleCombo.select(0); //defect 219855 - initially select first item
- // in comboBox
- // fStyleCombo.deselectAll();
- }
-
- /**
- * Determines size of color button copied from
- * org.eclipse.jdt.internal.ui.preferences.ColorEditor 1 modification -
- * added 4 to final height
- */
- private Point computeImageSize(Control window) {
- GC gc = new GC(window);
- Font f = JFaceResources.getFontRegistry().get(JFaceResources.DEFAULT_FONT);
- gc.setFont(f);
- int height = gc.getFontMetrics().getHeight();
- gc.dispose();
- Point p = new Point(height * 3 - 6, height + 4);
- return p;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TaskTagPreferenceTab.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TaskTagPreferenceTab.java
deleted file mode 100644
index 75ffb184a5..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TaskTagPreferenceTab.java
+++ /dev/null
@@ -1,484 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.MessageDialog;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.core.ModelPlugin;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class TaskTagPreferenceTab implements IPreferenceTab {
-
- public class InternalTableLabelProvider extends LabelProvider implements ITableLabelProvider {
- public InternalTableLabelProvider() {
- super();
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- if (columnIndex < 1)
- return element.toString();
- for (int i = 0; i < fTags.length; i++) {
- if (fTags[i].equals(element)) {
- if (fPriorities[i].intValue() == IMarker.PRIORITY_HIGH) {
- return ResourceHandler.getString("TaskTagPreferenceTab.0"); //$NON-NLS-1$
- }
- else if (fPriorities[i].intValue() == IMarker.PRIORITY_LOW) {
- return ResourceHandler.getString("TaskTagPreferenceTab.1"); //$NON-NLS-1$
- }
- else {
- return ResourceHandler.getString("TaskTagPreferenceTab.2"); //$NON-NLS-1$
- }
- }
- }
- return ResourceHandler.getString("TaskTagPreferenceTab.3"); //$NON-NLS-1$
- }
- }
-
- public class TaskTagDialog extends Dialog {
- public int priority = IMarker.PRIORITY_NORMAL;
- private Combo priorityCombo = null;
- private Text tagText = null;
- public String text = ""; //$NON-NLS-1$
-
- public TaskTagDialog(Shell parentShell) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- }
-
- protected void configureShell(Shell newShell) {
- super.configureShell(newShell);
- newShell.setText(ResourceHandler.getString("TaskTagPreferenceTab.5")); //$NON-NLS-1$
- }
-
- protected Control createButtonBar(Composite parent) {
- Control c = super.createButtonBar(parent);
- getButton(IDialogConstants.OK_ID).setEnabled(text.length() > 0);
- return c;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
- Label label = new Label(composite, SWT.NONE);
- label.setText(ResourceHandler.getString("TaskTagPreferenceTab.6")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
- tagText = new Text(composite, SWT.BORDER);
- tagText.setText(text);
- tagText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- tagText.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- getButton(IDialogConstants.OK_ID).setEnabled(tagText.getText().length() > 0 && !Arrays.asList(fTags).contains(tagText.getText()));
- }
- });
-
- label = new Label(composite, SWT.NONE);
- label.setText(ResourceHandler.getString("TaskTagPreferenceTab.7")); //$NON-NLS-1$
- label.setLayoutData(new GridData());
- priorityCombo = new Combo(composite, SWT.READ_ONLY | SWT.SINGLE);
- priorityCombo.setItems(new String[]{ResourceHandler.getString("TaskTagPreferenceTab.8"), ResourceHandler.getString("TaskTagPreferenceTab.9"), ResourceHandler.getString("TaskTagPreferenceTab.10")}); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- priorityCombo.select(2 - priority);
- priorityCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- priorityCombo.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- priority = 2 - priorityCombo.getSelectionIndex();
- }
- });
- return composite;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#okPressed()
- */
- protected void okPressed() {
- text = tagText.getText();
- priority = 2 - priorityCombo.getSelectionIndex();
- super.okPressed();
- }
- }
-
- private Control fControl;
-
- private Integer[] fPriorities;
-
- private String[] fTags;
-
- private boolean isDirty = false;
-
- protected TableViewer valueTable = null;
-
- /**
- *
- */
- public TaskTagPreferenceTab() {
- super();
- }
-
- /**
- *
- */
- protected void addTag() {
- TaskTagDialog dlg = new TaskTagDialog(fControl.getShell());
- String tag = ""; //$NON-NLS-1$
- int priority = IMarker.PRIORITY_NORMAL;
- int result = dlg.open();
- if (result == Window.OK) {
- isDirty = true;
- tag = dlg.text;
- priority = dlg.priority;
- List newTags = new ArrayList(Arrays.asList(fTags));
- newTags.add(tag);
- fTags = (String[]) newTags.toArray(new String[0]);
- List newPriorities = new ArrayList(Arrays.asList(fPriorities));
- newPriorities.add(new Integer(priority));
- fPriorities = (Integer[]) newPriorities.toArray(new Integer[0]);
- valueTable.setInput(fTags);
- valueTable.getTable().setSelection(fTags.length - 1);
- }
- }
-
- public Control createContents(Composite parent) {
- loadPreferenceValues();
-
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayout(new GridLayout(2, false));
- fControl = composite;
-
- valueTable = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL);
- valueTable.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- TableColumn textColumn = new TableColumn(valueTable.getTable(), SWT.NONE, 0);
- textColumn.setText(ResourceHandler.getString("TaskTagPreferenceTab.12")); //$NON-NLS-1$
- TableColumn priorityColumn = new TableColumn(valueTable.getTable(), SWT.NONE, 1);
- priorityColumn.setText(ResourceHandler.getString("TaskTagPreferenceTab.13")); //$NON-NLS-1$
- valueTable.setContentProvider(new ArrayContentProvider());
- valueTable.setLabelProvider(new InternalTableLabelProvider());
- valueTable.getTable().setLinesVisible(true);
- valueTable.getTable().setHeaderVisible(true);
- TableLayout layout = new TableLayout();
- layout.addColumnData(new ColumnWeightData(1, 140, true));
- layout.addColumnData(new ColumnWeightData(1, 140, true));
- valueTable.getTable().setLayout(layout);
-
- Composite buttons = new Composite(composite, SWT.NONE);
- buttons.setLayout(new GridLayout());
- buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
-
- final Button addButton = new Button(buttons, SWT.PUSH);
- addButton.setText(ResourceHandler.getString("TaskTagPreferenceTab.14")); //$NON-NLS-1$
- addButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER));
- final Button editButton = new Button(buttons, SWT.PUSH);
- editButton.setText(ResourceHandler.getString("TaskTagPreferenceTab.15")); //$NON-NLS-1$
- editButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER));
- final Button removeButton = new Button(buttons, SWT.PUSH);
- removeButton.setText(ResourceHandler.getString("TaskTagPreferenceTab.16")); //$NON-NLS-1$
- removeButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER));
-
- Label spacer = new Label(buttons, SWT.NONE);
- spacer.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER));
- final Button upButton = new Button(buttons, SWT.PUSH);
- upButton.setText(ResourceHandler.getString("TaskTagPreferenceTab.17")); //$NON-NLS-1$
- upButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER));
- final Button downButton = new Button(buttons, SWT.PUSH);
- downButton.setText(ResourceHandler.getString("TaskTagPreferenceTab.18")); //$NON-NLS-1$
- downButton.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_CENTER));
-
- editButton.setEnabled(false);
- removeButton.setEnabled(false);
- upButton.setEnabled(false);
- downButton.setEnabled(false);
-
- Label warning = new Label(composite, SWT.NONE);
- warning.setLayoutData(new GridData());
- warning.setText(ResourceHandler.getString("TaskTagPreferenceTab.19")); //$NON-NLS-1$
-
- valueTable.addPostSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- boolean enabledForSelection = !event.getSelection().isEmpty();
- editButton.setEnabled(enabledForSelection);
- removeButton.setEnabled(enabledForSelection);
- if (valueTable.getTable() != null && !valueTable.getTable().isDisposed()) {
- upButton.setEnabled(enabledForSelection && valueTable.getTable().getSelectionIndex() > 0);
- downButton.setEnabled(enabledForSelection && valueTable.getTable().getSelectionIndex() < fTags.length - 1);
- }
- else {
- upButton.setEnabled(false);
- downButton.setEnabled(false);
- }
- }
- });
- addButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- addTag();
- }
- });
- editButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- editTag(valueTable.getTable().getSelectionIndex());
- }
- });
- removeButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- removeTag(valueTable.getTable().getSelectionIndex());
- }
- });
- upButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- moveTagUp(valueTable.getTable().getSelectionIndex());
- upButton.setEnabled(valueTable.getTable().getSelectionIndex() > 0);
- downButton.setEnabled(valueTable.getTable().getSelectionIndex() < fTags.length - 1);
- if(!upButton.isEnabled()) {
- downButton.setFocus();
- }
- }
- });
- downButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- moveTagDown(valueTable.getTable().getSelectionIndex());
- upButton.setEnabled(valueTable.getTable().getSelectionIndex() > 0);
- downButton.setEnabled(valueTable.getTable().getSelectionIndex() < fTags.length - 1);
- if(!downButton.isEnabled()) {
- upButton.setFocus();
- }
- }
- });
-
-
- valueTable.setInput(fTags);
-
- WorkbenchHelp.setHelp(composite, IHelpContextIds.PREFWEBX_TASKTAGS_HELPID);
- return composite;
- }
-
- /**
- * @param selection
- */
- protected void editTag(int i) {
- if (i < 0) {
- return;
- }
-
- int selection = valueTable.getTable().getSelectionIndex();
- TaskTagDialog dlg = new TaskTagDialog(fControl.getShell());
- dlg.text = fTags[selection];
- dlg.priority = fPriorities[selection].intValue();
- int result = dlg.open();
- if (result == Window.OK) {
- isDirty = true;
- fTags[selection] = dlg.text;
- fPriorities[selection] = new Integer(dlg.priority);
- valueTable.refresh();
- }
- }
-
- public String getTitle() {
- return ResourceHandler.getString("TaskTagPreferenceTab.20"); //$NON-NLS-1$
- }
-
- private void loadPreferenceValues() {
- String tags = ModelPlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_TAGS);
- String priorities = ModelPlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_PRIORITIES);
- loadTagsAndPriorities(tags, priorities);
- }
-
- /**
- * @param tags
- * @param priorities
- */
- private void loadTagsAndPriorities(String tags, String priorities) {
- fTags = StringUtils.unpack(tags);
-
- StringTokenizer toker = null;
- List list = new ArrayList();
-
- toker = new StringTokenizer(priorities, ","); //$NON-NLS-1$
- while (toker.hasMoreTokens()) {
- Integer number = null;
- try {
- number = Integer.valueOf(toker.nextToken());
- }
- catch (NumberFormatException e) {
- number = new Integer(IMarker.PRIORITY_NORMAL);
- }
- list.add(number);
- }
- fPriorities = (Integer[]) list.toArray(new Integer[0]);
- }
-
- protected void moveTagDown(int i) {
- String tag = fTags[i];
- Integer priority = fPriorities[i];
- fTags[i] = fTags[i + 1];
- fPriorities[i] = fPriorities[i + 1];
- fTags[i + 1] = tag;
- fPriorities[i + 1] = priority;
- valueTable.refresh(fTags);
- valueTable.getTable().select(i + 1);
- }
-
- protected void moveTagUp(int i) {
- String tag = fTags[i];
- Integer priority = fPriorities[i];
- fTags[i] = fTags[i - 1];
- fPriorities[i] = fPriorities[i - 1];
- fTags[i - 1] = tag;
- fPriorities[i - 1] = priority;
- valueTable.refresh(fTags);
- valueTable.getTable().select(i - 1);
- }
-
- public void performApply() {
- save();
- isDirty = false;
- }
-
- public void performDefaults() {
- String tags = ModelPlugin.getDefault().getPluginPreferences().getDefaultString(CommonModelPreferenceNames.TASK_TAG_TAGS);
- String priorities = ModelPlugin.getDefault().getPluginPreferences().getDefaultString(CommonModelPreferenceNames.TASK_TAG_PRIORITIES);
- loadTagsAndPriorities(tags, priorities);
- if (valueTable != null && valueTable.getControl() != null && !valueTable.getControl().isDisposed()) {
- valueTable.setInput(fTags);
- }
- isDirty = false;
- }
-
- public void performOk() {
- save();
- if (isDirty) {
- MessageDialog dialog = new MessageDialog(fControl.getShell(), ResourceHandler.getString("TaskTagPreferenceTab.22"), fControl.getShell().getImage(), ResourceHandler.getString("TaskTagPreferenceTab.23"), MessageDialog.QUESTION, new String[]{ResourceHandler.getString("TaskTagPreferenceTab.24"), ResourceHandler.getString("TaskTagPreferenceTab.25"), ResourceHandler.getString("TaskTagPreferenceTab.26")}, 2); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- int button = dialog.open();
- if (button == 0) {
- Job buildJob = new Job(ResourceHandler.getString("TaskTagPreferenceTab.27")) { //$NON-NLS-1$
-
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
- int errorCount = 0;
- for (int i = 0; i < projects.length && !monitor.isCanceled(); i++) {
- try {
- projects[i].build(IncrementalProjectBuilder.FULL_BUILD, ModelPlugin.STRUCTURED_BUILDER, new HashMap(), new SubProgressMonitor(monitor, projects.length));
- }
- catch (CoreException e) {
- Logger.logException(e);
- errorCount++;
- }
- }
- IStatus status = null;
- if (monitor.isCanceled()) {
- status = new Status(IStatus.CANCEL, EditorPlugin.ID, IStatus.OK, ResourceHandler.getString("TaskTagPreferenceTab.28"), null); //$NON-NLS-1$
- }
- else if (errorCount == 0) {
- status = new Status(IStatus.OK, EditorPlugin.ID, IStatus.OK, ResourceHandler.getString("TaskTagPreferenceTab.29"), null); //$NON-NLS-1$
- }
- else {
- status = new Status(IStatus.ERROR, EditorPlugin.ID, IStatus.OK, ResourceHandler.getString("TaskTagPreferenceTab.30"), null); //$NON-NLS-1$
- }
- return status;
- }
- };
- buildJob.schedule(500);
- }
- }
- isDirty = false;
- }
-
- /**
- * @param selection
- */
- protected void removeTag(int i) {
- if (i < 0) {
- return;
- }
- isDirty = true;
- List tags = new ArrayList(Arrays.asList(fTags));
- List priorities = new ArrayList(Arrays.asList(fPriorities));
- tags.remove(i);
- priorities.remove(i);
- fTags = (String[]) tags.toArray(new String[0]);
- fPriorities = (Integer[]) priorities.toArray(new Integer[0]);
- valueTable.setInput(fTags);
- }
-
- /**
- *
- */
- private void save() {
- String tags = StringUtils.pack(fTags);
- ModelPlugin.getDefault().getPluginPreferences().setValue(CommonModelPreferenceNames.TASK_TAG_TAGS, tags);
-
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < fPriorities.length; i++) {
- buf.append(String.valueOf(fPriorities[i]));
- if (i < fPriorities.length - 1)
- buf.append(","); //$NON-NLS-1$
- }
- ModelPlugin.getDefault().getPluginPreferences().setValue(CommonModelPreferenceNames.TASK_TAG_PRIORITIES, buf.toString());
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TextHoverPreferenceTab.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TextHoverPreferenceTab.java
deleted file mode 100644
index 154f67a5d7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TextHoverPreferenceTab.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.text.Assert;
-import org.eclipse.jface.viewers.ArrayContentProvider;
-import org.eclipse.jface.viewers.CheckStateChangedEvent;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ICheckStateListener;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.KeyEvent;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.preferences.CommonEditorPreferenceNames;
-import org.eclipse.wst.sse.ui.taginfo.TextHoverManager;
-import org.eclipse.wst.sse.ui.taginfo.TextHoverManager.TextHoverDescriptor;
-import org.eclipse.wst.sse.ui.util.EditorUtility;
-
-
-/**
- * Preference tab for Structured text editor hover help preferences
- * @author amywu
- */
-public class TextHoverPreferenceTab extends AbstractPreferenceTab {
-
- private class InternalTableLabelProvider extends LabelProvider implements ITableLabelProvider {
- public InternalTableLabelProvider() {
- super();
- }
-
- public Image getColumnImage(Object element, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object element, int columnIndex) {
- switch (columnIndex) {
- case 0: // text hover label
- return ((TextHoverManager.TextHoverDescriptor)element).getLabel();
-
- case 1: // text hover state mask
- return ((TextHoverManager.TextHoverDescriptor)element).getModifierString();
-
- default:
- break;
- }
-
- return null;
- }
- }
-
- private static final String DELIMITER= ResourceHandler.getString("TextHoverPreferenceTab.delimiter"); //$NON-NLS-1$
-
- private TextHoverDescriptor[] fTextHovers; // current list of text hovers for this preference page
- private Text fModifierEditor;
- private Table fHoverTable;
- private TableViewer fHoverTableViewer;
- private TableColumn fNameColumn;
- private TableColumn fModifierColumn;
- private Text fDescription;
-
- public TextHoverPreferenceTab(PreferencePage mainPreferencePage, OverlayPreferenceStore store) {
- Assert.isNotNull(mainPreferencePage);
- Assert.isNotNull(store);
- setMainPreferencePage(mainPreferencePage);
- setOverlayStore(store);
- getOverlayStore().addKeys(createOverlayStoreKeys());
- }
-
- private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() {
- ArrayList overlayKeys= new ArrayList();
-
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CommonEditorPreferenceNames.EDITOR_ANNOTATION_ROLL_OVER));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, CommonEditorPreferenceNames.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE));
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CommonEditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS));
-
- OverlayPreferenceStore.OverlayKey[] keys= new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /* (non-Javadoc)
- */
- public Control createContents(Composite tabFolder) {
- Composite hoverComposite= new Composite(tabFolder, SWT.NONE);
- GridLayout layout= new GridLayout();
- layout.numColumns= 2;
- hoverComposite.setLayout(layout);
- GridData gd= new GridData(GridData.FILL_BOTH);
- hoverComposite.setLayoutData(gd);
-
- // commented out until these preferences are actually handled in some way
-// String rollOverLabel= ResourceHandler.getString("TextHoverPreferenceTab.annotationRollover"); //$NON-NLS-1$
-// addCheckBox(hoverComposite, rollOverLabel, CommonEditorPreferenceNames.EDITOR_ANNOTATION_ROLL_OVER, 0);
-//
-// // Affordance checkbox
-// String showAffordanceLabel = ResourceHandler.getString("TextHoverPreferenceTab.showAffordance"); //$NON-NLS-1$
-// addCheckBox(hoverComposite, showAffordanceLabel, CommonEditorPreferenceNames.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE, 0);
-
- Label label= new Label(hoverComposite, SWT.NONE);
- label.setText(ResourceHandler.getString("TextHoverPreferenceTab.hoverPreferences")); //$NON-NLS-1$
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalAlignment= GridData.BEGINNING;
- gd.horizontalSpan= 2;
- label.setLayoutData(gd);
-
- fHoverTableViewer= CheckboxTableViewer.newCheckList(hoverComposite, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION);
- // Hover table
- fHoverTable= fHoverTableViewer.getTable();
- fHoverTable.setHeaderVisible(true);
- fHoverTable.setLinesVisible(true);
-
- gd= new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan= 2;
- fHoverTable.setLayoutData(gd);
-
- TableLayout tableLayout= new TableLayout();
- tableLayout.addColumnData(new ColumnWeightData(1, 140, true));
- tableLayout.addColumnData(new ColumnWeightData(1, 140, true));
- fHoverTable.setLayout(tableLayout);
-
- fHoverTable.addSelectionListener(new SelectionListener() {
- public void widgetSelected(SelectionEvent e) {
- handleHoverListSelection();
- }
- public void widgetDefaultSelected(SelectionEvent e) {
- }
- });
-
- fNameColumn= new TableColumn(fHoverTable, SWT.NONE);
- fNameColumn.setText(ResourceHandler.getString("TextHoverPreferenceTab.nameColumnTitle")); //$NON-NLS-1$
- fNameColumn.setResizable(true);
-
- fModifierColumn= new TableColumn(fHoverTable, SWT.NONE);
- fModifierColumn.setText(ResourceHandler.getString("TextHoverPreferenceTab.modifierColumnTitle")); //$NON-NLS-1$
- fModifierColumn.setResizable(true);
-
- fHoverTableViewer.setUseHashlookup(true);
- fHoverTableViewer.setContentProvider(new ArrayContentProvider());
- fHoverTableViewer.setLabelProvider(new InternalTableLabelProvider());
- ((CheckboxTableViewer)fHoverTableViewer).addCheckStateListener(new ICheckStateListener() {
- /*
- * @see org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged(org.eclipse.jface.viewers.CheckStateChangedEvent)
- */
- public void checkStateChanged(CheckStateChangedEvent event) {
- String id= ((TextHoverDescriptor)event.getElement()).getId();
- if (id == null)
- return;
-
- TextHoverManager.TextHoverDescriptor[] descriptors= getTextHoverManager().getTextHovers();
- TextHoverManager.TextHoverDescriptor hoverConfig= null;
- int i= 0, length= fTextHovers.length;
- while (i < length) {
- if (id.equals(descriptors[i].getId())) {
- hoverConfig = fTextHovers[i];
- hoverConfig.setEnabled(event.getChecked());
- fModifierEditor.setEnabled(event.getChecked());
- fHoverTableViewer.setSelection(new StructuredSelection(descriptors[i]));
- }
- i++;
- }
-
- handleHoverListSelection();
- updateStatus(hoverConfig);
- }
- });
-
- // Text field for modifier string
- label= new Label(hoverComposite, SWT.LEFT);
- label.setText(ResourceHandler.getString("TextHoverPreferenceTab.keyModifier")); //$NON-NLS-1$
- fModifierEditor= new Text(hoverComposite, SWT.BORDER);
- gd= new GridData(GridData.HORIZONTAL_ALIGN_FILL);
- fModifierEditor.setLayoutData(gd);
-
- fModifierEditor.addKeyListener(new KeyListener() {
- private boolean isModifierCandidate;
- public void keyPressed(KeyEvent e) {
- isModifierCandidate= e.keyCode > 0 && e.character == 0 && e.stateMask == 0;
- }
-
- public void keyReleased(KeyEvent e) {
- if (isModifierCandidate && e.stateMask > 0 && e.stateMask == e.stateMask && e.character == 0) {// && e.time -time < 1000) {
- String text= fModifierEditor.getText();
- Point selection= fModifierEditor.getSelection();
- int i= selection.x - 1;
- while (i > -1 && Character.isWhitespace(text.charAt(i))) {
- i--;
- }
- boolean needsPrefixDelimiter= i > -1 && !String.valueOf(text.charAt(i)).equals(DELIMITER);
-
- i= selection.y;
- while (i < text.length() && Character.isWhitespace(text.charAt(i))) {
- i++;
- }
- boolean needsPostfixDelimiter= i < text.length() && !String.valueOf(text.charAt(i)).equals(DELIMITER);
-
- String insertString;
-
- if (needsPrefixDelimiter && needsPostfixDelimiter)
- insertString= ResourceHandler.getString("JavaEditorHoverConfigurationBlock.insertDelimiterAndModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
- else if (needsPrefixDelimiter)
- insertString= ResourceHandler.getString("JavaEditorHoverConfigurationBlock.insertDelimiterAndModifier", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
- else if (needsPostfixDelimiter)
- insertString= ResourceHandler.getString("JavaEditorHoverConfigurationBlock.insertModifierAndDelimiter", new String[] {Action.findModifierString(e.stateMask)}); //$NON-NLS-1$
- else
- insertString= Action.findModifierString(e.stateMask);
-
- if (insertString != null)
- fModifierEditor.insert(insertString);
- }
- }
- });
-
- fModifierEditor.addModifyListener(new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- handleModifierModified();
- }
- });
-
- // Description
- Label descriptionLabel= new Label(hoverComposite, SWT.LEFT);
- descriptionLabel.setText(ResourceHandler.getString("TextHoverPreferenceTab.description")); //$NON-NLS-1$
- gd= new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
- gd.horizontalSpan= 2;
- descriptionLabel.setLayoutData(gd);
- fDescription= new Text(hoverComposite, SWT.LEFT | SWT.WRAP | SWT.MULTI | SWT.READ_ONLY | SWT.BORDER);
- gd= new GridData(GridData.FILL_BOTH);
- gd.horizontalSpan= 2;
- fDescription.setLayoutData(gd);
-
- initialize();
-
- Dialog.applyDialogFont(hoverComposite);
-
- WorkbenchHelp.setHelp(hoverComposite, IHelpContextIds.PREFSTE_HOVERS_HELPID);
- return hoverComposite;
- }
-
- /* (non-Javadoc)
- */
- public String getTitle() {
- return ResourceHandler.getString("TextHoverPreferenceTab.title"); //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- */
- public void performApply() {
- performOk();
- }
-
- /* (non-Javadoc)
- */
- public void performDefaults() {
- initialize();
- }
-
- /* (non-Javadoc)
- */
- public void performOk() {
- String textHoverString = generateTextHoverString();
- getOverlayStore().setValue(CommonEditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS, textHoverString);
- getTextHoverManager().resetTextHovers(); // notify text hover manager it should reset to get latest preferences
- }
-
- private String generateTextHoverString() {
- StringBuffer buf= new StringBuffer();
-
- for (int i= 0; i < fTextHovers.length; i++) {
- buf.append(fTextHovers[i].getId());
- buf.append(TextHoverManager.HOVER_ATTRIBUTE_SEPARATOR);
- buf.append(Boolean.toString(fTextHovers[i].isEnabled()));
- buf.append(TextHoverManager.HOVER_ATTRIBUTE_SEPARATOR);
- String modifier= fTextHovers[i].getModifierString();
- if (modifier == null || modifier.length() == 0)
- modifier= TextHoverManager.NO_MODIFIER;
- buf.append(modifier);
- buf.append(TextHoverManager.HOVER_SEPARATOR);
- }
- return buf.toString();
- }
-
- private void initialize() {
- restoreFromOverlay();
- fHoverTableViewer.setInput(fTextHovers);
-
- initializeFields();
- }
-
- /**
- * Populates fTextHovers with text hover description from the overlay store
- * (which is the preferences)
- */
- private void restoreFromOverlay() {
- String descriptorsString = getOverlayStore().getString(CommonEditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS);
- fTextHovers = getTextHoverManager().generateTextHoverDescriptors(descriptorsString);
- }
-
- private TextHoverManager getTextHoverManager() {
- return EditorPlugin.getDefault().getTextHoverManager();
- }
-
- /*
- * (non-Javadoc)
- */
- protected void initializeFields() {
- super.initializeFields();
-
- fModifierEditor.setEnabled(false);
- // initialize checkboxes in hover table
- for (int i= 0; i < fTextHovers.length; i++)
- fHoverTable.getItem(i).setChecked(fTextHovers[i].isEnabled());
- fHoverTableViewer.refresh();
- }
-
- private void handleHoverListSelection() {
- int i= fHoverTable.getSelectionIndex();
-
- if (i == -1) {
- if (fHoverTable.getSelectionCount() == 0)
- fModifierEditor.setEnabled(false);
- return;
- }
-
- boolean enabled= fTextHovers[i].isEnabled();
- fModifierEditor.setEnabled(enabled);
- fModifierEditor.setText(fTextHovers[i].getModifierString());
- String description= fTextHovers[i].getDescription();
- if (description == null)
- description= ""; //$NON-NLS-1$
- fDescription.setText(description);
- }
-
- private void handleModifierModified() {
- int i= fHoverTable.getSelectionIndex();
- if (i == -1)
- return;
-
- String modifiers= fModifierEditor.getText();
- fTextHovers[i].setModifierString(modifiers);
-
- // update table
- fHoverTableViewer.refresh(fTextHovers[i]);
-
- updateStatus(fTextHovers[i]);
- }
-
- private void updateStatus(TextHoverManager.TextHoverDescriptor hoverConfig) {
- IStatus status = new StatusInfo();
-
- if (hoverConfig != null && hoverConfig.isEnabled() && EditorUtility.computeStateMask(hoverConfig.getModifierString()) == -1)
- status= new StatusInfo(IStatus.ERROR, ResourceHandler.getString("TextHoverPreferenceTab.modifierIsNotValid", new String[] {hoverConfig.getModifierString()})); //$NON-NLS-1$
-
- int i= 0;
- HashMap stateMasks= new HashMap(fTextHovers.length);
- while (status.isOK() && i < fTextHovers.length) {
- if (fTextHovers[i].isEnabled()) {
- String label= fTextHovers[i].getLabel();
- Integer stateMask= new Integer(EditorUtility.computeStateMask(fTextHovers[i].getModifierString()));
- if (stateMask.intValue() == -1)
- status= new StatusInfo(IStatus.ERROR, ResourceHandler.getString("TextHoverPreferenceTab.modifierIsNotValidForHover", new String[] {fTextHovers[i].getModifierString(), label})); //$NON-NLS-1$
- else if (stateMasks.containsKey(stateMask))
- status= new StatusInfo(IStatus.ERROR, ResourceHandler.getString("TextHoverPreferenceTab.duplicateModifier", new String[] {label, (String)stateMasks.get(stateMask)})); //$NON-NLS-1$
- else
- stateMasks.put(stateMask, label);
- }
- i++;
- }
-
- updateStatus(status);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TranslucencyPreferenceTab.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TranslucencyPreferenceTab.java
deleted file mode 100644
index 9f47987fb3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/preferences/ui/TranslucencyPreferenceTab.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.preferences.ui;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.ui.help.WorkbenchHelp;
-import org.eclipse.wst.sse.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class TranslucencyPreferenceTab implements IPreferenceTab {
- /**
- *
- */
- public TranslucencyPreferenceTab() {
- super();
- }
-
-
- /* (non-Javadoc)
- */
- public Control createContents(Composite tabFolder) {
- Label label = new Label(tabFolder, SWT.NONE);
- WorkbenchHelp.setHelp(label, IHelpContextIds.PREFWEBX_READONLY_HELPID);
- return label;
- }
-
- /* (non-Javadoc)
- */
- public String getTitle() {
- return ResourceHandler.getString("TranslucencyPreferenceTab.0"); //$NON-NLS-1$
- }
- /* (non-Javadoc)
- */
- public void performApply() {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- */
- public void performDefaults() {
- // TODO Auto-generated method stub
-
- }
- /* (non-Javadoc)
- */
- public void performOk() {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryProvider.java
deleted file mode 100644
index 998e6eb13c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryProvider.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.registry;
-
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-public interface AdapterFactoryProvider {
-
- // TODO_issue: IDocumentTypeHandler doesn't seem correct in this API.
- // reexamine and see if should be ModelHandler, or ContentTypeIdentifer
- // instead.
- public boolean isFor(IDocumentTypeHandler contentTypeDescription);
-
- public void addAdapterFactories(IStructuredModel structuredModel);
-
- /**
- * This method should only add those factories related to embedded content
- * type
- */
- public void reinitializeFactories(IStructuredModel structuredModel);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistry.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistry.java
deleted file mode 100644
index 26c078c152..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistry.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.registry;
-
-import java.util.Iterator;
-
-/**
- * This is basically a "factory for factories". It is to used to associate
- * "edit time" AdapterFactories with a StrucutredModel, based on the
- * IStructuredModel's ContentTypeDescription. In plugin.xml files, there
- * should be an AdapterFactoryProvider defined for every definition
- * of ContentTypeDescription.
- */
-public interface AdapterFactoryRegistry {
-
- //NSD: David, shouldn't this be named getAdapterFactoryProviders?
- public Iterator getAdapterFactories();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryImpl.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryImpl.java
deleted file mode 100644
index 7cefd08993..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryImpl.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.registry;
-
-import java.util.HashSet;
-import java.util.Iterator;
-
-public class AdapterFactoryRegistryImpl implements AdapterFactoryRegistry {
-
- private static AdapterFactoryRegistry instance = null;
- private HashSet hashSet = null;
-
- private AdapterFactoryRegistryImpl() {
- super();
- hashSet = new HashSet();
- AdapterFactoryRegistryReader.readRegistry(hashSet);
- }
-
- static synchronized public AdapterFactoryRegistry getInstance() {
- if (instance == null) {
- instance = new AdapterFactoryRegistryImpl();
- }
- return instance;
- }
-
- public Iterator getAdapterFactories() {
- return hashSet.iterator();
- }
-
- void add(AdapterFactoryProvider adapterFactoryProvider) {
- hashSet.add(adapterFactoryProvider);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryReader.java
deleted file mode 100644
index 29a4384671..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/AdapterFactoryRegistryReader.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.registry;
-
-import java.util.Set;
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-/**
- * This class just converts what's in the plugins registry
- * into a form more easily useable by others, the ContentTypeRegistry.
- */
-class AdapterFactoryRegistryReader {
-
- //
- protected final static String PLUGIN_ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$
- protected final static String EXTENSION_POINT_ID = "adapterFactoryDescription"; //$NON-NLS-1$
- protected final static String TAG_NAME = "adapterFactoryDescription"; //$NON-NLS-1$
- protected final static String ATT_CLASS = "class"; //$NON-NLS-1$
-
- // protected final static String ADAPTER_CLASS = "adapterClass"; //$NON-NLS-1$
- // protected final static String DOC_TYPE_ID = "docTypeId"; //$NON-NLS-1$
- // protected final static String MIME_TYPE_LIST = "mimeTypeList"; //$NON-NLS-1$
- //
- /**
- * ContentTypeRegistryReader constructor comment.
- */
- AdapterFactoryRegistryReader() {
- super();
- }
-
- protected static AdapterFactoryProvider readElement(IConfigurationElement element) {
- AdapterFactoryProvider adapterFactoryProvider = null;
- if (element.getName().equals(TAG_NAME)) {
- try {
- adapterFactoryProvider = (AdapterFactoryProvider) element.createExecutableExtension(ATT_CLASS);
- }
- catch (Throwable e) {
- // if the provider throws any exception, just log and continue
- Logger.logException(e);
- }
- }
- return adapterFactoryProvider;
- }
-
- /**
- * We simply require an 'add' method, of what ever it is we are to read into
- */
- static void readRegistry(Set set) {
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- AdapterFactoryProvider adapterFactoryProvider = readElement(elements[i]);
- if (adapterFactoryProvider != null) {
- set.add(adapterFactoryProvider);
- Logger.trace("Initialization", "adding to AdapterFactoryRegistry: " + adapterFactoryProvider.toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryProvider.java
deleted file mode 100644
index ba9becf66c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryProvider.java
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.registry.embedded;
-
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-
-public interface EmbeddedAdapterFactoryProvider {
-
- public boolean isFor(EmbeddedTypeHandler typeHandler);
-
- public void addAdapterFactories(IStructuredModel structuredModel);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryImpl.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryImpl.java
deleted file mode 100644
index 8119c9b325..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryImpl.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.registry.embedded;
-
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.ui.registry.AdapterFactoryRegistry;
-
-
-public class EmbeddedAdapterFactoryRegistryImpl implements AdapterFactoryRegistry {
-
- private static AdapterFactoryRegistry instance = null;
- private HashSet hashSet = null;
-
- private EmbeddedAdapterFactoryRegistryImpl() {
- super();
- hashSet = new HashSet();
- EmbeddedAdapterFactoryRegistryReader.readRegistry(hashSet);
- }
-
- static synchronized public AdapterFactoryRegistry getInstance() {
- if (instance == null) {
- instance = new EmbeddedAdapterFactoryRegistryImpl();
- }
- return instance;
- }
-
- public Iterator getAdapterFactories() {
- return hashSet.iterator();
- }
-
- void add(EmbeddedAdapterFactoryProvider adapterFactoryProvider) {
- hashSet.add(adapterFactoryProvider);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryReader.java
deleted file mode 100644
index e83445dd70..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/registry/embedded/EmbeddedAdapterFactoryRegistryReader.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.registry.embedded;
-
-import java.util.Set;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.util.Assert;
-
-
-/**
- * This class just converts what's in the plugins registry
- * into a form more easily useable by others, the ContentTypeRegistry.
- */
-class EmbeddedAdapterFactoryRegistryReader {
-
- //
- protected final static String PLUGIN_ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$
- protected final static String EXTENSION_POINT_ID = "embeddedAdapterFactoryProvider"; //$NON-NLS-1$
- protected final static String TAG_NAME = "embeddedAdapterFactoryProvider"; //$NON-NLS-1$
- protected final static String ATT_CLASS = "class"; //$NON-NLS-1$
- // protected final static String ADAPTER_CLASS = "adapterClass"; //$NON-NLS-1$
- // protected final static String DOC_TYPE_ID = "docTypeId"; //$NON-NLS-1$
- // protected final static String MIME_TYPE_LIST = "mimeTypeList"; //$NON-NLS-1$
-
- //
- /**
- * ContentTypeRegistryReader constructor comment.
- */
- EmbeddedAdapterFactoryRegistryReader() {
- super();
- }
-
- protected static EmbeddedAdapterFactoryProvider readElement(IConfigurationElement element) {
- EmbeddedAdapterFactoryProvider embeddedAdapterFactoryProvider = null;
- if (element.getName().equals(TAG_NAME)) {
- String className = element.getAttribute(ATT_CLASS);
- // if className is null, then no one defined the extension point for design view
- if (className != null) {
- try {
- embeddedAdapterFactoryProvider = (EmbeddedAdapterFactoryProvider) element.createExecutableExtension(ATT_CLASS);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- }
-
- Assert.isNotNull(embeddedAdapterFactoryProvider, "Error reading embedded adapter factory registry"); //$NON-NLS-1$
- return embeddedAdapterFactoryProvider;
- }
-
- /**
- * We simply require an 'add' method, of what ever it is we are to read into
- */
- static void readRegistry(Set set) {
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- EmbeddedAdapterFactoryProvider adapterFactoryProvider = readElement(elements[i]);
- set.add(adapterFactoryProvider);
- Logger.trace("Initialization", "adding to AdapterFactoryRegistry: " + adapterFactoryProvider.toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/AbstractLineStyleProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/AbstractLineStyleProvider.java
deleted file mode 100644
index 46545678b4..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/AbstractLineStyleProvider.java
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.style;
-
-import java.util.Collection;
-import java.util.HashMap;
-
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.wst.sse.core.preferences.PreferenceChangeListener;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionCollection;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.ui.preferences.PreferenceManager;
-import org.eclipse.wst.sse.ui.util.EditorUtility;
-
-
-public abstract class AbstractLineStyleProvider implements PreferenceChangeListener {
- /** Contains all text attributes pretaining to this line style provider*/
- private HashMap fTextAttributes = null;
-
- // had to make this not final, or got in to infinite recursion during class loading in VAJava!
- // (must be a VAJava thing)
- private LineStyleProvider defaultAttributeProvider = null;
- private IStructuredDocument fDocument;
- private Highlighter fHighlighter;
- private boolean initialized;
-
- //protected IStructuredDocumentRegion currentStructuredDocumentRegion;
- // Note: the var=x.class contructs were put into this method
- // as a workaround for slow VAJava class lookups. They compiler
- // assigns them to a variable in the JDK, but Class.forName("x")
- // in VAJava. It is workaround specific for VAJava environment, so could
- // be simplified in future.
- static Class LineStyleProviderClass = LineStyleProvider.class;
-
- // we keep track of LogMessage to avoid writing hundreds of messages,
- // but still give a hint that something is wrong with attributeProviders and/or regions.
- // It's only written in the case of a program error, but there's no use adding
- // salt to the wound.
- //private boolean wroteOneLogMessage;
- /**
- */
- protected AbstractLineStyleProvider() {
- }
-
- protected void addEmptyRange(int start, int length, Collection holdResults) {
- StyleRange result = new StyleRange();
- result.start = start;
- result.length = length;
- holdResults.add(result);
- }
-
- /**
- * this version does "trim" regions to match request
- */
- protected StyleRange createStyleRange(ITextRegionCollection flatNode, ITextRegion region, TextAttribute attr, int startOffset, int length) {
-
- int start = flatNode.getStartOffset(region);
- if (start < startOffset)
- start = startOffset;
- int maxOffset = startOffset + length;
- int end = flatNode.getEndOffset(region); // use get length directly instead of end-start?
- if (end > maxOffset)
- end = maxOffset;
- StyleRange result = new StyleRange(start, end - start, attr.getForeground(), attr.getBackground(), attr.getStyle());
- return result;
-
- }
-
- protected TextAttribute createTextAttribute(RGB foreground, RGB background, boolean bold) {
- return new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, bold ? SWT.BOLD : SWT.NORMAL);
- }
-
- protected TextAttribute getAttributeFor(ITextRegion region) {
- // should be "abstract" method
- return null;
- }
-
- abstract protected PreferenceManager getColorManager();
-
- /**
- * See also Highligher::getTextAttributeProvider
- */
- protected LineStyleProvider getDefaultLineStyleProvider() {
- if (defaultAttributeProvider == null) {
- defaultAttributeProvider = new LineStyleProviderForNoOp();
- }
- return defaultAttributeProvider;
- }
-
- /**
- */
- protected Highlighter getHighlighter() {
- return fHighlighter;
- }
-
- public void init(IStructuredDocument structuredDocument, Highlighter highlighter) {
-
- commonInit(structuredDocument, highlighter);
-
- if (isInitialized())
- return;
-
- registerPreferenceManager();
-
- setInitialized(true);
- }
-
- protected void commonInit(IStructuredDocument document, Highlighter highlighter) {
-
- fDocument = document;
- fHighlighter = highlighter;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type
- * allows it to return true in more than one case.
- */
- public boolean isAdapterForType(java.lang.Object type) {
- return type == LineStyleProviderClass;
- }
-
- public void preferencesChanged() {
- // force a full update of the text viewer
- fHighlighter.refreshDisplay();
- }
-
- public boolean prepareRegions(ITypedRegion typedRegion, int lineRequestStart, int lineRequestLength, Collection holdResults) {
- final int partitionStartOffset = typedRegion.getOffset();
- final int partitionLength = typedRegion.getLength();
- IStructuredDocumentRegion structuredDocumentRegion = getDocument().getRegionAtCharacterOffset(partitionStartOffset);
- boolean handled = false;
-
- handled = prepareTextRegions(structuredDocumentRegion, partitionStartOffset, partitionLength, holdResults);
-
- return handled;
- }
-
- private boolean prepareTextRegions(IStructuredDocumentRegion structuredDocumentRegion, int partitionStartOffset, int partitionLength, Collection holdResults) {
- boolean handled = false;
- final int partitionEndOffset = partitionStartOffset + partitionLength - 1;
- while (structuredDocumentRegion != null && structuredDocumentRegion.getStartOffset() <= partitionEndOffset) {
- ITextRegion region = null;
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- int nRegions = regions.size();
- StyleRange styleRange = null;
- for (int i = 0; i < nRegions; i++) {
- region = regions.get(i);
- TextAttribute attr = null;
- TextAttribute previousAttr = null;
- if (structuredDocumentRegion.getStartOffset(region) > partitionEndOffset)
- break;
- if (structuredDocumentRegion.getEndOffset(region) <= partitionStartOffset)
- continue;
-
- if (region instanceof ITextRegionCollection) {
- handled = prepareTextRegion((ITextRegionCollection) region, partitionStartOffset, partitionLength, holdResults);
- }
- else {
-
- attr = getAttributeFor(region);
- if (attr != null) {
- handled = true;
- // if this region's attr is the same as previous one, then just adjust the previous style range
- // instead of creating a new instance of one
- // note: to use 'equals' in this case is important, since sometimes
- // different instances of attributes are associated with a region, even the
- // the attribute has the same values.
- // TODO: this needs to be improved to handle readonly regions correctly
- if ((styleRange != null) && (previousAttr != null) && (previousAttr.equals(attr))) {
- styleRange.length += region.getLength();
- }
- else {
- styleRange = createStyleRange(structuredDocumentRegion, region, attr, partitionStartOffset, partitionLength);
- holdResults.add(styleRange);
- // technically speaking, we don't need to update previousAttr
- // in the other case, because the other case is when it hasn't changed
- previousAttr = attr;
- }
- }
- else {
- previousAttr = null;
- }
- }
-
- if (Debug.syntaxHighlighting && !handled) {
- System.out.println("not handled in prepareRegions"); //$NON-NLS-1$
- }
- }
- structuredDocumentRegion = structuredDocumentRegion.getNext();
- }
- return handled;
- }
-
- /**
- * @param region
- * @param start
- * @param length
- * @param holdResults
- * @return
- */
- private boolean prepareTextRegion(ITextRegionCollection blockedRegion, int partitionStartOffset, int partitionLength, Collection holdResults) {
- boolean handled = false;
- final int partitionEndOffset = partitionStartOffset + partitionLength - 1;
- ITextRegion region = null;
- ITextRegionList regions = blockedRegion.getRegions();
- int nRegions = regions.size();
- StyleRange styleRange = null;
- for (int i = 0; i < nRegions; i++) {
- region = regions.get(i);
- TextAttribute attr = null;
- TextAttribute previousAttr = null;
- if (blockedRegion.getStartOffset(region) > partitionEndOffset)
- break;
- if (blockedRegion.getEndOffset(region) <= partitionStartOffset)
- continue;
-
- if (region instanceof ITextRegionCollection) {
- handled = prepareTextRegion((ITextRegionCollection) region, partitionStartOffset, partitionLength, holdResults);
- }
- else {
-
- attr = getAttributeFor(region);
- if (attr != null) {
- handled = true;
- // if this region's attr is the same as previous one, then just adjust the previous style range
- // instead of creating a new instance of one
- // note: to use 'equals' in this case is important, since sometimes
- // different instances of attributes are associated with a region, even the
- // the attribute has the same values.
- // TODO: this needs to be improved to handle readonly regions correctly
- if ((styleRange != null) && (previousAttr != null) && (previousAttr.equals(attr))) {
- styleRange.length += region.getLength();
- }
- else {
- styleRange = createStyleRange(blockedRegion, region, attr, partitionStartOffset, partitionLength);
- holdResults.add(styleRange);
- // technically speaking, we don't need to update previousAttr
- // in the other case, because the other case is when it hasn't changed
- previousAttr = attr;
- }
- }
- else {
- previousAttr = null;
- }
- }
- }
- return handled;
- }
-
- protected void registerPreferenceManager() {
- PreferenceManager mgr = getColorManager();
- if (mgr != null) {
- mgr.addPreferenceChangeListener(this);
- }
- }
-
- public void release() {
- unRegisterPreferenceManager();
- getTextAttributes().clear();
- }
-
- protected void unRegisterPreferenceManager() {
- PreferenceManager mgr = getColorManager();
- if (mgr != null) {
- mgr.removePreferenceChangeListener(this);
- }
- }
-
- /**
- * Returns the initialized.
- * @return boolean
- */
- public boolean isInitialized() {
- return initialized;
- }
-
- /**
- * Sets the initialized.
- * @param initialized The initialized to set
- */
- public void setInitialized(boolean initialized) {
- this.initialized = initialized;
- }
-
- protected IStructuredDocument getDocument() {
- return fDocument;
- }
- /**
- * Returns the hashtable containing all the text attributes for this line style provider.
- * Lazily creates a hashtable if one has not already been created.
- * @return
- */
- protected HashMap getTextAttributes() {
- if (fTextAttributes == null) {
- fTextAttributes = new HashMap();
- }
- return fTextAttributes;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/Highlighter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/Highlighter.java
deleted file mode 100644
index f9054825c7..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/Highlighter.java
+++ /dev/null
@@ -1,518 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.style;
-
-
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.swt.custom.LineStyleEvent;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-/**
- * This class is to directly mediate between the Flat Model data structure
- * and the text widget's text and events. It assumes there only the model
- * is interested in text events, and all other views will work from that model.
- * Changes to the text widgets input can cause changes in the model, which in turn
- * cause changes to the widget's display.
- *
- */
-public class Highlighter implements IHighlighter {
- private final String READONLY_KEY_POSTFIX = ".readonly"; //$NON-NLS-1$
-
- private double readOnlyBackgroundScaleFactor = 0.1;
-
- private double readOnlyForegroundScaleFactor = 0.3;
-
- private YUV_RGBConverter rgbConverter;
-
- private IStructuredDocument fStructuredDocument;
- private StyledText textWidget;
- private ITextViewer textViewer;
-
- protected final LineStyleProvider NOOP_PROVIDER = new LineStyleProviderForNoOp();
- private final StyleRange[] EMPTY_STYLE_RANGE = new StyleRange[0];
- private ArrayList holdStyleResults;
- private HashMap fTableOfProviders;
-
- private int fSavedOffset = -1;
- private int fSavedLength = -1;
- private StyleRange[] fSavedRanges = null;
-
- private final boolean DEBUG = false;
-
- public Highlighter() {
- super();
- }
-
- private Map getTableOfProviders() {
- if (fTableOfProviders == null) {
- fTableOfProviders = new HashMap();
- }
- return fTableOfProviders;
- }
-
- public void addProvider(String partitionType, LineStyleProvider provider) {
- getTableOfProviders().put(partitionType, provider);
- }
-
- public void removeProvider(String partitionType) {
- getTableOfProviders().remove(partitionType);
- }
-
- /**
- *
- * @deprecated - use no-arg constructor, and install/uninstall
- */
- public Highlighter(ITextViewer newTextViewer) {
- this();
- setTextViewer(newTextViewer);
- }
-
- protected void adjust(StyleRange[] ranges, int adjustment) {
- for (int i = 0; i < ranges.length; i++) {
- ranges[i].start += adjustment;
- }
- }
-
- protected void addEmptyRange(int start, int length, Collection holdResults) {
- StyleRange result = new StyleRange();
- result.start = start;
- result.length = length;
- holdResults.add(result);
- }
-
- protected IStructuredDocument getDocument() {
-
- return fStructuredDocument;
- }
-
- /**
- * A passthrough method that extracts relevant data from the LineStyleEvent
- * and passes it along. This method was separated for performance testing purposes.
- *
- * @see org.eclipse.swt.custom.LineStyleListener#lineGetStyle(LineStyleEvent)
- */
- public void lineGetStyle(LineStyleEvent event) {
- int offset = event.lineOffset;
- int length = event.lineText.length();
-
- // // for some reason, we are sometimes asked for the same style range over and
- // // over again. This was found to happen during 'revert' of a file with one
- // // line in it that is 40K long! So, while I don't know root cause, caching
- // // the styled ranges in case the exact same request is made multiple times
- // // seems like cheap insurance.
- if (offset == fSavedOffset && length == fSavedLength && fSavedRanges != null) {
- event.styles = fSavedRanges;
- }
- else {
- // need to assign this array here, or else the field won't get updated
- event.styles = lineGetStyle(offset, length);
- // now saved "cached data" for repeated requests which are exaclty same
- fSavedOffset = offset;
- fSavedLength = length;
- fSavedRanges = event.styles;
- }
- }
-
- public StyleRange[] lineGetStyle(int eventLineOffset, int eventLineLength) {
- StyleRange[] eventStyles = EMPTY_STYLE_RANGE;
- try {
- if (getDocument() == null) {
-
- // during initialization, this is sometimes called before our structured
- // is set, in which case we set styles to be the empty style range
- // (event.styles can not be null)
- eventStyles = EMPTY_STYLE_RANGE;
- return eventStyles;
- }
- int start = eventLineOffset;
- int length = eventLineLength;
- int end = start + length - 1;
-
- // we sometimes get odd requests from the very last CRLF in the document
- // it has no length, and there is no node for it!
- if (length == 0) {
- eventStyles = EMPTY_STYLE_RANGE;
- }
- else {
- IRegion vr = null;
- if (getTextViewer() != null) {
- vr = getTextViewer().getVisibleRegion();
- }
- else {
- vr = new Region(0, getDocument().getLength());
- }
- if (start > vr.getLength()) {
- eventStyles = EMPTY_STYLE_RANGE;
- }
- else {
- // Determine if we're highlighting a visual portion of the model not
- // starting at zero. If so, adjust the location from which we retrieve
- // the style information
- if (vr.getOffset() > 0) {
- start += vr.getOffset();
- end += vr.getOffset();
- }
- // // ================
- // if (start == fSavedOffset && length == fSavedLength && fSavedRanges != null) {
- // eventStyles = (StyleRange[]) fSavedRanges;
- // } else {
-
- ITypedRegion[] partitions = getDocument().getDocumentPartitioner().computePartitioning(start, length);
- eventStyles = prepareStyleRangesArray(partitions, start, length);
-
- // If there is a subtext offset, the style ranges must be adjusted to the expected
- // offsets
- if (vr.getOffset() > 0)
- adjust(eventStyles, -vr.getOffset());
-
- // fSavedOffset = start;
- // fSavedLength = length;
- // fSavedRanges = (StyleRange[]) eventStyles;
-
- // for debugging only
- if (DEBUG) {
- if (!valid(eventStyles, eventLineOffset, eventLineLength)) {
- Logger.log(Logger.WARNING, "Highlighter::lineGetStyle found invalid styles at offset " + eventLineOffset); //$NON-NLS-1$
- }
- }
- // }
- }
- }
- }
- catch (Exception e) {
- // if ANY exception occurs during highlighting,
- // just return "no highlighting"
- eventStyles = EMPTY_STYLE_RANGE;
- if (Debug.syntaxHighlighting) {
- System.out.println("Exception during highlighting!"); //$NON-NLS-1$
- }
- }
- return eventStyles;
- }
-
- /**
- * Note: its very important this method never return null, which is why
- * the final null check is in a finally clause
- */
-
- protected StyleRange[] prepareStyleRangesArray(ITypedRegion[] partitions, int start, int length) {
-
- StyleRange[] result = EMPTY_STYLE_RANGE;
-
- if (holdStyleResults == null) {
- holdStyleResults = new ArrayList(20);
- }
- else {
- holdStyleResults.clear();
- }
-
- // to do: make some of these instance variables to prevent creation on stack
- LineStyleProvider attributeProvider = null;
- boolean handled = false;
- for (int i = 0; i < partitions.length; i++) {
- ITypedRegion typedRegion = partitions[i];
- attributeProvider = getProviderFor(typedRegion);
-
- // //REMINDER: eventually need to remove this one, and use only structuredDocument
- //attributeProvider.init(getModel(), this);
- attributeProvider.init(getDocument(), this);
-
- // handled = attributeProvider.prepareRegions(typedRegion, start, length, holdStyleResults);
- handled = attributeProvider.prepareRegions(typedRegion, typedRegion.getOffset(), typedRegion.getLength(), holdStyleResults);
- if (Debug.syntaxHighlighting && !handled) {
- System.out.println("Did not handle highlighting in Highlighter inner while"); //$NON-NLS-1$
- }
- }
-
- int resultSize = holdStyleResults.size();
- if (resultSize == 0) {
- result = EMPTY_STYLE_RANGE;
- }
- else {
- result = new StyleRange[resultSize];
- holdStyleResults.trimToSize();
- System.arraycopy(holdStyleResults.toArray(), 0, result, 0, resultSize);
- }
- result = convertReadOnlyRegions(result, start, length);
- return result;
- }
-
- /**
- * @param result
- * @return
- */
- private StyleRange[] convertReadOnlyRegions(StyleRange[] result, int start, int length) {
- IStructuredDocument structuredDocument = getDocument();
-
- // for client/provider simplicity (and consisten look and feel)
- // we'll handle readonly regions in one spot, here in highlighter.
- // though I suspect may have to be more sophisticated later.
- // For example, it a fair assumption that each readonly region
- // be on an ITextRegion boundry, but we do combine consequtive
- // styles, when found to be equivilent.
- // Plus, for now, we'll just adjust background. Eventually
- // will us a "dimming" algrorightm. to adjust color's satuation/brightness
- if (structuredDocument.containsReadOnly(start, length)) {
- // something is read-only in the line, so go through each style, and adjust
- for (int i = 0; i < result.length; i++) {
- StyleRange styleRange = result[i];
- if (structuredDocument.containsReadOnly(styleRange.start, styleRange.length)) {
- // should do background first. Its used by forground
- //adjustBackground(styleRange);
- adjustForground(styleRange);
- }
- }
- }
-
- return result;
- }
-
- private void adjustForground(StyleRange styleRange) {
- RGB oldRGB = null;
- //Color oldColor = styleRange.foreground;
- Color oldColor = styleRange.background;
- if (oldColor == null) {
- //oldRGB = getTextWidget().getForeground().getRGB();
- oldColor = getTextWidget().getBackground();
- oldRGB = oldColor.getRGB();
- }
- else {
- oldRGB = oldColor.getRGB();
- }
- Color newColor = getCachedColorFor(oldRGB);
- if (newColor == null) {
- // make text "closer to" background lumanence
- double target = getRGBConverter().calculateYComponent(oldColor);
- RGB newRGB = getRGBConverter().transformRGBToGrey(oldRGB, readOnlyForegroundScaleFactor, target);
-
- // save conversion, so calculations only need to be done once
- cacheColor(oldRGB, newRGB);
- newColor = getCachedColorFor(oldRGB);
- }
- styleRange.foreground = newColor;
- }
-
- private void adjustBackground(StyleRange styleRange) {
-
- RGB oldRGB = null;
- Color oldColor = styleRange.background;
- if (oldColor == null) {
- oldColor = getTextWidget().getBackground();
- }
- oldRGB = oldColor.getRGB();
- Color newColor = getCachedColorFor(oldRGB);
- if (newColor == null) {
- double target = getRGBConverter().calculateYComponent(oldColor);
- // if background is "light" make it darker, and vice versa
- if (target < 0.5)
- target = 1.0;
- else
- target = 0.0;
- RGB newRGB = getRGBConverter().transformRGB(oldRGB, readOnlyBackgroundScaleFactor, target);
-
- cacheColor(oldRGB, newRGB);
- newColor = getCachedColorFor(oldRGB);
- }
- styleRange.background = newColor;
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- * @param oldRGB
- * @param newColor
- */
- private void cacheColor(RGB oldRGB, RGB newColor) {
- // symbolic name for newColor
- String readOnlyKey = oldRGB.toString()+ READONLY_KEY_POSTFIX;
-
- // add to platform color registry
- JFaceResources.getColorRegistry().put(readOnlyKey, newColor);
- }
-
- /**
- * This method is just to get existing Colors,
- * to be used for readonly regions
- * cached by "old" (non-readonly) RGB values
- */
- private Color getCachedColorFor(RGB oldRGB) {
- // symbolic name for oldRGB
- String readOnlyKey = oldRGB.toString()+ READONLY_KEY_POSTFIX;
-
- // get the color from the platform color registry
- return JFaceResources.getColorRegistry().get(readOnlyKey);
- }
-
- private YUV_RGBConverter getRGBConverter() {
- if (rgbConverter == null) {
- rgbConverter = new YUV_RGBConverter();
- }
- return rgbConverter;
- }
-
- /**
- * Method getProviderFor.
- * @param typedRegion
- * @return LineStyleProvider
- */
- private LineStyleProvider getProviderFor(ITypedRegion typedRegion) {
- String type = typedRegion.getType();
- LineStyleProvider result = (LineStyleProvider) fTableOfProviders.get(type);
- if (result == null) {
- result = NOOP_PROVIDER;
- }
-
- return result;
- }
-
- public void refreshDisplay() {
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.redraw();
- }
-
- /**
- */
- public void refreshDisplay(int start, int length) {
- if (textWidget != null && !textWidget.isDisposed())
- textWidget.redrawRange(start, length, true);
- }
-
- public void setDocument(IStructuredDocument structuredDocument) {
- fStructuredDocument = structuredDocument;
- }
-
- /**
- * @deprecated - use setTextViewer(ITextViewer)
- * this will become private
- */
- public void setTextWidget(StyledText newTextWidget) {
- if (textWidget != null) {
- textWidget.removeLineStyleListener(this);
- }
- textWidget = newTextWidget;
- textWidget.addLineStyleListener(this);
- }
-
- /**
- * Purely a debugging aide.
- */
- private boolean valid(StyleRange[] eventStyles, int startOffset, int lineLength) {
- boolean result = false;
- if (eventStyles != null) {
- if (eventStyles.length > 0) {
- StyleRange first = eventStyles[0];
- StyleRange last = eventStyles[eventStyles.length - 1];
- if (startOffset > first.start) {
- result = false;
- }
- else {
- int lineEndOffset = startOffset + lineLength;
- int lastOffset = last.start + last.length;
- if (lastOffset > lineEndOffset) {
- result = false;
- }
- else {
- result = true;
- }
- }
- }
- else {
- // a zero length array is ok
- result = true;
- }
- }
- return result;
- }
-
- /**
- * Returns the textViewer.
- * @return ITextViewer
- */
- public ITextViewer getTextViewer() {
- return textViewer;
- }
-
- /**
- * Sets the textViewer.
- * @param textViewer The textViewer to set
- * @deprecated - used install/uninstall
- */
- public void setTextViewer(ITextViewer textViewer) {
- this.textViewer = textViewer;
- if (getTextViewer() != null)
- setTextWidget(textViewer.getTextWidget());
- }
-
- public void install(ITextViewer newTextViewer) {
- this.textViewer = newTextViewer;
- if (getTextViewer() != null)
- setTextWidget(newTextViewer.getTextWidget());
- refreshDisplay();
- }
-
- /* (non-Javadoc)
- */
- public void uninstall() {
- if (textWidget != null && !textWidget.isDisposed()) {
- textWidget.removeLineStyleListener(this);
- }
-
- Collection providers = getTableOfProviders().values();
- Iterator iterator = providers.iterator();
- while (iterator.hasNext()) {
- LineStyleProvider lineStyleProvider = (LineStyleProvider) iterator.next();
- lineStyleProvider.release();
- // this remove probably isn't strictly needed, since
- // typically highlighter instance as a whole will go
- // away ... but in case that ever changes, this seems like
- // a better style.
- iterator.remove();
- }
-
- // clear out cached variables (d282894)
- fSavedOffset = -1;
- fSavedLength = -1;
- fSavedRanges = null;
- }
-
- /**
- * @return
- */
- protected StyledText getTextWidget() {
- return textWidget;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/IHighlighter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/IHighlighter.java
deleted file mode 100644
index 8f2f855c3b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/IHighlighter.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.style;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.custom.LineStyleListener;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-/**
- * @author davidw
- *
- * To change this generated comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public interface IHighlighter extends LineStyleListener {
-
- public void addProvider(String partitionType, LineStyleProvider provider);
-
- public void removeProvider(String partitionType);
-
- public void setDocument(IStructuredDocument structuredDocument);
-
- void install(ITextViewer viewer);
-
- void uninstall();
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProvider.java
deleted file mode 100644
index 09be06bcd5..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.style;
-
-
-
-import java.util.Collection;
-
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-public interface LineStyleProvider {
-
- void init(IStructuredDocument document, Highlighter highlighter);
-
- /**
- * This method must add StyleRanges to the holdResults collection, for the text
- * starting with startStructuredDocumentRegion and ending with endStructuredDocumentRegion.
- */
- boolean prepareRegions(ITypedRegion currentRegion, int start, int length, Collection holdResults);
-
- /**
- * This method must add StyleRanges to the holdResults collection, for the text
- * starting with startStructuredDocumentRegion and ending with endStructuredDocumentRegion.
- * @deprecated -- use single node version
- * I'd like to get rid of this method (if no objections) and
- * just do the "looping" from start to end node in highlighter.
- */
- //void prepareStyleRanges(ITextRegionContainer startStructuredDocumentRegion, ITextRegionContainer endStructuredDocumentRegion, int start, int length, Collection holdResults);
- /**
- * This method allows the implementer to free up any "resources"
- * they might be holding on to (such as listening for preference
- * changes)
- */
- void release();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProviderForNoOp.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProviderForNoOp.java
deleted file mode 100644
index aab52e3122..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/LineStyleProviderForNoOp.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.style;
-
-
-
-import java.util.Collection;
-
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.wst.sse.ui.preferences.PreferenceManager;
-
-
-/**
- * This class is used by default, if no attribute provider
- * is found for a certain node type. Its probably an error
- * in a factory somewhere if an adapter is not found,
- * but this class allows the logic to proceed basically
- * simply providing default colored syntax highlighting.
- */
-public class LineStyleProviderForNoOp extends AbstractLineStyleProvider implements LineStyleProvider {
-
-
- /**
- */
- protected PreferenceManager getColorManager() {
- return null;
- }
-
- /**
- */
- public boolean prepareRegions(ITypedRegion currentRegion, int start, int length, Collection holdResults) {
- // add nothing
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/YUV_RGBConverter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/YUV_RGBConverter.java
deleted file mode 100644
index 7e6cea7726..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/style/YUV_RGBConverter.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.style;
-
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-/**
- * A utility class to do various color manipulations
- */
-public class YUV_RGBConverter {
- /**
- * This class "holds" the YUV values corresponding to RGB color
- */
- public class YUV {
- /**
- * normalize to "average" gamma 2.2222 or 1/0.45
- */
- double gammaNormalized(double colorComponent) {
- if (colorComponent < 0.018) {
- return colorComponent * 0.45;
- }
- else {
- return 1.099 * Math.pow(colorComponent, 0.45) - 0.099;
- }
- }
-
- double inverseGammaNormalized(double colorComponent) {
- if (colorComponent < 0.018) {
- return colorComponent * .222;
- }
- else {
- return Math.pow(((.9099 * colorComponent + 0.09)), 2.22);
- }
- }
-
- class NormalizedRGB {
- private final double maxRGB = 256.0;
- double red;
- double green;
- double blue;
-
- public NormalizedRGB(RGB rgb) {
- // first normalize to between 0 - 1
- red = rgb.red / maxRGB;
- green = rgb.green / maxRGB;
- blue = rgb.blue / maxRGB;
-
- red = gammaNormalized(red);
- green = gammaNormalized(green);
- blue = gammaNormalized(blue);
-
- }
- }
-
- private RGB originalRGB;
- private NormalizedRGB normalizedRGB;
- private double y = -1;
- private double u = -1;
- private double v = -1;
-
- private YUV() {
- super();
- }
-
- public YUV(RGB rgb) {
- this();
- originalRGB = rgb;
- normalizedRGB = new NormalizedRGB(rgb);
- // force calculations
- getY();
- getV();
- getU();
- }
-
- public YUV(double y, double u, double v) {
- this();
- this.y = y;
- this.u = u;
- this.v = v;
- }
-
- public double getU() {
- if (u == -1) {
- u = 0.4949 * (normalizedRGB.blue - getY());
- }
- return u;
-
- }
-
- public double getV() {
- if (v == -1) {
- v = 0.877 * (normalizedRGB.red - getY());
- }
- return v;
- }
-
- public double getY() {
- if (y == -1) {
- y = 0.299 * normalizedRGB.red + 0.587 * normalizedRGB.green + 0.114 * normalizedRGB.blue;
- }
- return y;
- }
-
- /**
- * @return RGB based on original RGB and current YUV values;
- */
- public RGB getRGB() {
- RGB result = null;
- double r = getY() + 1.14 * getV();
- double g = getY() - 0.395 * getU() - 0.58 * getV();
- double b = getY() + 2.032 * getU();
-
- int red = (int) (inverseGammaNormalized(r) * 256);
- int green = (int) (inverseGammaNormalized(g) * 256);
- int blue = (int) (inverseGammaNormalized(b) * 256);
- if (red < 0)
- red = 0;
- else if (red > 255)
- red = 255;
- if (green < 0)
- green = 0;
- else if (green > 255)
- green = 255;
- if (blue < 0)
- blue = 0;
- else if (blue > 255)
- blue = 255;
-
- result = new RGB(red, green, blue);
- return result;
- }
-
- }
-
- public YUV_RGBConverter() {
- super();
- }
-
- public RGB transformRGB(RGB originalRGB, double scaleFactor, double target) {
- RGB transformedRGB = null;
- //CCIR601 yuv = new CCIR601(originalRGB);
- YUV yuv = new YUV(originalRGB);
- double y = yuv.getY();
- // zero is black, one is white
- if (y < target) {
- // is "dark" make lighter
- y = y + ((target - y) * scaleFactor);
- }
- else {
- // is "light" make darker
- y = y - ((y - target) * scaleFactor);
- }
- //yuv.setY(y);
- YUV newYUV = new YUV(y, yuv.getU(), yuv.getV());
- //CCIR601 newYUV = new CCIR601(y, yuv.getCb601(), yuv.getCr601());
- transformedRGB = newYUV.getRGB();
- return transformedRGB;
- }
-
- public RGB transformRGBToGrey(RGB originalRGB, double scaleFactor, double target) {
- RGB transformedRGB = null;
- // we left the "full" API method signature, but this
- // version does not take into account originalRGB, though
- // it might someday.
- // for now, we'll simply make the new RGB grey, either a little
- // lighter, or a little darker than background.
- double y = 0;
- double mid = 0.5;
- // zero is black, one is white
- if (target < mid) {
- // is "dark" make lighter
- y = target + scaleFactor;
- }
- else {
- // is "light" make darker
- y = target - scaleFactor;
- }
- int c = (int) Math.round(y * 255);
- // just to gaurd against mis-use, or scale's values greater
- // than mid point (and possibly rounding error)
- if (c > 255)
- c = 255;
- if (c < 0)
- c = 0;
- transformedRGB = new RGB(c, c, c);
- return transformedRGB;
- }
-
- public double calculateYComponent(Color targetColor) {
- return new YUV(targetColor.getRGB()).getY();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AbstractBestMatchHoverProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AbstractBestMatchHoverProcessor.java
deleted file mode 100644
index 1edf4273ed..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AbstractBestMatchHoverProcessor.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.taginfo;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.internal.taginfo.DebugInfoHoverProcessor;
-
-
-/**
- * Provides the best hover help documentation (by using other hover help processors)
- * Priority of hover help processors is:
- * ProblemHoverProcessor, TagInfoProcessor, AnnotationHoverProcessor
- */
-public abstract class AbstractBestMatchHoverProcessor implements ITextHover {
- /**
- * @deprecated just use list of text hovers
- */
- protected ITextHover fAnnotationHover;
- private List fTextHovers; // list of text hovers to consider in best match
- private ITextHover fBestMatchHover; // current best match text hover
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextHover#getHoverInfo(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion)
- */
- public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
- String displayText = null;
-
- // already have a best match hover picked out from getHoverRegion call
- if (fBestMatchHover != null) {
- displayText = fBestMatchHover.getHoverInfo(viewer, hoverRegion);
- }
- // either had no best match hover or best match hover returned null
- if (displayText == null) {
- // go through list of text hovers and return first display string
- Iterator i = getTextHovers().iterator();
- while ((i.hasNext()) && (displayText == null)) {
- ITextHover hover = (ITextHover)i.next();
- displayText = hover.getHoverInfo(viewer, hoverRegion);
- }
- }
- return displayText;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer viewer, int offset) {
- IRegion hoverRegion = null;
-
- // go through list of text hovers and return first hover region
- ITextHover hover = null;
- Iterator i = getTextHovers().iterator();
- while ((i.hasNext()) && (hoverRegion == null)) {
- hover = (ITextHover)i.next();
- hoverRegion = hover.getHoverRegion(viewer, offset);
- }
-
- // store the text hover processor that found region
- if (hoverRegion != null)
- fBestMatchHover = hover;
- else
- fBestMatchHover = null;
-
- return hoverRegion;
- }
-
- /**
- * @deprecated just use list of text hovers
- */
- protected ITextHover getAnnotationHover() {
- if (fAnnotationHover == null) {
- fAnnotationHover = new AnnotationHoverProcessor();
- }
- return fAnnotationHover;
- }
-
- protected List getTextHovers() {
- if (fTextHovers == null) {
- fTextHovers = createTextHoversList();
- }
- return fTextHovers;
- }
-
- /**
- * Create a list of text hovers applicable to this best match hover processor
- * @return List of ITextHover - in abstract class this is empty list
- */
- protected List createTextHoversList() {
- List hoverList = new ArrayList();
- // if currently debugging, then add the debug hover to the list of best match
- if (Logger.isTracing(DebugInfoHoverProcessor.TRACEFILTER)) {
- hoverList.add(new DebugInfoHoverProcessor());
- }
-
- hoverList.add(new ProblemAnnotationHoverProcessor());
- ITextHover taginfo = getTagInfoHover();
- if (taginfo != null) {
- hoverList.add(taginfo);
- }
- hoverList.add(new AnnotationHoverProcessor());
- return hoverList;
- }
-
- /**
- * @return the appropriate tag info hover help processor
- */
- protected abstract ITextHover getTagInfoHover();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AnnotationHoverProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AnnotationHoverProcessor.java
deleted file mode 100644
index 82cc0c8986..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/AnnotationHoverProcessor.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.taginfo;
-
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-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.IAnnotationModel;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.ui.editors.text.EditorsUI;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.AnnotationPreference;
-import org.eclipse.ui.texteditor.ChainedPreferenceStore;
-import org.eclipse.ui.texteditor.DefaultMarkerAnnotationAccess;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.sse.ui.ITemporaryAnnotation;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * Hover help that displays annotations shown in text of editor.
- * Currently, this text hover is used in conjunction with AbstractTextHoverProcessor.
- *
- * @author amywu
- */
-public class AnnotationHoverProcessor implements ITextHover {
- private DefaultMarkerAnnotationAccess fAnnotationAccess = new DefaultMarkerAnnotationAccess();
- protected IPreferenceStore fPreferenceStore = null;
- private static final String EDITOR_PLUGIN_ID = "org.eclipse.wst.sse.ui"; //$NON-NLS-1$
-
- private final static String PARAGRAPH_START = "<p>"; //$NON-NLS-1$
- private final static String PARAGRAPH_END = "</p>"; //$NON-NLS-1$
- private final static String LIST_BEGIN = "<ul>"; //$NON-NLS-1$
- private final static String LIST_ELEMENT = "<li>"; //$NON-NLS-1$
-
- /**
- *
- */
- public AnnotationHoverProcessor() {
- super();
- }
-
- /**
- * Formats a msg to a proper html message
- * @param msg - assumes msg is neither null nor empty string
- * @return
- */
- protected String formatMessage(String msg) {
- StringBuffer buf = new StringBuffer();
- buf.append(PARAGRAPH_START);
- buf.append(StringUtils.convertToHTMLContent(msg));
- buf.append(PARAGRAPH_END);
- return buf.toString();
- }
-
- /**
- * Formats multiple messages into proper html message
- * @param messages
- * @return
- */
- protected String formatMessages(List messages) {
- StringBuffer buffer = new StringBuffer();
- buffer.append(PARAGRAPH_START);
- buffer.append(ResourceHandler.getString("Multiple_errors")); //$NON-NLS-1$
- buffer.append(LIST_BEGIN);
-
- Iterator e = messages.iterator();
- while (e.hasNext()) {
- buffer.append(LIST_ELEMENT);
- buffer.append(StringUtils.convertToHTMLContent((String) e.next()));
- }
- buffer.append(PARAGRAPH_END);
- return buffer.toString();
- }
-
- /* (non-Javadoc)
- */
- public String getHoverInfo(ITextViewer viewer, IRegion hoverRegion) {
- IAnnotationModel model = ((SourceViewer) viewer).getAnnotationModel();
- if (model != null) {
- List messages = new ArrayList();
- Iterator e = model.getAnnotationIterator();
- while (e.hasNext()) {
- Annotation a = (Annotation) e.next();
- if (!isAnnotationValid(a))
- continue;
-
- Position p = model.getPosition(a);
- // check if this is an annotation in the region we are concerned with
- if (p.overlapsWith(hoverRegion.getOffset(), hoverRegion.getLength())) {
- String msg = a.getText();
- if ((msg != null) && msg.trim().length() > 0) {
- // it is possible for temporary annotations to duplicate other annotations so make sure not to add dups
- if (a instanceof ITemporaryAnnotation) {
- boolean duplicated = false;
- int j = 0;
- while (j < messages.size() && !duplicated) {
- duplicated = messages.get(j).equals(msg);
- ++j;
- }
- if (!duplicated) {
- messages.add(msg);
- }
- }
- else {
- messages.add(msg);
- }
- }
- }
- }
- if (messages.size() > 1) {
- return formatMessages(messages);
- }
- else if (messages.size() > 0) {
- return formatMessage(messages.get(0).toString());
- }
- }
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.text.ITextHover#getHoverRegion(org.eclipse.jface.text.ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- IAnnotationModel model = ((SourceViewer) textViewer).getAnnotationModel();
- Region hoverRegion = null;
-
- if (model != null) {
- Iterator e = model.getAnnotationIterator();
- while (e.hasNext()) {
- Annotation a = (Annotation) e.next();
- if (!isAnnotationValid(a))
- continue;
- Position p = model.getPosition(a);
- if (p.includes(offset)) {
- // find the smallest region containing offset
- if ((hoverRegion == null) || (hoverRegion.getLength() > p.getLength())) {
- hoverRegion = new Region(p.getOffset(), p.getLength());
- }
- }
- }
- }
- return hoverRegion;
- }
-
- /**
- * Retreives the preference store
- * If no preference store is currently stored, retreive the appropriate preference store
- */
- protected IPreferenceStore getPreferenceStore() {
- if (fPreferenceStore == null) {
- IPreferenceStore sseEditorPrefs = ((AbstractUIPlugin) Platform.getPlugin(EDITOR_PLUGIN_ID)).getPreferenceStore();
- IPreferenceStore baseEditorPrefs = EditorsUI.getPreferenceStore();
- fPreferenceStore = new ChainedPreferenceStore(new IPreferenceStore[] { sseEditorPrefs, baseEditorPrefs });
- }
- return fPreferenceStore;
- }
-
- /**
- * Returns the annotation preference for the given annotation.
- * (copied from org.eclipse.jdt.internal.ui.text.java.hover.AnnotationHover)
- * @param annotation the annotation
- * @return the annotation preference or <code>null</code> if none
- */
- private AnnotationPreference getAnnotationPreference(Annotation annotation) {
-
- if (annotation.isMarkedDeleted())
- return null;
- return EditorsUI.getAnnotationPreferenceLookup().getAnnotationPreference(annotation);
- }
-
- protected boolean isAnnotationValid(Annotation a) {
- AnnotationPreference preference = getAnnotationPreference(a);
- String textPreferenceKey = preference.getTextPreferenceKey();
- String highlightPreferenceKey = preference.getHighlightPreferenceKey();
- if (preference == null || textPreferenceKey == null || !(getPreferenceStore().getBoolean(textPreferenceKey))
- || highlightPreferenceKey == null || getPreferenceStore().getBoolean(highlightPreferenceKey))
- return false;
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/ProblemAnnotationHoverProcessor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/ProblemAnnotationHoverProcessor.java
deleted file mode 100644
index aa26b1d239..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/ProblemAnnotationHoverProcessor.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.taginfo;
-
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-
-
-/**
- * Hover help that displays problem annotations when shown in text of editor.
- *
- * @author amywu
- */
-public class ProblemAnnotationHoverProcessor extends AnnotationHoverProcessor {
-
- /**
- *
- */
- public ProblemAnnotationHoverProcessor() {
- super();
- }
-
-
- /* (non-Javadoc)
- */
- protected boolean isAnnotationValid(Annotation a) {
- String type = a.getType();
- if (TemporaryAnnotation.ANNOT_ERROR.equals(type) || TemporaryAnnotation.ANNOT_WARNING.equals(type))
- return super.isAnnotationValid(a);
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/TextHoverManager.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/TextHoverManager.java
deleted file mode 100644
index cc0ba15d0c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/taginfo/TextHoverManager.java
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.taginfo;
-
-import java.util.HashMap;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.preferences.CommonEditorPreferenceNames;
-
-
-
-/**
- * Manages text hovers for Structured Text editors
- * @author amywu
- */
-public class TextHoverManager {
- /**
- * Contains description of a text hover
- */
- public class TextHoverDescriptor {
- private String fId;
- private String fLabel;
- private String fDescription;
- private boolean fEnabled;
- private String fModifierString;
-
- /**
- * @param id
- * @param label
- * @param desc
- */
- public TextHoverDescriptor(String id, String label, String desc) {
- fId = id;
- fLabel = label;
- fDescription = desc;
- }
- /**
- * @param id
- * @param label
- * @param desc
- * @param enabled
- * @param modifierString
- */
- public TextHoverDescriptor(String id, String label, String desc, boolean enabled, String modifierString) {
- fId = id;
- fLabel = label;
- fDescription = desc;
- fEnabled = enabled;
- fModifierString = modifierString;
- }
-
- /**
- * @return Returns the fEnabled.
- */
- public boolean isEnabled() {
- return fEnabled;
- }
- /**
- * @return Returns the fId.
- */
- public String getId() {
- return fId;
- }
- /**
- * @return Returns the fLabel
- */
- public String getLabel() {
- return fLabel;
- }
- /**
- * @return Returns the fDescription.
- */
- public String getDescription() {
- return fDescription;
- }
- /**
- * @return Returns the fModifierString.
- */
- public String getModifierString() {
- return fModifierString;
- }
- /**
- * @param enabled The fEnabled to set.
- */
- public void setEnabled(boolean enabled) {
- fEnabled = enabled;
- }
- /**
- * @param modifierString The fModifierString to set.
- */
- public void setModifierString(String modifierString) {
- fModifierString = modifierString;
- }
- }
-
- // list of different types of Source editor hovers
- public static final String COMBINATION_HOVER = "combinationHover"; //$NON-NLS-1$
- public static final String PROBLEM_HOVER = "problemHover"; //$NON-NLS-1$
- public static final String DOCUMENTATION_HOVER = "documentationHover"; //$NON-NLS-1$
- public static final String ANNOTATION_HOVER = "annotationHover"; //$NON-NLS-1$
- public static final String[] TEXT_HOVER_IDS = new String[] { COMBINATION_HOVER, PROBLEM_HOVER, DOCUMENTATION_HOVER, ANNOTATION_HOVER };
-
- // hover labels are in .properties file with the key in the form of "[id].label"
- private static final String LABEL_KEY = ".label"; //$NON-NLS-1$
- // hover descriptions are in .properties file with the key in the form of "[id].desc"
- private static final String DESCRIPTION_KEY = ".desc"; //$NON-NLS-1$
-
- public static final String NO_MODIFIER = "0"; //$NON-NLS-1$
- public static final String HOVER_ATTRIBUTE_SEPARATOR = "|"; //$NON-NLS-1$
- public static final String HOVER_SEPARATOR= ";"; //$NON-NLS-1$
- /**
- * Current list of Structured Text editor text hovers
- */
- private TextHoverDescriptor[] fTextHovers;
-
- public TextHoverManager() {
- super();
- }
-
-
- /**
- * Returns the text hovers for Structured Text editor. If fTextHover has not been
- * initialied, it will be initialized.
- * @return Returns the fTextHovers.
- */
- public TextHoverDescriptor[] getTextHovers() {
- if (fTextHovers == null) {
- String textHoverStrings = getPreferenceStore().getString(CommonEditorPreferenceNames.EDITOR_TEXT_HOVER_MODIFIERS);
- fTextHovers = generateTextHoverDescriptors(textHoverStrings);
- }
- return fTextHovers;
- }
-
- /**
- * Sets fTextHovers to null so that next time getTextHovers is called,
- * fTextHovers will be populated with the latest preferences.
- */
- public void resetTextHovers() {
- fTextHovers = null;
- }
-
- /**
- * Generate a list of text hover descriptors from the given delimited string
- * @param textHoverStrings
- * @return
- */
- public TextHoverDescriptor[] generateTextHoverDescriptors(String textHoverStrings) {
- StringTokenizer st = new StringTokenizer(textHoverStrings, HOVER_SEPARATOR);
-
- // read from preference and load id-descriptor mapping to a hash table
- HashMap idToModifier = new HashMap (st.countTokens());
- while (st.hasMoreTokens()) {
- String textHoverString = st.nextToken();
- StringTokenizer st2 = new StringTokenizer(textHoverString, HOVER_ATTRIBUTE_SEPARATOR);
- if (st2.countTokens() == 3) {
- String id = st2.nextToken();
- boolean enabled = Boolean.valueOf(st2.nextToken()).booleanValue();
- String modifierString = st2.nextToken();
- if (modifierString.equals(NO_MODIFIER))
- modifierString= ""; //$NON-NLS-1$
-
- TextHoverDescriptor descriptor = new TextHoverDescriptor(id, ResourceHandler.getString(id+LABEL_KEY), ResourceHandler.getString(id+DESCRIPTION_KEY), enabled, modifierString);
- // should check to see if ids appear more than once
- idToModifier.put(id, descriptor);
- }
- }
-
- // go through all defined text hovers and match with their preference
- TextHoverDescriptor[] descriptors = new TextHoverDescriptor[TEXT_HOVER_IDS.length];
- for (int i= 0; i < TEXT_HOVER_IDS.length; i++) {
- TextHoverDescriptor desc = (TextHoverDescriptor)idToModifier.get(TEXT_HOVER_IDS[i]);
- if (desc != null) {
- descriptors[i] = desc;
- } else {
- descriptors[i] = new TextHoverDescriptor(TEXT_HOVER_IDS[i], ResourceHandler.getString(TEXT_HOVER_IDS[i]+LABEL_KEY), ResourceHandler.getString(TEXT_HOVER_IDS+DESCRIPTION_KEY));
- }
- }
- return descriptors;
- }
-
- private IPreferenceStore getPreferenceStore() {
- return ((AbstractUIPlugin)Platform.getPlugin(EditorPlugin.ID)).getPreferenceStore();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionContributor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionContributor.java
deleted file mode 100644
index 67f755f49e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionContributor.java
+++ /dev/null
@@ -1,363 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.action.GroupMarker;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.action.Separator;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.ide.IDEActionFactory;
-import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionConstants;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.wst.sse.ui.GotoAnnotationAction;
-import org.eclipse.wst.sse.ui.ISourceViewerActionBarContributor;
-import org.eclipse.wst.sse.ui.extension.ExtendedEditorActionBuilder;
-import org.eclipse.wst.sse.ui.extension.IExtendedContributor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-/**
- * XMLEditorActionContributor
- *
- * This class should not be used inside multi page editor's ActionBarContributor,
- * since cascaded init() call from the ActionBarContributor
- * will causes exception and it leads to lose whole toolbars.
- *
- * Instead, use SourcePageActionContributor for source page contributor
- * of multi page editor.
- *
- * Note that this class is still valid for single page editor.
- */
-public class ActionContributor extends BasicTextEditorActionContributor implements ISourceViewerActionBarContributor, IExtendedContributor {
- private static final String[] EDITOR_IDS = {"org.eclipse.wst.sse.ui.StructuredTextEditor"}; //$NON-NLS-1$
-
- protected Separator fCommandsSeparator = null;
- protected MenuManager fExpandSelectionToMenu = null;
- protected RetargetTextEditorAction fStructureSelectEnclosingAction = null;
- protected RetargetTextEditorAction fStructureSelectNextAction = null;
- protected RetargetTextEditorAction fStructureSelectPreviousAction = null;
- protected RetargetTextEditorAction fStructureSelectHistoryAction = null;
- protected RetargetTextEditorAction fShiftRight = null;
- protected RetargetTextEditorAction fShiftLeft = null;
- protected MenuManager fConvertDelimitersMenu = null; // convert line delimiters submenu
- protected RetargetTextEditorAction fConvertToWindows; // convert to windows action
- protected RetargetTextEditorAction fConvertToUNIX; // convert to unix action
- protected RetargetTextEditorAction fConvertToMac; // convert to mac action
-
- protected RetargetTextEditorAction fToggleComment = null;
- protected RetargetTextEditorAction fAddBlockComment = null;
- protected RetargetTextEditorAction fRemoveBlockComment = null;
-
- protected GotoAnnotationAction fPreviousAnnotation = null;
- protected GotoAnnotationAction fNextAnnotation = null;
- protected Separator fToolbarSeparator = null;
- protected GroupMarker fToolbarAdditionsGroupMarker = null;
- protected GroupMarker fMenuAdditionsGroupMarker = null;
- protected IExtendedContributor extendedContributor;
- protected RetargetTextEditorAction fToggleInsertModeAction;
-
- public ActionContributor() {
- super();
-
- ResourceBundle resourceBundle = ResourceHandler.getResourceBundle();
-
- fCommandsSeparator = new Separator();
-
- // edit commands
- fStructureSelectEnclosingAction = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_ENCLOSING + StructuredTextEditorActionConstants.DOT);
- fStructureSelectEnclosingAction.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_ENCLOSING);
-
- fStructureSelectNextAction = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_NEXT + StructuredTextEditorActionConstants.DOT);
- fStructureSelectNextAction.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_NEXT);
-
- fStructureSelectPreviousAction = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_PREVIOUS + StructuredTextEditorActionConstants.DOT);
- fStructureSelectPreviousAction.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_PREVIOUS);
-
- fStructureSelectHistoryAction = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_HISTORY + StructuredTextEditorActionConstants.DOT);
- fStructureSelectHistoryAction.setActionDefinitionId(ActionDefinitionIds.STRUCTURE_SELECT_HISTORY);
-
- fExpandSelectionToMenu = new MenuManager(ResourceHandler.getString("ExpandSelectionToMenu.label")); //$NON-NLS-1$
- fExpandSelectionToMenu.add(fStructureSelectEnclosingAction);
- fExpandSelectionToMenu.add(fStructureSelectNextAction);
- fExpandSelectionToMenu.add(fStructureSelectPreviousAction);
- fExpandSelectionToMenu.add(fStructureSelectHistoryAction);
-
- // source commands
- fShiftRight = new RetargetTextEditorAction(resourceBundle, ITextEditorActionConstants.SHIFT_RIGHT + StructuredTextEditorActionConstants.DOT);
- fShiftRight.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_RIGHT);
-
- fShiftLeft = new RetargetTextEditorAction(resourceBundle, ITextEditorActionConstants.SHIFT_LEFT + StructuredTextEditorActionConstants.DOT);
- fShiftLeft.setActionDefinitionId(ITextEditorActionDefinitionIds.SHIFT_LEFT);
-
- fConvertToWindows = new RetargetTextEditorAction(resourceBundle, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS + StructuredTextEditorActionConstants.DOT);
- fConvertToUNIX = new RetargetTextEditorAction(resourceBundle, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX + StructuredTextEditorActionConstants.DOT);
- fConvertToMac = new RetargetTextEditorAction(resourceBundle, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC + StructuredTextEditorActionConstants.DOT);
-
- fConvertDelimitersMenu = new MenuManager(ResourceHandler.getString("ConvertLineDelimitersMenu.label")); //$NON-NLS-1$
- fConvertDelimitersMenu.add(fConvertToWindows);
- fConvertDelimitersMenu.add(fConvertToUNIX);
- fConvertDelimitersMenu.add(fConvertToMac);
-
- fToggleComment = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_TOGGLE_COMMENT + StructuredTextEditorActionConstants.DOT);
- fToggleComment.setActionDefinitionId(ActionDefinitionIds.TOGGLE_COMMENT);
-
- fAddBlockComment = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_ADD_BLOCK_COMMENT + StructuredTextEditorActionConstants.DOT);
- fAddBlockComment.setActionDefinitionId(ActionDefinitionIds.ADD_BLOCK_COMMENT);
-
- fRemoveBlockComment = new RetargetTextEditorAction(resourceBundle, StructuredTextEditorActionConstants.ACTION_NAME_REMOVE_BLOCK_COMMENT + StructuredTextEditorActionConstants.DOT);
- fRemoveBlockComment.setActionDefinitionId(ActionDefinitionIds.REMOVE_BLOCK_COMMENT);
-
- // goto prev/next error
- // CMVC 249017 for JavaEditor consistancy
- fPreviousAnnotation = new GotoAnnotationAction("Previous_error", false); //$NON-NLS-1$
- fPreviousAnnotation.setActionDefinitionId("org.eclipse.ui.navigate.previous"); //$NON-NLS-1$
-
- fNextAnnotation = new GotoAnnotationAction("Next_error", true); //$NON-NLS-1$
- fNextAnnotation.setActionDefinitionId("org.eclipse.ui.navigate.next"); //$NON-NLS-1$
-
- // Read action extensions.
- ExtendedEditorActionBuilder builder = new ExtendedEditorActionBuilder();
- extendedContributor = builder.readActionExtensions(getExtensionIDs());
-
- fMenuAdditionsGroupMarker = new GroupMarker(StructuredTextEditorActionConstants.GROUP_NAME_MENU_ADDITIONS);
- fToolbarSeparator = new Separator();
- fToolbarAdditionsGroupMarker = new GroupMarker(StructuredTextEditorActionConstants.GROUP_NAME_TOOLBAR_ADDITIONS);
-
- fToggleInsertModeAction= new RetargetTextEditorAction(resourceBundle, "Editor.ToggleInsertMode.", IAction.AS_CHECK_BOX); //$NON-NLS-1$
- fToggleInsertModeAction.setActionDefinitionId(ITextEditorActionDefinitionIds.TOGGLE_INSERT_MODE);
- }
-
- protected String[] getExtensionIDs() {
- return EDITOR_IDS;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.IEditorActionBarContributor#init(org.eclipse.ui.IActionBars, org.eclipse.ui.IWorkbenchPage)
- */
- public void init(IActionBars bars, IWorkbenchPage page) {
- super.init(bars, page);
- }
-
- /**
- * @see org.eclipse.ui.part.EditorActionBarContributor#dispose()
- */
- public void dispose() {
- super.dispose();
-
- if (extendedContributor != null)
- extendedContributor.dispose();
- }
-
- /**
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(IMenuManager)
- */
- public void contributeToMenu(IMenuManager menu) {
- super.contributeToMenu(menu);
-
- addToMenu(menu);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToMenu(menu);
- }
- }
-
- protected void addToMenu(IMenuManager menu) {
- // edit commands
- IMenuManager editMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_EDIT);
- if (editMenu != null) {
- editMenu.add(fCommandsSeparator);
- editMenu.add(fToggleInsertModeAction);
- editMenu.add(fCommandsSeparator);
- editMenu.add(fExpandSelectionToMenu);
- editMenu.add(fCommandsSeparator);
- editMenu.add(fMenuAdditionsGroupMarker);
- }
-
- // source commands
- String sourceMenuLabel = ResourceHandler.getString("SourceMenu.label"); //$NON-NLS-1$
- String sourceMenuId = "sourceMenuId"; // This is just a menu id. No need to translate. //$NON-NLS-1$
- IMenuManager sourceMenu = new MenuManager(sourceMenuLabel, sourceMenuId);
- menu.insertAfter(IWorkbenchActionConstants.M_EDIT, sourceMenu);
- if (sourceMenu != null) {
- sourceMenu.add(fCommandsSeparator);
- sourceMenu.add(fToggleComment);
- sourceMenu.add(fAddBlockComment);
- sourceMenu.add(fRemoveBlockComment);
- sourceMenu.add(fShiftRight);
- sourceMenu.add(fShiftLeft);
- sourceMenu.add(fCommandsSeparator);
- sourceMenu.add(fConvertDelimitersMenu);
- }
- }
-
- /* (non-Javadoc)
- */
- public void contributeToPopupMenu(IMenuManager menu) {
-
- addToPopupMenu(menu);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToPopupMenu(menu);
- }
- }
-
- protected void addToPopupMenu(IMenuManager menu) {
- // add nothing
- }
-
- /**
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(IToolBarManager)
- */
- public void contributeToToolBar(IToolBarManager toolBarManager) {
- super.contributeToToolBar(toolBarManager);
-
- addToToolBar(toolBarManager);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToToolBar(toolBarManager);
- }
- }
-
- protected void addToToolBar(IToolBarManager toolBarManager) {
- toolBarManager.add(fToolbarSeparator);
- toolBarManager.add(fToolbarAdditionsGroupMarker);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToStatusLine(org.eclipse.jface.action.IStatusLineManager)
- */
- public void contributeToStatusLine(IStatusLineManager manager) {
- super.contributeToStatusLine(manager);
-
- addToStatusLine(manager);
-
- if (extendedContributor != null) {
- extendedContributor.contributeToStatusLine(manager);
- }
- }
-
- protected void addToStatusLine(IStatusLineManager manager) {
- }
-
- /* (non-Javadoc)
- */
- public void updateToolbarActions() {
- if (extendedContributor != null) {
- extendedContributor.updateToolbarActions();
- }
- }
-
- /**
- * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart activeEditor) {
- if (getActiveEditorPart() == activeEditor)
- return;
- super.setActiveEditor(activeEditor);
-
- ITextEditor textEditor = getTextEditor(activeEditor);
-
- IActionBars actionBars = getActionBars();
- if (actionBars != null) {
- // register actions that have a dynamic editor.
- actionBars.setGlobalActionHandler(ActionFactory.NEXT.getId(), fNextAnnotation); // is this the corrent mapping?
- actionBars.setGlobalActionHandler(ActionFactory.PREVIOUS.getId(), fPreviousAnnotation); // is this the corrent mapping?
-
- actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_NEXT_ANNOTATION, fNextAnnotation);
- actionBars.setGlobalActionHandler(ITextEditorActionDefinitionIds.GOTO_PREVIOUS_ANNOTATION, fPreviousAnnotation);
-
- IStatusLineManager statusLineManager = actionBars.getStatusLineManager();
- if (statusLineManager != null) {
- statusLineManager.setMessage(null);
- statusLineManager.setErrorMessage(null);
- }
- if (textEditor != null) {
- actionBars.setGlobalActionHandler(IDEActionFactory.ADD_TASK.getId(), getAction(textEditor, IDEActionFactory.ADD_TASK.getId()));
- actionBars.setGlobalActionHandler(IDEActionFactory.BOOKMARK.getId(), getAction(textEditor, IDEActionFactory.BOOKMARK.getId()));
- }
- }
-
- fStructureSelectEnclosingAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_ENCLOSING));
- fStructureSelectNextAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_NEXT));
- fStructureSelectPreviousAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_PREVIOUS));
- fStructureSelectHistoryAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_STRUCTURE_SELECT_HISTORY));
-
- fShiftRight.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_RIGHT));
- fShiftLeft.setAction(getAction(textEditor, ITextEditorActionConstants.SHIFT_LEFT));
-
- // line delimiter conversion - tie to text editor's action
- fConvertToWindows.setAction(getAction(textEditor, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_WINDOWS));
- fConvertToUNIX.setAction(getAction(textEditor, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_UNIX));
- fConvertToMac.setAction(getAction(textEditor, ITextEditorActionConstants.CONVERT_LINE_DELIMITERS_TO_MAC));
-
- fToggleComment.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_TOGGLE_COMMENT));
- fAddBlockComment.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_ADD_BLOCK_COMMENT));
- fRemoveBlockComment.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_REMOVE_BLOCK_COMMENT));
-
- // go to prev/next error
- // CMVC 249017 for JavaEditor consistancy
- fPreviousAnnotation.setEditor(textEditor);
- fNextAnnotation.setEditor(textEditor);
-
- fToggleInsertModeAction.setAction(getAction(textEditor, ITextEditorActionConstants.TOGGLE_INSERT_MODE));
-
- if (extendedContributor != null) {
- extendedContributor.setActiveEditor(activeEditor);
- }
- }
-
- /**
- * @param editor
- * @return
- */
- protected ITextEditor getTextEditor(IEditorPart editor) {
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- if (textEditor == null && editor != null)
- textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
- return textEditor;
- }
-
- /*
- * (non-Javadoc)
- */
- public void setViewerSpecificContributionsEnabled(boolean enabled) {
- fShiftRight.setEnabled(enabled);
- fShiftLeft.setEnabled(enabled);
- fNextAnnotation.setEnabled(enabled);
- fPreviousAnnotation.setEnabled(enabled);
-
- /*
- fComment.setEnabled(enabled);
- fUncomment.setEnabled(enabled);
- */
- fToggleComment.setEnabled(enabled);
- fAddBlockComment.setEnabled(enabled);
- fRemoveBlockComment.setEnabled(enabled);
- // convert line delimiters are not source viewer-specific
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionDefinitionIds.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionDefinitionIds.java
deleted file mode 100644
index af6172b4f2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActionDefinitionIds.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-
-
-/**
- * Defines the definitions ids for editor actions.
- */
-public interface ActionDefinitionIds {
- public final static String QUICK_FIX = "org.eclipse.wst.sse.ui.edit.edit.text.java.correction.assist.proposals";//$NON-NLS-1$
- public final static String COMMENT = "org.eclipse.wst.sse.ui.edit.comment";//$NON-NLS-1$
- public final static String UNCOMMENT = "org.eclipse.wst.sse.ui.edit.uncomment";//$NON-NLS-1$
- public final static String TOGGLE_COMMENT = "org.eclipse.wst.sse.ui.edit.toggle.comment";//$NON-NLS-1$
- public final static String ADD_BLOCK_COMMENT = "org.eclipse.wst.sse.ui.edit.add.block.comment";//$NON-NLS-1$
- public final static String REMOVE_BLOCK_COMMENT = "org.eclipse.wst.sse.ui.edit.remove.block.comment";//$NON-NLS-1$
- public final static String CLEANUP_DOCUMENT = "org.eclipse.wst.sse.ui.edit.cleanup.document";//$NON-NLS-1$
- public final static String FORMAT_DOCUMENT = "org.eclipse.wst.sse.ui.edit.format.document";//$NON-NLS-1$
- public final static String FORMAT_ACTIVE_ELEMENTS = "org.eclipse.wst.sse.ui.edit.format.active.elements";//$NON-NLS-1$
- public final static String OPEN_FILE = "org.eclipse.wst.sse.ui.edit.open.file.from.source";//$NON-NLS-1$
- public final static String STRUCTURE_SELECT_ENCLOSING = "org.eclipse.wst.sse.ui.edit.structure.select.enclosing";//$NON-NLS-1$
- public final static String STRUCTURE_SELECT_NEXT = "org.eclipse.wst.sse.ui.edit.structure.select.next";//$NON-NLS-1$
- public final static String STRUCTURE_SELECT_PREVIOUS = "org.eclipse.wst.sse.ui.edit.structure.select.previous";//$NON-NLS-1$
- public final static String STRUCTURE_SELECT_HISTORY = "org.eclipse.wst.sse.ui.edit.structure.select.last";//$NON-NLS-1$
- public final static String INFORMATION = "org.eclipse.wst.sse.ui.edit.show.javadoc";//$NON-NLS-1$
-
- public final static String ADD_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.add.breakpoints";//$NON-NLS-1$
- public final static String MANAGE_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.manage.breakpoints";//$NON-NLS-1$
- public final static String EDIT_BREAKPOINTS = "org.eclipse.wst.sse.ui.edit.breakpoints.edit";//$NON-NLS-1$
- public final static String FIND_OCCURRENCES = "org.eclipse.wst.sse.ui.edit.search.find.occurrences";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActiveEditorActionHandler.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActiveEditorActionHandler.java
deleted file mode 100644
index 51ff6ed3d2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ActiveEditorActionHandler.java
+++ /dev/null
@@ -1,273 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuCreator;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.swt.events.HelpListener;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchSite;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public class ActiveEditorActionHandler implements IAction {
-
- private String fActionId;
- private IAction fTargetAction;
- private IWorkbenchSite fSite;
-
- public ActiveEditorActionHandler(IWorkbenchSite site, String id) {
- super();
- fActionId = id;
- fSite = site;
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#addPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- public void addPropertyChangeListener(IPropertyChangeListener listener) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getAccelerator()
- */
- public int getAccelerator() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getAccelerator() : 0);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getActionDefinitionId()
- */
- public String getActionDefinitionId() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getActionDefinitionId() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getDescription()
- */
- public String getDescription() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getDescription() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getDisabledImageDescriptor()
- */
- public ImageDescriptor getDisabledImageDescriptor() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getDisabledImageDescriptor() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getHelpListener()
- */
- public HelpListener getHelpListener() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getHelpListener() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getHoverImageDescriptor()
- */
- public ImageDescriptor getHoverImageDescriptor() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getHoverImageDescriptor() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getId()
- */
- public String getId() {
- return getClass().getName() + hashCode();
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getImageDescriptor()
- */
- public ImageDescriptor getImageDescriptor() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getImageDescriptor() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getMenuCreator()
- */
- public IMenuCreator getMenuCreator() {
- return null;
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getStyle()
- */
- public int getStyle() {
- return IAction.AS_PUSH_BUTTON;
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getText()
- */
- public String getText() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getText() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#getToolTipText()
- */
- public String getToolTipText() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.getToolTipText() : null);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#isChecked()
- */
- public boolean isChecked() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.isChecked() : true);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#isEnabled()
- */
- public boolean isEnabled() {
- updateTargetAction();
- return (fTargetAction != null ? fTargetAction.isEnabled() : false);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#removePropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
- */
- public void removePropertyChangeListener(IPropertyChangeListener listener) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- updateTargetAction();
- if (fTargetAction != null)
- fTargetAction.run();
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#runWithEvent(org.eclipse.swt.widgets.Event)
- */
- public void runWithEvent(Event event) {
- updateTargetAction();
- if (fTargetAction != null)
- fTargetAction.runWithEvent(event);
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setActionDefinitionId(java.lang.String)
- */
- public void setActionDefinitionId(String id) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setChecked(boolean)
- */
- public void setChecked(boolean checked) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setDescription(java.lang.String)
- */
- public void setDescription(String text) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setDisabledImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
- */
- public void setDisabledImageDescriptor(ImageDescriptor newImage) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setEnabled(boolean)
- */
- public void setEnabled(boolean enabled) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setHelpListener(org.eclipse.swt.events.HelpListener)
- */
- public void setHelpListener(HelpListener listener) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setHoverImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
- */
- public void setHoverImageDescriptor(ImageDescriptor newImage) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setId(java.lang.String)
- */
- public void setId(String id) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setImageDescriptor(org.eclipse.jface.resource.ImageDescriptor)
- */
- public void setImageDescriptor(ImageDescriptor newImage) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setMenuCreator(org.eclipse.jface.action.IMenuCreator)
- */
- public void setMenuCreator(IMenuCreator creator) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setText(java.lang.String)
- */
- public void setText(String text) {
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#setToolTipText(java.lang.String)
- */
- public void setToolTipText(String text) {
- }
-
- /**
- * @deprecated
- * @see org.eclipse.jface.action.IAction#setAccelerator(int)
- */
- public void setAccelerator(int keycode) {
- }
-
- private void updateTargetAction() {
- if (fSite != null && fSite.getWorkbenchWindow() != null && fSite.getWorkbenchWindow().getActivePage() != null) {
- IEditorPart part = fSite.getWorkbenchWindow().getActivePage().getActiveEditor();
- ITextEditor editor = null;
- if (part instanceof ITextEditor)
- editor = (ITextEditor) part;
- else
- editor = (ITextEditor) (part != null ? part.getAdapter(ITextEditor.class) : null);
- if (editor != null) {
- fTargetAction = editor.getAction(fActionId);
- }
- else {
- fTargetAction = null;
- }
- }
- else
- fTargetAction = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/BasicAutoEditStrategy.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/BasicAutoEditStrategy.java
deleted file mode 100644
index 920aa0df28..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/BasicAutoEditStrategy.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.ui.texteditor.ITextEditor;
-
-public abstract class BasicAutoEditStrategy implements IAutoEditStrategy {
- /**
- * Return the active text editor if possible, otherwise the active editor part.
- * @return
- * @todo Generated comment
- */
- protected Object getActiveTextEditor() {
- AbstractUIPlugin plugin = (AbstractUIPlugin) Platform.getPlugin(PlatformUI.PLUGIN_ID);
- IWorkbenchWindow window = plugin.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- if (editor instanceof ITextEditor)
- return editor;
- ITextEditor textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
- if (textEditor != null)
- return textEditor;
- return editor;
- }
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/CleanupAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/CleanupAction.java
deleted file mode 100644
index c1026b92c2..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/CleanupAction.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.sse.core.cleanup.IStructuredCleanupProcessor;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public abstract class CleanupAction extends TextEditorAction {
- protected Dialog fCleanupDialog;
-
- public CleanupAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- }
-
- public void run() {
- if (getTextEditor() instanceof StructuredTextEditor) {
- final StructuredTextEditor editor = (StructuredTextEditor) getTextEditor();
- Dialog cleanupDialog = getCleanupDialog(editor.getSite().getShell());
- if (cleanupDialog != null) {
- if (cleanupDialog.open() == Window.OK) {
- // setup runnable
- Runnable runnable = new Runnable() {
- public void run() {
- IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor();
- if (cleanupProcessor != null)
- cleanupProcessor.cleanupModel(editor.getModel());
- }
- };
-
- try {
- // begin recording
- ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
- editor.getModel().beginRecording(this, ResourceHandler.getString("Cleanup_Document_UI_"), ResourceHandler.getString("Cleanup_Document_UI_"), selection.getOffset(), selection.getLength()); //$NON-NLS-1$ //$NON-NLS-2$
-
- // tell the model that we are about to make a big model change
- editor.getModel().aboutToChangeModel();
-
- // run
- BusyIndicator.showWhile(editor.getTextViewer().getControl().getDisplay(), runnable);
- }
- finally {
- // tell the model that we are done with the big model change
- editor.getModel().changedModel();
-
- // end recording
- ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
- editor.getModel().endRecording(this, selection.getOffset(), selection.getLength());
- }
- }
-
- }
- }
- }
-
- protected abstract Dialog getCleanupDialog(Shell shell);
-
- protected abstract IStructuredCleanupProcessor getCleanupProcessor();
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRActionDelegate.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRActionDelegate.java
deleted file mode 100644
index 090e28a408..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRActionDelegate.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-public class ConvertLineDelimitersToCRActionDelegate extends ConvertLineDelimitersToCRLFActionDelegate {
- public ConvertLineDelimitersToCRActionDelegate() {
- super();
-
- setLineDelimiter("\r"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRLFActionDelegate.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRLFActionDelegate.java
deleted file mode 100644
index 568cc13906..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToCRLFActionDelegate.java
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import java.io.FileOutputStream;
-import java.io.IOException;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.editors.text.TextFileDocumentProvider;
-import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class ConvertLineDelimitersToCRLFActionDelegate extends ResourceActionDelegate {
- protected String fLineDelimiter = "\r\n"; //$NON-NLS-1$
-
- /*
- * (non-Javadoc)
- *
- */
- protected boolean processorAvailable(IResource resource) {
- boolean result = false;
- try {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
-
- IContentDescription contentDescription = file.getContentDescription();
- if (contentDescription != null) {
- IContentType contentType = contentDescription.getContentType();
- if (contentType.isKindOf(Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.text"))) //$NON-NLS-1$
- return true;
- }
- }
- else if (resource instanceof IContainer) {
- IContainer container = (IContainer) resource;
-
- IResource[] members;
- members = container.members();
- for (int i = 0; i < members.length; i++) {
- boolean available = processorAvailable(members[i]);
-
- if (available) {
- result = true;
- break;
- }
- }
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected void process(IProgressMonitor monitor, IResource resource) {
- convert(monitor, resource);
-
- try {
- resource.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- catch (CoreException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + resource.getName()); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected void initProgressDialog(ResourceActionProgressDialog progressDialog) {
- progressDialog.setDialogTitle(ResourceHandler.getString("ConvertLineDelimitersToCRLFActionDelegate.0")); //$NON-NLS-1$
- progressDialog.setActionCompletedMessage(ResourceHandler.getString("ConvertLineDelimitersToCRLFActionDelegate.1")); //$NON-NLS-1$
- progressDialog.setActionCancelledMessage(ResourceHandler.getString("ConvertLineDelimitersToCRLFActionDelegate.2")); //$NON-NLS-1$
- }
-
- protected void convert(IProgressMonitor monitor, IResource resource) {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
-
- if (monitor == null || !monitor.isCanceled())
- convert(monitor, file);
- }
- else if (resource instanceof IContainer) {
- IContainer container = (IContainer) resource;
-
- try {
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- if (monitor == null || !monitor.isCanceled())
- convert(monitor, members[i]);
- }
- }
- catch (CoreException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + resource.getName()); //$NON-NLS-1$
- }
- }
- }
-
- protected void convert(IProgressMonitor monitor, IFile file) {
- try {
- IContentDescription contentDescription = file.getContentDescription();
- if (contentDescription == null)
- return;
-
- IContentType contentType = contentDescription.getContentType();
- if (contentType.isKindOf(Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.text"))) { //$NON-NLS-1$
- if (monitor == null || !monitor.isCanceled()) {
- monitor.setTaskName(ResourceHandler.getString("ConvertLineDelimitersToCRLFActionDelegate.3") + " " + file.getFullPath() + "..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
- try {
- IFileEditorInput input = new FileEditorInput(file);
- IDocumentProvider documentProvider = new TextFileDocumentProvider();
- documentProvider.connect(new FileEditorInput(file));
- IDocument document = documentProvider.getDocument(new FileEditorInput(file));
- documentProvider.disconnect(input);
-
- int lineCount = document.getNumberOfLines();
- for (int i = 0; i < lineCount; i++) {
- if (!monitor.isCanceled()) {
- 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);
- }
- }
- }
-
- writeFile(monitor, file, document.get());
- }
- catch (CoreException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + file.getName()); //$NON-NLS-1$
- }
- catch (BadLocationException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + file.getName()); //$NON-NLS-1$
- }
- }
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
-
- protected void writeFile(IProgressMonitor monitor, IFile file, String outputString) {
- FileOutputStream outputStream = null;
- try {
- outputStream = new FileOutputStream(file.getLocation().toString());
- outputStream.write(outputString.getBytes(file.getCharset()));
- }
- catch (IOException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + file.getName()); //$NON-NLS-1$
- }
- catch (CoreException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + file.getName()); //$NON-NLS-1$
- }
- finally {
- try {
- if (outputStream != null)
- outputStream.close();
- }
- catch (IOException e) {
- // do nothing
- }
- }
- }
-
- /**
- * @param lineDelimiter
- * The fLineDelimiter to set.
- */
- public void setLineDelimiter(String lineDelimiter) {
- fLineDelimiter = lineDelimiter;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToLFActionDelegate.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToLFActionDelegate.java
deleted file mode 100644
index 2832f89478..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ConvertLineDelimitersToLFActionDelegate.java
+++ /dev/null
@@ -1,21 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-public class ConvertLineDelimitersToLFActionDelegate extends ConvertLineDelimitersToCRLFActionDelegate {
- public ConvertLineDelimitersToLFActionDelegate() {
- super();
-
- setLineDelimiter("\n"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/FormatActionDelegate.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/FormatActionDelegate.java
deleted file mode 100644
index 450feb6728..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/FormatActionDelegate.java
+++ /dev/null
@@ -1,149 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.wst.encoding.exceptions.MalformedInputExceptionWithDetail;
-import org.eclipse.wst.sse.core.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.extension.FormatProcessorsExtensionReader;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class FormatActionDelegate extends ResourceActionDelegate {
- /*
- * (non-Javadoc)
- *
- */
- protected boolean processorAvailable(IResource resource) {
- boolean result = false;
- try {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
-
- IStructuredFormatProcessor formatProcessor = null;
- IContentDescription contentDescription = file.getContentDescription();
- if (contentDescription != null) {
- IContentType contentType = contentDescription.getContentType();
- formatProcessor = getFormatProcessor(contentType.getId());
- }
- if (formatProcessor != null)
- result = true;
- }
- else if (resource instanceof IContainer) {
- IContainer container = (IContainer) resource;
-
- IResource[] members;
- members = container.members();
- for (int i = 0; i < members.length; i++) {
- boolean available = processorAvailable(members[i]);
-
- if (available) {
- result = true;
- break;
- }
- }
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
-
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected void process(IProgressMonitor monitor, IResource resource) {
- format(monitor, resource);
-
- try {
- resource.refreshLocal(IResource.DEPTH_INFINITE, null);
- }
- catch (CoreException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + resource.getName()); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected void initProgressDialog(ResourceActionProgressDialog progressDialog) {
- progressDialog.setDialogTitle(ResourceHandler.getString("FormatActionDelegate.0")); //$NON-NLS-1$
- progressDialog.setActionCompletedMessage(ResourceHandler.getString("FormatActionDelegate.1")); //$NON-NLS-1$
- progressDialog.setActionCancelledMessage(ResourceHandler.getString("FormatActionDelegate.2")); //$NON-NLS-1$
- }
-
- protected IStructuredFormatProcessor getFormatProcessor(String contentTypeId) {
- return FormatProcessorsExtensionReader.getInstance().getFormatProcessor(contentTypeId);
- }
-
- protected void format(IProgressMonitor monitor, IResource resource) {
- if (resource instanceof IFile) {
- IFile file = (IFile) resource;
-
- if (monitor == null || !monitor.isCanceled())
- format(monitor, file);
- }
- else if (resource instanceof IContainer) {
- IContainer container = (IContainer) resource;
-
- try {
- IResource[] members = container.members();
- for (int i = 0; i < members.length; i++) {
- if (monitor == null || !monitor.isCanceled())
- format(monitor, members[i]);
- }
- }
- catch (CoreException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + resource.getName()); //$NON-NLS-1$
- }
- }
- }
-
- protected void format(IProgressMonitor monitor, IFile file) {
- try {
- IContentDescription contentDescription = file.getContentDescription();
- if (contentDescription == null)
- return;
-
- IContentType contentType = contentDescription.getContentType();
- IStructuredFormatProcessor formatProcessor = getFormatProcessor(contentType.getId());
- if (formatProcessor != null && (monitor == null || !monitor.isCanceled())) {
- monitor.setTaskName(ResourceHandler.getString("FormatActionDelegate.3") + " " + file.getFullPath() + "..."); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- formatProcessor.setProgressMonitor(monitor);
- formatProcessor.formatFile(file);
- }
- }
- catch (MalformedInputExceptionWithDetail e) {
- monitor.setTaskName(ResourceHandler.getString("FormatActionDelegate.4") + file.getName()); //$NON-NLS-1$
- }
- catch (IOException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + file.getName()); //$NON-NLS-1$
- }
- catch (CoreException e) {
- monitor.setTaskName(ResourceHandler.getString("ActionDelegate.0") + file.getName()); //$NON-NLS-1$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionDelegate.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionDelegate.java
deleted file mode 100644
index bb301db2f9..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionDelegate.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IActionDelegate;
-import org.eclipse.ui.PlatformUI;
-
-public class ResourceActionDelegate implements IActionDelegate {
- protected IStructuredSelection fSelection;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
- */
- public void run(IAction action) {
- if (fSelection != null && !fSelection.isEmpty()) {
- Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- ResourceActionProgressDialog progressDialog = new ResourceActionProgressDialog(shell);
- progressDialog.setCancelable(true);
- initProgressDialog(progressDialog);
- try {
- progressDialog.run(true, true, new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) {
- Object[] elements = fSelection.toArray();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] instanceof IResource) {
- process(monitor, (IResource) elements[i]);
- }
- }
- }
- });
- }
- catch (InvocationTargetException e) {
- e.printStackTrace();
- }
- catch (InterruptedException e) {
- e.printStackTrace();
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction,
- * org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IAction action, ISelection selection) {
- if (selection instanceof IStructuredSelection) {
- fSelection = (IStructuredSelection) selection;
- boolean available = false;
-
- Object[] elements = fSelection.toArray();
- for (int i = 0; i < elements.length; i++) {
- if (elements[i] instanceof IResource) {
- available = processorAvailable((IResource) elements[i]);
-
- if (available)
- break;
- }
- }
-
- action.setEnabled(available);
- }
- }
-
- protected boolean processorAvailable(IResource resource) {
- return false;
- }
-
- protected void process(IProgressMonitor monitor, IResource resource) {
-
- }
-
- protected void initProgressDialog(ResourceActionProgressDialog progressDialog) {
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionProgressDialog.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionProgressDialog.java
deleted file mode 100644
index b93fed9b44..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/ResourceActionProgressDialog.java
+++ /dev/null
@@ -1,564 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import java.lang.reflect.InvocationTargetException;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IProgressMonitorWithBlocking;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IconAndMessageDialog;
-import org.eclipse.jface.dialogs.ProgressIndicator;
-import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.operation.ModalContext;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Cursor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class ResourceActionProgressDialog extends IconAndMessageDialog implements IRunnableContext {
- protected Text fText = null;
- protected String fDialogTitle = ResourceHandler.getString("ResourceActionProgressDialog.0"); //$NON-NLS-1$
- protected String fActionCompletedMessage = ResourceHandler.getString("ResourceActionProgressDialog.1"); //$NON-NLS-1$
- protected String fActionCancelledMessage = ResourceHandler.getString("ResourceActionProgressDialog.2"); //$NON-NLS-1$
-
- /**
- * Name to use for task when normal task name is empty string.
- */
- private static String DEFAULT_TASKNAME = JFaceResources.getString("ProgressMonitorDialog.message"); //$NON-NLS-1$
-
- /**
- * Constants for label and monitor size
- */
- private static int LABEL_DLUS = 21;
- private static int BAR_DLUS = 9;
-
-
- /**
- * The progress indicator control.
- */
- protected ProgressIndicator progressIndicator;
-
- /**
- * The label control for the task. Kept for backwards compatibility.
- */
- protected Label taskLabel;
-
- /**
- * The label control for the subtask.
- */
- protected Label subTaskLabel;
-
- /**
- * The Okay button control.
- */
- protected Button okButton;
-
- /**
- * The Cancel button control.
- */
- protected Button cancel;
-
- /**
- * Indicates whether the Cancel button is to be shown.
- */
- protected boolean operationCancelableState = false;
-
- /**
- * Indicates whether the Cancel button is to be enabled.
- */
- protected boolean enableCancelButton;
-
- /**
- * The progress monitor.
- */
- private ProgressMonitor progressMonitor = new ProgressMonitor();
-
- /**
- * The name of the current task (used by ProgressMonitor).
- */
- private String task;
-
- /**
- * The nesting depth of currently running runnables.
- */
- private int nestingDepth;
-
- /**
- * The cursor used in the cancel button;
- */
- protected Cursor arrowCursor;
-
- /**
- * The cursor used in the shell;
- */
- private Cursor waitCursor;
-
- /**
- * Flag indicating whether to open or merely create the dialog before run.
- */
- private boolean openOnRun = true;
-
- /**
- * Internal progress monitor implementation.
- */
- private class ProgressMonitor implements IProgressMonitorWithBlocking {
-
- private String fSubTask = "";//$NON-NLS-1$
- private boolean fIsCanceled;
- protected boolean forked = false;
- protected boolean locked = false;
-
- public void beginTask(String name, int totalWork) {
- if (progressIndicator.isDisposed())
- return;
-
- if (name == null)
- task = "";//$NON-NLS-1$
- else
- task = name;
-
- String s = task;
- if (s.length() <= 0)
- s = DEFAULT_TASKNAME;
- setMessage(s);
- if (!forked)
- update();
-
- if (totalWork == UNKNOWN) {
- progressIndicator.beginAnimatedTask();
- }
- else {
- progressIndicator.beginTask(totalWork);
- }
- }
-
- public void done() {
- if (!progressIndicator.isDisposed()) {
- progressIndicator.sendRemainingWork();
- progressIndicator.done();
- }
- }
-
- public void setTaskName(String name) {
- if (name == null)
- task = "";//$NON-NLS-1$
- else
- task = name;
-
- String s = task;
- if (s.length() <= 0)
- s = DEFAULT_TASKNAME;
- setMessage(s);
- if (!forked)
- update();
- }
-
- public boolean isCanceled() {
- return fIsCanceled;
- }
-
- public void setCanceled(boolean b) {
- fIsCanceled = b;
- if (locked)
- clearBlocked();
- }
-
- public void subTask(String name) {
- if (subTaskLabel.isDisposed())
- return;
-
- if (name == null)
- fSubTask = "";//$NON-NLS-1$
- else
- fSubTask = name;
-
- subTaskLabel.setText(fSubTask);
- if (!forked)
- subTaskLabel.update();
- }
-
- public void worked(int work) {
- internalWorked(work);
- }
-
- public void internalWorked(double work) {
- if (!progressIndicator.isDisposed())
- progressIndicator.worked(work);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#clearBlocked()
- */
- public void clearBlocked() {
- setMessage(task);
- locked = false;
- imageLabel.setImage(getImage());
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus)
- */
- public void setBlocked(IStatus reason) {
- setMessage(reason.getMessage());
- locked = true;
- imageLabel.setImage(getImage());
-
- }
- }
-
- /**
- * Enables the cancel button (asynchronously).
- */
- private void asyncSetOperationCancelButtonEnabled(final boolean b) {
- if (getShell() != null) {
- getShell().getDisplay().asyncExec(new Runnable() {
- public void run() {
- setOperationCancelButtonEnabled(b);
- }
- });
- }
- }
-
- protected void cancelPressed() {
- //NOTE: this was previously done from a listener installed on the
- // cancel
- //button. On GTK, the listener installed by Dialog.createButton is
- // called
- //first and this was throwing an exception because the cancel button
- //was already disposed
- cancel.setEnabled(false);
- progressMonitor.setCanceled(true);
- super.cancelPressed();
- }
-
- /*
- * (non-Javadoc) Method declared on Window.
- */
- /**
- * The <code>ProgressMonitorDialog</code> implementation of this method
- * only closes the dialog if there are no currently running runnables.
- */
- public boolean close() {
- if (getNestingDepth() <= 0) {
- clearCursors();
- return super.close();
- }
- return false;
- }
-
- /**
- * Clear the cursors in the dialog.
- */
- protected void clearCursors() {
- if (cancel != null && !cancel.isDisposed()) {
- cancel.setCursor(null);
- }
- Shell shell = getShell();
- if (shell != null && !shell.isDisposed()) {
- shell.setCursor(null);
- }
- if (arrowCursor != null)
- arrowCursor.dispose();
- if (waitCursor != null)
- waitCursor.dispose();
- arrowCursor = null;
- waitCursor = null;
- }
-
- /*
- * (non-Javadoc) Method declared in Window.
- */
- protected void configureShell(Shell shell) {
- super.configureShell(shell);
-
- shell.setText(fDialogTitle);
- if (waitCursor == null)
- waitCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_WAIT);
- shell.setCursor(waitCursor);
- }
-
- /*
- * (non-Javadoc) Method declared on Dialog.
- */
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
-
- // cancel button
- cancel = createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, true);
- if (arrowCursor == null)
- arrowCursor = new Cursor(cancel.getDisplay(), SWT.CURSOR_ARROW);
- cancel.setCursor(arrowCursor);
- setOperationCancelButtonEnabled(enableCancelButton);
- }
-
-
- /*
- * (non-Javadoc) Method declared in Window.
- */
- protected Point getInitialSize() {
-
- Point calculatedSize = super.getInitialSize();
- if (calculatedSize.x < 450)
- calculatedSize.x = 450;
- return calculatedSize;
- }
-
- /**
- * Returns the progress monitor to use for operations run in this progress
- * dialog.
- *
- * @return the progress monitor
- */
- public IProgressMonitor getProgressMonitor() {
- return progressMonitor;
- }
-
- /*
- * (non-Javadoc) Method declared on IRunnableContext. Runs the given
- * <code> IRunnableWithProgress </code> with the progress monitor for this
- * progress dialog. The dialog is opened before it is run, and closed
- * after it completes.
- */
- public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
- setCancelable(cancelable);
- try {
- aboutToRun();
- //Let the progress monitor know if they need to update in UI
- // Thread
- progressMonitor.forked = fork;
- ModalContext.run(runnable, fork, getProgressMonitor(), getShell().getDisplay());
- }
- finally {
- finishedRun();
- }
- }
-
- /**
- * Returns whether the dialog should be opened before the operation is
- * run. Defaults to <code>true</code>
- *
- * @return <code>true</code> to open the dialog before run,
- * <code>false</code> to only create the dialog, but not open it
- */
- public boolean getOpenOnRun() {
- return openOnRun;
- }
-
- /**
- * Sets whether the dialog should be opened before the operation is run.
- * NOTE: Setting this to false and not forking a process may starve any
- * asyncExec that tries to open the dialog later.
- *
- * @param openOnRun
- * <code>true</code> to open the dialog before run,
- * <code>false</code> to only create the dialog, but not open
- * it
- */
- public void setOpenOnRun(boolean openOnRun) {
- this.openOnRun = openOnRun;
- }
-
- /**
- * Returns the nesting depth of running operations.
- *
- * @return the nesting depth of running operations
- */
- protected int getNestingDepth() {
- return nestingDepth;
- }
-
- /**
- * Increments the nesting depth of running operations.
- */
- protected void incrementNestingDepth() {
- nestingDepth++;
- }
-
- protected void decrementNestingDepth() {
- nestingDepth--;
- }
-
- /**
- * Called just before the operation is run. Default behaviour is to open
- * or create the dialog, based on the setting of <code>getOpenOnRun</code>,
- * and increment the nesting depth.
- */
- protected void aboutToRun() {
- if (getOpenOnRun()) {
- open();
- }
- else {
- create();
- }
- incrementNestingDepth();
- }
-
- /**
- * Called just after the operation is run. Default behaviour is to
- * decrement the nesting depth, and close the dialog.
- */
- protected void finishedRun() {
- decrementNestingDepth();
-
- if (progressMonitor.isCanceled())
- fText.append("\n" + fActionCancelledMessage); //$NON-NLS-1$
- else
- fText.append("\n" + fActionCompletedMessage); //$NON-NLS-1$
- clearCursors();
- okButton.setEnabled(true);
- cancel.setEnabled(false);
- getShell().setDefaultButton(okButton);
- }
-
- /**
- * Sets whether the progress dialog is cancelable or not.
- *
- * @param cancelable
- * <code>true</code> if the end user can cancel this progress
- * dialog, and <code>false</code> if it cannot be canceled
- */
- public void setCancelable(boolean cancelable) {
- if (cancel == null)
- enableCancelButton = cancelable;
- else
- asyncSetOperationCancelButtonEnabled(cancelable);
- }
-
- /**
- * Helper to enable/disable Cancel button for this dialog.
- *
- * @param b
- * <code>true</code> to enable the cancel button, and
- * <code>false</code> to disable it
- */
- protected void setOperationCancelButtonEnabled(boolean b) {
- operationCancelableState = b;
- cancel.setEnabled(b);
- }
-
- /*
- * @see org.eclipse.jface.dialogs.IconAndMessageDialog#getImage()
- */
- protected Image getImage() {
- Display display = PlatformUI.getWorkbench().getDisplay();
- return display.getSystemImage(SWT.ICON_INFORMATION);
- //return JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_INFO);
- }
-
- /**
- * Set the message in the message label.
- */
- private void setMessage(String messageString) {
- //must not set null text in a label
- message = messageString == null ? "" : messageString; //$NON-NLS-1$
- if (fText == null || fText.isDisposed())
- return;
- fText.append(message + "\n"); //$NON-NLS-1$
- }
-
- /**
- * Update the message label. Required if the monitor is forked.
- */
- private void update() {
- if (messageLabel == null || messageLabel.isDisposed())
- return;
- messageLabel.update();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.window.Window#open()
- */
- public int open() {
- //Check to be sure it is not already done. If it is just return OK.
- if (!getOpenOnRun()) {
- if (getNestingDepth() == 0)
- return OK;
- }
- return super.open();
- }
-
- /**
- * @param parent
- */
- public ResourceActionProgressDialog(Shell parent) {
- super(parent);
- setShellStyle(SWT.BORDER | SWT.TITLE | SWT.APPLICATION_MODAL); // no
- // close
- // button
- setBlockOnOpen(false);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
- */
- protected Control createDialogArea(Composite parent) {
- Composite composite = (Composite) super.createDialogArea(parent);
-
- fText = new Text(composite, SWT.MULTI | SWT.BORDER | SWT.READ_ONLY | SWT.V_SCROLL | SWT.NO_FOCUS | SWT.H_SCROLL);
- fText.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND));
- GridData gridData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.VERTICAL_ALIGN_FILL);
- gridData.grabExcessVerticalSpace = true;
- gridData.grabExcessHorizontalSpace = true;
- gridData.heightHint = convertVerticalDLUsToPixels(300);
- gridData.widthHint = convertHorizontalDLUsToPixels(400);
- fText.setLayoutData(gridData);
-
- return composite;
- }
-
- /**
- * @param dialogTitle The fDialogTitle to set.
- */
- public void setDialogTitle(String dialogTitle) {
- fDialogTitle = dialogTitle;
- }
-
- /**
- * @param actionCompletedMessage The fActionCompletedMessage to set.
- */
- public void setActionCompletedMessage(String actionCompletedMessage) {
- fActionCompletedMessage = actionCompletedMessage;
- }
-
- /**
- * @param actionCancelledMessage The fActionCancelledMessage to set.
- */
- public void setActionCancelledMessage(String actionCancelledMessage) {
- fActionCancelledMessage = actionCancelledMessage;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/SharedEditorPluginImageHelper.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/SharedEditorPluginImageHelper.java
deleted file mode 100644
index 11083bb959..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/SharedEditorPluginImageHelper.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-
-
-public class SharedEditorPluginImageHelper {
- public static final String IMG_DLCL_COLLAPSEALL = EditorPluginImages.IMG_DLCL_COLLAPSEALL;
- public static final String IMG_ELCL_COLLAPSEALL = EditorPluginImages.IMG_ELCL_COLLAPSEALL;
- public static final String IMG_DLCL_DELETE = EditorPluginImages.IMG_DLCL_DELETE;
- public static final String IMG_ELCL_DELETE = EditorPluginImages.IMG_ELCL_DELETE;
- public static final String IMG_DLCL_SYNCED = EditorPluginImages.IMG_DLCL_SYNCED;
- public static final String IMG_ELCL_SYNCED = EditorPluginImages.IMG_ELCL_SYNCED;
-
- /**
- * Retrieves the specified image from the source editor plugin's image registry.
- * Note: The returned <code>Image</code> is managed by the workbench; clients
- * must <b>not</b> dispose of the returned image.
- *
- * @param symbolicName the symbolic name of the image; there are constants
- * declared in this class for build-in images that come with the source editor
- * @return the image, or <code>null</code> if not found
- */
- public static Image getImage(String symbolicName) {
- return EditorPluginImageHelper.getInstance().getImage(symbolicName);
- }
-
- /**
- * Retrieves the image descriptor for specified image from the source editor plugin's
- * image registry. Unlike <code>Image</code>s, image descriptors themselves do
- * not need to be disposed.
- *
- * @param symbolicName the symbolic name of the image; there are constants
- * declared in this interface for build-in images that come with the source editor
- * @return the image descriptor, or <code>null</code> if not found
- */
- public static ImageDescriptor getImageDescriptor(String symbolicName) {
- return EditorPluginImageHelper.getInstance().getImageDescriptor(symbolicName);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/StructuredTextEditorActionConstants.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/StructuredTextEditorActionConstants.java
deleted file mode 100644
index 6552c0d549..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/StructuredTextEditorActionConstants.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui;
-
-
-
-public interface StructuredTextEditorActionConstants {
-
- public final static String GROUP_NAME_MENU_ADDITIONS = "MenuAdditions";//$NON-NLS-1$
- public final static String GROUP_NAME_TOOLBAR_ADDITIONS = "ToolbarAdditions";//$NON-NLS-1$
- public final static String ACTION_NAME_CONTENTASSIST_PROPOSALS = "ContentAssistProposals";//$NON-NLS-1$
- public final static String ACTION_NAME_CONTENTASSIST_CONTEXT_INFORMATION = "ContentAssistContextInformation";//$NON-NLS-1$
- public final static String ACTION_NAME_QUICK_FIX = "QuickFix";//$NON-NLS-1$
- public final static String ACTION_NAME_COMMENT = "Comment";//$NON-NLS-1$
- public final static String ACTION_NAME_UNCOMMENT = "Uncomment";//$NON-NLS-1$
- public final static String ACTION_NAME_TOGGLE_COMMENT = "ToggleComment";//$NON-NLS-1$
- public final static String ACTION_NAME_ADD_BLOCK_COMMENT = "AddBlockComment";//$NON-NLS-1$
- public final static String ACTION_NAME_REMOVE_BLOCK_COMMENT = "RemoveBlockComment";//$NON-NLS-1$
- public final static String ACTION_NAME_CLEANUP_DOCUMENT = "CleanupDocument";//$NON-NLS-1$
- public final static String ACTION_NAME_FORMAT_DOCUMENT = "FormatDocument";//$NON-NLS-1$
- public final static String ACTION_NAME_FORMAT_ACTIVE_ELEMENTS = "FormatActiveElements";//$NON-NLS-1$
- public final static String ACTION_NAME_MANAGE_BREAKPOINTS = "ManageBreakpoints";//$NON-NLS-1$
- public final static String ACTION_NAME_OPEN_FILE = "OpenFileFromSource";//$NON-NLS-1$
- public final static String ACTION_NAME_STRUCTURE_SELECT_ENCLOSING = "StructureSelectEnclosing";//$NON-NLS-1$
- public final static String ACTION_NAME_STRUCTURE_SELECT_NEXT = "StructureSelectNext";//$NON-NLS-1$
- public final static String ACTION_NAME_STRUCTURE_SELECT_PREVIOUS = "StructureSelectPrevious";//$NON-NLS-1$
- public final static String ACTION_NAME_STRUCTURE_SELECT_HISTORY = "StructureSelectHistory";//$NON-NLS-1$
- public final static String ACTION_NAME_INFORMATION = "ShowTooltipDesc";//$NON-NLS-1$
- public final static String ACTION_NAME_FIND_OCCURRENCES = "FindOccurrences"; //$NON-NLS-1$
-
- public final static String DOT = ".";//$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/text/DocumentRegionEdgeMatcher.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/text/DocumentRegionEdgeMatcher.java
deleted file mode 100644
index 66a64623df..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/ui/text/DocumentRegionEdgeMatcher.java
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.ui.text;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.source.ICharacterPairMatcher;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-/**
- * Matches the start and ending characters of IStructuredDocumentRegions with
- * the given allowed types. Note that Eclipse R3M8 only paints single
- * character-wide matches and this isn't true pair matching behavior. See RFE
- * #56836 at https://bugs.eclipse.org/bugs/show_bug.cgi?id=56836.
- */
-public class DocumentRegionEdgeMatcher implements ICharacterPairMatcher {
-
- public static final String ID = "characterpairmatcher"; //$NON-NLS-1$
-
- protected List fRegionTypes;
-
- protected int fAnchor;
-
- protected ICharacterPairMatcher fNextMatcher;
-
- public DocumentRegionEdgeMatcher(String[] validContexts, ICharacterPairMatcher nextMatcher) {
- fRegionTypes = Arrays.asList(validContexts);
- fNextMatcher = nextMatcher;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.source.ICharacterPairMatcher#match(org.eclipse.jface.text.IDocument,
- * int)
- */
- public IRegion match(IDocument document, int offset) {
- IRegion match = null;
- if (!fRegionTypes.isEmpty() && document instanceof IStructuredDocument) {
- IStructuredDocumentRegion docRegion = ((IStructuredDocument) document).getRegionAtCharacterOffset(offset);
- if (docRegion != null) {
- // look at the previous document region first since its end ==
- // this one's start
- if (docRegion.getPrevious() != null && docRegion.getPrevious().getEndOffset() == offset && fRegionTypes.contains(docRegion.getPrevious().getType())) {
- fAnchor = ICharacterPairMatcher.RIGHT;
- match = new Region(docRegion.getPrevious().getStartOffset(), 1);
- }
- // check for offset in the last text region for a match to
- // document region start offset
- else if (fRegionTypes.contains(docRegion.getType()) && docRegion.getStartOffset(docRegion.getLastRegion()) <= offset && offset <= docRegion.getEndOffset(docRegion.getLastRegion())) {
- fAnchor = ICharacterPairMatcher.RIGHT;
- match = new Region(docRegion.getStartOffset(), 1);
- }
- // check for offset in the first text region for a match to
- // document region end offset
- else if (fRegionTypes.contains(docRegion.getType())) {
- if (docRegion.getStartOffset(docRegion.getFirstRegion()) <= offset && offset <= docRegion.getEndOffset(docRegion.getFirstRegion())) {
- fAnchor = ICharacterPairMatcher.LEFT;
- match = new Region(docRegion.getEndOffset() - 1, 1);
- }
- }
- }
- }
- if (match == null && fNextMatcher != null) {
- fAnchor = -1;
- match = fNextMatcher.match(document, offset);
- }
- return match;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.source.ICharacterPairMatcher#getAnchor()
- */
- public int getAnchor() {
- if (fAnchor < 0 && fNextMatcher != null)
- return fNextMatcher.getAnchor();
- return fAnchor;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.source.ICharacterPairMatcher#dispose()
- */
- public void dispose() {
- if (fNextMatcher != null)
- fNextMatcher.dispose();
- }
-
- /*
- * @see org.eclipse.jface.text.source.ICharacterPairMatcher#clear()
- */
- public void clear() {
- if (fNextMatcher != null)
- fNextMatcher.clear();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/AccessibleInputDialog.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/AccessibleInputDialog.java
deleted file mode 100644
index 8dd7a9fad8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/AccessibleInputDialog.java
+++ /dev/null
@@ -1,244 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.dialogs.IInputValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * A simple input dialog for soliciting an input string
- * from the user.
- * <p>
- * This concete dialog class can be instantiated as is,
- * or further subclassed as required.
- *
- * NOTE: This class was mainly copied from org.eclipse.jface.dialogs.InputDialog
- * except the error message label was turned into a read-only text widget to
- * make the dialog accessible. (https://bugs.eclipse.org/bugs/show_bug.cgi?id=61069)
- * </p>
- */
-public class AccessibleInputDialog extends Dialog {
-
-
- /**
- * The title of the dialog.
- */
- private String title;
-
- /**
- * The message to display, or <code>null</code> if none.
- */
- private String message;
-
- /**
- * The input value; the empty string by default.
- */
- private String value= "";//$NON-NLS-1$
-
- /**
- * The input validator, or <code>null</code> if none.
- */
- private IInputValidator validator;
-
- /**
- * Ok button widget.
- */
- private Button okButton;
-
- /**
- * Input text widget.
- */
- private Text text;
-
- /**
- * Error message read-only text widget.
- */
- private Text errorMessageLabel;
-/**
- * Creates an input dialog with OK and Cancel buttons.
- * Note that the dialog will have no visual representation (no widgets)
- * until it is told to open.
- * <p>
- * Note that the <code>open</code> method blocks for input dialogs.
- * </p>
- *
- * @param parentShell the parent shell
- * @param dialogTitle the dialog title, or <code>null</code> if none
- * @param dialogMessage the dialog message, or <code>null</code> if none
- * @param initialValue the initial input value, or <code>null</code> if none
- * (equivalent to the empty string)
- * @param validator an input validator, or <code>null</code> if none
- */
-public AccessibleInputDialog(Shell parentShell, String dialogTitle, String dialogMessage, String initialValue, IInputValidator validator) {
- super(parentShell);
- this.title = dialogTitle;
- message = dialogMessage;
- if (initialValue == null)
- value = "";//$NON-NLS-1$
- else
- value = initialValue;
- this.validator = validator;
-}
-/* (non-Javadoc)
- * Method declared on Dialog.
- */
-protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- value= text.getText();
- } else {
- value= null;
- }
- super.buttonPressed(buttonId);
-}
-/* (non-Javadoc)
- * Method declared in Window.
- */
-protected void configureShell(Shell shell) {
- super.configureShell(shell);
- if (title != null)
- shell.setText(title);
-}
-/* (non-Javadoc)
- * Method declared on Dialog.
- */
-protected void createButtonsForButtonBar(Composite parent) {
- // create OK and Cancel buttons by default
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
-
- //do this here because setting the text will set enablement on the ok button
- text.setFocus();
- if (value != null) {
- text.setText(value);
- text.selectAll();
- }
-}
-/* (non-Javadoc)
- * Method declared on Dialog.
- */
-protected Control createDialogArea(Composite parent) {
- // create composite
- Composite composite = (Composite)super.createDialogArea(parent);
-
- // create message
- if (message != null) {
- Label label = new Label(composite, SWT.WRAP);
- label.setText(message);
- GridData data = new GridData(
- GridData.GRAB_HORIZONTAL |
- GridData.GRAB_VERTICAL |
- GridData.HORIZONTAL_ALIGN_FILL |
- GridData.VERTICAL_ALIGN_CENTER);
- data.widthHint = convertHorizontalDLUsToPixels(IDialogConstants.MINIMUM_MESSAGE_AREA_WIDTH);
- label.setLayoutData(data);
- label.setFont(parent.getFont());
- }
-
- text= new Text(composite, SWT.SINGLE | SWT.BORDER);
- text.setLayoutData(new GridData(
- GridData.GRAB_HORIZONTAL |
- GridData.HORIZONTAL_ALIGN_FILL));
- text.addModifyListener(
- new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- validateInput();
- }
- }
- );
- text.setFont(parent.getFont());
-
- errorMessageLabel = new Text(composite, SWT.READ_ONLY);
- errorMessageLabel.setLayoutData(new GridData(
- GridData.GRAB_HORIZONTAL |
- GridData.HORIZONTAL_ALIGN_FILL));
- errorMessageLabel.setFont(parent.getFont());
-
- return composite;
-}
-/**
- * Returns the error message text widget.
- *
- * @return the error message text widget
- */
-protected Text getErrorMessageLabel() {
- return errorMessageLabel;
-}
-/**
- * Returns the ok button.
- *
- * @return the ok button
- */
-protected Button getOkButton() {
- return okButton;
-}
-/**
- * Returns the text area.
- *
- * @return the text area
- */
-protected Text getText() {
- return text;
-}
-/**
- * Returns the validator.
- *
- * @return the validator
- */
-protected IInputValidator getValidator() {
- return validator;
-}
-/**
- * Returns the string typed into this input dialog.
- *
- * @return the input string
- */
-public String getValue() {
- return value;
-}
-/**
- * Validates the input.
- * <p>
- * The default implementation of this framework method
- * delegates the request to the supplied input validator object;
- * if it finds the input invalid, the error message is displayed
- * in the dialog's message line.
- * This hook method is called whenever the text changes in the
- * input field.
- * </p>
- */
-protected void validateInput() {
-
- String errorMessage = null;
-
- if (validator != null) {
- errorMessage = validator.isValid(text.getText());
- }
-
- // Bug 16256: important not to treat "" (blank error) the same as null (no error)
- errorMessageLabel.setText(errorMessage == null ? "" : errorMessage); //$NON-NLS-1$
- okButton.setEnabled(errorMessage == null);
-
- errorMessageLabel.getParent().update();
-}
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Assert.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Assert.java
deleted file mode 100644
index acdf01d936..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Assert.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-import org.eclipse.wst.sse.ui.Logger;
-
-/**
- * <code>Assert</code> is useful for for embedding runtime sanity checks
- * in code.
- * The predicate methods all test a condition and throw some
- * type of unchecked exception if the condition does not hold.
- * <p>
- * Assertion failure exceptions, like most runtime exceptions, are
- * thrown when something is misbehaving. Assertion failures are invariably
- * unspecified behavior; consequently, clients should never rely on
- * these being thrown (and certainly should not being catching them
- * specifically).
- * </p>
- */
-public final class Assert {
-
- /**
- * <code>AssertionFailedException</code> is a runtime exception thrown
- * by some of the methods in <code>Assert</code>.
- * <p>
- * This class is not declared public to prevent some misuses; programs that catch
- * or otherwise depend on assertion failures are susceptible to unexpected
- * breakage when assertions in the code are added or removed.
- * </p>
- */
- class AssertionFailedException extends RuntimeException {
- /** Constructs a new exception.
- */
- public AssertionFailedException() {
- }
-
- /** Constructs a new exception with the given message.
- */
- public AssertionFailedException(String detail) {
- super(detail);
- }
- }
-
- /* This class is not intended to be instantiated. */
- private Assert() {
- }
-
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression) {
- return isLegal(expression, ""); //$NON-NLS-1$
- }
-
- /** Asserts that an argument is legal. If the given boolean is
- * not <code>true</code>, an <code>IllegalArgumentException</code>
- * is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- * @exception IllegalArgumentException if the legality test failed
- */
- public static boolean isLegal(boolean expression, String message) {
- if (!expression)
- throw new IllegalArgumentException();
- return expression;
- }
-
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param object the value to test
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
- public static void isNotNull(Object object) {
- isNotNull(object, ""); //$NON-NLS-1$
- }
-
- /** Asserts that the given object is not <code>null</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param object the value to test
- * @param message the message to include in the exception
- * @exception IllegalArgumentException if the object is <code>null</code>
- */
- public static void isNotNull(Object object, String message) {
- if (object == null) {
- Logger.log(Logger.ERROR, "null_argument: " + message); //$NON-NLS-1$
- throw new Assert().new AssertionFailedException();
- }
- }
-
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- *
- * @param expression the outcode of the check
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression) {
- return isTrue(expression, ""); //$NON-NLS-1$
- }
-
- /** Asserts that the given boolean is <code>true</code>. If this
- * is not the case, some kind of unchecked exception is thrown.
- * The given message is included in that exception, to aid debugging.
- *
- * @param expression the outcode of the check
- * @param message the message to include in the exception
- * @return <code>true</code> if the check passes (does not return
- * if the check fails)
- */
- public static boolean isTrue(boolean expression, String message) {
- if (!expression) {
- Logger.log(Logger.ERROR, "assertion failed: " + message); //$NON-NLS-1$
- throw new Assert().new AssertionFailedException();
- }
- return expression;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/EditorUtility.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/EditorUtility.java
deleted file mode 100644
index 4ddf67bfea..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/EditorUtility.java
+++ /dev/null
@@ -1,134 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Color;
-import org.eclipse.swt.graphics.RGB;
-
-/**
- * Helpful methods to be used with the Source Editor
- */
-public class EditorUtility {
- /**
- * Computes the state mask for the given modifier string.
- *
- * @param modifiers the string with the modifiers, separated by '+', '-', ';', ',' or '.'
- * @return the state mask or -1 if the input is invalid
- */
- public static int computeStateMask(String modifiers) {
- if (modifiers == null)
- return -1;
-
- if (modifiers.length() == 0)
- return SWT.NONE;
-
- int stateMask = 0;
- StringTokenizer modifierTokenizer = new StringTokenizer(modifiers, ",;.:+-* "); //$NON-NLS-1$
- while (modifierTokenizer.hasMoreTokens()) {
- int modifier = EditorUtility.findLocalizedModifier(modifierTokenizer.nextToken());
- if (modifier == 0 || (stateMask & modifier) == modifier)
- return -1;
- stateMask = stateMask | modifier;
- }
- return stateMask;
- }
-
- /**
- * Maps the localized modifier name to a code in the same
- * manner as #findModifier.
- *
- * @return the SWT modifier bit, or <code>0</code> if no match was found
- * @see findModifier
- */
- public static int findLocalizedModifier(String token) {
- if (token == null)
- return 0;
-
- if (token.equalsIgnoreCase(Action.findModifierString(SWT.CTRL)))
- return SWT.CTRL;
- if (token.equalsIgnoreCase(Action.findModifierString(SWT.SHIFT)))
- return SWT.SHIFT;
- if (token.equalsIgnoreCase(Action.findModifierString(SWT.ALT)))
- return SWT.ALT;
- if (token.equalsIgnoreCase(Action.findModifierString(SWT.COMMAND)))
- return SWT.COMMAND;
-
- return 0;
- }
-
- /**
- * Returns the modifier string for the given SWT modifier
- * modifier bits.
- *
- * @param stateMask the SWT modifier bits
- * @return the modifier string
- */
- public static String getModifierString(int stateMask) {
- String modifierString = ""; //$NON-NLS-1$
- if ((stateMask & SWT.CTRL) == SWT.CTRL)
- modifierString = appendModifierString(modifierString, SWT.CTRL);
- if ((stateMask & SWT.ALT) == SWT.ALT)
- modifierString = appendModifierString(modifierString, SWT.ALT);
- if ((stateMask & SWT.SHIFT) == SWT.SHIFT)
- modifierString = appendModifierString(modifierString, SWT.SHIFT);
- if ((stateMask & SWT.COMMAND) == SWT.COMMAND)
- modifierString = appendModifierString(modifierString, SWT.COMMAND);
-
- return modifierString;
- }
-
- /**
- * Appends to modifier string of the given SWT modifier bit
- * to the given modifierString.
- *
- * @param modifierString the modifier string
- * @param modifier an int with SWT modifier bit
- * @return the concatenated modifier string
- */
- private static String appendModifierString(String modifierString, int modifier) {
- if (modifierString == null)
- modifierString = ""; //$NON-NLS-1$
- String newModifierString = Action.findModifierString(modifier);
- if (modifierString.length() == 0)
- return newModifierString;
- return modifierString + " + " + newModifierString; //$NON-NLS-1$
- }
-
- /**
- * Temporary method to help migrate from using StructuredTextColors to using base ColorRegistry.
- * Instead of using symbolic names in the color registry, we are currently mapping the rgb.toString
- * value to corresponding color.
- * @param rgb
- * @return Color
- */
- public static Color getColor(RGB rgb) {
- if (rgb == null)
- return null;
-
- // get the color from the platform color registry
- Color color = JFaceResources.getColorRegistry().get(rgb.toString());
-
- // if the platform color registry does not have this color yet, add to the registry
- if (color == null) {
- JFaceResources.getColorRegistry().put(rgb.toString(), rgb);
- color = JFaceResources.getColorRegistry().get(rgb.toString());
- }
- return color;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ImageRegistry.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ImageRegistry.java
deleted file mode 100644
index 4c84256859..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ImageRegistry.java
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.util.Assert;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-
-/**
- * An image registry maintains a mapping between symbolic image names and SWT
- * image objects or special image descriptor objects which defer the creation
- * of SWT image objects until they are needed.
- * <p>
- * An image registry owns all of the image objects registered with it, and can
- * automatically dispose of them when the registered SWT Display is disposed.
- * Clients may also request that the images be disposed of manually, but <em>utmost care must be taken when
- * doing so</em>.
- * </p>
- * <p>
- *
- * <p>
- * Unlike the FontRegistry, it is an error to replace images. As a result there
- * are no events that fire when values are changed in the registry. Images
- * which are replaced may not be disposed of correctly.
- * </p>
- *
- * @deprecated - use base ImageRegistry (JFaceResources.getImageRegistry() instead TODO remove in C5 or earlier
- */
-public class ImageRegistry {
- /**
- * Table of known images keyed by symbolic image name (key type: <code>String</code>,
- * value type: <code>org.eclipse.swt.graphics.Image</code> or <code>ImageDescriptor</code>).
- */
- protected Map table = new HashMap(10);
-
- /**
- * Creates an empty image registry.
- * <p>
- * There must be an SWT Display created in the current thread before
- * calling this method.
- * </p>
- */
- public ImageRegistry() {
- Display display = getDisplay();
- if (display != null) {
- hookDisplayDispose(display);
- }
- }
-
- /**
- * Creates an empty image registry.
- */
- public ImageRegistry(Display display) {
- Assert.isNotNull(display);
- hookDisplayDispose(display);
- }
-
- /**
- * Shuts down this image registry and disposes of all registered images.
- */
- public void dispose() {
- if (table != null) {
- for (Iterator e = table.values().iterator(); e.hasNext();) {
- Object next = e.next();
- if (next instanceof Image) {
- ((Image) next).dispose();
- }
- }
- table = new HashMap(10);
- }
- }
-
- /**
- * Returns the image associated with the given key in this registry, or
- * <code>null</code> if none.
- *
- * @param key
- * the key
- * @return the image, or <code>null</code> if none
- */
- public Image get(String key) {
- Object entry = table.get(key);
- if (entry == null) {
- return null;
- }
- if (entry instanceof Image) {
- return (Image) entry;
- }
- Image image = ((ImageDescriptor) entry).createImage();
- table.put(key, image);
- return image;
- }
-
- /**
- * Hook a dispose listener on the SWT display.
- *
- * @param display
- * the Display
- */
- private void hookDisplayDispose(Display display) {
- display.disposeExec(new Runnable() {
- public void run() {
- dispose();
- }
- });
- }
-
- /**
- * Adds (or replaces) an image descriptor to this registry. The first time
- * this new entry is retrieved, the image descriptor's image will be
- * computed (via</code> ImageDescriptor.createImage</code>) and
- * remembered. This method replaces an existing image descriptor associated
- * with the given key, but fails if there is a real image associated with
- * it.
- *
- * @param key
- * the key
- * @param descriptor
- * the ImageDescriptor
- * @exception IllegalArgumentException
- * if the key already exists
- */
- public void put(String key, ImageDescriptor descriptor) {
- Object entry = table.get(key);
- if (entry == null || entry instanceof ImageDescriptor) {
- // replace with the new descriptor
- table.put(key, descriptor);
- return;
- }
- throw new IllegalArgumentException("ImageRegistry key already in use: " + key);//$NON-NLS-1$
- }
-
- /**
- * Adds an image to this registry. This method fails if there is already an
- * image with the given key.
- * <p>
- * Note that an image registry owns all of the image objects registered
- * with it, and automatically disposes of them the SWT Display is disposed.
- * Because of this, clients must not register an image object that is
- * managed by another object.
- * </p>
- *
- * @param key
- * the key
- * @param image
- * the image
- * @exception IllegalArgumentException
- * if the key already exists
- */
- public void put(String key, Image image) {
- Object entry = table.get(key);
- if (entry == null || entry instanceof ImageDescriptor) {
- // replace with the new descriptor
- table.put(key, image);
- return;
- }
- throw new IllegalArgumentException("ImageRegistry key already in use: " + key);//$NON-NLS-1$
- }
-
- private Display getDisplay() {
- return PlatformUI.getWorkbench().getDisplay();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/PlatformStatusLineUtil.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/PlatformStatusLineUtil.java
deleted file mode 100644
index bc5ccc784f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/PlatformStatusLineUtil.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.custom.StyledText;
-import org.eclipse.swt.custom.VerifyKeyListener;
-import org.eclipse.swt.events.FocusAdapter;
-import org.eclipse.swt.events.FocusEvent;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.MouseListener;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.events.VerifyEvent;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-
-
-/**
- * Utility to display (and/or clear) messages on the status line.
- * @author pavery
- */
-public class PlatformStatusLineUtil {
-
- private class ClearErrorMessage implements Runnable {
- public void run() {
- displayMessage(null);
- }
- }
- /**
- * Used to clear message on focus loss, change of selection, key type, etc...
- */
- private class OneTimeListener extends FocusAdapter implements VerifyKeyListener, SelectionListener, MouseListener {
-
- private Runnable fRunner = null;
- private StyledText fStyledText;
-
- public OneTimeListener(StyledText target, Runnable r) {
- fStyledText = target;
- fRunner = r;
- fStyledText.addVerifyKeyListener(this);
- fStyledText.addFocusListener(this);
- fStyledText.addSelectionListener(this);
- fStyledText.addMouseListener(this);
- }
-
- public void focusLost(FocusEvent e) {
- unhookAndRun();
- }
- public void mouseDoubleClick(MouseEvent e) {
- unhookAndRun();
- }
- public void mouseDown(MouseEvent e) {
- unhookAndRun();
- }
- public void mouseUp(MouseEvent e) {
- //
- }
-
- private void unhookAndRun() {
- fStyledText.removeVerifyKeyListener(this);
- fStyledText.removeFocusListener(this);
- fStyledText.removeSelectionListener(this);
- fStyledText.removeMouseListener(this);
- fStyledText.getDisplay().asyncExec(fRunner);
- }
-
- public void verifyKey(VerifyEvent event) {
- unhookAndRun();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- unhookAndRun();
- }
-
- public void widgetSelected(SelectionEvent e) {
- unhookAndRun();
- }
- }
- // end OneTimeListener
-
- private static PlatformStatusLineUtil singleton = null;
-
- private PlatformStatusLineUtil() {
- // force use of singleton
- }
-
- private static PlatformStatusLineUtil getInstance() {
- if(singleton == null)
- singleton = new PlatformStatusLineUtil();
- return singleton;
- }
-
- private static void addOneTimeClearListener(StructuredTextEditor editor) {
- if(editor != null) {
- ITextViewer viewer = editor.getTextViewer();
- if(viewer != null)
- addOneTimeClearListener(viewer.getTextWidget());
- }
- }
- private static void addOneTimeClearListener(StyledText widget) {
- getInstance().new OneTimeListener(widget, getInstance().new ClearErrorMessage());
- }
- private static IEditorPart getActiveEditor() {
-
- IEditorPart editor = null;
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if(window == null) {
- IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
- if(windows.length > 0)
- window = windows[0];
- }
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null)
- editor = page.getActiveEditor();
- }
- return editor;
- }
-
- /**
- * Status line will be cleared w/ key type, or selection change
- * @param widget
- */
- public static void addOneTimeClearListener() {
- IEditorPart editor = getActiveEditor();
- if(editor != null && editor instanceof StructuredTextEditor)
- addOneTimeClearListener((StructuredTextEditor)editor);
- }
-
- /**
- * Clears the status line immediately
- */
- public static void clearStatusLine() {
- displayMessage(null);
- }
-
- /**
- * Display a message on the status line (no beep)
- * @param msg
- */
- public static void displayMessage(String msg) {
-
- IEditorPart editor = getActiveEditor();
- if (editor != null)
- editor.getEditorSite().getActionBars().getStatusLineManager().setErrorMessage(msg);
-
- }
- /**
- * Display a message on the status line (with a beep)
- * @param msg
- */
- public static void displayErrorMessage(String msg) {
-
- displayMessage(msg);
- PlatformUI.getWorkbench().getDisplay().beep();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/RegistryReader.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/RegistryReader.java
deleted file mode 100644
index f5c2d73b01..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/RegistryReader.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-
-
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtension;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-/**
- * Template implementation of a registry reader that creates objects
- * representing registry contents. Typically, an extension
- * contains one element, but this reader handles multiple
- * elements per extension.
- *
- * To start reading the extensions from the registry for an
- * extension point, call the method <code>readRegistry</code>.
- *
- * To read children of an IConfigurationElement, call the
- * method <code>readElementChildren</code> from your implementation
- * of the method <code>readElement</code>, as it will not be
- * done by default.
- */
-public abstract class RegistryReader {
-
-
- protected static final String TAG_DESCRIPTION = "description"; //$NON-NLS-1$
-
- /**
- * The constructor.
- */
- protected RegistryReader() {
- }
-
- /**
- * This method extracts description as a subelement of
- * the given element.
- * @return description string if defined, or empty string
- * if not.
- */
- protected String getDescription(IConfigurationElement config) {
- IConfigurationElement[] children = config.getChildren(TAG_DESCRIPTION);
- if (children.length >= 1) {
- return children[0].getValue();
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Logs the error in the workbench log using the provided
- * text and the information in the configuration element.
- */
- protected void logError(IConfigurationElement element, String text) {
- IExtension extension = element.getDeclaringExtension();
- IPluginDescriptor descriptor = extension.getDeclaringPluginDescriptor();
- StringBuffer buf = new StringBuffer();
- buf.append("Plugin " + descriptor.getUniqueIdentifier() + ", extension " + extension.getExtensionPointUniqueIdentifier()); //$NON-NLS-2$//$NON-NLS-1$
- buf.append("\n" + text); //$NON-NLS-1$
- Logger.log(Logger.ERROR, buf.toString());
- }
-
- /**
- * Logs a very common registry error when a required attribute is missing.
- */
- protected void logMissingAttribute(IConfigurationElement element, String attributeName) {
- logError(element, "Required attribute '" + attributeName + "' not defined"); //$NON-NLS-2$//$NON-NLS-1$
- }
-
- /**
- * Logs a registry error when the configuration element is unknown.
- */
- protected void logUnknownElement(IConfigurationElement element) {
- logError(element, "Unknown extension tag found: " + element.getName()); //$NON-NLS-1$
- }
-
- /**
- * Apply a reproducable order to the list of extensions
- * provided, such that the order will not change as
- * extensions are added or removed.
- */
- protected IExtension[] orderExtensions(IExtension[] extensions) {
- // By default, the order is based on plugin id sorted
- // in ascending order. The order for a plugin providing
- // more than one extension for an extension point is
- // dependent in the order listed in the XML file.
- Sorter sorter = new Sorter() {
- public boolean compare(Object extension1, Object extension2) {
- String s1 = ((IExtension) extension1).getDeclaringPluginDescriptor().getUniqueIdentifier().toUpperCase();
- String s2 = ((IExtension) extension2).getDeclaringPluginDescriptor().getUniqueIdentifier().toUpperCase();
- //Return true if elementTwo is 'greater than' elementOne
- return s2.compareTo(s1) > 0;
- }
- };
-
- Object[] sorted = sorter.sort(extensions);
- IExtension[] sortedExtension = new IExtension[sorted.length];
- System.arraycopy(sorted, 0, sortedExtension, 0, sorted.length);
- return sortedExtension;
- }
-
- /**
- * Implement this method to read element's attributes.
- * If children should also be read, then implementor
- * is responsible for calling <code>readElementChildren</code>.
- * Implementor is also responsible for logging missing
- * attributes.
- *
- * @return true if element was recognized, false if not.
- */
- protected abstract boolean readElement(IConfigurationElement element);
-
- /**
- * Read the element's children. This is called by
- * the subclass' readElement method when it wants
- * to read the children of the element.
- */
- protected void readElementChildren(IConfigurationElement element) {
- readElements(element.getChildren());
- }
-
- /**
- * Read each element one at a time by calling the
- * subclass implementation of <code>readElement</code>.
- *
- * Logs an error if the element was not recognized.
- */
- protected void readElements(IConfigurationElement[] elements) {
- for (int i = 0; i < elements.length; i++) {
- if (!readElement(elements[i]))
- logUnknownElement(elements[i]);
- }
- }
-
- /**
- * Read one extension by looping through its
- * configuration elements.
- */
- protected void readExtension(IExtension extension) {
- readElements(extension.getConfigurationElements());
- }
-
- /**
- * Start the registry reading process using the
- * supplied plugin ID and extension point.
- */
- protected void readRegistry(IPluginRegistry registry, String pluginId, String extensionPoint) {
- IExtensionPoint point = registry.getExtensionPoint(pluginId, extensionPoint);
- if (point != null) {
- IExtension[] extensions = point.getExtensions();
- extensions = orderExtensions(extensions);
- for (int i = 0; i < extensions.length; i++)
- readExtension(extensions[i]);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ShowViewAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ShowViewAction.java
deleted file mode 100644
index 6d0402797f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/ShowViewAction.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.dialogs.ErrorDialog;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.internal.WorkbenchMessages;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-
-
-/**
- * Surfaces a View.
- *
- * @author Nitin Dahyabhai
- */
-public abstract class ShowViewAction extends Action {
- /**
- *
- */
- public ShowViewAction() {
- super();
- }
-
- /**
- * @param text
- */
- public ShowViewAction(String text) {
- super(text);
- }
-
- /**
- * @param text
- * @param image
- */
- public ShowViewAction(String text, ImageDescriptor image) {
- super(text, image);
- }
-
- /**
- * @param text
- * @param style
- */
- public ShowViewAction(String text, int style) {
- super(text, style);
- }
-
- /**
- * @return
- */
- protected abstract String getViewID();
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#run()
- */
- public void run() {
- super.run();
- showView();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
- */
- public void runWithEvent(Event event) {
- super.runWithEvent(event);
- showView();
- }
-
- /**
- *
- */
- private void showView() {
- IWorkbenchWindow window = EditorPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow();
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- try {
- page.showView(getViewID());
- }
- catch (PartInitException e) {
- ErrorDialog.openError(window.getShell(), WorkbenchMessages.getString("ShowView.errorTitle"), //$NON-NLS-1$
- e.getMessage(), e.getStatus());
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Sorter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Sorter.java
deleted file mode 100644
index 93ddd04568..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/Sorter.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-
-
-/**
- * The SortOperation takes a collection of objects and returns
- * a sorted collection of these objects. Concrete instances of this
- * class provide the criteria for the sorting of the objects based on
- * the type of the objects.
- */
-public abstract class Sorter {
-
- /**
- * Returns true if elementTwo is 'greater than' elementOne
- * This is the 'ordering' method of the sort operation.
- * Each subclass overides this method with the particular
- * implementation of the 'greater than' concept for the
- * objects being sorted.
- */
- public abstract boolean compare(Object elementOne, Object elementTwo);
-
- /**
- * Sort the objects in sorted collection and return that collection.
- */
- private Object[] quickSort(Object[] sortedCollection, int left, int right) {
- int originalLeft = left;
- int originalRight = right;
- Object mid = sortedCollection[(left + right) / 2];
-
- do {
- while (compare(sortedCollection[left], mid))
- left++;
- while (compare(mid, sortedCollection[right]))
- right--;
- if (left <= right) {
- Object tmp = sortedCollection[left];
- sortedCollection[left] = sortedCollection[right];
- sortedCollection[right] = tmp;
- left++;
- right--;
- }
- }
- while (left <= right);
-
- if (originalLeft < right)
- sortedCollection = quickSort(sortedCollection, originalLeft, right);
- if (left < originalRight)
- sortedCollection = quickSort(sortedCollection, left, originalRight);
-
- return sortedCollection;
- }
-
- /**
- * Return a new sorted collection from this unsorted collection.
- * Sort using quick sort.
- */
- public Object[] sort(Object[] unSortedCollection) {
- int size = unSortedCollection.length;
- Object[] sortedCollection = new Object[size];
-
- //copy the array so can return a new sorted collection
- System.arraycopy(unSortedCollection, 0, sortedCollection, 0, size);
- if (size > 1)
- quickSort(sortedCollection, 0, size - 1);
-
- return sortedCollection;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/SourceEditorImageHelper.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/SourceEditorImageHelper.java
deleted file mode 100644
index 794dc8f81a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/util/SourceEditorImageHelper.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.util;
-
-
-
-import java.util.HashMap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-
-
-/**
- * @deprecated use EditorPluginImageHelper for internal and
- * SharedEditorPluginImageHelper for public images
- */
-public class SourceEditorImageHelper {
- protected HashMap descRegistry = null; // save a descriptor for each image
-
- /**
- * XMLProposalHelper constructor comment.
- */
- public SourceEditorImageHelper() {
- super();
- }
-
- public Image createImage(String resource) {
- Object o = getImageDescriptorRegistry().get(resource);
- ImageDescriptor desc = null;
- if (o != null)
- desc = (ImageDescriptor) o;
- else {
- desc = createImageDescriptor(resource);
- }
-
- Image image = desc.createImage();
- getImageRegistry().put(resource, image);
- return image;
- }
-
- public Image getImage(String resource) {
- Image image = getImageRegistry().get(resource);
- if (image == null) {
- image = createImage(resource);
- }
- return image;
- }
-
- public ImageDescriptor getImageDescriptor(String resource) {
- ImageDescriptor imageDescriptor = null;
- Object o = getImageDescriptorRegistry().get(resource);
- if (o == null) {
- //create a descriptor
- createImageDescriptor(resource);
- }
- return imageDescriptor;
- }
-
- private ImageDescriptor createImageDescriptor(String resource) {
- ImageDescriptor imageDescriptor = AbstractUIPlugin.imageDescriptorFromPlugin(EditorPlugin.ID, resource);
- if (imageDescriptor != null) {
- getImageDescriptorRegistry().put(resource, imageDescriptor);
- } else {
- imageDescriptor = ImageDescriptor.getMissingImageDescriptor();
- }
-
- return imageDescriptor;
- }
-
- private ImageRegistry getImageRegistry() {
- return JFaceResources.getImageRegistry();
- }
-
- protected HashMap getImageDescriptorRegistry() {
- if (descRegistry == null)
- descRegistry = new HashMap();
- return descRegistry;
- }
-
- public void release() {
- descRegistry = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/CaretEvent.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/CaretEvent.java
deleted file mode 100644
index b152569e1a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/CaretEvent.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.view.events;
-
-
-
-/**
- * Simply holds data to be passed to CaretEventListeners
- */
-public class CaretEvent extends java.util.EventObject {
-
- // initialize to impossible location
- int fPosition = -1;
-
- /**
- * doesnt't make sense to have a CaretEvent without the Caret postion, so use other constructor
- */
- protected CaretEvent(Object source) {
- super(source);
- }
-
- /**
- * This is the preferred constructor.
- */
- public CaretEvent(Object source, int position) {
- super(source);
- setPosition(position);
- }
-
- public int getPosition() {
- return fPosition;
- }
-
- void setPosition(int newPosition) {
- fPosition = newPosition;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ICaretListener.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ICaretListener.java
deleted file mode 100644
index b671431476..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ICaretListener.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.view.events;
-
-
-
-public interface ICaretListener extends java.util.EventListener {
-
- public void caretMoved(CaretEvent event);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/INodeSelectionListener.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/INodeSelectionListener.java
deleted file mode 100644
index e43bb49a2b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/INodeSelectionListener.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.view.events;
-
-
-
-public interface INodeSelectionListener {
-
- void nodeSelectionChanged(NodeSelectionChangedEvent event);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ITextSelectionListener.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ITextSelectionListener.java
deleted file mode 100644
index 4c663488df..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/ITextSelectionListener.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.view.events;
-
-
-
-public interface ITextSelectionListener {
-
- void textSelectionChanged(TextSelectionChangedEvent event);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/NodeSelectionChangedEvent.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/NodeSelectionChangedEvent.java
deleted file mode 100644
index da36235397..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/NodeSelectionChangedEvent.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.view.events;
-
-
-
-import java.util.List;
-
-public class NodeSelectionChangedEvent extends java.util.EventObject {
-
- List fSelectedNodes;
- int fCaretPosition;
-
- public NodeSelectionChangedEvent(Object source, List selectedNodes, int caretPosition) {
- super(source);
- fSelectedNodes = selectedNodes;
- fCaretPosition = caretPosition;
- }
-
- public int getCaretPosition() {
- return fCaretPosition;
- }
-
- public List getSelectedNodes() {
- return fSelectedNodes;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/TextSelectionChangedEvent.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/TextSelectionChangedEvent.java
deleted file mode 100644
index b80186b16c..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/view/events/TextSelectionChangedEvent.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.view.events;
-
-
-
-public class TextSelectionChangedEvent extends java.util.EventObject {
-
- int fTextSelectionStart;
- int fTextSelectionEnd;
-
- public TextSelectionChangedEvent(Object source, int textSelectionStart, int textSelectionEnd) {
- super(source);
- fTextSelectionStart = textSelectionStart;
- fTextSelectionEnd = textSelectionEnd;
- }
-
- public int getTextSelectionEnd() {
- return fTextSelectionEnd;
- }
-
- public int getTextSelectionStart() {
- return fTextSelectionStart;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/ContentOutlineConfiguration.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/ContentOutlineConfiguration.java
deleted file mode 100644
index 7236f33e36..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/ContentOutlineConfiguration.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-import java.util.List;
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.wst.sse.ui.extension.IExtendedConfiguration;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-
-
-/**
- * Configuration class for Outline Pages. Not finalized.
- *
- * @author Nitin Dahyabhai
- *
- */
-public class ContentOutlineConfiguration implements IExtendedConfiguration {
-
- public final static String ID = "contentoutlineconfiguration"; //$NON-NLS-1$
-
- protected IContentProvider fContentProvider;
- private String fDeclaringID = null;
- protected IDoubleClickListener fDoubleClickListener;
- private KeyListener[] fKeyListeners;
- protected ILabelProvider fLabelProvider;
-
- public ContentOutlineConfiguration() {
- super();
- fDeclaringID = getClass().getName();
- }
-
- private IContentProvider createTreeContentProvider() {
- return new ITreeContentProvider() {
- public void dispose() {
- // do nothing
- }
-
- public Object[] getChildren(Object parentElement) {
- return new Object[0];
- }
-
- public Object[] getElements(Object inputElement) {
- return new Object[0];
- }
-
- public Object getParent(Object element) {
- return null;
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- // do nothing
- }
- };
- }
-
- /**
- * @param viewer
- * @return the ITreeContentProvider to use with this viewer
- */
- public IContentProvider getContentProvider(TreeViewer viewer) {
- if (fContentProvider == null)
- fContentProvider = createTreeContentProvider();
- return fContentProvider;
- }
-
- /**
- * @return Returns the declaringID, useful for remembering settings.
- */
- public String getDeclaringID() {
- if (fDeclaringID == null)
- return "???"; //$NON-NLS-1$
- return fDeclaringID;
- }
-
- /**
- * @param viewer
- * @return the IDoubleClickListener to be notified when the viewer receives
- * a double click event
- */
- public IDoubleClickListener getDoubleClickListener(TreeViewer viewer) {
- return null;
- }
-
- /**
- *
- * @param viewer
- * @return an array of KeyListeners to attach to the TreeViewer's Control.
- * The listeners should adhere to the KeyEvent.doit field to ensure
- * proper behaviors. Ordering of the event notifications is dependent on
- * the Control in the TreeViewer.
- */
- public KeyListener[] getKeyListeners(TreeViewer viewer) {
- if (fKeyListeners == null)
- fKeyListeners = new KeyListener[0];
- return fKeyListeners;
- }
-
- /**
- * @param viewer
- * @return the ILabelProvider for items within the viewer
- */
- public ILabelProvider getLabelProvider(TreeViewer viewer) {
- if (fLabelProvider == null)
- fLabelProvider = new LabelProvider();
- return fLabelProvider;
- }
-
- /**
- * @param viewer
- * @return IContributionItem[] for the local menu
- */
- public IContributionItem[] getMenuContributions(TreeViewer viewer) {
- return new IContributionItem[0];
- }
-
- /**
- * @param viewer
- * @return the IMenuListener to notify when the viewer's context menu is
- * about to be show
- */
- public IMenuListener getMenuListener(TreeViewer viewer) {
- return null;
- }
-
- /**
- * @param event
- * @return The (filtered) list of selected nodes from this event. Uses
- * include mapping model selection onto elements provided by the
- * content provider. Should only return elements that will be
- * shown in the Tree Control.
- */
- public List getSelectedNodes(NodeSelectionChangedEvent event) {
- return event.getSelectedNodes();
- }
-
- /**
- * @param viewer
- * @return the ISelectionChangedListener to notify when the viewer's
- * selection changes
- */
- public ISelectionChangedListener getSelectionChangedListener(TreeViewer viewer) {
- return null;
- }
-
- /**
- * @param viewer
- * @return IContributionItem[] for the local toolbar
- */
- public IContributionItem[] getToolbarContributions(TreeViewer viewer) {
- return new IContributionItem[0];
- }
-
- /**
- * Adopted since you can't easily removeDragSupport from StructuredViewers
- *
- * @param treeViewer
- * @return
- */
- public TransferDragSourceListener[] getTransferDragSourceListeners(TreeViewer treeViewer) {
- return new TransferDragSourceListener[0];
- }
-
- /**
- * Adopted since you can't easily removeDropSupport from StructuredViewers
- *
- * @param treeViewer
- * @return
- */
- public TransferDropTargetListener[] getTransferDropTargetListeners(TreeViewer treeViewer) {
- return new TransferDropTargetListener[0];
- }
-
- /**
- * Should node selection changes affect selection in the TreeViewer?
- *
- * @return
- */
- public boolean isLinkedWithEditor(TreeViewer treeViewer) {
- return false;
- }
-
- /**
- * @param declaringID
- * The declaringID to set.
- */
- public void setDeclaringID(String declaringID) {
- fDeclaringID = declaringID;
- }
-
- /**
- * General hook for resource releasing and listener removal when
- * configurations change or the viewer is disposed of
- *
- * @param viewer
- */
- public void unconfigure(TreeViewer viewer) {
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapter.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapter.java
deleted file mode 100644
index 1ce7cfd8be..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-
-
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.INodeAdapter;
-
-public interface IJFaceNodeAdapter extends INodeAdapter {
-
- public Object[] getChildren(Object node);
-
- /**
- * Returns an enumeration with the elements belonging to the
- * passed element. These are the top level items in a list, tree,
- * table, etc...
- */
- public Object[] getElements(Object node);
-
- /**
- * Fetches the label image specific to this object instance.
- */
- public Image getLabelImage(Object node);
-
- /**
- * Fetches the label text specific to this object instance.
- */
- public String getLabelText(Object node);
-
- public Object getParent(Object node);
-
- public boolean hasChildren(Object node);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapterFactory.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapterFactory.java
deleted file mode 100644
index da9d791316..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/IJFaceNodeAdapterFactory.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-import java.util.Collection;
-
-public interface IJFaceNodeAdapterFactory {
- public void addListener(Object listener);
-
- /**
- * returns "copy" so no one can modify our list.
- * Its is a shallow copy.
- */
- public Collection getListeners();
-
- public void removeListener(Object listener);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateAction.java
deleted file mode 100644
index dbefea604f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateAction.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.ui.texteditor.IUpdate;
-
-/**
- * An IAction.AS_CHECK_BOX action that sets and gets its checked state along with
- * a value from a preference store. Should be used with
- * PropertyChangeUpdateActionContributionItem to listen to changes in the store.
- */
-public class PropertyChangeUpdateAction extends Action implements IUpdate {
- private String fPreferenceKey;
- private IPreferenceStore fStore;
- private boolean fUpdateFromPropertyChange = true;
-
- public PropertyChangeUpdateAction(String text, IPreferenceStore store, String preferenceKey, boolean defaultValue) {
- super(text, IAction.AS_CHECK_BOX);
- fPreferenceKey = preferenceKey;
- fStore = store;
- fStore.setDefault(getPreferenceKey(), defaultValue);
- setChecked(getPreferenceStore().getBoolean(getPreferenceKey()));
- }
-
- /**
- * @return Returns the orderPreferenceKey.
- */
- public String getPreferenceKey() {
- return fPreferenceKey;
- }
-
- /**
- * @return Returns the store.
- */
- public IPreferenceStore getPreferenceStore() {
- return fStore;
- }
-
- /**
- * @return Returns the updateFromPropertyChange.
- */
- public boolean isUpdateFromPropertyChange() {
- return fUpdateFromPropertyChange;
- }
-
- public final void run() {
- super.run();
- fStore.setValue(getPreferenceKey(), isChecked());
- if (!isUpdateFromPropertyChange())
- update();
- }
-
- /**
- * @param updateFromPropertyChange The updateFromPropertyChange to set.
- */
- public void setUpdateFromPropertyChange(boolean updateFromPropertyChange) {
- fUpdateFromPropertyChange = updateFromPropertyChange;
- }
-
- public void update() {
- setChecked(fStore.getBoolean(getPreferenceKey()));
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateActionContributionItem.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateActionContributionItem.java
deleted file mode 100644
index c87c1fc28b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/PropertyChangeUpdateActionContributionItem.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.ui.texteditor.IUpdate;
-
-/**
- * A listerner
- */
-public class PropertyChangeUpdateActionContributionItem extends ActionContributionItem {
-
- private class PreferenceUpdateListener implements IPropertyChangeListener {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(fProperty)) {
- ((IUpdate) getAction()).update();
- }
- }
- }
-
- private IPropertyChangeListener fListener = null;
-
- protected String fProperty = null;
- private IPreferenceStore fStore;
-
- public PropertyChangeUpdateActionContributionItem(PropertyChangeUpdateAction action) {
- super(action);
- fProperty = action.getPreferenceKey();
- fStore = action.getPreferenceStore();
- fListener = new PreferenceUpdateListener();
- connect();
- }
-
- public void connect() {
- fStore.addPropertyChangeListener(fListener);
- }
-
- public void disconnect() {
- if (fStore != null)
- fStore.removePropertyChangeListener(fListener);
- }
-
- public void dispose() {
- super.dispose();
- disconnect();
- fProperty = null;
- fStore = null;
- }
-
- public String toString() {
- if (getAction().getId() != null)
- return super.toString();
- else
- return getClass().getName() + "(text=" + getAction().getText() + ")"; //$NON-NLS-1$ //$NON-NLS-2$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/SourceEditorTreeViewer.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/SourceEditorTreeViewer.java
deleted file mode 100644
index 9ff65b3daa..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/SourceEditorTreeViewer.java
+++ /dev/null
@@ -1,238 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Item;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.swt.widgets.Widget;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.StructuredTextSelectionChangedEvent;
-
-
-public class SourceEditorTreeViewer extends TreeViewer {
- private int fCaretPosition;
- private ISelectionListener[] fInvalidSelectionListeners = null;
-
- /**
- * SourceEditorTreeViewer constructor comment.
- *
- * @param parent
- * org.eclipse.swt.widgets.Composite
- */
- public SourceEditorTreeViewer(Composite parent) {
- super(parent);
- }
-
- /**
- * SourceEditorTreeViewer constructor comment.
- *
- * @param tree
- * org.eclipse.swt.widgets.Tree
- */
- public SourceEditorTreeViewer(Tree tree) {
- super(tree);
- }
-
- protected void handleSelect(SelectionEvent event) {
- // handle case where an earlier selection listener disposed the
- // control.
- Control control = getControl();
- if (control != null && !control.isDisposed()) {
- updateStructuredTextSelection(getSelection());
- }
- }
-
- /*
- * (non-Javadoc) Method declared on StructuredViewer.
- */
- public void internalRefresh(Object element) {
- // If the input object is null just return.
- if (element == null)
- return;
-
- // The following skip refresh logic tries to optimize performance of
- // the content outliner.
- // However, when there is a structure change to the model, even if the
- // selection is the same
- // we should refresh the tree in case the structure change is in the
- // children of the current selection.
- // The following logic commented out for 178731.
- //
- // Skip refresh if new selection equals old selection.
- //org.eclipse.jface.viewers.ISelection selection = getSelection();
- //if (selection instanceof
- // org.eclipse.jface.viewers.IStructuredSelection)
- // if (((org.eclipse.jface.viewers.IStructuredSelection)
- // selection).size() == 1)
- // if (((org.eclipse.jface.viewers.IStructuredSelection)
- // selection).getFirstElement().equals(element))
- // return;
-
- Widget item = findItem(element);
- if (item != null) {
- // pick up structure changes too
- internalRefresh(item, element, true);
- }
- }
-
- /**
- * Refreshes the tree starting at the given widget.
- *
- * @param widget
- * the widget
- * @param element
- * the element
- * @param doStruct
- * <code>true</code> if structural changes are to be picked
- * up, and <code>false</code> if only label provider changes
- * are of interest
- */
- private void internalRefresh(Widget widget, Object element, boolean doStruct) {
- // To avoid flashing, set repaint off while updating the tree.
- getControl().setRedraw(false);
-
- if (widget instanceof Item) {
- if (doStruct) {
- updatePlus((Item) widget, element);
- }
- updateItem(widget, element);
- }
-
- if (doStruct) {
- Object[] children = getSortedChildren(element);
- updateChildren(widget, element, children);
- }
- // recurse
- Item[] children = getChildren(widget);
- if (children != null) {
- for (int i = 0; i < children.length; i++) {
- Widget item = children[i];
- Object data = item.getData();
- if (data != null)
- internalRefresh(item, data, doStruct);
- }
- }
-
- // The purpose of the following line of code was to minimize the
- // number of items in the tree needed to be repainted.
- // Expanding/collapsing the tree for the user is a little confusing.
- // Also, with new improvements to cut down unnesessary
- // notifications to the tree, this may not be needed.
- //expandToLevel(element, 1);
-
- getControl().setRedraw(true);
- }
-
- /**
- * Runs the given updateCode while selection changed notification is
- * turned off. This ensures that no selection changes are fired as a side
- * effect of updating the SWT control.
- */
-
- /*
- * protected void preservingSelection(Runnable updateCode) { // This
- * method is overridden to get rid of the selection handling // that the
- * super classes do after the update. We have added our own // selection
- * handling in here. IStructuredModel model = (IStructuredModel)
- * getInput(); IndexedRegion node = null;
- *
- * if (model != null) node = model.getIndexedRegion(fCaretPosition);
- *
- * updateCode.run();
- *
- * if (model != null) if (node == null) setSelection(new
- * StructuredSelection()); else setSelection(new
- * StructuredSelection(node)); }
- */
- public void setCaretPosition(int caretPosition) {
- fCaretPosition = caretPosition;
- }
-
- public void setSelection(ISelection selection, boolean reveal) {
- if (reveal)
- updateStructuredTextSelection(selection);
-
- super.setSelection(selection, reveal);
- }
-
- protected void updateStructuredTextSelection(ISelection selection) {
- SelectionChangedEvent event = new StructuredTextSelectionChangedEvent(this, selection);
- fireSelectionChanged(event);
- }
-
- protected void handleInvalidSelection(ISelection invalidSelection, ISelection newSelection) {
- IStructuredModel model = (IStructuredModel) getInput();
- Object selectedNode = model.getIndexedRegion(fCaretPosition);
- if (selectedNode != null)
- newSelection = new StructuredSelection(selectedNode);
- // notify listeners that the TreeViewer has received an invalid
- // selection
- fireInvalidSelection(newSelection);
- super.handleInvalidSelection(invalidSelection, newSelection);
- }
-
- public synchronized void addInvalidSelectionListener(ISelectionListener listener) {
- ISelectionListener[] newListeners = fInvalidSelectionListeners;
- if (fInvalidSelectionListeners != null && fInvalidSelectionListeners.length > 0) {
- List oldListeners = new ArrayList(Arrays.asList(fInvalidSelectionListeners));
- if (!oldListeners.contains(listener)) {
- oldListeners.add(listener);
- newListeners = (ISelectionListener[]) oldListeners.toArray(new ISelectionListener[0]);
- }
- }
- else {
- newListeners = new ISelectionListener[]{listener};
- }
- fInvalidSelectionListeners = newListeners;
- }
-
- /**
- * @param newSelection
- */
- private void fireInvalidSelection(ISelection newSelection) {
- if (fInvalidSelectionListeners != null) {
- ISelectionListener[] listeners = fInvalidSelectionListeners;
- for (int i = 0; i < listeners.length; i++) {
- listeners[i].selectionChanged(null, newSelection);
- }
- }
- }
-
- public synchronized void removeInvalidSelectionListener(ISelectionListener listener) {
- ISelectionListener[] newListeners = fInvalidSelectionListeners;
- if (fInvalidSelectionListeners != null && fInvalidSelectionListeners.length > 1) {
- List oldListeners = new ArrayList(Arrays.asList(fInvalidSelectionListeners));
- if (oldListeners.contains(listener)) {
- oldListeners.remove(listener);
- newListeners = (ISelectionListener[]) oldListeners.toArray(new ISelectionListener[0]);
- }
- }
- // there was only 1, remove the entire array
- else {
- newListeners = null;
- }
- fInvalidSelectionListeners = newListeners;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredContentOutlineConfiguration.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredContentOutlineConfiguration.java
deleted file mode 100644
index 760a4766a3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredContentOutlineConfiguration.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.ActionContributionItem;
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.IDoubleClickListener;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.ui.EditorPlugin;
-import org.eclipse.wst.sse.ui.Logger;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.preferences.PreferenceKeyGenerator;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-
-
-public class StructuredContentOutlineConfiguration extends ContentOutlineConfiguration {
- /**
- * Structured source files tend to have large/long tree structures. Add a collapse
- * action to help with navigation.
- */
- protected class CollapseTreeAction extends Action {
- private TreeViewer fTreeViewer = null;
-
- public CollapseTreeAction(TreeViewer viewer) {
- super(ResourceHandler.getString("StructuredContentOutlineConfiguration.0"), AS_PUSH_BUTTON); //$NON-NLS-1$
- setImageDescriptor(COLLAPSE_E);
- setDisabledImageDescriptor(COLLAPSE_D);
- setToolTipText(getText());
- fTreeViewer = viewer;
- }
-
- public void run() {
- super.run();
- fTreeViewer.collapseAll();
- }
- }
-
- protected class ToggleLinkAction extends PropertyChangeUpdateAction {
-
- public ToggleLinkAction(IPreferenceStore store, String preference) {
- super(ResourceHandler.getString("StructuredContentOutlineConfiguration.1"), store, preference, true); //$NON-NLS-1$
- setToolTipText(getText());
- setDisabledImageDescriptor(SYNCED_D);
- setImageDescriptor(SYNCED_E);
- update();
- }
-
- public void update() {
- setLinkWithEditor(isChecked());
- }
- }
-
- private StructuredTextEditor fEditor = null;
-
- private boolean fIsLinkWithEditor = false;
- private Map fMenuContributions = null;
-
- private Map fToolbarContributions = null;
-
- private final String OUTLINE_LINK_PREF = "outline-link-editor"; //$NON-NLS-1$
-
- protected ImageDescriptor SYNCED_D = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_DLCL_SYNCED);
- protected ImageDescriptor SYNCED_E = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_ELCL_SYNCED);
-
- protected ImageDescriptor COLLAPSE_D = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_DLCL_COLLAPSEALL);
- protected ImageDescriptor COLLAPSE_E = EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_ELCL_COLLAPSEALL);
-
- public StructuredContentOutlineConfiguration() {
- super();
- }
-
- /**
- * @param viewer
- * @return
- */
- protected IContributionItem[] createMenuContributions(TreeViewer viewer) {
- IContributionItem[] items;
- IContributionItem toggleLinkItem = new PropertyChangeUpdateActionContributionItem(new ToggleLinkAction(EditorPlugin.getInstance().getPreferenceStore(), getLinkPreferenceKey()));
- items = super.getToolbarContributions(viewer);
- if (items == null) {
- items = new IContributionItem[]{toggleLinkItem};
- }
- else {
- IContributionItem[] combinedItems = new IContributionItem[items.length + 1];
- System.arraycopy(items, 0, combinedItems, 0, items.length);
- combinedItems[items.length] = toggleLinkItem;
- items = combinedItems;
- }
- return items;
- }
-
- protected IContributionItem[] createToolbarContributions(TreeViewer viewer) {
- IContributionItem[] items;
- IContributionItem collapseAllItem = new ActionContributionItem(new CollapseTreeAction(viewer));
- items = super.getToolbarContributions(viewer);
- if (items == null) {
- items = new IContributionItem[]{collapseAllItem};
- }
- else {
- IContributionItem[] combinedItems = new IContributionItem[items.length + 1];
- System.arraycopy(items, 0, combinedItems, 0, items.length);
- combinedItems[items.length] = collapseAllItem;
- // combinedItems[items.length + 1] = toggleLinkItem;
- items = combinedItems;
- }
- return items;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getDoubleClickListener(org.eclipse.jface.viewers.TreeViewer)
- */
- public IDoubleClickListener getDoubleClickListener(TreeViewer viewer) {
- return getEditor().getViewerSelectionManager();
- }
-
- /**
- * @return
- */
- public StructuredTextEditor getEditor() {
- return fEditor;
- }
-
- protected IJFaceNodeAdapterFactory getFactory() {
- IFactoryRegistry factoryRegistry = getEditor().getModel().getFactoryRegistry();
- IJFaceNodeAdapterFactory adapterFactory = (IJFaceNodeAdapterFactory) factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
- if (adapterFactory == null) {
- Logger.log(Logger.ERROR, "model has no JFace adapter factory"); //$NON-NLS-1$
- }
- return adapterFactory;
- }
-
- protected String getLinkPreferenceKey() {
- return PreferenceKeyGenerator.generateKey(OUTLINE_LINK_PREF, getDeclaringID());
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public final IContributionItem[] getMenuContributions(TreeViewer viewer) {
- if (fMenuContributions == null) {
- fMenuContributions = new HashMap();
- }
-
- IContributionItem[] items = (IContributionItem[]) fMenuContributions.get(viewer);
- if (items == null) {
- items = createMenuContributions(viewer);
- fMenuContributions.put(viewer, items);
- }
- return items;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public List getSelectedNodes(NodeSelectionChangedEvent event) {
- if (isLinkedWithEditor())
- return super.getSelectedNodes(event);
- else
- return null;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getSelectionChangedListener(org.eclipse.jface.viewers.TreeViewer)
- */
- public ISelectionChangedListener getSelectionChangedListener(TreeViewer viewer) {
- return getEditor().getViewerSelectionManager();
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public final IContributionItem[] getToolbarContributions(TreeViewer viewer) {
- if (fToolbarContributions == null) {
- fToolbarContributions = new HashMap();
- }
-
- IContributionItem[] items = (IContributionItem[]) fToolbarContributions.get(viewer);
- if (items == null) {
- items = createToolbarContributions(viewer);
- fToolbarContributions.put(viewer, items);
- }
- return items;
- }
-
- protected boolean isLinkedWithEditor() {
- return fIsLinkWithEditor;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean isLinkedWithEditor(TreeViewer treeViewer) {
- return isLinkedWithEditor();
- }
-
- /**
- * @param editor
- */
- public void setEditor(StructuredTextEditor editor) {
- fEditor = editor;
- }
-
- /**
- * @param isLinkWithEditor
- * The isLinkWithEditor to set.
- */
- protected void setLinkWithEditor(boolean isLinkWithEditor) {
- fIsLinkWithEditor = isLinkWithEditor;
- }
-
- public void unconfigure(TreeViewer viewer) {
- super.unconfigure(viewer);
- IContributionItem[] items = (IContributionItem[]) fToolbarContributions.get(viewer);
- if (items != null) {
- for (int i = 0; i < items.length; i++) {
- if (items[i] instanceof PropertyChangeUpdateActionContributionItem) {
- ((PropertyChangeUpdateActionContributionItem) items[i]).disconnect();
- }
- }
- fToolbarContributions.remove(viewer);
- }
- items = (IContributionItem[]) fMenuContributions.get(viewer);
- if (items != null) {
- for (int i = 0; i < items.length; i++) {
- if (items[i] instanceof PropertyChangeUpdateActionContributionItem) {
- ((PropertyChangeUpdateActionContributionItem) items[i]).disconnect();
- }
- }
- fMenuContributions.remove(viewer);
- }
- fLabelProvider = null;
- fContentProvider = null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredTextEditorContentOutlinePage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredTextEditorContentOutlinePage.java
deleted file mode 100644
index 2cbe867ea8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/contentoutline/StructuredTextEditorContentOutlinePage.java
+++ /dev/null
@@ -1,455 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.contentoutline;
-
-import java.util.List;
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.action.IContributionManager;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.jface.util.DelegatingDragAdapter;
-import org.eclipse.jface.util.DelegatingDropAdapter;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSource;
-import org.eclipse.swt.dnd.DropTarget;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.events.KeyListener;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Menu;
-import org.eclipse.swt.widgets.Tree;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.ISelectionListener;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.texteditor.IUpdate;
-import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.IModelStateListener;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.ViewerSelectionManager;
-import org.eclipse.wst.sse.ui.ui.ActiveEditorActionHandler;
-import org.eclipse.wst.sse.ui.view.events.INodeSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.ITextSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-import org.eclipse.wst.sse.ui.view.events.TextSelectionChangedEvent;
-
-
-public class StructuredTextEditorContentOutlinePage extends ContentOutlinePage implements INodeSelectionListener, ITextSelectionListener, IUpdate {
- // Disables Tree redraw during large model changes
- protected class ControlRedrawEnabler implements IModelStateListener {
- public void modelAboutToBeChanged(IStructuredModel model) {
- Control control = getControl();
- if ((control != null) && (!control.isDisposed()))
- control.setRedraw(false);
- }
-
- public void modelChanged(IStructuredModel model) {
- Control control = getControl();
- if ((control != null) && (!control.isDisposed()))
- control.setRedraw(true);
- }
-
- public void modelDirtyStateChanged(IStructuredModel model, boolean isDirty) {
- // do nothing
- }
-
- public void modelResourceDeleted(IStructuredModel model) {
- // do nothing
- }
-
- public void modelResourceMoved(IStructuredModel originalmodel, IStructuredModel movedmodel) {
- // do nothing
- }
- }
-
- protected static ContentOutlineConfiguration NULL_CONFIGURATION = new ContentOutlineConfiguration();
- private TransferDragSourceListener[] fActiveDragListeners;
- private TransferDropTargetListener[] fActiveDropListeners;
- private ContentOutlineConfiguration fConfiguration;
-
- private MenuManager fContextMenuManager;
- private DelegatingDragAdapter fDragAdapter;
- private DragSource fDragSource;
- private DelegatingDropAdapter fDropAdapter;
- private DropTarget fDropTarget;
- protected IStructuredModel fModel;
- // current selection, maintained so selection doesn't bounce back from the
- // Tree
- ISelection fSelection;
- protected SourceEditorTreeViewer fTreeViewer;
- protected ViewerSelectionManager fViewerSelectionManager;
- private IModelStateListener fInternalModelStateListener;
-
- public StructuredTextEditorContentOutlinePage() {
- super();
- fInternalModelStateListener = new ControlRedrawEnabler();
- fSelection = StructuredSelection.EMPTY;
- }
-
- /**
- * @see ContentOutlinePage#createControl
- */
- public void createControl(Composite parent) {
- fTreeViewer = new SourceEditorTreeViewer(new Tree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL));
- // create the context menu
- fContextMenuManager = new MenuManager("#popup"); //$NON-NLS-1$
- fContextMenuManager.setRemoveAllWhenShown(true);
- Menu menu = fContextMenuManager.createContextMenu(fTreeViewer.getControl());
- fTreeViewer.getControl().setMenu(menu);
- fDragAdapter = new DelegatingDragAdapter();
- fDragSource = new DragSource(fTreeViewer.getControl(), DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK);
- fDropAdapter = new DelegatingDropAdapter();
- fDropTarget = new DropTarget(fTreeViewer.getControl(), DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK);
- setConfiguration(getConfiguration());
- fTreeViewer.setInput(getModel());
- IJFaceNodeAdapterFactory adapterFactory = getViewerRefreshFactory();
- if (adapterFactory != null) {
- adapterFactory.addListener(fTreeViewer);
- }
- // update local selection on invalid selection to prevent bounces
- fTreeViewer.addInvalidSelectionListener(new ISelectionListener() {
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- fSelection = selection;
- }
- });
- fTreeViewer.addPostSelectionChangedListener(this);
- }
-
- public void dispose() {
- super.dispose();
- // remove this text viewer from the old model's list of model state
- // listeners
- if (fModel != null)
- fModel.removeModelStateListener(fInternalModelStateListener);
- // disconnect from the ViewerSelectionManager
- if (fViewerSelectionManager != null) {
- fViewerSelectionManager.removeNodeSelectionListener(this);
- }
- IJFaceNodeAdapterFactory adapterFactory = getViewerRefreshFactory();
- if (adapterFactory != null) {
- adapterFactory.removeListener(fTreeViewer);
- }
- setConfiguration(NULL_CONFIGURATION);
- }
-
- /**
- * @return
- */
- public ContentOutlineConfiguration getConfiguration() {
- if (fConfiguration == null)
- return NULL_CONFIGURATION;
- return fConfiguration;
- }
-
- public Control getControl() {
- if (getTreeViewer() == null)
- return null;
- return getTreeViewer().getControl();
- }
-
- /**
- */
- protected IStructuredModel getModel() {
- return fModel;
- }
-
- protected List getSelectedNodes(NodeSelectionChangedEvent event) {
- return getConfiguration().getSelectedNodes(event);
- }
-
- public ISelection getSelection() {
- if (getTreeViewer() == null)
- return StructuredSelection.EMPTY;
- return getTreeViewer().getSelection();
- }
-
- /**
- * Returns this page's tree viewer.
- *
- * @return this page's tree viewer, or <code>null</code> if
- * <code>createControl</code> has not been called yet
- */
- protected TreeViewer getTreeViewer() {
- return fTreeViewer;
- }
-
- protected IJFaceNodeAdapterFactory getViewerRefreshFactory() {
- if (getModel() == null)
- return null;
- IFactoryRegistry factoryRegistry = getModel().getFactoryRegistry();
- IJFaceNodeAdapterFactory adapterFactory = (IJFaceNodeAdapterFactory) factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
- return adapterFactory;
- }
-
- /**
- * Returns this page's viewer selection manager.
- *
- * @return this page's viewer selection manager, or <code>null</code> if
- * <code>setViewerSelectionManager</code> has not been called
- * yet
- */
- public ViewerSelectionManager getViewerSelectionManager() {
- return fViewerSelectionManager;
- }
-
- public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
- if (getTreeViewer() != null && getConfiguration().isLinkedWithEditor(getTreeViewer())) {
- List selectedNodes = getSelectedNodes(event);
- if (selectedNodes != null) {
- StructuredSelection selection = new StructuredSelection(selectedNodes);
- setSelection(selection);
- int caretPosition = event.getCaretPosition();
- ((SourceEditorTreeViewer) getTreeViewer()).setCaretPosition(caretPosition);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.views.contentoutline.ContentOutlinePage#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
- */
- public void selectionChanged(SelectionChangedEvent event) {
- if (!fSelection.equals(event.getSelection())) {
- super.selectionChanged(event);
- }
- }
-
- public void setActionBars(IActionBars actionBars) {
- super.setActionBars(actionBars);
- getSite().getActionBars().setGlobalActionHandler(ActionFactory.UNDO.getId(), new ActiveEditorActionHandler(getSite(), ActionFactory.UNDO.getId()));
- getSite().getActionBars().setGlobalActionHandler(ActionFactory.REDO.getId(), new ActiveEditorActionHandler(getSite(), ActionFactory.REDO.getId()));
- }
-
- /**
- * @param configuration
- */
- public void setConfiguration(ContentOutlineConfiguration configuration) {
- // intentionally do not check to see if the new configuration != old
- // configuration
- if (fTreeViewer != null) {
- // remove the key listeners
- if (fTreeViewer.getControl() != null && !fTreeViewer.getControl().isDisposed()) {
- KeyListener[] listeners = getConfiguration().getKeyListeners(fTreeViewer);
- for (int i = 0; i < listeners.length; i++) {
- fTreeViewer.getControl().removeKeyListener(listeners[i]);
- }
- }
- // remove any menu listeners
- if (fContextMenuManager != null) {
- IMenuListener listener = getConfiguration().getMenuListener(fTreeViewer);
- if (listener != null)
- fContextMenuManager.removeMenuListener(listener);
- }
- // clear the selection changed and double click listeners from the
- // configuration
- if (getConfiguration().getSelectionChangedListener(fTreeViewer) != null)
- removeSelectionChangedListener(getConfiguration().getSelectionChangedListener(fTreeViewer));
- if (getConfiguration().getDoubleClickListener(fTreeViewer) != null)
- fTreeViewer.removeDoubleClickListener(getConfiguration().getDoubleClickListener(fTreeViewer));
- IContributionItem[] toolbarItems = getConfiguration().getToolbarContributions(fTreeViewer);
- if (toolbarItems.length > 0 && getSite() != null && getSite().getActionBars() != null && getSite().getActionBars().getToolBarManager() != null) {
- IContributionManager toolbar = getSite().getActionBars().getToolBarManager();
- for (int i = 0; i < toolbarItems.length; i++) {
- toolbar.remove(toolbarItems[i]);
- }
- toolbar.update(false);
- }
- IContributionItem[] menuItems = getConfiguration().getMenuContributions(fTreeViewer);
- if (menuItems.length > 0 && getSite().getActionBars().getMenuManager() != null) {
- IContributionManager menubar = getSite().getActionBars().getMenuManager();
- for (int i = 0; i < menuItems.length; i++) {
- menubar.remove(menuItems[i]);
- }
- menubar.update(false);
- }
- // clear the DnD listeners and transfer types
- if (fDragAdapter != null && !fDragAdapter.isEmpty() && !fDragSource.isDisposed() && fDragSource.getTransfer().length > 0) {
- if (fActiveDragListeners != null) {
- for (int i = 0; i < fActiveDragListeners.length; i++) {
- fDragAdapter.removeDragSourceListener(fActiveDragListeners[i]);
- }
- }
- fActiveDragListeners = null;
- fDragSource.removeDragListener(fDragAdapter);
- fDragSource.setTransfer(new Transfer[0]);
- }
- if (fDropAdapter != null && !fDropAdapter.isEmpty() && !fDropTarget.isDisposed() && fDropTarget.getTransfer().length > 0) {
- if (fActiveDropListeners != null) {
- for (int i = 0; i < fActiveDropListeners.length; i++) {
- fDropAdapter.removeDropTargetListener(fActiveDropListeners[i]);
- }
- }
- fActiveDropListeners = null;
- fDropTarget.removeDropListener(fDropAdapter);
- fDropTarget.setTransfer(new Transfer[0]);
- }
- // release any ties to this tree viewer
- getConfiguration().unconfigure(fTreeViewer);
- }
-
- fConfiguration = configuration;
- if (fConfiguration == null)
- fConfiguration = NULL_CONFIGURATION;
- fSelection = StructuredSelection.EMPTY;
-
- if (fTreeViewer != null && fTreeViewer.getControl() != null && !fTreeViewer.getControl().isDisposed()) {
- // add a menu listener if one is provided
- IMenuListener listener = getConfiguration().getMenuListener(fTreeViewer);
- if (listener != null)
- fContextMenuManager.addMenuListener(listener);
- // (re)set the providers
- fTreeViewer.setLabelProvider(getConfiguration().getLabelProvider(fTreeViewer));
- fTreeViewer.setContentProvider(getConfiguration().getContentProvider(fTreeViewer));
- if (getConfiguration().getSelectionChangedListener(fTreeViewer) != null)
- addSelectionChangedListener(getConfiguration().getSelectionChangedListener(fTreeViewer));
- if (getConfiguration().getDoubleClickListener(fTreeViewer) != null)
- fTreeViewer.addDoubleClickListener(getConfiguration().getDoubleClickListener(fTreeViewer));
- IContributionItem[] toolbarItems = getConfiguration().getToolbarContributions(fTreeViewer);
- if (toolbarItems.length > 0 && getSite() != null && getSite().getActionBars() != null && getSite().getActionBars().getToolBarManager() != null) {
- IContributionManager toolbar = getSite().getActionBars().getToolBarManager();
- for (int i = 0; i < toolbarItems.length; i++) {
- toolbar.add(toolbarItems[i]);
- }
- toolbar.update(true);
- }
- IContributionItem[] menuItems = getConfiguration().getMenuContributions(fTreeViewer);
- if (menuItems.length > 0 && getSite().getActionBars().getMenuManager() != null) {
- IContributionManager menu = getSite().getActionBars().getMenuManager();
- for (int i = 0; i < menuItems.length; i++) {
- menuItems[i].setVisible(true);
- menu.add(menuItems[i]);
- menuItems[i].update();
- }
- menu.update(true);
- }
- // add the allowed DnD listeners and types
- TransferDragSourceListener[] dragListeners = fConfiguration.getTransferDragSourceListeners(fTreeViewer);
- if (fDragAdapter != null && dragListeners.length > 0) {
- for (int i = 0; i < dragListeners.length; i++) {
- fDragAdapter.addDragSourceListener(dragListeners[i]);
- }
- fActiveDragListeners = dragListeners;
- fDragSource.addDragListener(fDragAdapter);
- fDragSource.setTransfer(fDragAdapter.getTransfers());
- }
- TransferDropTargetListener[] dropListeners = fConfiguration.getTransferDropTargetListeners(fTreeViewer);
- if (fDropAdapter != null && dropListeners.length > 0) {
- for (int i = 0; i < dropListeners.length; i++) {
- fDropAdapter.addDropTargetListener(dropListeners[i]);
- }
- fActiveDropListeners = dropListeners;
- fDropTarget.addDropListener(fDropAdapter);
- fDropTarget.setTransfer(fDropAdapter.getTransfers());
- }
- // add the key listeners
- KeyListener[] listeners = getConfiguration().getKeyListeners(fTreeViewer);
- for (int i = 0; i < listeners.length; i++) {
- fTreeViewer.getControl().addKeyListener(listeners[i]);
- }
- }
- }
-
- /**
- * Sets focus to a part in the page.
- */
- public void setFocus() {
- getTreeViewer().getControl().setFocus();
- }
-
- /**
- * Sets the input of the outline page
- */
- public void setModel(IStructuredModel newModel) {
- if (newModel != fModel) {
- if (fModel != null)
- fModel.removeModelStateListener(fInternalModelStateListener);
- fModel = newModel;
- if (getTreeViewer() != null && getControl() != null && !getControl().isDisposed()) {
- setConfiguration(getConfiguration());
- fTreeViewer.setInput(fModel);
- update();
- }
- fModel.addModelStateListener(fInternalModelStateListener);
- }
- }
-
- public void setSelection(ISelection selection) {
- if (getTreeViewer() != null && selection instanceof IStructuredSelection) {
- /**
- * Selection sent to the Tree widget comes back as a
- * selectionChanged event. To avoid bouncing an externally set
- * selection back to our listeners, track the last selection that
- * originated elsewhere so we can skip sending it back out. If
- * selection came from the Tree widget (by user interaction), it
- * will be different.
- */
- if (!fSelection.equals(selection)) {
- if (selection == null || ((IStructuredSelection) selection).getFirstElement() == null) {
- fSelection = StructuredSelection.EMPTY;
- }
- else {
- fSelection = selection;
- }
- getTreeViewer().setSelection(fSelection, getConfiguration().isLinkedWithEditor(getTreeViewer()));
- }
- }
- }
-
- public void setViewerSelectionManager(ViewerSelectionManager viewerSelectionManager) {
- // disconnect from old one
- if (fViewerSelectionManager != null) {
- fViewerSelectionManager.removeNodeSelectionListener(this);
- fViewerSelectionManager.removeTextSelectionListener(this);
- }
- fViewerSelectionManager = viewerSelectionManager;
- // connect to new one
- if (fViewerSelectionManager != null) {
- fViewerSelectionManager.addNodeSelectionListener(this);
- fViewerSelectionManager.addTextSelectionListener(this);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void textSelectionChanged(TextSelectionChangedEvent event) {
- if (getConfiguration().isLinkedWithEditor(getTreeViewer())) {
- int caretPosition = event.getTextSelectionStart();
- ((SourceEditorTreeViewer) getTreeViewer()).setCaretPosition(caretPosition);
- }
- }
-
- /**
- * redraws the tree
- */
- public void update() {
- if (getTreeViewer() != null) {
- Control control = getTreeViewer().getControl();
- control.setRedraw(false);
- getTreeViewer().refresh();
- control.setRedraw(true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySheetEntryLabelProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySheetEntryLabelProvider.java
deleted file mode 100644
index 86b8f24254..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySheetEntryLabelProvider.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-
-
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.views.properties.IPropertySheetEntry;
-import org.eclipse.wst.sse.core.INodeNotifier;
-
-public class AdapterPropertySheetEntryLabelProvider extends LabelProvider {
- public Image getImage(Object element) {
- if (element == null)
- return null;
- if (element instanceof IPropertySheetEntry) {
- return ((IPropertySheetEntry) element).getImage();
- }
- if (element instanceof INodeNotifier) {
- IPropertySheetEntry entry = (IPropertySheetEntry) ((INodeNotifier) element).getAdapterFor(IPropertySheetEntry.class);
- if (entry != null)
- return entry.getImage();
- }
- return super.getImage(element);
- }
-
- public String getText(Object element) {
- if (element == null)
- return null;
- if (element instanceof IPropertySheetEntry) {
- return ((IPropertySheetEntry) element).getValueAsString();
- }
- if (element instanceof INodeNotifier) {
- IPropertySheetEntry entry = (IPropertySheetEntry) ((INodeNotifier) element).getAdapterFor(IPropertySheetEntry.class);
- if (entry != null)
- return entry.getValueAsString();
- }
- return super.getText(element);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySourceProvider.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySourceProvider.java
deleted file mode 100644
index 044ff8206f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/AdapterPropertySourceProvider.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-
-
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.wst.sse.core.INodeNotifier;
-
-public class AdapterPropertySourceProvider implements IPropertySourceProvider {
-
- public AdapterPropertySourceProvider() {
- super();
- }
-
- public IPropertySource getPropertySource(Object object) {
- if (object instanceof INodeNotifier) {
- return (IPropertySource) ((INodeNotifier) object).getAdapterFor(IPropertySource.class);
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ConfigurablePropertySheetPage.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ConfigurablePropertySheetPage.java
deleted file mode 100644
index c6cfd3848b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ConfigurablePropertySheetPage.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.custom.TableTree;
-import org.eclipse.swt.custom.TableTreeItem;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.ui.views.properties.IPropertySheetEntry;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.ui.ViewerSelectionManager;
-import org.eclipse.wst.sse.ui.ui.ActiveEditorActionHandler;
-import org.eclipse.wst.sse.ui.view.events.INodeSelectionListener;
-import org.eclipse.wst.sse.ui.view.events.NodeSelectionChangedEvent;
-import org.eclipse.wst.sse.ui.views.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.views.contentoutline.IJFaceNodeAdapterFactory;
-
-
-/**
- * A configurable IPropertySheetPage since the standard PropertySheetPage does
- * not expose its viewer field.
- */
-
-public class ConfigurablePropertySheetPage extends PropertySheetPage implements INodeSelectionListener {
-
- private PropertySheetConfiguration fConfiguration;
- // has the widget been created?
- private boolean fIsRealized = false;
- private IMenuManager fMenuManager;
-
- protected PageBook fParentPageBook = null;
- // are we refreshing the contents?
- protected boolean fRefreshing = false;
-
- protected RemoveAction fRemoveAction;
- private IStatusLineManager fStatusLineManager;
-
- protected IStructuredModel fStructuredModel = null;
- private IToolBarManager fToolBarManager;
-
- private ViewerSelectionManager fViewerSelectionManager;
-
- private final PropertySheetConfiguration NULL_CONFIGURATION = new PropertySheetConfiguration();
-
- public ConfigurablePropertySheetPage() {
- super();
- }
-
- public void createControl(Composite parent) {
- setPropertySourceProvider(getConfiguration().getPropertySourceProvider());
- super.createControl(parent);
- if (parent instanceof PageBook)
- fParentPageBook = (PageBook) parent;
- }
-
- public void dispose() {
- // disconnect from the ViewerSelectionManager
- if (getViewerSelectionManager() != null) {
- getViewerSelectionManager().removeNodeSelectionListener(this);
- }
- setModel(null);
- setConfiguration(null);
- super.dispose();
- }
-
- /**
- * @return
- */
- public PropertySheetConfiguration getConfiguration() {
- if (fConfiguration == null)
- fConfiguration = NULL_CONFIGURATION;
- return fConfiguration;
- }
-
- public IStructuredModel getModel() {
- return fStructuredModel;
- }
-
- protected IJFaceNodeAdapterFactory getViewerRefreshFactory() {
- if (getModel() == null)
- return null;
- IFactoryRegistry factoryRegistry = getModel().getFactoryRegistry();
- IJFaceNodeAdapterFactory adapterFactory = (IJFaceNodeAdapterFactory) factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
- return adapterFactory;
- }
-
- /**
- * @return Returns the viewerSelectionManager.
- */
- public ViewerSelectionManager getViewerSelectionManager() {
- return fViewerSelectionManager;
- }
-
- /*
- * @see PropertySheetPage#handleEntrySelection(ISelection)
- */
- public void handleEntrySelection(ISelection selection) {
- // Useful for enabling/disabling actions based on the
- // selection (or lack thereof). Also, ensure that the
- // control exists before sending selection to it.
- if (fIsRealized && selection != null) {
- super.handleEntrySelection(selection);
- fRemoveAction.setEnabled(!selection.isEmpty());
- // if (selection != null && !selection.isEmpty() && selection
- // instanceof IStructuredSelection) {
- // IPropertySheetEntry entry = (IPropertySheetEntry)
- // ((IStructuredSelection) selection).getFirstElement();
- // }
- }
- }
-
- /**
- * @return Returns the isRealized.
- */
- public boolean isRealized() {
- return fIsRealized;
- }
-
- public void makeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
- super.makeContributions(menuManager, toolBarManager, statusLineManager);
- fMenuManager = menuManager;
- fToolBarManager = toolBarManager;
- fStatusLineManager = statusLineManager;
-
- fRemoveAction = new RemoveAction(this);
- toolBarManager.add(fRemoveAction);
- menuManager.add(fRemoveAction);
- getConfiguration().addContributions(menuManager, toolBarManager, statusLineManager);
-
- menuManager.update(true);
- fIsRealized = true;
- }
-
- public void nodeSelectionChanged(NodeSelectionChangedEvent event) {
- selectionChanged(null, new StructuredSelection(event.getSelectedNodes()));
- }
-
- /**
- * @see org.eclipse.ui.views.properties.PropertySheetPage#refresh()
- */
- public void refresh() {
- /**
- * Avoid refreshing the property sheet if it is already doing so. A
- * refresh can prompt an active cell editor to close, applying the
- * value and altering the selected node. In that case, a loop could
- * occur.
- */
-
- if (!fRefreshing) {
- fRefreshing = true;
- super.refresh();
- fRefreshing = false;
- }
- else {
- // detected a loop in the property sheet (shouldn't happen)
- }
- }
-
- /**
- * TODO: implement removal
- */
- public void remove() {
- if (getControl() instanceof TableTree) {
- TableTreeItem[] items = ((TableTree) getControl()).getSelection();
- if (items != null && items.length == 1) {
- IPropertySheetEntry entry = (IPropertySheetEntry) items[0].getData();
- ISelection selection = getConfiguration().getSelection(null, new StructuredSelection(getViewerSelectionManager().getSelectedNodes()));
- if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) {
- IPropertySource source = getConfiguration().getPropertySourceProvider().getPropertySource(((IStructuredSelection) selection).getFirstElement());
- if (source != null && source instanceof IPropertySourceExtension) {
- ((IPropertySourceExtension) source).removeProperty(entry.getDisplayName());
- }
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.ISelectionListener#selectionChanged(org.eclipse.ui.IWorkbenchPart,
- * org.eclipse.jface.viewers.ISelection)
- */
- public void selectionChanged(IWorkbenchPart part, ISelection selection) {
- super.selectionChanged(part, getConfiguration().getSelection(part, selection));
- }
-
- public void setActionBars(IActionBars actionBars) {
- super.setActionBars(actionBars);
- getSite().getActionBars().setGlobalActionHandler(ActionFactory.UNDO.getId(), new ActiveEditorActionHandler(getSite(), ActionFactory.UNDO.getId()));
- getSite().getActionBars().setGlobalActionHandler(ActionFactory.REDO.getId(), new ActiveEditorActionHandler(getSite(), ActionFactory.REDO.getId()));
- }
-
- /**
- * @param configuration
- * The configuration to set.
- */
- public void setConfiguration(PropertySheetConfiguration configuration) {
- if (fConfiguration != null && isRealized()) {
- fConfiguration.removeContributions(fMenuManager, fToolBarManager, fStatusLineManager);
- fConfiguration.unconfigure();
- }
-
- fConfiguration = configuration;
-
- if (fConfiguration != null) {
- setPropertySourceProvider(fConfiguration.getPropertySourceProvider());
- if (isRealized())
- fConfiguration.addContributions(fMenuManager, fToolBarManager, fStatusLineManager);
- }
- }
-
- /**
- * Asks this page to take focus within its pagebook view.
- */
- public void setFocus() {
- super.setFocus();
- if (fParentPageBook != null)
- fParentPageBook.showPage(getControl());
- }
-
- /**
- * Sets the model.
- *
- * @param model
- * The model to set
- */
- public void setModel(IStructuredModel model) {
- if (model != fStructuredModel) {
- IJFaceNodeAdapterFactory refresher = getViewerRefreshFactory();
- if (refresher != null)
- refresher.removeListener(this);
- fStructuredModel = model;
- refresher = getViewerRefreshFactory();
- if (refresher != null)
- refresher.addListener(this);
- }
- }
-
- public void setViewerSelectionManager(ViewerSelectionManager viewerSelectionManager) {
- // disconnect from old one
- if (fViewerSelectionManager != null) {
- fViewerSelectionManager.removeNodeSelectionListener(this);
- }
-
- fViewerSelectionManager = viewerSelectionManager;
-
- // connect to new one
- if (fViewerSelectionManager != null) {
- fViewerSelectionManager.addNodeSelectionListener(this);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/CustomPropertyDescriptor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/CustomPropertyDescriptor.java
deleted file mode 100644
index 5005ebae30..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/CustomPropertyDescriptor.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-public class CustomPropertyDescriptor extends PropertyDescriptor {
-
- protected Class cellEditorClass = null;
-
- /**
- * Returns a property descriptor with a unique name and
- * a display name.
- *
- * @param id the id for the property
- * @param displayName the name to display for the property
- */
- public CustomPropertyDescriptor(Object id, String newDisplayName, Class editorClass) {
- super(id, newDisplayName);
- setDescription((String) id);
- setCellEditorClass(editorClass);
- }
-
- /**
- * Returns a property descriptor with a unique name and
- * a display name.
- *
- * @param uniqueName the unique name of the property
- * @param displayName the name to display for the property
- */
- public CustomPropertyDescriptor(String uniqueName, String newDisplayName) {
- this(uniqueName, newDisplayName, TextCellEditor.class);
- }
-
- public CellEditor createPropertyEditor(Composite parent) {
- return getPropertyEditor(parent);
- }
-
- public Class getCellEditorClass() {
- return cellEditorClass;
- }
-
- /**
- * Returns the editor used to edit the property.
- *
- * @return an editor for the property
- */
- protected CellEditor getPropertyEditor(Composite parent) {
- if (getCellEditorClass() == null)
- return null;
-
- java.lang.reflect.Constructor constructor = null;
- try {
- constructor = getCellEditorClass().getDeclaredConstructor(new Class[]{Composite.class});
- }
- catch (NoSuchMethodException nsme) {
- return new TextCellEditor(parent);
- }
- if (constructor != null) {
- try {
- return (CellEditor) constructor.newInstance(new Object[]{parent});
- }
- catch (InstantiationException ie) {
- }
- catch (java.lang.reflect.InvocationTargetException ite) {
- }
- catch (IllegalAccessException iae) {
- }
- }
- return new TextCellEditor(parent);
- }
-
- public void setCellEditorClass(Class newCellEditorClass) {
- cellEditorClass = newCellEditorClass;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/EnumeratedStringPropertyDescriptor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/EnumeratedStringPropertyDescriptor.java
deleted file mode 100644
index 82cccf3215..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/EnumeratedStringPropertyDescriptor.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-
-
-import java.util.Arrays;
-
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-/**
- * This class should be used for properties which require
- * a combo box cell editor and whose values consist of a
- * list of enumerated strings.
- */
-public class EnumeratedStringPropertyDescriptor extends PropertyDescriptor {
- protected StringComboBoxCellEditor fEditor;
- protected Composite fParent;
-
- /**
- * The enumerated possible values for the described property
- */
- protected String fValues[] = null;
-
- /**
- * Returns a property descriptor with a name.
- *
- * @param name the unique name of the property
- * @param displayName the name to display for the property
- * @param valuesArray an array of possible values
- */
- public EnumeratedStringPropertyDescriptor(Object id, String newDisplayName, String[] valuesArray) {
- super(id, newDisplayName);
- setDescription((String) id);
- fValues = valuesArray;
- }
-
- /**
- * Creates and returns a new cell editor for editing this property. Returns
- * <code>null</code> if the property is not editable.
- *
- * @param parent the parent widget for the cell editor
- * @return the cell editor for this property, or <code>null</code> if this
- * property cannot be edited
- */
- public CellEditor createPropertyEditor(Composite parent) {
- // Check to see if we already have a Cell Editor with a valid Control under the given parent.
- // If any of that's not true, create and return a new Cell Editor
- if (fEditor == null || fEditor.getControl() == null || fEditor.getControl().isDisposed() || parent != fParent)
- fEditor = new StringComboBoxCellEditor(parent, fValues);
- fParent = parent;
- return fEditor;
- }
-
- public void updateValues(String newValues[]) {
- if (Arrays.equals(fValues, newValues))
- return;
- fValues = newValues;
- if (fEditor != null) {
- fEditor.setItems(newValues);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/IPropertySourceExtension.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/IPropertySourceExtension.java
deleted file mode 100644
index f6ee6021bb..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/IPropertySourceExtension.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-import org.eclipse.ui.views.properties.IPropertySource;
-
-public interface IPropertySourceExtension extends IPropertySource {
- void removeProperty(Object propertyObject);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/PropertySheetConfiguration.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/PropertySheetConfiguration.java
deleted file mode 100644
index eb2d28ddf6..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/PropertySheetConfiguration.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.jface.action.IToolBarManager;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.wst.sse.ui.extension.IExtendedConfiguration;
-
-
-/**
- * Configuration class for Property Sheet Pages. Not finalized.
- * @author Nitin Dahyabhai
- */
-
-public class PropertySheetConfiguration implements IExtendedConfiguration {
-
- private class NullPropertySource implements IPropertySource {
- private final IPropertyDescriptor[] descriptors = new IPropertyDescriptor[0];
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
- */
- public Object getEditableValue() {
- return null;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
- */
- public IPropertyDescriptor[] getPropertyDescriptors() {
- return descriptors;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
- */
- public Object getPropertyValue(Object id) {
- return ""; //$NON-NLS-1$
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
- */
- public boolean isPropertySet(Object id) {
- return false;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#resetPropertyValue(java.lang.Object)
- */
- public void resetPropertyValue(Object id) {
- // do nothing
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
- */
- public void setPropertyValue(Object id, Object value) {
- // do nothing
- }
- }
-
- private class NullPropertySourceProvider implements IPropertySourceProvider {
- private IPropertySource fNullPropertySource = null;
-
- /* (non-Javadoc)
- * @see org.eclipse.ui.views.properties.IPropertySourceProvider#getPropertySource(java.lang.Object)
- */
- public IPropertySource getPropertySource(Object object) {
- if (fNullPropertySource == null)
- fNullPropertySource = new NullPropertySource();
- return fNullPropertySource;
- }
- }
-
- public static final String ID = "propertysheetconfiguration"; //$NON-NLS-1$
-
- private String fDeclaringID;
-
- private IEditorPart fEditor;
- protected IPropertySourceProvider fPropertySourceProvider = null;
-
- public PropertySheetConfiguration() {
- super();
- }
-
- public void addContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
- // do nothing
- }
-
- /**
- * @return
- */
- protected IPropertySourceProvider createPropertySourceProvider() {
- return new NullPropertySourceProvider();
- }
-
- /**
- * @return Returns the declaringID.
- */
- public String getDeclaringID() {
- return fDeclaringID;
- }
-
- /**
- * @return Returns the editor.
- */
- public IEditorPart getEditor() {
- return fEditor;
- }
-
- /**
- * Returns the correct IPropertySourceProvider
- */
- public IPropertySourceProvider getPropertySourceProvider() {
- if (fPropertySourceProvider == null)
- fPropertySourceProvider = createPropertySourceProvider();
- return fPropertySourceProvider;
- }
-
- /**
- * Allows for filteration of selection before being sent to the viewer
- * @param selectingPart - may be null
- * @param selection
- * @return
- */
- public ISelection getSelection(IWorkbenchPart selectingPart, ISelection selection) {
- return selection;
- }
-
- public void removeContributions(IMenuManager menuManager, IToolBarManager toolBarManager, IStatusLineManager statusLineManager) {
- // do nothing
- }
-
- /* (non-Javadoc)
- */
- public void setDeclaringID(String declaringID) {
- fDeclaringID = declaringID;
- }
-
- /**
- * @param editor The editor to set.
- */
- public void setEditor(IEditorPart editor) {
- fEditor = editor;
- }
-
- public void unconfigure() {
- // do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/RemoveAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/RemoveAction.java
deleted file mode 100644
index d1ef838e53..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/RemoveAction.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-
-
-public class RemoveAction extends Action {
- private ConfigurablePropertySheetPage fPage;
-
- public RemoveAction(ConfigurablePropertySheetPage page) {
- super();
- fPage = page;
- setText(getText());
- setToolTipText(getText());
- setImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_ELCL_DELETE));
- setDisabledImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_DLCL_DELETE));
- }
-
- /**
- * @see org.eclipse.jface.action.Action#getText()
- */
- public String getText() {
- return ResourceHandler.getString("RemoveAction.0"); //$NON-NLS-1$
- }
-
- /**
- * @see org.eclipse.jface.action.IAction#run()
- */
- public void run() {
- fPage.remove();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ShowPropertiesAction.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ShowPropertiesAction.java
deleted file mode 100644
index 224c9fead5..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/ShowPropertiesAction.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-import org.eclipse.wst.sse.ui.nls.ResourceHandler;
-import org.eclipse.wst.sse.ui.util.ShowViewAction;
-
-
-/**
- * Surfaces the Properties view
- *
- * @author Nitin Dahyabhai
- */
-public class ShowPropertiesAction extends ShowViewAction {
- private final static String VIEW_ID = "org.eclipse.ui.views.PropertySheet"; //$NON-NLS-1$
-
- public ShowPropertiesAction() {
- super(ResourceHandler.getString("ShowPropertiesAction.0"), EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_OBJ_PROP_PS)); //$NON-NLS-1$
- }
-
- protected String getViewID() {
- return VIEW_ID;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StringComboBoxCellEditor.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StringComboBoxCellEditor.java
deleted file mode 100644
index 8da9c21c57..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StringComboBoxCellEditor.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-
-
-import org.eclipse.jface.viewers.ComboBoxCellEditor;
-import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.wst.sse.ui.Logger;
-
-
-/**
- * An extended ComboBoxCellEditor that selects and returns Strings
- */
-
-public class StringComboBoxCellEditor extends ComboBoxCellEditor {
- private boolean fSettingValue = false;
-
- /**
- *
- */
- public StringComboBoxCellEditor() {
- super();
- }
-
- /**
- * @param parent
- * @param items
- */
- public StringComboBoxCellEditor(Composite parent, String[] items) {
- super(parent, items);
- }
-
- /**
- * @param parent
- * @param items
- * @param style
- */
- public StringComboBoxCellEditor(Composite parent, String[] items, int style) {
- super(parent, items, style);
- }
-
- protected Object doGetValue() {
- // otherwise limits to set of valid values
- Object index = super.doGetValue();
- int selection = -1;
- if (index instanceof Integer)
- selection = ((Integer) index).intValue();
- if (selection >= 0)
- return getItems()[selection];
- else if (getControl() instanceof CCombo) {
- // retrieve the actual text as the list of valid items doesn't contain the value
- return ((CCombo) getControl()).getText();
- }
- return null;
- }
-
- protected void doSetValue(Object value) {
- if (fSettingValue)
- return;
- fSettingValue = true;
- if (value instanceof Integer) {
- super.doSetValue(value);
- }
- else {
- String stringValue = value.toString();
- int selection = -1;
- for (int i = 0; i < getItems().length; i++)
- if (getItems()[i].equals(stringValue))
- selection = i;
- if (selection >= 0)
- super.doSetValue(new Integer(selection));
- else {
- super.doSetValue(new Integer(-1));
- if (getControl() instanceof CCombo && !stringValue.equals(((CCombo) getControl()).getText())) {
- // update the Text widget
- ((CCombo) getControl()).setText(stringValue);
- }
- }
- }
- fSettingValue = false;
- }
-
- public void setItems(String[] newItems) {
- if (getControl() == null || getControl().isDisposed()) {
- Logger.log(Logger.ERROR, "Attempted to update item list for disposed cell editor"); //$NON-NLS-1$
- return;
- }
-
- // keep selection if possible
- Object previousSelectedValue = getValue();
- super.setItems(newItems);
- if (previousSelectedValue != null && getControl() instanceof CCombo) {
- for (int i = 0; i < newItems.length; i++) {
- if (newItems[i].equals(previousSelectedValue))
- setValue(previousSelectedValue);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StructuredPropertySheetConfiguration.java b/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StructuredPropertySheetConfiguration.java
deleted file mode 100644
index 5e14da7e21..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/org/eclipse/wst/sse/ui/views/properties/StructuredPropertySheetConfiguration.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-* Copyright (c) 2002 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 - Initial API and implementation
-* Jens Lukowski/Innoopract - initial renaming/restructuring
-*
-*/
-package org.eclipse.wst.sse.ui.views.properties;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-/**
- * A PropertySheetConfiguration appropriate for StructuredTextEditors and StructuredModels
- */
-public class StructuredPropertySheetConfiguration extends PropertySheetConfiguration {
- /**
- * Utility method also used in subclasses
- */
- protected static IModelManager getModelManager() {
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- protected IStructuredModel fModel;
-
- /**
- *
- */
- public StructuredPropertySheetConfiguration() {
- super();
- }
-
- /* (non-Javadoc)
- */
- protected IPropertySourceProvider createPropertySourceProvider() {
- return new AdapterPropertySourceProvider();
- }
-
- /**
- * @return Returns the model.
- */
- public IStructuredModel getModel() {
- return fModel;
- }
-
- /* (non-Javadoc)
- */
- public ISelection getSelection(IWorkbenchPart selectingPart, ISelection selection) {
- ISelection preferredSelection = selection;
- if (selection instanceof ITextSelection && fModel != null) {
- // on text selection, find the appropriate IndexedRegion
- ITextSelection textSel = (ITextSelection) selection;
- Object inode = getModel().getIndexedRegion(textSel.getOffset());
- if (inode != null) {
- preferredSelection = new StructuredSelection(inode);
- }
- }
- else if (selection instanceof IStructuredSelection) {
- // don't support more than one selected node
- if (((IStructuredSelection) selection).size() > 1)
- preferredSelection = StructuredSelection.EMPTY;
- }
- return preferredSelection;
- }
-
- /**
- * @return
- */
- public void setEditor(IEditorPart editor) {
- super.setEditor(editor);
- IStructuredModel model = null;
- if (editor != null) {
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else
- textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
- if (textEditor != null) {
- IDocument document = textEditor.getDocumentProvider().getDocument(editor.getEditorInput());
- if (document != null)
- model = getModelManager().getExistingModelForRead(document);
- else
- model = null;
- }
- }
- // as long as the editor remains valid, we won't be the last reference to this model
- if (fModel != null)
- fModel.releaseFromRead();
- fModel = model;
- }
-
- /* (non-Javadoc)
- */
- public void unconfigure() {
- super.unconfigure();
- setEditor(null);
- }
-
-}

Back to the top