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
parent13c034178ca8ffe88d7f877113f84e9c78d54c0e (diff)
downloadwebtools.sourceediting-6fdcc7185a155ce3b8eccaed32db98524c3c29f9.tar.gz
webtools.sourceediting-6fdcc7185a155ce3b8eccaed32db98524c3c29f9.tar.xz
webtools.sourceediting-6fdcc7185a155ce3b8eccaed32db98524c3c29f9.zip
removing previous, in prep for refresh
-rw-r--r--bundles/org.eclipse.wst.sse.core/build.properties7
-rw-r--r--bundles/org.eclipse.wst.sse.core/plugin.properties13
-rw-r--r--bundles/org.eclipse.wst.sse.core/plugin.xml72
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/Models.properties63
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.java79
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java283
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java218
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java1187
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.java44
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.java60
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.java182
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.java59
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.java24
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.java279
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.java36
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java34
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.java60
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.java30
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java62
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.java22
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java389
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.java97
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java34
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java122
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.java76
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java1712
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java215
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java93
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.java35
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.java60
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.java42
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java120
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/AbstractBuilderParticipant.java164
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/MarkerParticipant.java137
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagParticipant.java280
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagSeeker.java424
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java271
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java480
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.java88
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.java23
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java55
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.java109
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.java142
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.java19
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.java47
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.java21
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.java32
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.java21
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java51
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.java101
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java391
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java120
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.java21
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java81
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java26
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.java30
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.java144
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java25
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java81
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.java54
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java48
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java48
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java141
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.java33
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.java33
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.java83
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.java85
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.java50
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java455
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.java19
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.java107
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.java30
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormattingStrategy.java21
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.java44
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormattingStrategy.java95
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.java22
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java169
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.java171
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.java32
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.java194
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java152
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java377
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java115
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.java75
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java37
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java113
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java70
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java287
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java105
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java49
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java176
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler.java74
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler1.java74
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java211
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.java86
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java2126
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java613
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java130
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java348
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java1714
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.java86
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.java111
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java126
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java224
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java72
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.java64
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.java47
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandlerForJSP.java29
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.java32
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.java76
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.java23
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.java111
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.java32
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.java58
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.java24
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.java52
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.java28
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.java24
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.java78
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java137
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.java20
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java62
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java186
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java89
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.java30
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.java41
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.java86
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.java58
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.java43
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java87
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.java83
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.java27
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java26
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java571
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java62
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java34
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextUndoManager.java95
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Assert.java140
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Debug.java193
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.java110
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.java171
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java148
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java217
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java68
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java39
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java711
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java81
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.java76
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.java125
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.java31
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.java69
-rw-r--r--bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.java24
-rw-r--r--bundles/org.eclipse.wst.sse.ui/build.properties13
-rw-r--r--bundles/org.eclipse.wst.sse.ui/html/maintopic.html13
-rw-r--r--bundles/org.eclipse.wst.sse.ui/html/subtopic.html13
-rw-r--r--bundles/org.eclipse.wst.sse.ui/html/toc.html13
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/ctool16/spellcheck.gifbin370 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/collapseall.gifbin155 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/delete.gifbin221 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/synced.gifbin149 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/dtool16/spellcheck.gifbin243 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/collapseall.gifbin157 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/delete.gifbin351 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/synced.gifbin233 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/etool16/spellcheck.gifbin370 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/obj16/occ_match.gifbin121 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/obj16/preferences.gifbin224 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/full/obj16/prop_ps.gifbin344 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/icons/sourceEditor.gifbin353 -> 0 bytes
-rw-r--r--bundles/org.eclipse.wst.sse.ui/javadoc.xml22
-rw-r--r--bundles/org.eclipse.wst.sse.ui/jspdebug.properties1
-rw-r--r--bundles/org.eclipse.wst.sse.ui/plugin.properties68
-rw-r--r--bundles/org.eclipse.wst.sse.ui/plugin.xml540
-rw-r--r--bundles/org.eclipse.wst.sse.ui/schema/extendedconfiguration.exsd292
-rw-r--r--bundles/org.eclipse.wst.sse.ui/src/Editing.properties573
-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
-rw-r--r--bundles/org.eclipse.wst.sse.ui/toc.xml13
438 files changed, 0 insertions, 68053 deletions
diff --git a/bundles/org.eclipse.wst.sse.core/build.properties b/bundles/org.eclipse.wst.sse.core/build.properties
deleted file mode 100644
index e3909c4d5d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/build.properties
+++ /dev/null
@@ -1,7 +0,0 @@
-bin.includes = plugin.properties,\
- model.jar,\
- plugin.xml,\
- .options
-jars.compile.order = model.jar
-source.model.jar = src/
-output.model.jar = bin/
diff --git a/bundles/org.eclipse.wst.sse.core/plugin.properties b/bundles/org.eclipse.wst.sse.core/plugin.properties
deleted file mode 100644
index bdfcf7c6bc..0000000000
--- a/bundles/org.eclipse.wst.sse.core/plugin.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-Structured_Text_Model.name=Structured Text Model
-Structured_Text_Model_NL_Support.name=Structured Text Model NL Support
-# extension names
-Adapt_On_Create_Factory_Extension.name=Adapt On Create Factory Extension
-Document_Types_Extension.name=Document Types Extension
-JSP_Embedded_Content_Type_Handler_Extension.name=JSP Embedded Content Type Handler Extension
-Content_Type_Factory_Contribution_Extension.name=Content Type Factory Contribution Extension
-CSS_Profile_Extension.name=CSS Profile Extension
-Comment_Element_Handler_Extension.name=Comment Element Handler Extension
-Model_Handler_Extension.name=Model Handler Extension
-Structured_Builder_Participant_Extension.name=Structured Builder Participant Extension
-SDMB.name=Structured Document and Model Builder
-Format_Processors_Extension.name=Format Processors Extension
diff --git a/bundles/org.eclipse.wst.sse.core/plugin.xml b/bundles/org.eclipse.wst.sse.core/plugin.xml
deleted file mode 100644
index 865037f047..0000000000
--- a/bundles/org.eclipse.wst.sse.core/plugin.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.wst.sse.core"
- name="%Structured_Text_Model.name"
- version="1.0.0"
- provider-name="Eclipse.org"
- class="org.eclipse.wst.sse.core.ModelPlugin">
-
- <runtime>
- <library name="model.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.core.resources"/>
-<!-- need to re-export jface.txt since our API depends on it,
- such as IStructuredDocument extends IDocument
- -->
- <import plugin="org.eclipse.jface.text" export="true"/>
-<!-- need to re-export emf.common since our API depends on it,
- such as StructuredTextUndoManager's getCommmand method returns an
- emf.common.Command
- -->
- <import plugin="org.eclipse.emf.common" export="true"/>
- <import plugin="org.eclipse.wst.contentmodel"/>
- <import plugin="org.eclipse.wst.xml.uriresolver"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.wst.encoding"/>
- <import plugin="org.eclipse.core.filebuffers"/>
- </requires>
-
-
-<!-- deprecated -->
- <extension-point id="adaptOnCreateFactory" name="%Adapt_On_Create_Factory_Extension.name"/>
- <extension-point id="documentTypes" name="%Document_Types_Extension.name"/>
- <extension-point id="embeddedTypeHandler" name="JSP Embedded Content Type Handler"/>
- <extension-point id="contentTypeFactoryContribution" name="%Content_Type_Factory_Contribution_Extension.name"/>
-<!-- I commented out ... clients should just use the normal platform way of registering these
- adapterFactories. At worst, they'd need a small plugin with 'startup' specified ... but that's
- better than us getting hit with the performance impact (of loading plugins and pre-reqs, etc.).
- <extension-point id="uriResolverAdapterFactory" name="Resource Adapter Factory for Creating URIResolvers"/>
- -->
- <extension-point id="cssprofile" name="%CSS_Profile_Extension.name"/>
- <extension-point id="commentElementHandler" name="%Comment_Element_Handler_Extension.name"/>
-<!-- this plug-in provides support for this extension point -->
- <extension-point id="modelHandler" name="%Model_Handler_Extension.name"/>
-<!-- builder participant; must implement org.eclipse.wst.sse.core.builder.IBuilderParticipant -->
- <extension-point id="builderparticipant" name="%Structured_Builder_Participant_Extension.name" schema="schema/builderparticipant.exsd"/>
- <extension-point id="formatProcessors" name="%Format_Processors_Extension.name" schema="schema/formatProcessors.exsd"/>
-
-<!-- not for use by clients -->
- <extension-point id="builderdelegate" name="Structured Builder Delegate"/>
-
- <extension point="org.eclipse.core.resources.builders"
- id="structuredbuilder"
- name="%SDMB.name">
- <builder
- hasNature="false">
- <run
- class="org.eclipse.wst.sse.core.internal.builder.StructuredDocumentBuilder"
- >
- </run>
- </builder>
- </extension>
-<!-- define our task marker type -->
- <extension id="task" name="Structured Sources Task" point="org.eclipse.core.resources.markers">
- <super type="org.eclipse.core.resources.taskmarker"/>
- <persistent value="true"/>
- </extension>
-</plugin>
diff --git a/bundles/org.eclipse.wst.sse.core/src/Models.properties b/bundles/org.eclipse.wst.sse.core/src/Models.properties
deleted file mode 100644
index bf4ca252f8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/Models.properties
+++ /dev/null
@@ -1,63 +0,0 @@
-Invalid_character_('<')_fo_ERROR_=IWAK0028E Invalid character ('<') found
-Invalid_character_('>')_fo_ERROR_=IWAK0029E Invalid character ('>') found
-Invalid_character_('&')_fo_ERROR_=IWAK0030E Invalid character ('&') found
-Original_Error__UI_=Original Error:
-Program_Error__ModelManage_EXC_=IWAK0031E Program Error: ModelManagerImpl::saveModel. Model should be in the cache
-Invalid_character_('__')_f_EXC_=IWAK0032E Invalid character ('\"') found
-Unkown_internal_scanner_er_ERROR_=IWAK0033E Unkown internal scanner error
-Internal_error__unknown_st_ERROR_=IWAK0034E Internal error: unknown state
-Error__could_not_match_inp_ERROR_=IWAK0035E Error: could not match input
-Error__pushback_value_was__ERROR_=IWAK0036E Error: pushback value was too large
-An_I/O_error_occured_while_EXC_=IWAK0037E An I/O error occured while scanning :
-3concat=File not found : \"{0}\"
-5concat=Error opening file \"{0}\"
-ul_____(template)_UI_=ul (template)
-<ul>_n__<li>_Item_one_</li_UI_=<ul>\n <li> Item one </li>\n <li> Item two </li>\n</ul>\n
-dl_____(template)_UI_=dl (template)
-<dl>_n__<dt>_First_definit_UI_=<dl>\n <dt> First definition <dd> First explanation\n <dt> Second definition <dd> Second explanation\n</dl>\n
-table_____(template)_UI_=table (template)
-<table_border>_n__<tr>_n___UI_=<table border>\n <tr>\n <th>Column 1 Heading</th>\n <th>Column 2 Heading</th>\n </tr>\n <tr>\n <td>Row 1: Col 1</td>\n <td>Row 1: Col 2</td>\n </tr>\n</table>\n
-ol_____(template)_UI_=ol (template)
-<ol>_n__<li>_Item_one_</li_UI_=<ol>\n <li> Item one </li>\n <li> Item two </li>\n</ol>\n
-html____(template)_UI_=html (template)
-<html>_n<head>_n<title>Ins_UI_=<html>\n<head>\n<title>Insert title here</title>\n</head>\n<body>\n<|c>\n</body>\n</html>
-script_____(commented)_UI_=script (commented)
-style_____(commented)_UI_=style (commented)
-img_____(map)_UI=img (map)
-Usage___java_HTMLTokenizer_EXC_=IWAK0038E Usage : java HTMLTokenizer <inputfile>
-## on the following line, just translate: "place title here" and "place content here"
-__>_n_t_t<TITLE><|c>place__UI_=\">\n\t\t<TITLE><|c>place title here</TITLE>\n\t</HEAD>\n\t<BODY>\n\t\tplace content here\n\t</BODY>\n</HTML>
-A_model's_id_can_not_be_nu_EXC_=IWAK0039E A model's id can not be null
-Flatmodel_constructor_doesn__t_know_how_to_deal_with_non-string_4=Flatmodel constructor doesn\'t know how to deal with non-string
-unexpected_ModelManager_Impl_1=unexpected ModelManager Impl
-continuous_1=continuous
-paged_2=paged
-visual_3=visual
-aural_4=aural
-tactile_5=tactile
-grid_6=grid
-bitmap_7=bitmap
-interactive_8=interactive
-static_9=static
-all_10=all
-Cleaning_up_element_{0}=Cleaning up element \"{0}\"
-Uppercasing_attribute_name_{0}=Uppercasing attribute name \"{0}\"
-Lowercasing_attribute_name_{0}=Lowercasing attribute name \"{0}\"
-Uppercasing_tag_name_{0}=Uppercasing tag name \"{0}\"
-Lowercasing_tag_name_{0}=Lowercasing tag name \"{0}\"
-Inserting_missing_end_tag_{0}=Inserting missing end tag \"{0}\"
-Inserting_missing_start_tag_{0}=Inserting missing start tag \"{0}\"
-Inserting_default_attribute_value_{0}=Inserting default attribute value \"{0}\"
-Quoting_attribute_value_{0}=Quoting attribute value \"{0}\"
-Formatting_start_tag_of_element_{0}=Formatting start tag of element \"{0}\"
-Formatting_end_tag_of_element_{0}=Formatting end tag of element \"{0}\"
-Formatting_element_{0}=Formatting element \"{0}\"
-Formatting_indentation_before_element_{0}=Formatting indentation before element \"{0}\"
-Formatting_indentation_after_element_{0}=Formatting indentation after element \"{0}\"
-Formatting_element_{0}=Formatting element \"{0}\"
-EOL_Windows_UI=Windows
-EOL_Unix_UI=UNIX
-EOL_Mac_UI=Mac
-NoTranslation=No translation
-StructuredDocumentBuilder.0=Updating builders
-ModelPlugin.0=Structured Builder
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.java
deleted file mode 100644
index 76274d5c7a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractAdapterFactory.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.core;
-
-/**
- * An abstract implementation of AdapterFactory that uses itself
- * as the key. Subclass to override behavior.
- */
-abstract public class AbstractAdapterFactory implements AdapterFactory {
-
- protected Object adapterKey;
- protected boolean shouldRegisterAdapter = true;
-
- public AbstractAdapterFactory() {
- // default constructor sets the adapterKey to the adapter factory itself (i.e. "this")
- adapterKey = this;
- }
-
- public AbstractAdapterFactory(Object adapterKey, boolean registerAdapters) {
- this.adapterKey = adapterKey;
- this.shouldRegisterAdapter = registerAdapters;
- }
-
- public INodeAdapter adapt(INodeNotifier target) {
- // target was null when all text deleted?
- if (target == null)
- return null;
- INodeAdapter adapter = target.getExistingAdapter(adapterKey);
- return adapter != null ? adapter : adaptNew(target);
- }
-
- public INodeAdapter adaptNew(INodeNotifier target) {
- INodeAdapter adapter = createAdapter(target);
- if (adapter == null)
- return adapter;
- if (shouldRegisterAdapter)
- target.addAdapter(adapter);
- return adapter;
- }
-
- abstract protected INodeAdapter createAdapter(INodeNotifier target);
-
- public boolean isFactoryForType(Object type) {
- return type.equals(adapterKey);
- }
-
- public void release() {
- // default is to do nothing
- }
-
- public void setAdapterKey(Object key) {
- if (adapterKey != null)
- throw new IllegalAccessError("INodeAdapter Key cannot be set more than once."); //$NON-NLS-1$
- adapterKey = key;
- }
-
- public void setRegisterAdapters(boolean flag) {
- shouldRegisterAdapter = flag;
- }
-
- /**
- * Subclasses should normally implement their own 'copy' method.
- * By default, we'll return the same instance, for convenience
- * of those using singleton factories.
- */
- public AdapterFactory copy() {
- return this;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java
deleted file mode 100644
index c76a0bacc0..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractModelLoader.java
+++ /dev/null
@@ -1,283 +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.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.Assert;
-
-
-/**
- * This class reads a file and creates an Structured Model.
- */
-public abstract class AbstractModelLoader implements ModelLoader {
- protected IDocumentLoader documentLoaderInstance;
- protected static final int encodingNameSearchLimit = 1000;
-
- /**
- * AbstractLoader constructor also initializes encoding converter/mapper
- */
- public AbstractModelLoader() {
- super();
- }
-
- /**
- * This method must return those factories which must be attached to the
- * structuredModel before content is applied.
- */
- public List getAdapterFactories() {
- // abstract method returns none
- return new ArrayList(0);
- }
-
- protected void addFactories(IStructuredModel model, List factoryList) {
- Assert.isNotNull(model);
- IFactoryRegistry registry = model.getFactoryRegistry();
- Assert.isNotNull(registry);
- if (factoryList != null) {
- Iterator iterator = factoryList.iterator();
- while (iterator.hasNext()) {
- AdapterFactory factory = (AdapterFactory) iterator.next();
- registry.addFactory(factory);
- }
- }
- }
-
- /**
- * This method should perform all the model initialization required before
- * it contains content, namely, it should call newModel, the
- * createNewStructuredDocument(), then add those adapter factories which
- * must be set before content is applied. This method should be called by
- * "load" method. (this is tentative API)
- */
- public IStructuredModel createModel() {
- documentLoaderInstance = null;
- IStructuredModel model = newModel();
- IEncodedDocument structuredDocument = getDocumentLoader().createNewStructuredDocument();
- if (structuredDocument instanceof IStructuredDocument) {
- model.setStructuredDocument((IStructuredDocument) structuredDocument);
- addFactories(model, getAdapterFactories());
- //
- initEmbeddedType(model);
- // For types with propagating adapters, its important
- // that the propagating adapter be in place before the contents
- // are set.
- preLoadAdapt(model);
- }
- return model;
- }
-
- abstract public IDocumentLoader getDocumentLoader();
-
- /**
- * Method initEmbeddedType. Nothing to do here in super class.
- *
- * @param model
- */
- protected void initEmbeddedType(IStructuredModel model) {
- }
-
- /**
- * This method is used for cloning models.
- */
- public IStructuredModel createModel(IStructuredModel oldModel) {
- documentLoaderInstance = null;
- IStructuredModel newModel = newModel();
- IStructuredDocument oldStructuredDocument = oldModel.getStructuredDocument();
- IStructuredDocument newStructuredDocument = oldStructuredDocument.newInstance();
- newModel.setStructuredDocument(newStructuredDocument);
- // NOTE: we DO NOT simply add the standard ones to the new model
- // addFactories(newModel, getAdapterFactories());
- // Now, we take the opportunity to add Factories from the oldModel's
- // registry to the new model's registry .. if they do not already
- // exist there.
- duplicateFactoryRegistry(newModel, oldModel);
- //addFactories(newModel, oldModel);
- initEmbeddedType(oldModel, newModel);
- // For types with propagating adapters, its important
- // that the propagating adapter be in place before the contents
- // are set.
- preLoadAdapt(newModel);
- return newModel;
- }
-
- /**
- * Method initEmbeddedType. Nothing to do here in super class.
- *
- * @param oldModel
- * @param newModel
- */
- protected void initEmbeddedType(IStructuredModel oldModel, IStructuredModel newModel) {
- }
-
- /**
- * deprecated -- use EncodingRule form
- */
- synchronized public void load(InputStream inputStream, IStructuredModel model, String encodingName, String lineDelimiter) throws UnsupportedEncodingException, java.io.IOException {
- // note we don't open the stream, so we don't close it
- // TEMP work around to maintain previous function,
- // until everyone can change to EncodingRule.FORCE_DEFAULT
- if (encodingName != null && encodingName.trim().length() == 0) {
- // redirect to new method
- load(inputStream, model, EncodingRule.FORCE_DEFAULT);
- }
- else {
- load(inputStream, model, EncodingRule.CONTENT_BASED);
- }
- }
-
- public void load(InputStream inputStream, IStructuredModel model, EncodingRule encodingRule) throws UnsupportedEncodingException, java.io.IOException {
- // note we don't open the stream, so we don't close it
- IEncodedDocument structuredDocument = model.getStructuredDocument();
- if (inputStream == null) {
- structuredDocument = getDocumentLoader().createNewStructuredDocument();
- }
- else {
- // assume's model has been initialized already with base location
- structuredDocument = getDocumentLoader().createNewStructuredDocument(model.getBaseLocation(), inputStream, encodingRule);
- // TODO: model's not designed for this!
- model.setStructuredDocument((IStructuredDocument) structuredDocument);
- ((IStructuredDocument) structuredDocument).fireNewDocument(this);
- }
- documentLoaderInstance = null;
-
- }
-
- public void load(String filename, InputStream inputStream, IStructuredModel model, String junk, String dummy) throws UnsupportedEncodingException, java.io.IOException {
- IEncodedDocument structuredDocument = model.getStructuredDocument();
- if (inputStream == null) {
- structuredDocument = getDocumentLoader().createNewStructuredDocument();
- }
- else {
- structuredDocument = getDocumentLoader().createNewStructuredDocument(filename, inputStream);
- }
- // TODO: model's not designed for this!
- model.setStructuredDocument((IStructuredDocument) structuredDocument);
- ((IStructuredDocument) structuredDocument).fireNewDocument(this);
- documentLoaderInstance = null;
-
- }
-
- /**
- * required by interface, being declared here abstractly just as another
- * reminder.
- */
- abstract public IStructuredModel newModel();
-
- /**
- * This method gets a fresh copy of the data, and repopulates the models
- * ... by a call to setText on the structuredDocument. This method is
- * needed in some cases where clients are sharing a model and then changes
- * canceled. Say for example, one editor and several "displays" are
- * sharing a model, if the editor is closed without saving changes, then
- * the displays still need a model, but they should revert to the original
- * unsaved version.
- */
- synchronized public void reload(InputStream inputStream, IStructuredModel structuredModel) {
- documentLoaderInstance = null;
- try {
- // temp solution ... we should be able to do better (more efficient) in future.
- // Adapters will (probably) need to be sensitive to the fact that the document instance changed
- // (by being life cycle listeners)
- load(inputStream, structuredModel, EncodingRule.CONTENT_BASED);
-
- // // Note: we apparently read the data (and encoding) correctly
- // // before, we just need to make sure we followed the same rule as
- // // before.
- // EncodingMemento previousMemento = structuredModel.getStructuredDocument().getEncodingMemento();
- // EncodingRule previousRule = previousMemento.getEncodingRule();
- // //IFile file = ResourceUtil.getFileFor(structuredModel);
- // // Note: there's opportunity here for some odd behavior, if the
- // // settings have changed from the first load to the reload. But,
- // // hopefully,
- // // will result in the intended behavior.
- // Reader allTextReader = getDocumentLoader().readInputStream(inputStream, previousRule);
- //
- // // TODO: avoid use of String instance
- // getDocumentLoader().reload(structuredModel.getStructuredDocument(), allTextReader);
- // // and now "reset" encoding memento to keep it current with the
- // // one
- // // that was just determined.
- // structuredModel.getStructuredDocument().setEncodingMemento(getDocumentLoader().getEncodingMemento());
- // structuredModel.setDirtyState(false);
- // StructuredTextUndoManager undoMgr = structuredModel.getUndoManager();
- // if (undoMgr != null) {
- // undoMgr.reset();
- // }
- }
- catch (UnsupportedEncodingException e) {
- // couldn't happen. The program has apparently
- // read the model once, and there'd be no reason the encoding
- // could not be used again.
- Logger.logException("Warning: XMLLoader::reload. This exception really should not have happened!! But will attemp to continue after dumping stack trace", e); //$NON-NLS-1$
- throw new Error("Program Error", e); //$NON-NLS-1$
- }
- catch (IOException e) {
- // couldn't happen. The program has apparently
- // read the model once, and there'd be no (common) reason it
- // couldn't be loaded again.
- Logger.logException("Warning: XMLLoader::reload. This exception really should not have happened!! But will attemp to continue after dumping stack trace", e); //$NON-NLS-1$
- throw new Error("Program Error", e); //$NON-NLS-1$
- }
- }
-
- /**
- * There's nothing to do here in abstract class for initializing adapters.
- * Subclasses can and should override this method and provide proper
- * intialization (For example, to get DOM document and 'getAdapter' on it,
- * so that the first node/notifier has the adapter on it.)
- */
- protected void preLoadAdapt(IStructuredModel structuredModel) {
- }
-
- /**
- * Normally, here in the abstact class, there's nothing to do, but we will
- * reset text, since this MIGHT end up being called to recover from error
- * conditions (e.g. IStructuredDocument exceptions) And, can be called by
- * subclasses.
- */
- public IStructuredModel reinitialize(IStructuredModel model) {
- // Note: the "minimumization" routines
- // of 'replaceText' allow many old nodes to pass through, when
- // really its assumed they are created anew.
- // so we need to use 'setText' (I think "setText' ends up
- // throwing a 'newModel' event though, that may have some
- // implications.
- model.getStructuredDocument().setText(this, model.getStructuredDocument().get());
- return model;
- }
-
- private void duplicateFactoryRegistry(IStructuredModel newModel, IStructuredModel oldModel) {
- List oldAdapterFactories = oldModel.getFactoryRegistry().getFactories();
- List newAdapterFactories = new ArrayList();
- Iterator oldListIterator = oldAdapterFactories.iterator();
- while (oldListIterator.hasNext()) {
- AdapterFactory oldAdapterFactory = (AdapterFactory) oldListIterator.next();
- // now "clone" the adapterfactory
- newAdapterFactories.add(oldAdapterFactory.copy());
- }
- // now that we have the "cloned" list, add to new model
- addFactories(newModel, newAdapterFactories);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java
deleted file mode 100644
index 9355b8aedc..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractNotifier.java
+++ /dev/null
@@ -1,218 +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.core;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-
-import org.eclipse.core.runtime.Platform;
-
-
-/**
- * AbstractNotifier is similar to (and based on) the EMF NotifierImpl
- * class. This class is simpler (that is, not as many functions).
- */
-public abstract class AbstractNotifier implements INodeNotifier {
-
- private INodeAdapter[] fAdapters;
- private int adapterCount = 0;
- private final static int growthConstant = 3;
- private final static boolean debugAdapterNotificationTime = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/dom/adapter/notification/time")); //$NON-NLS-1$ //$NON-NLS-2$
-
- /**
- * AbstractNotifier constructor comment.
- */
- public AbstractNotifier() {
- super();
- }
-
- /**
- * addAdapter method comment.
- */
- public synchronized void addAdapter(INodeAdapter adapter) {
-
- if (adapter == null)
- return;
- ensureCapacity(adapterCount + 1);
- fAdapters[adapterCount++] = adapter;
- }
-
- /**
- * Default behavior for getting an adapter.
- */
- public INodeAdapter getAdapterFor(Object type) {
- // first, we'll see if we already have one
- INodeAdapter result = getExistingAdapter(type);
- // if we didn't find one in our list already,
- // let's create it
- if (result == null) {
- IFactoryRegistry reg = getFactoryRegistry();
- if (reg != null) {
- AdapterFactory factory = reg.getFactoryFor(type);
- if (factory != null) {
- result = factory.adapt(this);
- }
- }
- // We won't prevent null from being returned, but it would be unusual.
- // It might be because Factory is not working correctly, or
- // not installed, so we'll allow warning message.
- if ((result == null) && (org.eclipse.wst.sse.core.util.Debug.displayWarnings)) {
- System.out.println("Warning: no adapter was found or created for " + type); //$NON-NLS-1$
- }
- }
- return result;
- }
-
- /**
- * Returns a shallow clone of list, since
- * clients should not manipulate our list directly.
- * Instead, they should use add/removeAdapter.
- */
- public Collection getAdapters() {
- if (fAdapters != null) {
- if (adapterCount == 0) {
- fAdapters = null;
- return Collections.EMPTY_LIST;
- }
- else {
- // we need to make a new array, to be sure
- // it doesn't contain nulls at end, which may be
- // present there for "growth".
- INodeAdapter[] tempAdapters = new INodeAdapter[adapterCount];
- System.arraycopy(fAdapters, 0, tempAdapters, 0, adapterCount);
- // EMF uses the unmodifiableCollection. Its a bit of a performance
- // drain, but may want to leave in since
- // it would "fail fast" if someone was trying to modify the list.
- return Collections.unmodifiableCollection(Arrays.asList(tempAdapters));
- //return Arrays.asList(newAdapters);
- }
- }
- else
- return Collections.EMPTY_LIST;
- }
-
- public INodeAdapter getExistingAdapter(Object type) {
- INodeAdapter result = null;
- for (int i = 0; i < adapterCount; i++) {
- INodeAdapter a = fAdapters[i];
- if (a.isAdapterForType(type)) {
- result = a;
- break;
- }
- }
- // if we didn't find one in our list,
- // return the null result
- return result;
- }
-
- abstract public IFactoryRegistry getFactoryRegistry();
-
- public void notify(int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
-
- if (fAdapters != null) {
- int localAdapterCount = 0;
- INodeAdapter[] localAdapters = null;
-
- // lock object while making local assignments
- synchronized (this) {
- localAdapterCount = adapterCount;
- localAdapters = new INodeAdapter[localAdapterCount];
- System.arraycopy(fAdapters, 0, localAdapters, 0, localAdapterCount);
- }
-
- for (int i = 0; i < localAdapterCount; i++) {
- INodeAdapter a = localAdapters[i];
-
- if (debugAdapterNotificationTime) {
- long getAdapterTimeCriteria = getAdapterTimeCriteria();
- long startTime = System.currentTimeMillis();
- // ** keep this line identical with non-debug version!!
- a.notifyChanged(this, eventType, changedFeature, oldValue, newValue, pos);
- long notifyDuration = System.currentTimeMillis() - startTime;
- if (getAdapterTimeCriteria >= 0 && notifyDuration > getAdapterTimeCriteria) {
- System.out.println("adapter notifyDuration: " + notifyDuration + " class: " + a.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- else {
- // ** keep this line identical with debug version!!
- a.notifyChanged(this, eventType, changedFeature, oldValue, newValue, pos);
- }
-
- }
- }
- }
-
- private long getAdapterTimeCriteria() {
- // to "re-get" the property each time is a little awkward, but we
- // do it that way to avoid adding instance variable just for debugging.
- // This method should only be called if debugAdapterNotifcationTime
- // is true.
- final String criteriaStr = Platform.getDebugOption("org.eclipse.wst.sse.core/dom/adapter/notification/time/criteria"); //$NON-NLS-1$
- long criteria = -1;
- if (criteriaStr != null) {
- try {
- criteria = Long.parseLong(criteriaStr);
- }
- catch (NumberFormatException e) {
- // catch to be sure we don't burb in notification loop,
- // but ignore, since just a debug aid
- }
- }
- return criteria;
- }
-
- public synchronized void removeAdapter(INodeAdapter a) {
- if (fAdapters == null || a == null)
- return;
- int newIndex = 0;
- INodeAdapter[] newAdapters = new INodeAdapter[fAdapters.length];
- int oldAdapterCount = adapterCount;
- boolean found = false;
- for (int oldIndex = 0; oldIndex < oldAdapterCount; oldIndex++) {
- INodeAdapter candidate = fAdapters[oldIndex];
- if (a == candidate) {
- adapterCount--;
- found = true;
- }
- else
- newAdapters[newIndex++] = fAdapters[oldIndex];
- }
- if (found)
- fAdapters = newAdapters;
- }
-
- private void ensureCapacity(int needed) {
- if (fAdapters == null) {
- // first time
- fAdapters = new INodeAdapter[needed + growthConstant];
- return;
- }
- int oldLength = fAdapters.length;
- if (oldLength < needed) {
- INodeAdapter[] oldAdapters = fAdapters;
- INodeAdapter[] newAdapters = new INodeAdapter[needed + growthConstant];
- System.arraycopy(oldAdapters, 0, newAdapters, 0, adapterCount);
- fAdapters = newAdapters;
- }
- }
-
- /**
- * Returns the adapterCount. Equivilent to, but faster than, getAdapters().size();
- * @return int
- */
- public int getAdapterCount() {
- return adapterCount;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java
deleted file mode 100644
index 8b94a97830..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AbstractStructuredModel.java
+++ /dev/null
@@ -1,1187 +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.core;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.encoding.EncodingRule;
-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.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.nls.ResourceHandler1;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.core.util.URIResolver;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-public abstract class AbstractStructuredModel implements IStructuredModel {
-
- /**
- * @deprecated - will likely be deprecated soon, in favor of direct 'adds'
- * ... but takes some redesign.
- */
- public void setFactoryRegistry(IFactoryRegistry factoryRegistry) {
-
- this.factoryRegistry = factoryRegistry;
- }
-
- class DirtyStateWatcher implements IStructuredDocumentListener {
-
- public void newModel(NewModelEvent structuredDocumentEvent) {
-
- // I don't think its safe to assume a new model
- // is always "fresh", so we'll leave dirty state
- // unchanged;
- // but we'll tell everyone about it.
- setDirtyState(fDirtyState);
- }
-
- public void noChange(NoChangeEvent structuredDocumentEvent) {
-
- // don't change dirty state
- }
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent) {
-
- setDirtyState(true);
- // no need to listen any more
- if (fStructuredDocument != null) {
- fStructuredDocument.removeModelChangedListener(fDirtyStateWatcher);
- }
- }
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent) {
-
- setDirtyState(true);
- // no need to listen any more
- if (fStructuredDocument != null) {
- fStructuredDocument.removeModelChangedListener(fDirtyStateWatcher);
- }
- }
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent) {
-
- setDirtyState(true);
- // no need to listen any more
- if (fStructuredDocument != null) {
- fStructuredDocument.removeModelChangedListener(fDirtyStateWatcher);
- }
- }
- }
-
- private LifecycleNotificationManager fLifecycleNotificationManager;
- private Object[] fModelStateListeners;
- private IStructuredDocument fStructuredDocument;
- private String fId;
- // private String fLineDelimiter;
- // private Object fType;
- private IModelHandler fModelHandler;
- private String fBaseLocation;
- private IModelManager fModelManager;
- private StructuredTextUndoManager fUndoManager = null;
- private IFactoryRegistry factoryRegistry;
- private boolean fDirtyState;
- private DirtyStateWatcher fDirtyStateWatcher;
- private URIResolver fResolver;
- private boolean fNewState = false;
- private int modelStateChanging;
- // private final static String platformLineDelimiter =
- // System.getProperty("line.separator"); //$NON-NLS-1$
- /**
- * The time stamp of the underlying resource's modification date, at the
- * time this model was created, or the last time it was saved. Note: for
- * this version, this variable is not set automatically, be needs to be
- * managed by client. The FileModelProvider does this for most cases, but
- * if client do not use FileModelProvider, they must set this variable
- */
- public long fSynchronizationStamp = IResource.NULL_STAMP;
- private boolean reinitializationNeeded;
- private Object reinitializeStateData;
-
- /**
- * AbstractStructuredModel constructor comment.
- */
- public AbstractStructuredModel() {
-
- super();
- fDirtyStateWatcher = new DirtyStateWatcher();
- }
-
- /**
- * This API allows clients to declare that they are about to make a "large"
- * change to the model. This change might be in terms of content or it
- * might be in terms of the model id or base location. Note that in the
- * case of embedded calls, notification to listners is sent only once. Note
- * that the client who is making these changes has the responsibility to
- * restore the models state once finished with the changes. See getMemento
- * and restoreState. The method isModelStateChanging can be used by a
- * client to determine if the model is already in a change sequence.
- */
- public synchronized void aboutToChangeModel() {
-
- // notice this is just a public avenue to our protected method
- fireModelAboutToBeChanged();
- }
-
- public synchronized void aboutToReinitializeModel() {
-
- // notice this is just a public avenue to our protected method
- fireModelAboutToBeReinitialized();
- }
-
- public synchronized void modelReinitialized() {
-
- // notice this is just a public avenue to our protected method
- fireModelReinitialized();
- }
-
- public synchronized void addModelLifecycleListener(IModelLifecycleListener listener) {
-
- if (fLifecycleNotificationManager == null) {
- fLifecycleNotificationManager = new LifecycleNotificationManager();
- }
- fLifecycleNotificationManager.addListener(listener);
- }
-
- /**
- * to be called only be "friendly" classes, such as ModelManger,
- * and subclasses.
- */
- protected void signalLifecycleEvent(ModelLifecycleEvent event) {
-
- if (fLifecycleNotificationManager == null)
- return;
- fLifecycleNotificationManager.signalLifecycleEvent(event);
- }
-
- public void removeModelLifecycleListener(IModelLifecycleListener listener) {
-
- // if manager is null, then none have been added, so
- // no need to remove it.
- if (fLifecycleNotificationManager == null)
- return;
- fLifecycleNotificationManager.removeListener(listener);
- }
-
- public synchronized void addModelStateListener(IModelStateListener listener) {
-
- if (!Utilities.contains(fModelStateListeners, listener)) {
- int oldSize = 0;
- if (fModelStateListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fModelStateListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fModelStateListeners != null) {
- System.arraycopy(fModelStateListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fModelStateListeners = newListeners;
- //
- // SIDE EFFECT
- // Tell listener just added, the current state
- //listener.elementDirtyStateChanged(this, isDirty());
- }
- }
-
- public void beginRecording(Object requester) {
-
- beginRecording(requester, null, null);
- }
-
- public void beginRecording(Object requester, int cursorPosition, int selectionLength) {
-
- beginRecording(requester, null, null, cursorPosition, 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, cursorPosition, selectionLength);
- }
-
- public void beginRecording(Object requester, String label, String description) {
-
- if (fUndoManager != null)
- fUndoManager.beginRecording(requester, label, description);
- }
-
- public void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength) {
-
- if (fUndoManager != null)
- fUndoManager.beginRecording(requester, label, description, cursorPosition, selectionLength);
- }
-
- /**
- * This API allows a client controlled way of notifying all ModelEvent
- * listners that the model has been changed. This method is a matched pair
- * to aboutToChangeModel, and must be called after aboutToChangeModel ...
- * or some listeners could be left waiting indefinitely for the changed
- * event. So, its suggested that changedModel always be in a finally
- * clause. Likewise, a client should never call changedModel without
- * calling aboutToChangeModel first. In the case of embedded calls, the
- * notification is just sent once.
- */
- public synchronized void changedModel() {
-
- // notice this is just a public avenue to our protected method
- fireModelChanged();
- // also note!
- // if we've been "changed" by a client, we might still need
- // to be re-initialized, so we'll check and handle that here.
- // Note only does this provide a solution to some "missed"
- // re-inits, in provides a built in way for clients to
- // "force" the model to handle itself, by bracketing any
- // changes with aboutToChange and changed, the model itself
- // will check. But only call re-init if all other pending
- // modelChanged states have been handled.
- if (modelStateChanging == 0 && isReinitializationNeeded()) {
- reinit();
- }
- }
-
- /**
- * Based on similar method in FileDocumentProvider. It will provide what
- * the modificationStamp would be if resetSynchronzationStamp(resource)
- * were used, although for this 'compute' API, no changes to the instance
- * are made.
- */
- public synchronized long computeModificationStamp(IResource resource) {
-
- long modificationStamp = resource.getModificationStamp();
- IPath path = resource.getLocation();
- if (path == null) {
- return modificationStamp;
- }
- // Note: checking existence of file is a little different than impl in
- // the FileDocumentProvider. See defect number 223790.
- File file = path.toFile();
- if (!file.exists()) {
- return modificationStamp;
- }
- modificationStamp = file.lastModified();
- return modificationStamp;
- }
-
- /**
- * Provides a copy of the model, but a new ID must be provided. The
- * principle of this copy is not to copy fields, etc., as is typically done
- * in a clone method, but to return a model with the same content in the
- * structuredDocument. Note: It is the callers responsibility to
- * setBaseLocation, listners, etc., as appropriate. Type and Encoding are
- * the only fields set by this method. If the newId provided already exist
- * in the model manager, a ResourceInUse exception is thrown.
- */
- public synchronized IStructuredModel copy(String newId) throws ResourceInUse {
-
- IStructuredModel newModel = null;
- // this first one should fail, if not, its treated as an error
- // If the caller wants to use an existing one, they can call
- // getExisting
- // after this failure
- newModel = getModelManager().getExistingModelForEdit(newId);
- if (newModel != null) {
- // be sure to release the reference we got "by accident" (and no
- // longer need)
- newModel.releaseFromEdit();
- throw new ResourceInUse();
- }
- newModel = getModelManager().copyModelForEdit(getId(), newId);
- return newModel;
- }
-
- /**
- * Disable undo management.
- */
- public void disableUndoManagement() {
-
- if (fUndoManager != null)
- fUndoManager.disableUndoManagement();
- }
-
- /**
- * Enable undo management.
- */
- public void enableUndoManagement() {
-
- if (fUndoManager != null)
- fUndoManager.enableUndoManagement();
- }
-
- public void endRecording(Object requester) {
-
- if (fUndoManager != null)
- fUndoManager.endRecording(requester);
- }
-
- public void endRecording(Object requester, int cursorPosition, int selectionLength) {
-
- if (fUndoManager != null)
- fUndoManager.endRecording(requester, cursorPosition, selectionLength);
- }
-
- protected void fireModelAboutToBeReinitialized() {
-
- // 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
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- // NOTE: trick for transition. We actual use the same listeners
- // as modelState, but only send this to those that have
- // implemented ModelStateExtended.
- IModelStateListener listener = (IModelStateListener) holdListeners[i];
- if (listener instanceof IModelStateListenerExtended) {
- IModelStateListenerExtended extendedListner = (IModelStateListenerExtended) listener;
- extendedListner.modelAboutToBeReinitialized(this);
- }
- }
- }
- }
-
- protected void fireModelReinitialized() {
-
- // 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
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- // NOTE: trick for transition. We actual use the same listeners
- // as modelState, but only send this to those that have
- // implemented ModelStateExtended.
- IModelStateListener listener = (IModelStateListener) holdListeners[i];
- if (listener instanceof IModelStateListenerExtended) {
- IModelStateListenerExtended extendedListner = (IModelStateListenerExtended) listener;
- extendedListner.modelReinitialized(this);
- }
- }
- }
- }
-
- /**
- * Informs all registered model state listeners that the the model is about
- * to under go a "large" change. This change might be interms of contents,
- * in might be in terms of the model id or base location.
- */
- protected void fireModelAboutToBeChanged() {
-
- // notice we only fire this event if we are not already in a model
- // state changing sequence
- if (modelStateChanging == 0) {
- // 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
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelAboutToBeChanged(this);
- }
- }
- }
- // we always increment counter, for every request (so must receive
- // corresponding number of 'changedModel' requests)
- modelStateChanging++;
- }
-
- /**
- * Informs all registered model state listeners that an impending change is
- * now complete. This method must only be called by 'modelChanged' since it
- * keeps track of counts.
- */
- protected void fireModelChanged() {
-
- // always decrement
- modelStateChanging--;
- // to be less than zero is a programming error, but we'll reset to zero
- // with no error messages.
- if (modelStateChanging < 0)
- modelStateChanging = 0;
- // We only fire this event if all pending requests are done.
- // That is, if we've received the same number of fireModelChanged as we
- // have fireModelAboutToBeChanged.
- if (modelStateChanging == 0) {
- // 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
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelChanged(this);
- }
- }
- }
- }
-
- /**
- * Informs all registered model state listeners about a change in the dirty
- * state of the model. The dirty state is entirely about changes in the
- * content of the model (not, for example, about changes to id, or base
- * location -- see modelMoved).
- */
- protected void fireModelDirtyStateChanged(IStructuredModel element, boolean isDirty) {
-
- // 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
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelDirtyStateChanged(element, isDirty);
- }
- }
- }
-
- /**
- * Informs all registered model state listeners about the deletion of a
- * model's underlying resource.
- */
- protected void fireModelResourceDeleted(IStructuredModel element) {
-
- // 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
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelResourceDeleted(element);
- }
- }
- }
-
- /**
- * Informs all registered model state listeners that the resource
- * underlying a model has been moved. This is typically reflected in a
- * change to the id, baseLocation, or both.
- */
- protected void fireModelResourceMoved(IStructuredModel originalElement, IStructuredModel movedElement) {
-
- // 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
- if (fModelStateListeners != null) {
- Object[] holdListeners = fModelStateListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelStateListener) holdListeners[i]).modelResourceMoved(originalElement, movedElement);
- }
- }
- }
-
- /**
- * @return java.lang.String
- */
- public java.lang.String getBaseLocation() {
-
- return fBaseLocation;
- }
-
- /**
- *
- */
- public IFactoryRegistry getFactoryRegistry() {
-
- if (factoryRegistry == null) {
- factoryRegistry = new FactoryRegistry();
- }
- return factoryRegistry;
- }
-
- public IStructuredDocument getStructuredDocument() {
-
- return fStructuredDocument;
- }
-
- /**
- * The id is the id that the model manager uses to identify this model
- */
- public String getId() {
-
- return fId;
- }
-
- /**
- * This method returns a mememto that can later be used to restore the
- * state at this point. A model's state, in this sense, does not relate to
- * its content, or Ids, etc., just its dirty state, and its synchronization
- * state with its underlying resource. The 'resource' argument must be the
- * resource that underlies the instance of the model this method is sent
- * to. Note: this parameter will not be required in future versions of
- * 'strucutured model'.
- */
- public IStateMemento getMemento(IResource resource) {
-
- ModelStateMemento memento = new ModelStateMemento();
- memento.setUnderlyingResource(resource);
- memento.setDirtyState(isDirty());
- long modDate = computeModificationStamp(resource);
- memento.setDatesInSync(fSynchronizationStamp == modDate);
- return memento;
- }
-
- /**
- * This method is just for getting an instance of the model manager of the
- * right Impl type, to be used "internally" for making protected calls
- * directly to the impl class.
- */
- // TODO: those places we now use non-public methods can now be fixed.
- private ModelManagerImpl _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();
- }
- if (!(fModelManager instanceof ModelManagerImpl)) {
- throw new IllegalStateException(ResourceHandler1.getString("unexpected_ModelManager_Impl_1")); //$NON-NLS-1$
- }
- return (ModelManagerImpl) fModelManager;
- }
-
- /**
- */
- public IModelManager getModelManager() {
-
- return _getModelManager();
- }
-
- public abstract IndexedRegion getIndexedRegion(int offset);
-
- /**
- * This function returns the reference count of underlying model.
- */
- // TODO: try to refine the design not to use this function
- public synchronized int getReferenceCount() {
-
- if (getModelManager() == null)
- return 0;
- return getModelManager().getReferenceCount(getId());
- }
-
- /**
- * This function returns the reference count of underlying model.
- */
- // TODO: try to refine the design not to use this function
- public synchronized int getReferenceCountForEdit() {
-
- if (getModelManager() == null)
- return 0;
- return getModelManager().getReferenceCountForEdit(getId());
- }
-
- /**
- * This function returns the reference count of underlying model.
- */
- // TODO: try to refine the design not to use this function
- public synchronized int getReferenceCountForRead() {
-
- if (getModelManager() == null)
- return 0;
- return getModelManager().getReferenceCountForRead(getId());
- }
-
- /**
- */
- public URIResolver getResolver() {
-
- return fResolver;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 2:30:26
- * PM)
- *
- * @return long
- */
- public long getSynchronizationStamp() {
-
- return fSynchronizationStamp;
- }
-
- public StructuredTextUndoManager getUndoManager() {
-
- return fUndoManager;
- }
-
- public boolean isDirty() {
-
- return fDirtyState;
- }
-
- /**
- * This method can be called to determine if the model is within a
- * "aboutToChange" and "changed" sequence.
- */
- public synchronized boolean isModelStateChanging() {
-
- return modelStateChanging > 0;
- }
-
- public boolean isNew() {
-
- return fNewState;
- }
-
- public synchronized boolean isSaveNeeded() {
-
- if (!isSharedForEdit())
- return isDirty();
- else
- return false;
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public synchronized boolean isShared() {
-
- if (getModelManager() == null)
- return false;
- return getModelManager().isShared(getId());
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public synchronized boolean isSharedForEdit() {
-
- if (getModelManager() == null)
- return false;
- return getModelManager().isSharedForEdit(getId());
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public synchronized boolean isSharedForRead() {
-
- if (getModelManager() == null)
- return false;
- return getModelManager().isSharedForRead(getId());
- }
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- */
- public synchronized void releaseFromEdit() {
-
- if (getModelManager() == null) {
- throw new SourceEditingRuntimeException("Warning: AbstractStructuredModel::close: model manager was null during a close of a model (which should be impossible)"); //$NON-NLS-1$
- }
- else {
- // be sure to check the shared state before releasing. (Since
- // isShared assumes a count
- // of 1 means not shared ... and we want our '1' to be that one.)
- boolean isShared = isShared();
- _getModelManager().releaseFromEdit(getId());
- // if no one else is using us, free up
- // an resources
- if (!isShared) {
- _commonRelease();
- }
- }
- }
-
- private void _commonRelease() {
-
- if (factoryRegistry != null) {
- factoryRegistry.release();
- }
- // if document as not been changed, we'll still be listening for
- // first change. This is not a critical clean up, since presumanly
- // whole model and document are "going away", but can make
- // other memory leaks harder to find if we stay attached.
- // (Note: my first thought was to set fStructuredDocument to null also,
- // but there's others in shutdown process that still need to
- // get it, in order to disconnect from it.)
- if (fStructuredDocument != null) {
- fStructuredDocument.removeModelChangedListener(fDirtyStateWatcher);
- }
- }
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- */
- public synchronized void releaseFromRead() {
-
- if (getModelManager() == null) {
- throw new SourceEditingRuntimeException("Warning: AbstractStructuredModel::close: model manager was null during a close of a model (which should be impossible)"); //$NON-NLS-1$
- }
- else {
- // be sure to check the shared state before releasing. (Since
- // isShared assumes a count
- // of 1 means not shared ... and we want our '1' to be that one.)
- boolean isShared = isShared();
- _getModelManager().releaseFromRead(getId());
- // if no one else is using us, free up
- // an resources
- if (!isShared) {
- // factoryRegistry.release();
- _commonRelease();
- }
- }
- }
-
- /**
- * This function replenishes the model with the resource without saving any
- * possible changes. It is used when one editor may be closing, and
- * specifially says not to save the model, but another "display" of the
- * model still needs to hang on to some model, so needs a fresh copy.
- */
- public synchronized IStructuredModel reload(InputStream inputStream) throws IOException {
-
- IStructuredModel result = null;
- try {
- aboutToChangeModel();
- result = _getModelManager().reloadModel(getId(), inputStream);
- }
- catch (UnsupportedEncodingException e) {
- // its a very serious error to get an unsupported encoding
- // exception,
- // since we've presumable loaded it once already, so won't bother
- // with a checked exception.
- throw new SourceEditingRuntimeException(e);
- }
- finally {
- changedModel();
- }
- return result;
- }
-
- public synchronized IStructuredModel reinit() {
-
- IStructuredModel result = null;
- if (modelStateChanging == 0) {
- try {
- aboutToChangeModel();
- aboutToReinitializeModel();
- result = _getModelManager().reinitialize(this);
- }
- finally {
- setReinitializeNeeded(false);
- setReinitializeStateData(null);
- modelReinitialized();
- changedModel();
- }
- }
- else {
- System.out.println("indeed!!!"); //$NON-NLS-1$
- }
- return result;
- }
-
- public synchronized void save(OutputStream outputStream) throws UnsupportedEncodingException, CoreException, IOException {
-
- String stringId = getId();
- _getModelManager().saveModel(stringId, outputStream, EncodingRule.CONTENT_BASED);
- }
-
- public synchronized void save() throws UnsupportedEncodingException, IOException, CoreException {
-
- String stringId = getId();
- _getModelManager().saveModel(stringId, EncodingRule.CONTENT_BASED);
- }
-
- public synchronized void save(EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- String stringId = getId();
- _getModelManager().saveModel(stringId, encodingRule);
- }
-
- public synchronized void save(IFile iFile) throws UnsupportedEncodingException, IOException, CoreException {
-
- String stringId = getId();
- _getModelManager().saveModel(iFile, stringId, EncodingRule.CONTENT_BASED);
- }
-
- public synchronized void save(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- String stringId = getId();
- _getModelManager().saveModel(iFile, stringId, encodingRule);
- }
-
- public synchronized void removeModelStateListener(IModelStateListener listener) {
-
- if ((fModelStateListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fModelStateListeners, listener)) {
- int oldSize = fModelStateListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fModelStateListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fModelStateListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fModelStateListeners = newListeners;
- }
- }
- }
-
- /**
- * A method that modififies the model's synchonization stamp to match the
- * resource. Turns out there's several ways of doing it, so this ensures a
- * common algorithm.
- */
- public synchronized void resetSynchronizationStamp(IResource resource) {
-
- setSynchronizationStamp(computeModificationStamp(resource));
- }
-
- /**
- * This API allows a client to initiate notification to all interested
- * parties that a model's underlying resource has been deleted.
- */
- public synchronized void resourceDeleted() {
-
- // notice this is just a public avenue to our protected method
- fireModelResourceDeleted(this);
- }
-
- /**
- * This method allows a model client to initiate notification to all
- * interested parties that a model's underlying resource location has
- * changed. Note: we assume caller has already changed baseLocation, Id,
- * etc., since its really up to the client to determine what's "new" about
- * a moved model. Caution: 'this' and 'newModel' may be the same object.
- * This is the case for current working with FileModelProvider, but have
- * left the dual argument for future possiblities.
- */
- public synchronized void resourceMoved(IStructuredModel newModel) {
-
- // notice this is just a public avenue to our protected method
- fireModelResourceMoved(this, newModel);
- }
-
- public synchronized void restoreState(IStateMemento memento) {
-
- ModelStateMemento mMemento = (ModelStateMemento) memento;
- // be sure to use setter, so side effects take place.
- setDirtyState(mMemento.isDirtyState());
- if (mMemento.isDatesInSync()) {
- IResource resource = mMemento.getUnderlyingResource();
- setSynchronizationStamp(computeModificationStamp(resource));
- }
- }
-
- /**
- * This attribute is typically used to denote the model's underlying
- * resource.
- */
- public void setBaseLocation(java.lang.String newBaseLocation) {
-
- fBaseLocation = newBaseLocation;
- }
-
- /**
- *
- */
- public void setDirtyState(boolean dirtyState) {
-
- // no need to process (set or fire event), if same value
- if (fDirtyState != dirtyState) {
- // prechange notificaiton
- int type = ModelLifecycleEvent.MODEL_DIRTY_STATE | ModelLifecycleEvent.PRE_EVENT;
- ModelLifecycleEvent modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
-
-
- // the actual change
- fDirtyState = dirtyState;
-
- // old notification
- // TODO: C3 remove old notification
- if (fDirtyState == false) {
- // if we are being set to not dirty (such as just been saved)
- // then we need to start listening for changes
- // again to know when to set state to true;
- getStructuredDocument().addModelChangedListener(fDirtyStateWatcher);
- }
- fireModelDirtyStateChanged(this, dirtyState);
-
-
- // post change notification
- type = ModelLifecycleEvent.MODEL_DIRTY_STATE | ModelLifecycleEvent.POST_EVENT;
- modelLifecycleEvent = new ModelLifecycleEvent(this, type);
- signalLifecycleEvent(modelLifecycleEvent);
- }
- }
-
- /**
- * @param newStructuredDocument
- */
- public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
-
- if (fStructuredDocument != null)
- fStructuredDocument.removeModelChangedListener(fDirtyStateWatcher);
-
- // prechange notificaiton
- ModelLifecycleEvent modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.PRE_EVENT, this, fStructuredDocument, newStructuredDocument);
- signalLifecycleEvent(modelLifecycleEvent);
-
- // the actual change
- fStructuredDocument = newStructuredDocument;
-
-
- // at the super class level, we'll listen for structuredDocument
- // changes
- // so we can set our dirty state flag
- fStructuredDocument.addModelChangedListener(fDirtyStateWatcher);
-
- // post change notification
- modelLifecycleEvent = new DocumentChanged(ModelLifecycleEvent.POST_EVENT, this, fStructuredDocument, newStructuredDocument);
- signalLifecycleEvent(modelLifecycleEvent);
- }
-
- /**
- * The id is the id that the model manager uses to identify this model. If
- * it is being set here, it means the model manger is already managing the
- * model with another id, so we have to keep it in sync. This method calls
- * notifies listners, if they haven't been notified already, that a "model
- * state change" is about to occur.
- */
- public synchronized void setId(String newId) throws ResourceInUse {
-
- // It makes no sense, I don't think, to have an id of null, so we'll
- // throw
- // an illegal argument exception if someone trys. Note: the
- // IModelManager could
- // not manage a model with an id of null, since it uses hashtables, and
- // you can't
- // have a null id for a hashtable.
- if (newId == null)
- throw new IllegalArgumentException(ResourceHandler1.getString("A_model's_id_can_not_be_nu_EXC_")); //$NON-NLS-1$ = "A model's id can not be null"
- // To gaurd againt throwing a spurious ResourceInUse exception, which
- // can occur
- // when two pieces of code both want to change the id, so the second
- // request is
- // spurious, we'll ignore any requests that attempt to change the id to
- // what it
- // already is ... note, we use 'equals', not identity ('==') so that
- // things like
- // strings can be used. This is the same criteria that ids are found in
- // model manager
- // -- well, actually, I just checked, and for the hashtable impl, the
- // criteria uses .equals AND the condition that the hash values be
- // identical
- // (I'm assuming this is always true, if equals is true, for now, I'm
- // not sure
- // we can assume that hashtable will always be used, but in general,
- // should match.)
- //
- if (newId.equals(fId))
- return;
- // we must gaurd against reassigning an id to one that we already are
- // managing.
- if (getModelManager() != null) {
- IStructuredModel newModel = getModelManager().getExistingModelForEdit(newId);
- if (newModel != null) {
- // be sure to release the reference we got "by accident" (and
- // no longer need)
- newModel.releaseFromEdit();
- throw new ResourceInUse();
- }
- }
- try {
- // normal path
- aboutToChangeModel();
- String oldId = fId;
- fId = newId;
- if (getModelManager() != null) {
- // if managed and the id has changed, notify to IModelManager
- // TODO: try to refine the design not to do that
- if (oldId != null && newId != null && !newId.equals(oldId)) {
- getModelManager().moveModel(oldId, newId);
- }
- }
- }
- finally {
- // make sure this finally is only executed if 'about to Change
- // model' has
- // ben executed.
- changedModel();
- }
- }
-
- /**
- * @param newModelManager
- */
- public void setModelManager(IModelManager newModelManager) {
-
- fModelManager = newModelManager;
- }
-
- /**
- *
- */
- public void setNewState(boolean newState) {
-
- fNewState = newState;
- }
-
- /**
- * @param newResolver
- */
- public void setResolver(URIResolver newResolver) {
-
- fResolver = newResolver;
- }
-
- /**
- * Insert the method's description here. Creation date: (9/7/2001 2:30:26
- * PM)
- *
- * @param newSynchronizationStamp
- * long
- */
- protected void setSynchronizationStamp(long newSynchronizationStamp) {
-
- fSynchronizationStamp = newSynchronizationStamp;
- }
-
- public void setUndoManager(StructuredTextUndoManager undoManager) {
-
- fUndoManager = undoManager;
- }
-
- /**
- * Gets the contentTypeDescription.
- *
- * @return Returns a ContentTypeDescription
- */
- public IModelHandler getModelHandler() {
-
- return fModelHandler;
- }
-
- /**
- * Sets the contentTypeDescription.
- *
- * @param contentTypeDescription
- * The contentTypeDescription to set
- */
- public void setModelHandler(IModelHandler modelHandler) {
-
- // no need to fire events if modelHandler has been null
- // for this model --
- // this is an attempt at initialization optimization and may need
- // to change in future.
- boolean fireEvents = false;
- if (fModelHandler != null)
- fireEvents = true;
- if (fireEvents) {
- fireModelAboutToBeChanged();
- }
- fModelHandler = modelHandler;
- if (fireEvents) {
- fireModelChanged();
- }
- }
-
- public IStructuredModel newInstance() throws IOException {
-
- IStructuredModel newModel = null;
- // we delegate to the model manager, so loader, etc., can be
- // used.
- newModel = getModelManager().createNewInstance(this);
- return newModel;
- }
-
- /**
- * Sets a "flag" that reinitialization is needed.
- */
- public void setReinitializeNeeded(boolean needed) {
-
- reinitializationNeeded = needed;
- }
-
- public boolean isReinitializationNeeded() {
-
- return reinitializationNeeded;
- }
-
- /**
- * Holds any data that the reinit procedure might find useful in
- * reinitializing the model. This is handy, since the reinitialization may
- * not take place at once, and some "old" data may be needed to properly
- * undo previous settings. Note: the parameter was intentially made to be
- * of type 'Object' so different models can use in different ways.
- */
- public void setReinitializeStateData(Object object) {
-
- reinitializeStateData = object;
- }
-
- public Object getReinitializeStateData() {
-
- return reinitializeStateData;
- }
-
- /**
- * @see org.eclipse.wst.sse.core.IStructuredModel#getContentTypeIdentifier()
- */
- public String getContentTypeIdentifier() {
-
- return getModelHandler().getAssociatedContentTypeId();
- }
-
- public Object getAdapter(Class adapter) {
-
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.java
deleted file mode 100644
index 178fbe42ed..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/AdapterFactory.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.core;
-
-
-
-public interface AdapterFactory {
-
- /**
- * Method that returns the adapter associated with the given object.
- * It may be a singleton or not ... depending on the needs of the INodeAdapter ...
- * but in general it is recommended for an adapter to be stateless,
- * so the efficiencies of a singleton can be gained.
- *
- * The implementation of this method should call addAdapter on the adapted
- * object with the correct instance of the adapter.
- */
- INodeAdapter adapt(INodeNotifier object);
-
- boolean isFactoryForType(Object type);
-
- /**
- *
- */
- public void release();
-
- /**
- * returns an instance of the adapter factory. Unlike clone,
- * this method may return the same instance, such as in the case
- * where the AdapterFactory is intended to be a singleton.
- */
- public AdapterFactory copy();
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.java
deleted file mode 100644
index b8f8cdcb2f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/DocumentChanged.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.core;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-public class DocumentChanged extends ModelLifecycleEvent {
-
- private IStructuredDocument fOldDocument;
- private IStructuredDocument fNewDocument;
-
- protected DocumentChanged() {
-
- super(ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED);
-
- }
-
- protected DocumentChanged(int additionalType, IStructuredModel model) {
-
- super(model, ModelLifecycleEvent.MODEL_DOCUMENT_CHANGED | additionalType);
-
- }
-
- public DocumentChanged(int additionalType, IStructuredModel model, IStructuredDocument oldDocument, IStructuredDocument newDocument) {
-
- this(additionalType, model);
- fOldDocument = oldDocument;
- fNewDocument = newDocument;
- }
-
- public IStructuredDocument getNewDocument() {
-
- return fNewDocument;
- }
-
- void setNewDocument(IStructuredDocument newDocument) {
-
- fNewDocument = newDocument;
- }
-
- public IStructuredDocument getOldDocument() {
-
- return fOldDocument;
- }
-
- void setOldDocument(IStructuredDocument oldDocument) {
-
- fOldDocument = oldDocument;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.java
deleted file mode 100644
index 333a71134c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/FactoryRegistry.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.core;
-
-
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-/**
- * This class simply maintains the list of factories and
- * returns singleton instances of them. Some "built in"
- * types are automatically created form FactoryConfig,
- * if not found registerd, but normally clients can/should
- * register their own factories.
- *
- */
-public class FactoryRegistry implements IFactoryRegistry {
-
- private List factories;
-
- /**
- *
- */
- public FactoryRegistry() {
- super();
-
- }
-
- public void addFactory(AdapterFactory factory) {
- _getFactories().add(factory);
- }
-
- protected List _getFactories() {
-
- if (factories == null) {
- // may need to use java.util.Collections.synchronizedList() if syncronization becomes
- // necessary (and if so, remember to synchronize on factories)
- factories = new ArrayList();
- }
- return factories;
-
- }
-
- /**
- * This method is a not a pure resistry. Factories retrieved based on their response
- * to "isFactoryForType(type)". Note that if there is more than one factory that can
- * answer 'true' that the most recently added factory is used.
- */
- public AdapterFactory getFactoryFor(Object type) {
-
- AdapterFactory result = null;
- if (factories == null)
- return null;
- int listSize = factories.size();
- for (int i = listSize - 1; i >= 0; i--) {
- // It is the adapter factories responsibility to answer isFactoryForType so it gets choosen.
- // Notice we are going through the list backwards to get the factory added last.
- AdapterFactory a = (AdapterFactory) factories.get(i);
- if (a.isFactoryForType(type)) {
- result = a;
- break;
- }
- }
- return result;
-
- }
-
- /**
- *
- */
- public void release() {
- // modified to work on copy of list, for V5PTF1
- // send release to local copy of list
- // of factories, since some factories, during
- // their release function, may remove
- // themselves from the registry.
- List localList = getFactories();
- Iterator factoryIterator = localList.iterator();
- while (factoryIterator.hasNext()) {
- AdapterFactory a = (AdapterFactory) factoryIterator.next();
- // to help bullet proof code, we'll catch and log
- // any messages thrown by factories during release,
- // but we'll attempt to keep going.
- // In nearly all cases, though, such errors are
- // severe for product/client, and need to be fixed.
- try {
- a.release();
- }
- catch (Exception e) {
- Logger.logException("Program problem releasing factory" + a, e); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * Removes a factory if it can be retrieved by getFactoryFor(type). If there
- * is more than one, all are removed. If there is none, the call simply returns
- * (that is, it is not considered an error).
- */
- public void removeFactoriesFor(java.lang.Object type) {
- if (factories != null) {
- int listSize = factories.size();
- // we'll go backwards through list, since we're removing, so 'size' change won't matter.
- // Note: I'm assuming other items in the collection do not change position
- // simply because another was removed.
- for (int i = listSize - 1; i >= 0; i--) {
- // It is the adapter factories responsibility to answer isFactoryForType so it gets choosen.
- AdapterFactory a = (AdapterFactory) factories.get(i);
- if (a.isFactoryForType(type)) {
- factories.remove(a);
- }
- }
- }
- }
-
- public void removeFactory(AdapterFactory factory) {
- _getFactories().remove(factory);
-
- }
-
- /**
- * Returns a shallow cloned list of the factories
- * in the registry. Note: this can not be used to
- * add/remove factories. Its primarily provided for
- * those few cases where a list of factories must be
- * copied from one model and added to another.
- */
- public List getFactories() {
- // note: for object integrity, we don't let anyone get
- // our main list (so they have to add through addFactory),
- // but we will return a shallow "cloned" list.
- List factoryList = new ArrayList();
- List internalList = _getFactories();
- Iterator internalListIterator = internalList.iterator();
- while (internalListIterator.hasNext()) {
- // we assume they are all already AdapterFactories,
- // but no profit in casting here
- Object factory = internalListIterator.next();
- factoryList.add(factory);
- }
- return factoryList;
- }
-
- /*
- * @see IFactoryRegistry#contains(Object)
- */
- public boolean contains(Object type) {
- boolean result = false;
- // note: we're not using cloned list, so stricly speaking
- // is not thread safe.
- List internalList = _getFactories();
- Iterator internalListIterator = internalList.iterator();
- while (internalListIterator.hasNext()) {
- AdapterFactory factory = (AdapterFactory) internalListIterator.next();
- if (factory.isFactoryForType(type)) {
- result = true;
- break;
- }
- }
- return result;
- }
-
- public void clearFactories() {
- factories.clear();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.java
deleted file mode 100644
index 4d3c80e5e6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IFactoryRegistry.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.core;
-
-
-
-import java.util.List;
-
-public interface IFactoryRegistry {
-
- void addFactory(AdapterFactory factory);
-
- /**
- * This method is a not a pure resistry. Factories retrieved based on their response
- * to "isFactoryForType(type)". Note that if there is more than one factory that can
- * answer 'true' that the most recently added factory is used.
- */
- AdapterFactory getFactoryFor(Object type);
-
- /**
- *
- */
- void release();
-
- /**
- * Removes a factory if it can be retrieved by getFactoryFor(type). If there
- * is more than one, all are removed. If there is none, the call simply returns
- * (that is, it is not considered an error).
- */
- void removeFactoriesFor(Object type);
-
- void removeFactory(AdapterFactory factory);
-
- /**
- * Returns a shallow cloned list of the factories
- * in the registry.
- */
- List getFactories();
-
- /**
- * returns true if already contains a factory for the
- * given type. This is purely a convenience method for
- * those few cases that want to avoid adding a factory
- * if it is already in the registry.
- */
- boolean contains(Object type);
-
- void clearFactories();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.java
deleted file mode 100644
index fd27cb95cf..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelLifecycleListener.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.core;
-
-/**
- * This is an early version of a class that may change over the
- * next few milestones.
- */
-
-public interface IModelLifecycleListener {
- void processPreModelEvent(ModelLifecycleEvent event);
-
- void processPostModelEvent(ModelLifecycleEvent event);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.java
deleted file mode 100644
index 8b847a353b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManager.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.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Enumeration;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.URIResolver;
-
-
-/**
- * Responsible for providing a set of APIs for creating a new model manager, for managing (add or remove)
- * model loaders and model dumpers, and for managing (get, release, save, and save as) models.
- */
-public interface IModelManager {
-
- public final static String DUPLICATED_MODEL = "org.eclipse.wst.sse.core.IModelManager.DUPLICATED_MODEL"; //$NON-NLS-1$
- public final static String UNMANAGED_MODEL = "org.eclipse.wst.sse.core.IModelManager.UNMANAGED_MODEL"; //$NON-NLS-1$
-
- /**
- * This API allows clients to declare that they are about to make
- * a "large" change to the model. This change
- * might be in terms of content or it might be in terms of
- * the model id or base location.
- *
- * Note that in the case of embedded calls, notification to
- * listners is sent only once.
- *
- * The method isModelStateChanging can be used by a client
- * to determin if the model is already in a change sequence.
- */
- void aboutToChangeModels();
-
- /**
- * Conveience method, since a proper IStructuredDocument must have
- * a proper parser assigned.
- */
- IStructuredDocument createStructuredDocumentFor(IFile iFile) throws IOException, CoreException;
-
- /**
- * Conveience method, since a proper IStructuredDocument must have
- * a proper parser assigned. It should only be used when an
- * empty structuredDocument is needed. Otherwise, use
- * IFile form.
- */
- IStructuredDocument createStructuredDocumentFor(String contentTypeId);
-
- /**
- * @deprecated -- I marked as deprecated to discouage use
- * of this method. It does not really work for JSP fragments,
- * since JSP Fragments need an IFile to correctly look up
- * the content settings. Use IFile form instead. Note:
- * some confustion with it and the form for HTPP encoding,
- * so once a null arg is allowed in that API ... we can remove this one.
- * (after verifying again with Tom/Linksbuild)
- */
- IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver) throws IOException;
-
- IStructuredDocument createStructuredDocumentFor(String filename, String content, URIResolver resolver) throws IOException;
-
- IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver, String ianaEncodingName) throws IOException;
-
- /**
- * Conveience method. It depends on the loaders
- * newModel method to return an appropriate StrucuturedModel
- * appropriately initialized.
- */
- IStructuredModel createUnManagedStructuredModelFor(IFile iFile) throws IOException, CoreException;
-
- /**
- * Conveience method. It depends on the loaders
- * newModel method to return an appropriate StrucuturedModel
- * appropriately initialized.
- */
- IStructuredModel createUnManagedStructuredModelFor(String contentTypeId);
-
- IStructuredModel createUnManagedStructuredModelFor(String contentTypeId, URIResolver resolver);
-
- void addModelManagerListener(IModelManagerListener listener);
-
- /**
- * This API allows a client controlled way of notifying all ModelEvent
- * listners that the model has been changed. This method is a matched pair
- * to aboutToChangeModel, and must be called
- * after aboutToChangeModel ... or some listeners could be left waiting indefinitely
- * for the changed event. So, its suggested that changedModel always be in
- * a finally clause. Likewise, a client should never call changedModel without
- * calling aboutToChangeModel first.
- *
- * In the case of embedded calls, the notification is just sent once.
- *
- */
- void changedModels();
-
- IStructuredModel copyModelForEdit(String oldId, String newId) throws ResourceInUse;
-
- /**
- * This is similar to the getModel method, except this method does not create a model.
- * This method does increment the reference count (if it exists).
- * If the model does not already exist in the cache of models, null is returned.
- */
- public IStructuredModel getExistingModelForEdit(Object id);
-
- public IStructuredModel getExistingModelForEdit(IFile iFile);
-
- /**
- * This is similar to the getModel method, except this method does not create a model.
- * This method does increment the reference count (if it exists).
- * If the model does not already exist in the cache of models, null is returned.
- */
- public IStructuredModel getExistingModelForRead(Object id);
-
- public IStructuredModel getExistingModelForRead(IFile iFile);
-
- public Enumeration getExistingModelIds();
-
- public IStructuredModel getModelForEdit(IFile iFile) throws IOException, CoreException;
-
- public IStructuredModel getModelForEdit(IFile iFile, String encoding, String lineDelimiter) throws java.io.UnsupportedEncodingException, IOException, CoreException;
-
- public IStructuredModel getModelForEdit(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- public IStructuredModel getModelForRead(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- public IStructuredModel getModelForRead(IFile iFile) throws IOException, CoreException;
-
- public IStructuredModel getModelForRead(IFile iFile, String encoding, String lineDelimiter) throws java.io.UnsupportedEncodingException, IOException, CoreException;
-
- public IStructuredModel getModelForEdit(String filename, InputStream inStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException;
-
- public IStructuredModel getModelForRead(String filename, InputStream inStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException;
-
- /**
- * This method will not create a new model if it already exists ... if force is false.
- * The idea is that a client should call this method once with force set to false.
- * If the exception is thrown, then prompt client if they want to overwrite.
- */
- IStructuredModel getNewModelForEdit(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException;
-
- /**
- * This method will not create a new model if it already exists ... if force is false.
- * The idea is that a client should call this method once with force set to false.
- * If the exception is thrown, then prompt client if they want to overwrite.
- */
- IStructuredModel getNewModelForRead(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException;
-
- /**
- * This function returns the reference count of underlying model.
- * @param id Object The id of the model
- * TODO: try to refine the design not to use this function
- */
- int getReferenceCount(Object id);
-
- /**
- * This function returns the reference count of underlying model.
- * @param id Object The id of the model
- * TODO: try to refine the design not to use this function
- */
- int getReferenceCountForEdit(Object id);
-
- /**
- * This function returns the reference count of underlying model.
- * @param id Object The id of the model
- * TODO: try to refine the design not to use this function
- */
- int getReferenceCountForRead(Object id);
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- * @param id Object The id of the model
- */
- boolean isShared(Object id);
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- * @param id Object The id of the model
- */
- boolean isSharedForEdit(Object id);
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- * @param id Object The id of the model
- */
- boolean isSharedForRead(Object id);
-
- /**
- * This method can be called to determine if the model manager is within a "aboutToChange" and "changed" sequence.
- */
- public boolean isStateChanging();
-
- /**
- * This method changes the id of the model.
- * TODO: try to refine the design not to use this function
- */
- void moveModel(Object oldId, Object newId);
-
- /**
- * This is similar to the getModel method, except this method does not use the cached version,
- * but forces the cached version to be replaced with a fresh, unchanged version. Note: this method
- * does not change any reference counts. Also, if there is not already a cached version of the
- * model, then this call is essentially ignored (that is, it does not put a model in the cache) and
- * returns null.
- */
- IStructuredModel reloadModel(Object id, InputStream inStream) throws UnsupportedEncodingException;
-
- /**
- * This method can be called when the content type of a model
- * changes. Its assumed the contentType has already been changed,
- * and this method uses the text of the old one, to repopulate the
- * text of the new one. In theory, the actual instance could change,
- * (e.g. using 'saveAs' to go from xml to dtd), but in practice,
- * the intent of this API is to return the same instance, just using
- * different handlers, adapter factories, etc.
- */
- IStructuredModel reinitialize(IStructuredModel model) throws IOException;
-
- void removeModelManagerListener(IModelManagerListener listener);
-
- void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile) throws UnsupportedEncodingException, IOException, CoreException;
-
- /**
- * Calculate id provides a common way to determine the id from the input ... needed to
- * get and save the model. It is a simple class utility, but is an
- * instance method so can be accessed via interface.
- */
- public String calculateId(IFile file);
-
- /**
- * CalculateBaseLocation provides a common way to determine the baseLocation from the input.
- * The 'setBaseLocation' must still be called for a IStructuredModel, by the client using/creating it,
- * but this providides a convenient way to get a common value, if desired.
- * @deprecated is this still needed?
- */
- public String calculateBaseLocation(IFile file);
-
- /**
- * createNewInstance is similar to clone, except the new instance has no content.
- * Note: this produces an unmanaged model, for temporary use.
- * If a true shared model is desired, use "copy".
- */
- public IStructuredModel createNewInstance(IStructuredModel model) throws IOException;
-
- /**
- * Note: users of this 'model' must still release it
- * when finished.
- * Returns null if there's not a model corresponding to document.
- */
- IStructuredModel getExistingModelForRead(IDocument document);
-
- /**
- * Note: users of this 'model' must still release it
- * when finished.
- * Returns null if there's not a model corresponding to document.
- */
- IStructuredModel getExistingModelForEdit(IDocument document);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.java
deleted file mode 100644
index e19e9c5f1f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerListener.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.core;
-
-
-
-/**
- * Interface for those wanting to listen to events fired by the model manager.
- */
-public interface IModelManagerListener {
-
- /**
- * One or more models are about to be changed. This typically is initiated by
- * one client of the model (such as LinksBuilder), to signal that several models
- * are about to be changed. These models might be interrelated, so a listener
- * (such as FrameManger) will know to a "massive" change is about to take place.
- */
- void modelsAboutToBeChanged();
-
- /**
- * Signals that the changes foretold by modelsAboutToBeChanged have been made.
- * A typical use might be to refresh, or to resume processing that was suspended
- * as a result of modelsAboutToBeChanged.
- */
- void modelsChanged();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java
deleted file mode 100644
index eac5e3beed..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelManagerPlugin.java
+++ /dev/null
@@ -1,34 +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.core;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-
-
-/**
- * @author davidw
- *
- * To change the template for this generated type comment go to
- * Window>Preferences>Java>Code Generation>Code and Comments
- */
-public interface IModelManagerPlugin {
- // private static ModelManagerPlugin instance;
- public final static String ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
-
- public abstract IModelManager getModelManager();
-
- public abstract ModelHandlerRegistry getModelHandlerRegistry();
-
- public Preferences getPluginPreferences();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.java
deleted file mode 100644
index c626467fed..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListener.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.core;
-
-
-
-/**
- * Interface for those wanting to listen to a model's state changing.
- */
-public interface IModelStateListener {
-
- /**
- * A model is about to be changed. This typically is initiated by
- * one client of the model, to signal a large change and/or a change
- * to the model's ID or base Location. A typical use might be if a
- * client might want to suspend processing until all changes have
- * been made.
- */
- void modelAboutToBeChanged(IStructuredModel model);
-
- /**
- * Signals that the changes foretold by modelAboutToBeChanged have been made.
- * A typical use might be to refresh, or to resume processing that was suspended
- * as a result of modelAboutToBeChanged.
- */
- void modelChanged(IStructuredModel model);
-
- /**
- * Notifies that a model's dirty state has changed, and passes that
- * state in isDirty.
- * A model becomes dirty when any change is made, and becomes not-dirty
- * when the model is saved.
- */
- void modelDirtyStateChanged(IStructuredModel model, boolean isDirty);
-
- /**
- * A modelDeleted means the underlying resource has been deleted. The model
- * itself is not removed from model management until all have released it.
- * Note: baseLocation is not (necessarily) changed in this event, but may not be
- * accurate.
- */
- void modelResourceDeleted(IStructuredModel model);
-
- /**
- * A model has been renamed or copied (as in saveAs..). In the renamed case, the
- * two paramenters are the same instance, and only contain the new info for id and
- * base location.
- */
- void modelResourceMoved(IStructuredModel oldModel, IStructuredModel newModel);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.java
deleted file mode 100644
index 1b9b71f6da..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IModelStateListenerExtended.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.core;
-
-
-
-/**
- * This interface defines two new model level events. In order to avoid
- * unnecessary last minute changes from clients, this interface was created
- * as a "stop gap" measure. Eventually, it will become part of the normal
- * ModelStateListener interface.
- */
-public interface IModelStateListenerExtended extends IModelStateListener {
-
-
- void modelAboutToBeReinitialized(IStructuredModel structuredModel);
-
- void modelReinitialized(IStructuredModel structuredModel);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.java
deleted file mode 100644
index 6ce59946f0..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeAdapter.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.core;
-
-
-
-public interface INodeAdapter {
-
- /**
- * Allowing the INodeAdapter to compare itself against the type
- * allows it to return true in more than one case.
- */
- boolean isAdapterForType(Object type);
-
- /**
- */
- void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java
deleted file mode 100644
index 73a27ce019..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/INodeNotifier.java
+++ /dev/null
@@ -1,62 +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.core;
-
-
-
-import java.util.Collection;
-
-public interface INodeNotifier {
-
- // Possible values for eventType
- static final int CHANGE = 1; // update - non structural
- static final int ADD = 2;
- static final int REMOVE = 3;
- static final int STRUCTURE_CHANGED = 4; // sent in addition to adds and removed
- // when large changes are made to a sub-tree
- static final int CONTENT_CHANGED = 5; // sent to the parent notifier
- // these strings are for printing, such as during debuging
- static final String[] EVENT_TYPE_STRINGS = new String[]{"undefined", "CHANGE", "ADD", "REMOVE", "STRUCUTRED_CHANGED", "CONTENT_CHANGED"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
-
- // when the child value changed
-
- /**
- * Add an adapter of this notifier.
- */
- void addAdapter(INodeAdapter o);
-
- /**
- * Return an exisiting adapter of type "type" or if none found create
- * a new adapter using a registered adapter factory
- */
- INodeAdapter getAdapterFor(Object type);
-
- /**
- * Return a read-only Collection of the Adapters to this notifier.
- */
- Collection getAdapters();
-
- /**
- * Return an exisiting adapter of type "type" or null if none found
- */
- INodeAdapter getExistingAdapter(Object type);
-
- /**
- */
- void notify(int eventType, Object changedFeature, Object oldValue, Object newValue, int pos);
-
- /**
- * Remove an adapter of this notifier.
- */
- void removeAdapter(INodeAdapter o);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.java
deleted file mode 100644
index 9352767412..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStateMemento.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.core;
-
-
-
-/**
- * Marker-only interface, at this point.
- */
-public interface IStateMemento {
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java
deleted file mode 100644
index a3023f904f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IStructuredModel.java
+++ /dev/null
@@ -1,389 +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.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.wst.encoding.EncodingRule;
-import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.undo.StructuredTextUndoManager;
-import org.eclipse.wst.sse.core.util.URIResolver;
-
-
-/**
- */
-public interface IStructuredModel extends IAdaptable {
-
-
- /**
- * This API allows clients to declare that they are about to make a "large"
- * change to the model. This change might be in terms of content or it
- * might be in terms of the model id or base location.
- *
- * Note that in the case of embedded calls, notification to listners is
- * sent only once.
- *
- * Note that the client who is making these changes has the responsibility
- * to restore the models state once finished with the changes. See
- * getMemento and restoreState.
- *
- * The method isModelStateChanging can be used by a client to determine if
- * the model is already in a change sequence.
- */
- void aboutToChangeModel();
-
- void addModelLifecycleListener(IModelLifecycleListener listener);
-
- void addModelStateListener(IModelStateListener listener);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength);
-
- /**
- * This API allows a client controlled way of notifying all ModelEvent
- * listners that the model has been changed. This method is a matched pair
- * to aboutToChangeModel, and must be called after aboutToChangeModel ...
- * or some listeners could be left waiting indefinitely for the changed
- * event. So, its suggested that changedModel always be in a finally
- * clause. Likewise, a client should never call changedModel without
- * calling aboutToChangeModel first.
- *
- * In the case of embedded calls, the notification is just sent once.
- *
- */
- void changedModel();
-
- long computeModificationStamp(IResource resource);
-
- /**
- * Insert the method's description here. Creation date: (6/24/2001 7:52:24
- * PM)
- *
- */
- IStructuredModel copy(String id) throws ResourceInUse, ResourceAlreadyExists;
-
- /**
- * Disable undo management.
- */
- void disableUndoManagement();
-
- /**
- * Enable undo management.
- */
- void enableUndoManagement();
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester);
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * This is a client-defined value for what that client (and/or loader)
- * considers the "base" of the structure model
- */
- String getBaseLocation();
-
- /**
- * @return The associated content type identifier (String) for this model.
- */
- String getContentTypeIdentifier();
-
- IFactoryRegistry getFactoryRegistry();
-
- /**
- * The id is the id that the model manager uses to identify this model
- */
- String getId();
-
- /**
- *
- */
- IndexedRegion getIndexedRegion(int offset);
-
- /**
- * This method returns a mememto that can later be used to restore the
- * state at this point. A model's state, in this sense, does not relate to
- * its content, or Ids, etc., just its dirty state, and its synchronization
- * state with its underlying resource.
- *
- * The 'resource' argument must be the resource that underlies the instance
- * of the model this method is sent to. Note: this parameter will not be
- * required in future versions of 'strucutured model'.
- */
- IStateMemento getMemento(IResource resource);
-
- /**
- * ContentTypeDescription provides an object that describes what the
- * content of the file is, e.g. HTML, XML, etc. Compare with
- * getExternalFileTypeDescription. Though they both return objects of type
- * ContentTypeDescription, the external file type is intended to denote
- * JSP, regardless of what the content of that JSP file is. Even for a JSP
- * file, the ContentTypeDescription will be set according to that file's
- * "internal" contents.
- *
- * @return ContentTypeDescription
- */
- IModelHandler getModelHandler();
-
- IModelManager getModelManager();
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design not
- * to use this function
- */
- int getReferenceCount();
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design not
- * to use this function
- */
- int getReferenceCountForEdit();
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design not
- * to use this function
- */
- int getReferenceCountForRead();
-
- Object getReinitializeStateData();
-
- /**
- * Get URI resolution helper
- */
- URIResolver getResolver();
-
- IStructuredDocument getStructuredDocument();
-
- /**
- * modification date of underlying resource, when this model was open, or
- * last saved. (Note: for this version, the client must manage the accuracy
- * of this data)
- */
- long getSynchronizationStamp();
-
- /**
- * Get undo manager.
- */
- StructuredTextUndoManager getUndoManager();
-
- /**
- *
- */
- boolean isDirty();
-
- /**
- * This method can be called to determine if the model is within a
- * "aboutToChange" and "changed" sequence.
- */
- public boolean isModelStateChanging();
-
- /**
- *
- */
- boolean isNew();
-
- boolean isReinitializationNeeded();
-
- /**
- * This is a combination of if the model is dirty and if the model is
- * shared for write access. The last writer as the responsibility to be
- * sure the user is prompted to save.
- */
- public boolean isSaveNeeded();
-
- /**
- * This function returns true if either isSharedForRead or isSharedForWrite
- * is true.
- */
- boolean isShared();
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- boolean isSharedForEdit();
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- boolean isSharedForRead();
-
- /**
- * newInstance is similar to clone, except that the newInstance contains no
- * content. Its purpose is so clients can get a temporary, unmanaged, model
- * of the same "type" as the original. Note: the client may still need to
- * do some intialization of the model returned by newInstance, depending on
- * desired use. For example, the only factories in the newInstance are
- * those that would be normally be created for a model of the given
- * contentType. Others are not copied automatically, and if desired, should
- * be added by client.
- */
- IStructuredModel newInstance() throws IOException;
-
- /**
- * Performs a reinit procedure. For this model. Note for future: there may
- * be a day where the model returned from this method is a different
- * instance than the instance it was called on. This will occur when there
- * is full support for "save as" type functions, where the model could
- * theoretically change completely.
- */
- IStructuredModel reinit() throws IOException;
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- *
- */
- void releaseFromEdit();
-
- /**
- * This function allows the model to free up any resources it might be
- * using. In particular, itself, as stored in the IModelManager.
- *
- */
- void releaseFromRead();
-
- /**
- * This function replenishes the model with the resource without saving any
- * possible changes. It is used when one editor may be closing, and
- * specifially says not to save the model, but another "display" of the
- * model still needs to hang on to some model, so needs a fresh copy.
- */
- IStructuredModel reload(InputStream inputStream) throws IOException;
-
- void removeModelLifecycleListener(IModelLifecycleListener listener);
-
- void removeModelStateListener(IModelStateListener listener);
-
- /**
- * A method that modififies the model's synchonization stamp to match the
- * resource. Turns out there's several ways of doing it, so this ensures a
- * common algorithm.
- */
- void resetSynchronizationStamp(IResource resource);
-
- void resourceDeleted();
-
- void resourceMoved(IStructuredModel newModel);
-
- void restoreState(IStateMemento memento);
-
- void save() throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(IFile iFile) throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException;
-
- void save(OutputStream outputStream) throws UnsupportedEncodingException, IOException, CoreException;
-
- void setBaseLocation(String newBaseLocation);
-
- public void setDirtyState(boolean dirtyState);
-
- /**
- * @deprecated - this class will likely be removed in near future, but
- * takes some slight reimplentation on clients code.
- */
- void setFactoryRegistry(IFactoryRegistry registry);
-
- /**
- * The id is the id that the model manager uses to identify this model
- */
- void setId(String id) throws ResourceInUse;
-
- void setModelHandler(IModelHandler modelHandler);
-
- void setModelManager(IModelManager modelManager);
-
- public void setNewState(boolean newState);
-
- /**
- * Sets a "flag" that reinitialization is needed.
- */
- void setReinitializeNeeded(boolean b);
-
- /**
- * Holds any data that the reinit procedure might find useful in
- * reinitializing the model. This is handy, since the reinitialization may
- * not take place at once, and some "old" data may be needed to properly
- * undo previous settings. Note: the parameter was intentially made to be
- * of type 'Object' so different models can use in different ways.
- */
- void setReinitializeStateData(Object object);
-
- /**
- * Set the URI resolution helper
- */
- void setResolver(URIResolver uriResolver);
-
- void setStructuredDocument(IStructuredDocument structuredDocument);
-
- /**
- * Set undo manager.
- */
- void setUndoManager(StructuredTextUndoManager undoManager);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.java
deleted file mode 100644
index 9824d14501..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/IndexedRegion.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.core;
-
-
-
-/**
- * These are APIs found to be needed in our tree outline viewer,
- * that go beyond the standard DOM Node Interface.
- */
-public interface IndexedRegion {
-
- boolean contains(int testPosition);
-
- int getEndOffset();
-
- int getStartOffset();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.java
deleted file mode 100644
index ec391b52d5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/LifecycleNotificationManager.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.core;
-
-import org.eclipse.wst.sse.core.util.Utilities;
-
-/**
- * For "internal use" only, by AbstractStructuredModel
- */
-
-class LifecycleNotificationManager {
-
- private Object[] fListeners;
-
- LifecycleNotificationManager() {
-
- super();
- }
-
- synchronized void addListener(IModelLifecycleListener listener) {
-
- if (!Utilities.contains(fListeners, listener)) {
- int oldSize = 0;
- if (fListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fListeners != null) {
- System.arraycopy(fListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fListeners = newListeners;
- }
- }
-
- synchronized void removeListener(IModelLifecycleListener listener) {
-
- if ((fListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fListeners, listener)) {
- int oldSize = fListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fListeners = newListeners;
- }
- }
- }
-
- void signalLifecycleEvent(ModelLifecycleEvent event) {
-
- // 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
- if (fListeners != null) {
- Object[] holdListeners = fListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- IModelLifecycleListener listener = (IModelLifecycleListener) holdListeners[i];
- // only one type of listner for now ... this could become more complex
- if ((event.getInternalType() & ModelLifecycleEvent.PRE_EVENT) == ModelLifecycleEvent.PRE_EVENT) {
-
- listener.processPreModelEvent(event);
- }
- if ((event.getInternalType() & ModelLifecycleEvent.POST_EVENT) == ModelLifecycleEvent.POST_EVENT) {
- listener.processPostModelEvent(event);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java
deleted file mode 100644
index 99338aa87e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelDumper.java
+++ /dev/null
@@ -1,34 +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.core;
-
-
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.wst.encoding.EncodingRule;
-
-/**
- * Classes that implement this interface are responsible
- * for saving the model to the file system (or wherever
- * the dumpter wants).
- *
- */
-public interface ModelDumper {
-
- void dump(IStructuredModel model, OutputStream outputStream, EncodingRule encodingRule, IFile iFile) throws UnsupportedEncodingException, IOException, CoreException;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java
deleted file mode 100644
index 68c08dad5d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLifecycleEvent.java
+++ /dev/null
@@ -1,122 +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.core;
-
-/**
- * This is an early version of a class that may change over the
- * next few milestones.
- */
-
-
-public class ModelLifecycleEvent {
- // this list is for "public" consumption
- public static final int MODEL_SAVED = 0x0001;
- public static final int MODEL_RELEASED = 0x00002;
- public static final int MODEL_DOCUMENT_CHANGED = 0x0003;
- public static final int MODEL_DIRTY_STATE = 0x0004;
-
- // TODO: finish support for these
- // following not implemented yet
- //public static final int MODEL_REINITIALIZED = 0x0005;
- //public static final int MODEL_RELOADED = 0x0006;
- //public static final int ADAPTERS_NOTIFIED = 0x0007;
- //public static final int MODEL_RESOURCE_MOVED = 0x0008;
- //public static final int MODEL_RESOURCE_DELETED = 0x0009;
-
- // This list (upper two bytes) is for only internal mechanisms and subclasses
- // For simplicity they are "masked out" when client calls getType()
- protected static final int PRE_EVENT = 0x0100;
- protected static final int POST_EVENT = 0x0200;
-
-
- private IStructuredModel fModel;
- private int fType;
-
-
- private final static int MASK = 0x00FF;
-
- public ModelLifecycleEvent() {
- super();
- }
-
- public ModelLifecycleEvent(int type) {
- this();
- fType = type;
- }
-
- public ModelLifecycleEvent(IStructuredModel structuredModel, int type) {
- this(type);
- fModel = structuredModel;
- }
-
- public IStructuredModel getModel() {
-
- return fModel;
- }
-
- public int getType() {
-
- // for now, we'll mask type to "public" ones this easy
- // way ... but I know there must be a better way
- return fType & MASK;
- }
-
- public String toString() {
- String result = null;
- result = "ModelLifecycleEvent: " + debugString(fType); //$NON-NLS-1$
- return result;
- }
-
- private String debugString(int type) {
- String result = null;
- switch (type & MASK) {
- case MODEL_SAVED :
- result = "MODEL_SAVED"; //$NON-NLS-1$
- break;
- case MODEL_RELEASED :
- result = "MODEL_RELEASED"; //$NON-NLS-1$
- break;
- case MODEL_DOCUMENT_CHANGED :
- result = "MODEL_DOCUMENT_CHANGED"; //$NON-NLS-1$
- break;
- case MODEL_DIRTY_STATE :
- result = "MODEL_DIRTY_STATE"; //$NON-NLS-1$
- break;
- /* case MODEL_REINITIALIZED :
- result = "MODEL_REINITIALIZED";
- break;
- case MODEL_RELOADED :
- result = "MODEL_RELOADED";
- break;
- case ADAPTERS_NOTIFIED :
- result = "ADAPTERS_NOTIFIED";
- break;
- case MODEL_RESOURCE_MOVED :
- result = "MODEL_RESOURCE_MOVED";
- break;
- case MODEL_RESOURCE_DELETED :
- result = "MODEL_RESOURCE_DELETED";
- break;
- */
- default :
- throw new IllegalStateException("ModelLifecycleEvent did not have valid type"); //$NON-NLS-1$
- }
- return result;
- }
-
- protected int getInternalType() {
-
- return fType;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.java
deleted file mode 100644
index 84056f2e7b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelLoader.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.core;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-import org.eclipse.wst.encoding.EncodingRule;
-
-/**
- * Responsible for creating a new Model from a resource, or as a new, empty
- * instance.
- *
- */
-public interface ModelLoader {
- /**
- * This method should perform all the model initialization required before
- * it contains content, namely, it should call newModel, the
- * createNewStructuredDocument(), then setAdapterFactories. (this is
- * tentative)
- */
- IStructuredModel createModel();
-
- /**
- * Method createModel. Creates a new model based on old one.
- *
- * @param oldModel
- * @return IStructuredModel
- */
- IStructuredModel createModel(IStructuredModel oldModel);
-
- /**
- * This method must return those factories which must be attached to the
- * structuredModel before content is applied.
- */
- List getAdapterFactories();
-
- void load(InputStream inputStream, IStructuredModel model, EncodingRule encodingRule) throws IOException;
-
- void load(InputStream inputStream, IStructuredModel model, String encodingName, String lineDelimiter) throws IOException;
-
- void load(String filename, InputStream inputStream, IStructuredModel model, String encodingName, String lineDelimiter) throws IOException;
-
- ModelLoader newInstance();
-
- /**
- * This method should always return an new, empty Structured Model
- * appropriate for itself.
- */
- IStructuredModel newModel();
-
- IStructuredModel reinitialize(IStructuredModel model);
-
- /**
- * This method should get a fresh copy of the data, and repopulate the
- * models ... normally by a call to setText on the structuredDocument, for
- * StructuredModels. This method is needed in some cases where clients are
- * sharing a model and then changes canceled. Say for example, one editor
- * and several "displays" are sharing a model, if the editor is closed
- * without saving changes, then the displays still need a model, but they
- * should revert to the original unsaved version.
- */
- void reload(InputStream inputStream, IStructuredModel model);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java
deleted file mode 100644
index 63e9be7514..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelManagerImpl.java
+++ /dev/null
@@ -1,1712 +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.core;
-
-//import java.io.ByteArrayInputStream;
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.util.Dictionary;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.encoding.CodedIO;
-import org.eclipse.wst.encoding.CodedStreamCreator;
-import org.eclipse.wst.encoding.EncodingRule;
-import org.eclipse.wst.encoding.NullMemento;
-import org.eclipse.wst.sse.core.document.DocumentReader;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.exceptions.ResourceAlreadyExists;
-import org.eclipse.wst.sse.core.exceptions.ResourceInUse;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.internal.nls.ResourceHandler1;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.util.Assert;
-import org.eclipse.wst.sse.core.util.ProjectResolver;
-import org.eclipse.wst.sse.core.util.URIResolver;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-/**
- * This class is responsible for creating, retriving, and storing Sharable
- * models. It retrieves the cached objects by an id which is typically a
- * String representing the resources URI. Note: Its important that all clients
- * that share a resource do so using <b>identical </b> identifiers, or else
- * different instances will be created and retrieved, even if they all
- * technically point to the same resource on the file system. This class also
- * provides a convenient place to register Model Loaders and Dumpers based on
- * 'type'.
- */
-class ModelManagerImpl implements IModelManager {
-
- class EnumeratedModelIds implements Enumeration {
-
- Enumeration fSharedObjectKeys;
-
- protected EnumeratedModelIds(Dictionary sharedObjects) {
-
- if (sharedObjects == null) {
- // if no shared objects yet, return empty enumeration
- fSharedObjectKeys = null;
- }
- else {
- fSharedObjectKeys = sharedObjects.keys();
- }
- }
-
- public boolean hasMoreElements() {
-
- boolean result = false;
- if (fSharedObjectKeys != null)
- result = fSharedObjectKeys.hasMoreElements();
- return result;
- }
-
- public Object nextElement() {
-
- if (fSharedObjectKeys == null)
- throw new NoSuchElementException();
- return fSharedObjectKeys.nextElement();
- }
- }
-
- class ReadEditType {
-
- private String fType;
-
- ReadEditType(String type) {
-
- fType = type;
- }
- }
-
- /**
- * A Data class to track our shared objects
- */
- class SharedObject {
-
- int referenceCountForEdit;
- int referenceCountForRead;
- IStructuredModel theSharedObject;
-
- SharedObject(IStructuredModel sharedObject) {
-
- theSharedObject = sharedObject;
- referenceCountForRead = 0;
- referenceCountForEdit = 0;
- }
- }
-
- /**
- * Our singleton instance
- */
- private static ModelManagerImpl instance;
-
- synchronized static IModelManager getInstance() {
-
- // remember, static methods use different monitor than instance
- // methods,
- // but in this case its ok, since we're just protecting against two
- // thread
- // accessing static variable 'instance'
- if (instance == null) {
- instance = new ModelManagerImpl();
- }
- return instance;
- }
-
- private ReadEditType EDIT = new ReadEditType("edit"); //$NON-NLS-1$
-
- // private EmbeddedContentTypeRegistry embeddedContentTypeRegistry;
- private ModelHandlerRegistry fModelHandlerRegistry;
- private Object[] fModelManagerListeners;
- /**
- * Our cache of managed objects
- */
- private Dictionary managedObjects;
- private int modelManagerStateChanging;
- private ReadEditType READ = new ReadEditType("read"); //$NON-NLS-1$
- private final int READ_BUFFER_SIZE = 4096;
-
- private ModelManagerImpl() {
-
- super();
- // Note: see comment in plugin.xml for potentially
- // breaking change in behavior.
- // initResourceAdapters();
- }
-
- private synchronized IStructuredModel _commonGetModel(IFile iFile, ReadEditType rwType, EncodingRule encodingRule) throws java.io.UnsupportedEncodingException, IOException, CoreException {
-
- String id = calculateId(iFile);
- IModelHandler handler = calculateType(iFile);
- URIResolver resolver = calculateURIResolver(iFile);
- InputStream inputStream = Utilities.getMarkSupportedStream(iFile.getContents(true));
- IStructuredModel model = null;
- try {
- model = _commonGetModel(inputStream, id, handler, resolver, rwType, encodingRule);
- }
- finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- // for the IFile based APIs, we can set the
- // sync stamp ... for those using the 'filename'
- // form, its the client's reponsibility to set.
- // (Note: we do provide this "service" in the FileModelProvider,
- // for those using our source page and our FileModelProvider, that is
- // there if we notice it hasn't been set, we'll set it.
- //model.resetSynchronizationStamp(iFile);
- return model;
- }
-
- private synchronized IStructuredModel _commonGetModel(IFile iFile, ReadEditType rwType, String encoding, String lineDelimiter) throws java.io.UnsupportedEncodingException, IOException, CoreException {
-
- String id = calculateId(iFile);
- IModelHandler handler = calculateType(iFile);
- URIResolver resolver = calculateURIResolver(iFile);
- InputStream inputStream = Utilities.getMarkSupportedStream(iFile.getContents(true));
- inputStream.mark(CodedIO.MAX_MARK_SIZE);
- IStructuredModel model = null;
- try {
- model = _commonGetModel(inputStream, id, handler, resolver, rwType, encoding, lineDelimiter);
- }
- finally {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- // for the IFile based APIs, we can set the
- // sync stamp ... for those using the 'filename'
- // form, its the client's reponsibility to set.
- // (Note: we do provide this "service" in the FileModelProvider,
- // for those using our source page and our FileModelProvider, that is
- // there if we notice it hasn't been set, we'll set it.
- //model.resetSynchronizationStamp(iFile);
- return model;
- }
-
- private synchronized IStructuredModel _commonGetModel(InputStream inputStream, String id, IModelHandler handler, URIResolver resolver, ReadEditType rwType, EncodingRule encodingRule) throws IOException {
-
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- IStructuredModel model = null;
- if (sharedObject == null) {
- try {
- model = _commonModelInit(id, handler, resolver);
- ModelLoader loader = handler.getModelLoader();
- loader.load(Utilities.getMarkSupportedStream(inputStream), model, encodingRule);
- }
- catch (ResourceInUse e) {
- // impossible, since we've already found
- handleProgramError(e);
- }
- if (model != null) {
- // add to our cache
- sharedObject = new SharedObject(model);
- _initCount(sharedObject, rwType);
- getManagedObjects().put(id, sharedObject);
- }
- }
- else {
- // if shared object is initially in our cache, then simply
- // increment its ref count,
- // and return the object.
- _incrCount(sharedObject, rwType);
- }
- // we expect to always return something
- org.eclipse.wst.sse.core.util.Assert.isNotNull(sharedObject, "Program Error: no model recorded for id " + id); //$NON-NLS-1$
- // note: clients must call release for each time they call get.
- return sharedObject.theSharedObject;
- }
-
- private synchronized IStructuredModel _commonGetModel(InputStream inputStream, String id, IModelHandler handler, URIResolver resolver, ReadEditType rwType, String encoding, String lineDelimiter) throws IOException {
-
- if (id == null) {
- throw new IllegalArgumentException("Program Error: id may not be null"); //$NON-NLS-1$
- }
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- IStructuredModel model = null;
- if (sharedObject == null) {
- try {
- model = _commonModelInit(id, handler, resolver);
- ModelLoader loader = handler.getModelLoader();
- loader.load(id, Utilities.getMarkSupportedStream(inputStream), model, encoding, lineDelimiter);
- }
- catch (ResourceInUse e) {
- // impossible, since we've already found
- handleProgramError(e);
- }
- if (model != null) {
- // add to our cache
- sharedObject = new SharedObject(model);
- _initCount(sharedObject, rwType);
- getManagedObjects().put(id, sharedObject);
- }
- }
- else {
- // if shared object is initially in our cache, then simply
- // increment its ref count,
- // and return the object.
- _incrCount(sharedObject, rwType);
- }
- // we expect to always return something
- org.eclipse.wst.sse.core.util.Assert.isNotNull(sharedObject, "Program Error: no model recorded for id " + id); //$NON-NLS-1$
- // note: clients must call release for each time they call get.
- return sharedObject.theSharedObject;
- }
-
- private IStructuredModel _commonModelInit(String id, IModelHandler handler, URIResolver resolver) throws ResourceInUse {
-
- Assert.isNotNull(handler, "model handler can not be null"); //$NON-NLS-1$
- ModelLoader loader = handler.getModelLoader();
- IStructuredModel result = loader.createModel();
- // in the past, id was null for "unmanaged" case, so we won't
- // try and set it
- if (id != null) {
- result.setId(id);
- }
- result.setModelHandler(handler);
- result.setResolver(resolver);
- // some obvious redunancy here that maybe could be improved
- // in future, but is necessary for now
- result.setBaseLocation(id);
- if (resolver != null) {
- resolver.setFileBaseLocation(id);
- }
- addFactories(result, handler);
- return result;
- }
-
- private SharedObject _commonNewModel(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
-
- // let's check to see if resource already exists, either in our cache,
- // or on the system
- String id = calculateId(iFile);
- IModelHandler handler = calculateType(iFile);
- URIResolver resolver = calculateURIResolver(iFile);
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- IStructuredModel aSharedModel = null;
- // if shared object is null, then we do not have it already, which is
- // as normally expected.
- if (sharedObject == null) {
- // if not in cache, see if we can retrieve it
- aSharedModel = _commonModelInit(id, handler, resolver);
- ModelLoader loader = handler.getModelLoader();
- InputStream inputStream = null;
- try {
- inputStream = Utilities.getMarkSupportedStream(iFile.getContents(true));
- }
- catch (CoreException ce) {
- // file does not exist
- aSharedModel = null;
- }
- if (inputStream != null) {
- try {
- loader.load(inputStream, aSharedModel, null, null);
- }
- finally {
- inputStream.close();
- }
- }
- }
- else {
- // if sharedObject is not null, then
- // someone has asked us to create a new model for a given id, but
- // it in fact
- // is already in our cache with that id. In this case we will
- // throw
- // an "in use" exception,
- // (unless force is set to true). Because, to do otherwise we will
- // basically be
- // over writing a model that another client is already using. Not
- // nice.
- if (!force) {
- throw new ResourceInUse();
- }
- }
- // if we get here, and result (and shared object) are still null,
- // then all is ok, and we can create it,
- if (aSharedModel == null) {
- aSharedModel = _commonModelInit(id, handler, resolver);
- // rembember, don't set 'true' in model init, since that's always
- // used,
- // even when not new. 'new' is intended to mean "there is not yet
- // a
- // file" for the model.
- aSharedModel.setNewState(true);
- sharedObject = addToCache(id, aSharedModel);
- // when resource is provided, we can set
- // synchronization stamp ... otherwise client should
- // Note: one client which does this is FileModelProvider.
- aSharedModel.resetSynchronizationStamp(iFile);
- }
- else {
- // if result is not null, then we have to check
- // if 'force' was false before deciding to
- // throw an already exists exception.
- if (force) {
- sharedObject = addToCache(id, aSharedModel);
- // when resource is provided, we can set
- // synchronization stamp ... otherwise client should
- // Note: one client which does this is FileModelProvider.
- aSharedModel.resetSynchronizationStamp(iFile);
- }
- else {
- throw new ResourceAlreadyExists();
- }
- }
- if (aSharedModel != null) {
- // for the IFile based APIs, we can set the
- // sync stamp ... for those using the 'filename'
- // form, its the client's reponsibility to set.
- // (Note: we do provide this "service" in the FileModelProvider,
- // for those using our source page and our FileModelProvider, that
- // is
- // there if we notice it hasn't been set, we'll set it.
- aSharedModel.resetSynchronizationStamp(iFile);
- }
- return sharedObject;
- }
-
- private void _commonRelease(Object id, SharedObject sharedObject) {
-
- IStructuredModel localModel = sharedObject.theSharedObject;
- int type = ModelLifecycleEvent.MODEL_RELEASED | ModelLifecycleEvent.PRE_EVENT;
- // what's wrong with this design that a cast is needed here!?
- ModelLifecycleEvent event = new ModelLifecycleEvent(localModel, type);
- ((AbstractStructuredModel) localModel).signalLifecycleEvent(event);
- getManagedObjects().remove(id);
- type = ModelLifecycleEvent.MODEL_RELEASED | ModelLifecycleEvent.POST_EVENT;
- // what's wrong with this design that a cast is needed here!?
- event = new ModelLifecycleEvent(localModel, type);
- ((AbstractStructuredModel) localModel).signalLifecycleEvent(event);
- }
-
- private synchronized void _incrCount(SharedObject sharedObject, ReadEditType type) {
-
- if (type == READ) {
- sharedObject.referenceCountForRead++;
- }
- else if (type == EDIT) {
- sharedObject.referenceCountForEdit++;
- }
- else
- throw new IllegalArgumentException();
- }
-
- private synchronized void _initCount(SharedObject sharedObject, ReadEditType type) {
-
- if (type == READ) {
- sharedObject.referenceCountForRead = 1;
- }
- else if (type == EDIT) {
- sharedObject.referenceCountForEdit = 1;
- }
- else
- throw new IllegalArgumentException();
- }
-
- /**
- * This API allows clients to declare that they are about to make a
- * "massive" change one or more models. This change might be in terms of
- * content or it might be in terms of the model id or base location. Note
- * that in the case of embedded calls, notification to listners is sent
- * only once. The method isModelStateChanging can be used by a client to
- * determine if the model is already in a change sequence.
- */
- public synchronized void aboutToChangeModels() {
-
- // notice this is just a public avenue to our protected method
- fireModelsAboutToBeChanged();
- }
-
- protected void addFactories(IStructuredModel model, IModelHandler handler) {
-
- Assert.isNotNull(model, "model can not be null"); //$NON-NLS-1$
- Assert.isNotNull(handler, "model handler can not be null"); //$NON-NLS-1$
- IFactoryRegistry registry = model.getFactoryRegistry();
- Assert.isNotNull(registry, "Factory Registry can not be null"); //$NON-NLS-1$
- List factoryList = handler.getAdapterFactories();
- addFactories(model, factoryList);
- }
-
- protected void addFactories(IStructuredModel model, List factoryList) {
-
- Assert.isNotNull(model, "model can not be null"); //$NON-NLS-1$
- IFactoryRegistry registry = model.getFactoryRegistry();
- Assert.isNotNull(registry, "Factory Registry can not be null"); //$NON-NLS-1$
- // Note: we add all of them from handler, even if
- // already exists. May need to reconsider this.
- if (factoryList != null) {
- Iterator iterator = factoryList.iterator();
- while (iterator.hasNext()) {
- AdapterFactory factory = (AdapterFactory) iterator.next();
- registry.addFactory(factory);
- }
- }
- }
-
- public synchronized void addModelManagerListener(IModelManagerListener listener) {
-
- if (!Utilities.contains(fModelManagerListeners, listener)) {
- int oldSize = 0;
- if (fModelManagerListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fModelManagerListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fModelManagerListeners != null) {
- System.arraycopy(fModelManagerListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fModelManagerListeners = newListeners;
- //
- }
- }
-
- private SharedObject addToCache(String id, IStructuredModel aSharedModel) {
-
- SharedObject sharedObject;
- sharedObject = new SharedObject(aSharedModel);
- getManagedObjects().put(id, sharedObject);
- return sharedObject;
- }
-
- /**
- * CalculateBaseLocation provides a common way to determine the
- * baseLocation from the input. The 'setBaseLocation' must still be called
- * for a IStructuredModel, by the client using/creating it, but this
- * providides a convenient way to get a common value, if desired.
- *
- * @deprecated is this still needed?
- */
- public String calculateBaseLocation(IFile file) {
- Assert.isNotNull(file, "IFile parameter can not be null"); //$NON-NLS-1$
- return file.getLocation().toString();
- }
-
- /**
- * Calculate id provides a common way to determine the id from the input
- * ... needed to get and save the model. It is a simple class utility, but
- * is an instance method so can be accessed via interface.
- */
- public String calculateId(IFile file) {
-
- String id = null;
- // if file doesn't exist, getLocation can return null
- // and we'll return null in that case.
- // (normally this is not called if file doesn't exist, but
- // can in certain situations of a project being deleted
- // that had a file which is open in an editor.
- IPath path = file.getLocation();
- if (path != null)
- id = path.toString();
- return id;
- }
-
- /**
- * CalculateId provides a common way to determine the id from the provided
- * filename.
- */
- public String calculateId(String filename) {
-
- // providing common method for consistency.
- // May eventually need to "clean up"
- // any initial "file://" protocols, etc., but currently don't
- // know of anyone doing that.
- String id = filename;
- return id;
- }
-
- protected IModelHandler calculateType(IFile iFile) throws CoreException {
-
- // IModelManager mm = ((ModelManagerPlugin)
- // Platform.getPlugin(ModelManagerPlugin.ID)).getModelManager();
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler cd = cr.getHandlerFor(iFile);
- return cd;
- }
-
- private IModelHandler calculateType(String filename, InputStream inputStream) throws IOException {
-
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler cd = cr.getHandlerFor(filename, inputStream);
- return cd;
- }
-
- /**
- *
- */
- private URIResolver calculateURIResolver(IFile file) {
-
- // Note: see comment in plugin.xml for potentially
- // breaking change in behavior.
-
- IProject project = file.getProject();
- URIResolver resolver = (URIResolver) project.getAdapter(URIResolver.class);
- if (resolver == null)
- resolver = new ProjectResolver(project);
- resolver.setFileBaseLocation(calculateBaseLocation(file));
- return resolver;
- }
-
- /**
- * This API allows a client controlled way of notifying all
- * IModelManagerEvent listners that several models have changed. This
- * method is a matched pair to aboutToChangeModels, and must be called
- * after aboutToChangeModel ... or some listeners could be left waiting
- * indefinitely for the changed event. So, its suggested that
- * changedModels always be in a finally clause. Likewise, a client should
- * never call changedModel without calling aboutToChangeModel first. In
- * the case of embedded calls, the notification is just sent once.
- */
- public synchronized void changedModels() {
-
- // notice this is just a public avenue to our protected method
- fireModelsChanged();
- }
-
- /**
- * this used to be in loader, but has been moved here
- */
- protected IStructuredModel copy(IStructuredModel model, String newId) throws ResourceInUse {
-
- IStructuredModel newModel = null;
- IStructuredModel oldModel = model;
- IModelHandler modelHandler = oldModel.getModelHandler();
- ModelLoader loader = modelHandler.getModelLoader();
- // newModel = loader.newModel();
- newModel = loader.createModel(oldModel);
- //newId, oldModel.getResolver(), oldModel.getModelManager());
- newModel.setModelHandler(modelHandler);
- // IStructuredDocument oldStructuredDocument =
- // oldModel.getStructuredDocument();
- // IStructuredDocument newStructuredDocument =
- // oldStructuredDocument.newInstance();
- // newModel.setStructuredDocument(newStructuredDocument);
- newModel.setResolver(oldModel.getResolver());
- newModel.setModelManager(oldModel.getModelManager());
- //duplicateFactoryRegistry(newModel, oldModel);
- newModel.setId(newId);
- // set text of new one after all initialization is done
- String contents = oldModel.getStructuredDocument().getText();
- newModel.getStructuredDocument().setText(this, contents);
- return newModel;
- }
-
- /**
- */
- public synchronized IStructuredModel copyModelForEdit(String oldId, String newId) throws ResourceInUse {
-
- IStructuredModel newModel = null;
- // get the existing model associated with this id
- IStructuredModel model = getExistingModel(oldId);
- // if it doesn't exist, ignore request (though this would normally
- // be a programming error.
- if (model == null)
- return null;
- // now be sure newModel does not exist
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(newId);
- if (sharedObject != null) {
- throw new ResourceInUse();
- }
- // get loader based on existing type (note the type assumption)
- //Object type = ((IStructuredModel) model).getType();
- //IModelHandler type = model.getModelHandler();
- //ModelLoader loader = (ModelLoader) getModelLoaders().get(type);
- // ModelLoader loader = (ModelLoader) getModelLoaders().get(type);
- // ask the loader to copy
- newModel = copy(model, newId);
- if (newModel != null) {
- // add to our cache
- sharedObject = new SharedObject(newModel);
- sharedObject.referenceCountForEdit = 1;
- getManagedObjects().put(newId, sharedObject);
- trace("copied model", newId, sharedObject.referenceCountForEdit); //$NON-NLS-1$
- }
- return newModel;
- }
-
- /**
- * Similar to clone, except the new instance has no content. Note: this
- * produces an unmanaged model, for temporary use. If a true shared model
- * is desired, use "copy".
- */
- public IStructuredModel createNewInstance(IStructuredModel oldModel) throws IOException {
-
- IModelHandler handler = oldModel.getModelHandler();
- ModelLoader loader = handler.getModelLoader();
- IStructuredModel newModel = loader.createModel(oldModel);
- newModel.setModelHandler(handler);
- URIResolver oldResolver = oldModel.getResolver();
- newModel.setResolver(oldResolver);
- try {
- newModel.setId(DUPLICATED_MODEL);
- }
- catch (ResourceInUse e) {
- // impossible, since this is an unmanaged model
- }
- // base location should be null, but we'll set to
- // null to be sure.
- newModel.setBaseLocation(null);
- return newModel;
- }
-
- /**
- * Conveience method, since a proper IStructuredDocument must have a
- * proper parser assigned.
- */
- public synchronized IStructuredDocument createStructuredDocumentFor(IFile iFile) throws IOException, CoreException {
-
- IDocumentLoader loader = null;
- IModelHandler handler = calculateType(iFile);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument(iFile);
- return result;
- }
-
- /**
- * Conveience method, since a proper IStructuredDocument must have a
- * proper parser assigned. It should only be used when an empty
- * structuredDocument is needed. Otherwise, use IFile form.
- *
- * @deprecated - TODO: to be removed by C4 do we really need this? I
- * recommend to - use createStructuredDocumentFor(filename,
- * null, null) - the filename does not need to represent a
- * real - file, but can take for form of dummy.jsp, test.xml,
- * etc. - That way we don't hard code the handler, but specify
- * we - want the handler that "goes with" a certain type of -
- * file.
- */
- public synchronized IStructuredDocument createStructuredDocumentFor(String contentTypeId) {
-
- IDocumentLoader loader = null;
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler handler = cr.getHandlerForContentTypeId(contentTypeId);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
- return result;
- }
-
- /**
- * Conveience method, since a proper IStructuredDocument must have a
- * proper parser assigned.
- *
- * @deprecated -- - TODO: to be removed by C4 I marked as deprecated to
- * discouage use of this method. It does not really work for
- * JSP fragments, since JSP Fragments need an IFile to
- * correctly look up the content settings. Use IFile form
- * instead.
- */
- public IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver) throws IOException {
-
- IDocumentLoader loader = null;
- InputStream istream = Utilities.getMarkSupportedStream(inputStream);
- if (istream != null) {
- istream.reset();
- }
- IModelHandler handler = calculateType(filename, istream);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = null;
- if (inputStream == null) {
- result = (IStructuredDocument) loader.createNewStructuredDocument();
- }
- else {
- result = (IStructuredDocument) loader.createNewStructuredDocument(filename, istream);
- }
- return result;
- }
-
- /**
- * Special case method. This method was created for the special case where
- * there is an encoding for input stream that should override all the
- * normal rules for encoding. For example, if there is an encoding
- * (charset) specified in HTTP response header, then that encoding is used
- * to translate the input stream to a string, but then the normal encoding
- * rules are ignored, so that the string is not translated twice (for
- * example, if its an HTML "file", then even if it contains a charset in
- * meta tag, its ignored since its assumed its all correctly decoded by
- * the HTTP charset.
- */
- public IStructuredDocument createStructuredDocumentFor(String filename, InputStream inputStream, URIResolver resolver, String encoding) throws IOException {
-
- String content = readInputStream(inputStream, encoding);
- IStructuredDocument result = createStructuredDocumentFor(filename, content, resolver);
- return result;
- }
-
- /**
- * Conveience method. This method can be used when the resource does not
- * really exist (e.g. when content is being created, but hasn't been
- * written to disk yet). Note that since the content is being provided as
- * a String, it is assumed to already be decoded correctly so no
- * transformation is done.
- */
- public IStructuredDocument createStructuredDocumentFor(String filename, String content, URIResolver resolver) throws IOException {
-
- // TODO: avoid all these String instances
- StringBuffer contentBuffer = new StringBuffer(content);
- IDocumentLoader loader = null;
- IModelHandler handler = calculateType(filename, null); //inputStream);
- loader = handler.getDocumentLoader();
- IStructuredDocument result = (IStructuredDocument) loader.createNewStructuredDocument();
- StringBuffer convertedContent = loader.handleLineDelimiter(contentBuffer, result);
- result.setEncodingMemento(new NullMemento());
- result.setText(this, convertedContent.toString());
- return result;
- }
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- public synchronized IStructuredModel createUnManagedStructuredModelFor(IFile iFile) throws IOException, CoreException {
-
- IStructuredModel result = null;
- result = createUnManagedEmptyModelFor(iFile);
-
- IDocumentLoader loader = result.getModelHandler().getDocumentLoader();
- IEncodedDocument document = loader.createNewStructuredDocument(iFile);
-
- // TODO: model and adapters are typcially not designed for this!
- // Some will have to be lifecycle listeners react on 'document instance changed'
- // often having to re-parse the document (though presumably the first
- // time would have been minisule.
- result.setStructuredDocument((IStructuredDocument) document);
-
-
- // TODO: avoid these casts
- // Note: this "fireNewDocument" event is a bit "fake"
- // (it would have already been sent once, when the document
- // was really new, but we send it again here (until correct
- // whole instrastructure) to force it to be received by the
- // model (which triggers the lifecylce event).
- ((IStructuredDocument) document).fireNewDocument(this);
-
- return result;
- }
-
- /**
- * @param iFile
- * @param result
- * @return
- * @throws CoreException
- */
- private IStructuredModel createUnManagedEmptyModelFor(IFile iFile) throws CoreException {
-
- IStructuredModel result = null;
- IModelHandler handler = calculateType(iFile);
- String id = calculateId(iFile);
- URIResolver resolver = calculateURIResolver(iFile);
-
- try {
- result = _commonModelInit(id, handler, resolver);
- }
- catch (ResourceInUse e) {
- // impossible, since we're not sharing
- // (even if it really is in use ... we don't care)
- // this may need to be re-examined.
- Logger.trace("IModelManager", "ModelMangerImpl::createUnManagedStructuredModelFor. Model unexpectedly in use."); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- return result;
- }
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- public synchronized IStructuredModel createUnManagedStructuredModelFor(String contentTypeId) {
-
- return createUnManagedStructuredModelFor(contentTypeId, null);
- }
-
- /**
- * Conveience method. It depends on the loaders newModel method to return
- * an appropriate StrucuturedModel appropriately initialized.
- */
- public synchronized IStructuredModel createUnManagedStructuredModelFor(String contentTypeId, URIResolver resolver) {
-
- IStructuredModel result = null;
- ModelHandlerRegistry cr = getModelHandlerRegistry();
- IModelHandler handler = cr.getHandlerForContentTypeId(contentTypeId);
- try {
- result = _commonModelInit(UNMANAGED_MODEL, handler, resolver); //$NON-NLS-1$
- }
- catch (ResourceInUse e) {
- // impossible, since we're not sharing
- // (even if it really is in use ... we don't care)
- // this may need to be re-examined.
- Logger.trace("IModelManager", "ModelMangerImpl::createUnManagedStructuredModelFor. Model unexpectedly in use."); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return result;
- }
-
- private void dump(IStructuredModel model, OutputStream outputStream, EncodingRule encodingRule, IFile iFile) throws UnsupportedEncodingException, IOException, CoreException {
-
- //IFile iFile = getFileFor(model);
-
- IStructuredDocument structuredDocument = model.getStructuredDocument();
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- String filename = iFile.getName();
- Reader reader = new DocumentReader(structuredDocument);
- codedStreamCreator.set(filename, reader);
- codedStreamCreator.setPreviousEncodingMemento(structuredDocument.getEncodingMemento());
- ByteArrayOutputStream codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream(EncodingRule.CONTENT_BASED);
- InputStream codedStream = new ByteArrayInputStream(codedByteStream.toByteArray());
- iFile.setContents(codedStream, true, true, null);
-
- //getDocumentDumper().dump(outputStream, structuredDocument,
- // encodingRule, use3ByteBOM, file);
- model.setDirtyState(false);
- model.setNewState(false);
- }
-
- /**
- * Informs all registered model state listeners that the the model is
- * about to under go a "large" change. This change might be interms of
- * contents, in might be in terms of the model id or base location.
- */
- protected void fireModelsAboutToBeChanged() {
-
- // notice we only fire this event if we are not already in a model
- // state changing sequence
- if (modelManagerStateChanging == 0) {
- // 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
- if (fModelManagerListeners != null) {
- Object[] holdListeners = fModelManagerListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelManagerListener) holdListeners[i]).modelsAboutToBeChanged();
- }
- }
- }
- // we always increment counter, for every request (so must receive
- // corresponding number of 'changedModel' requests)
- modelManagerStateChanging++;
- }
-
- /**
- * Informs all registered model state listeners that an impending change
- * is now complete. This method must only be called by 'modelChanged'
- * since it keeps track of counts.
- */
- protected void fireModelsChanged() {
-
- // always decrement
- modelManagerStateChanging--;
- // to be less than zero is a programming error, but we'll reset to
- // zero
- // with no error messages.
- if (modelManagerStateChanging < 0)
- modelManagerStateChanging = 0;
- // We only fire this event if all pending requests are done.
- // That is, if we've received the same number of fireModelChanged as
- // we
- // have fireModelAboutToBeChanged.
- if (modelManagerStateChanging == 0) {
- // 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
- if (fModelManagerListeners != null) {
- Object[] holdListeners = fModelManagerListeners;
- for (int i = 0; i < holdListeners.length; i++) {
- ((IModelManagerListener) holdListeners[i]).modelsChanged();
- }
- }
- }
- }
-
- private IStructuredModel getExistingModel(Object id) {
-
- IStructuredModel result = null;
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- // if not, then we'll simply return null
- if (sharedObject != null) {
- result = sharedObject.theSharedObject;
- }
- return result;
- }
-
- /**
- * Note: users of this 'model' must still release it when finished.
- * Returns null if there's not a model corresponding to document.
- */
- public IStructuredModel getExistingModelForEdit(IDocument document) {
-
- IStructuredModel result = null;
- Enumeration ids = new EnumeratedModelIds(managedObjects);
- while (ids.hasMoreElements()) {
- Object potentialId = ids.nextElement();
- IStructuredModel tempResult = getExistingModel(potentialId);
- if (document == tempResult.getStructuredDocument()) {
- result = getExistingModelForEdit(potentialId);
- break;
- }
- }
- return result;
- }
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- */
- public synchronized IStructuredModel getExistingModelForEdit(IFile iFile) {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- Object id = calculateId(iFile);
- IStructuredModel result = getExistingModelForEdit(id);
- return result;
- }
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- *
- * @deprecated use IFile form - this one will become protected or private
- */
- public synchronized IStructuredModel getExistingModelForEdit(Object id) {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- IStructuredModel result = null;
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- // if not, then we'll simply return null
- if (sharedObject != null) {
- // if shared object is in our cache, then simply increment its ref
- // count,
- // and return the object.
- sharedObject.referenceCountForEdit++;
- result = sharedObject.theSharedObject;
- trace("got existing model for Edit: ", id); //$NON-NLS-1$
- trace(" incremented referenceCountForEdit ", id, sharedObject.referenceCountForEdit); //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- * Note: users of this 'model' must still release it when finished.
- * Returns null if there's not a model corresponding to document.
- */
- public IStructuredModel getExistingModelForRead(IDocument document) {
-
- IStructuredModel result = null;
- Enumeration ids = new EnumeratedModelIds(managedObjects);
- while (ids.hasMoreElements()) {
- Object potentialId = ids.nextElement();
- IStructuredModel tempResult = getExistingModel(potentialId);
- if (document == tempResult.getStructuredDocument()) {
- result = getExistingModelForRead(potentialId);
- break;
- }
- }
- return result;
- }
-
- public synchronized IStructuredModel getExistingModelForRead(IFile iFile) {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- Object id = calculateId(iFile);
- IStructuredModel result = getExistingModelForRead(id);
- return result;
- }
-
- /**
- * This is similar to the getModel method, except this method does not
- * create a model. This method does increment the reference count (if it
- * exists). If the model does not already exist in the cache of models,
- * null is returned.
- *
- * @deprecated use IFile form - this one will become protected or private
- */
- public synchronized IStructuredModel getExistingModelForRead(Object id) {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- IStructuredModel result = null;
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- // if not, then we'll simply return null
- if (sharedObject != null) {
- // if shared object is in our cache, then simply increment its ref
- // count,
- // and return the object.
- sharedObject.referenceCountForRead++;
- result = sharedObject.theSharedObject;
- }
- return result;
- }
-
- /**
- * @deprecated DMW: Tom, this is "special" for links builder Assuming its
- * still needed, wouldn't it be better to change to
- * getExistingModels()?
- */
- public synchronized Enumeration getExistingModelIds() {
-
- Enumeration result = new EnumeratedModelIds(managedObjects);
- return result;
- }
-
- // TODO: replace (or suplement) this is a "model info" association to the
- // IFile that created the model
- protected IFile getFileFor(IStructuredModel model) {
-
- if (model == null)
- return null;
- String path = model.getBaseLocation();
- if (path == null || path.length() == 0) {
- Object id = model.getId();
- if (id == null)
- return null;
- path = id.toString();
- }
- // TOODO needs rework for linked resources
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = root.getFileForLocation(new Path(path));
- return file;
- }
-
- /**
- * @return java.util.Dictionary
- */
- protected java.util.Dictionary getManagedObjects() {
-
- if (managedObjects == null) {
- managedObjects = new Hashtable();
- }
- return managedObjects;
- }
-
- /**
- * One of the primary forms to get a managed model
- */
- public synchronized IStructuredModel getModelForEdit(IFile iFile) throws IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, EDIT, null, null);
- }
-
- /**
- */
- public IStructuredModel getModelForEdit(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, EDIT, encodingRule);
- }
-
- public synchronized IStructuredModel getModelForEdit(IFile iFile, String encoding, String lineDelimiter) throws java.io.UnsupportedEncodingException, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, EDIT, encoding, lineDelimiter);
- }
-
- /**
- * @see IModelManager
- * @deprecated use IFile or String form
- */
- public synchronized IStructuredModel getModelForEdit(Object id, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
-
- Assert.isNotNull(id, "IFile parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForEdit(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- /**
- * @see IModelManager
- * @deprecated - use IFile or String form
- */
- public synchronized IStructuredModel getModelForEdit(Object id, Object modelType, String encodingName, String lineDelimiter, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForEdit(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- public synchronized IStructuredModel getModelForEdit(String filename, InputStream inputStream, URIResolver resolver) throws IOException {
-
- InputStream istream = Utilities.getMarkSupportedStream(inputStream);
- IModelHandler handler = calculateType(filename, istream);
- Assert.isNotNull(handler, "model handler can not be null"); //$NON-NLS-1$
- IStructuredModel result = null;
- result = _commonGetModel(istream, filename, handler, resolver, EDIT, null, null);
- return result;
- }
-
- /**
- * One of the primary forms to get a managed model
- */
- public synchronized IStructuredModel getModelForRead(IFile iFile) throws IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, READ, null, null);
- }
-
- public IStructuredModel getModelForRead(IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, READ, encodingRule);
- }
-
- public synchronized IStructuredModel getModelForRead(IFile iFile, String encodingName, String lineDelimiter) throws java.io.UnsupportedEncodingException, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- return _commonGetModel(iFile, READ, encodingName, lineDelimiter);
- }
-
- /**
- * @see IModelManager
- * @deprecated use IFile or String form
- */
- public synchronized IStructuredModel getModelForRead(Object id, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForRead(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- /**
- * @see IModelManager
- * @deprecated use IFile form
- */
- public synchronized IStructuredModel getModelForRead(Object id, Object modelType, String encodingName, String lineDelimiter, InputStream inputStream, URIResolver resolver) throws java.io.UnsupportedEncodingException, IOException {
-
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- String stringId = id.toString();
- return getModelForRead(stringId, Utilities.getMarkSupportedStream(inputStream), resolver);
- }
-
- public synchronized IStructuredModel getModelForRead(String filename, InputStream inputStream, URIResolver resolver) throws IOException {
-
- InputStream istream = Utilities.getMarkSupportedStream(inputStream);
- IModelHandler handler = calculateType(filename, istream);
- IStructuredModel result = null;
- result = _commonGetModel(istream, filename, handler, resolver, READ, null, null);
- return result;
- }
-
- /**
- * @deprecated - only temporarily visible
- */
- public ModelHandlerRegistry getModelHandlerRegistry() {
-
- if (fModelHandlerRegistry == null) {
- fModelHandlerRegistry = ModelHandlerRegistry.getInstance();
- }
- return fModelHandlerRegistry;
- }
-
- /**
- * @see IModelManager#getNewModelForEdit(IFile, boolean)
- */
- public synchronized IStructuredModel getNewModelForEdit(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = _commonNewModel(iFile, force);
- sharedObject.referenceCountForEdit = 1;
- //_traceFiner("created new model for Edit: ", id);
- //_traceFinest(" set referenceCountForEdit", id,
- // sharedObject.referenceCountForEdit);
- return sharedObject.theSharedObject;
- }
-
- /**
- * @see IModelManager#getNewModelForRead(IFile, boolean)
- */
- public synchronized IStructuredModel getNewModelForRead(IFile iFile, boolean force) throws ResourceAlreadyExists, ResourceInUse, IOException, CoreException {
-
- Assert.isNotNull(iFile, "IFile parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = _commonNewModel(iFile, force);
- sharedObject.referenceCountForRead = 1;
- //_traceFiner("created new model for Edit: ", id);
- //_traceFinest(" set referenceCountForEdit", id,
- // sharedObject.referenceCountForEdit);
- return sharedObject.theSharedObject;
- }
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- public synchronized int getReferenceCount(java.lang.Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead + sharedObject.referenceCountForEdit;
- return count;
- }
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- public synchronized int getReferenceCountForEdit(java.lang.Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForEdit;
- return count;
- }
-
- /**
- * This function returns the reference count of underlying model.
- *
- * @param id
- * Object The id of the model TODO: try to refine the design
- * not to use this function
- */
- public synchronized int getReferenceCountForRead(java.lang.Object id) {
- Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead;
- return count;
- }
-
- private void handleProgramError(Throwable t) {
-
- Logger.logException("Impossible Program Error", t); //$NON-NLS-1$
- }
-
- /**
- * Register adapters for resources using an extension point. Required to
- * ensure that calculateURIResolver has the necessary factories registered
- * before any models are loaded.
- *
- * @deprecated - wrong place to do this
- */
- protected void initResourceAdapters() {
-
- // Note: see comment in plugin.xml for potentially
- // breaking change in behavior.
-
- // new URIResolverAdapterFactoryRegistryReader().loadRegistry();
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- */
- public synchronized boolean isShared(java.lang.Object id) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- boolean result = false;
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead + sharedObject.referenceCountForEdit;
- result = count > 1;
- return result;
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- *
- * @param id
- * Object The id of the model
- */
- public synchronized boolean isSharedForEdit(java.lang.Object id) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- boolean result = false;
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForEdit;
- result = count > 1;
- return result;
- }
-
- /**
- * This function returns true if there are other references to the
- * underlying model.
- *
- * @param id
- * Object The id of the model
- */
- public synchronized boolean isSharedForRead(java.lang.Object id) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- int count = 0;
- boolean result = false;
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject != null)
- count = sharedObject.referenceCountForRead;
- result = count > 1;
- return result;
- }
-
- /**
- * This method can be called to determine if the model manager is within a
- * "aboutToChange" and "changed" sequence.
- */
- public synchronized boolean isStateChanging() {
-
- return modelManagerStateChanging > 0;
- }
-
- /**
- * This method changes the id of the model. TODO: try to refine the design
- * not to use this function
- */
- public synchronized void moveModel(Object oldId, Object newId) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(oldId, "id parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(oldId);
- // if not found in cache, ignore request.
- // this would normally be a program error
- if (sharedObject != null) {
- getManagedObjects().remove(oldId);
- getManagedObjects().put(newId, sharedObject);
- }
- }
-
- private String readInputStream(InputStream inputStream, String ianaEncodingName) throws UnsupportedEncodingException, IOException {
-
- String allText = null;
- if ((ianaEncodingName != null) && (ianaEncodingName.length() != 0)) {
- String enc = CodedIO.getAppropriateJavaCharset(ianaEncodingName);
- if (enc == null) {
- // if no conversion was possible, let's assume that
- // the encoding is already a java encoding name, so we'll
- // proceed with that assumption. This is the case, for
- // example,
- // for the reload() procedure.
- // If in fact it is not a valid java encoding, then
- // the "allText=" line will cause an
- // UnsupportedEncodingException
- enc = ianaEncodingName;
- }
- allText = readInputStream(new InputStreamReader(inputStream, enc));
- }
- else {
- // we normally assume encoding is provided for this method, but if
- // not,
- // we'll use platform default
- allText = readInputStream(new InputStreamReader(inputStream));
- }
- return allText;
- }
-
- private String readInputStream(InputStreamReader inputStream) throws IOException {
-
- int numRead = 0;
- StringBuffer buffer = new StringBuffer();
- char tBuff[] = new char[READ_BUFFER_SIZE];
- while ((numRead = inputStream.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- }
- // remember -- we didn't open stream ... so we don't close it
- return buffer.toString();
- }
-
- /*
- * @see IModelManager#reinitialize(IStructuredModel)
- */
- public synchronized IStructuredModel reinitialize(IStructuredModel model) {
-
- // getHandler (assume its the "new one")
- IModelHandler handler = model.getModelHandler();
- // getLoader for that new one
- ModelLoader loader = handler.getModelLoader();
- // ask it to reinitialize
- model = loader.reinitialize(model);
- // the loader should check to see if the one it received
- // is the same type it would normally create.
- // if not, it must "start from scratch" and create a whole
- // new one.
- // if it is of the same type, it should just 'replace text'
- // replacing all the existing text with the new text.
- // the important one is the JSP loader ... it should go through
- // its embedded content checking and initialization
- return model;
- }
-
- /**
- * @see IModelManager
- * @deprecated -- I think these can eventually become 'protected' methods
- */
- public synchronized void releaseFromEdit(Object id) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- // if not found in cache, ignore request.
- // this would normally be a program error, but if doNotCache is true,
- // then it won't be found in the cache.
- if (sharedObject != null) {
- sharedObject.referenceCountForEdit--;
- trace("Decremented referenceCountForEdit", id, sharedObject.referenceCountForEdit); //$NON-NLS-1$
- if ((sharedObject.referenceCountForRead == 0) && (sharedObject.referenceCountForEdit == 0)) {
- _commonRelease(id, sharedObject);
- trace("model released (in releaseFromEdit)", id); //$NON-NLS-1$
- }
- else {
- // the following is just an integrity check
- // we only need to check edit, since edit is what we
- // decremented above
- if (sharedObject.referenceCountForEdit < 0) {
- throw new IllegalStateException(" ModelManagerImpl::releaseFromEdit. edit reference count found to be less than zero"); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * @see IModelManager
- * @deprecated -- I think these can eventually become 'protected' methods
- */
- public synchronized void releaseFromRead(Object id) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- // if not found in cache, ignore request.
- // this would normally be a program error, but if doNotCache is true,
- // then it won't be found in the cache.
- if (sharedObject != null) {
- sharedObject.referenceCountForRead--;
- trace("Decremented referenceCountForRead ", id, sharedObject.referenceCountForRead); //$NON-NLS-1$
- if ((sharedObject.referenceCountForRead == 0) && (sharedObject.referenceCountForEdit == 0)) {
- _commonRelease(id, sharedObject);
- trace("model released (in releaseFromRead) ", id); //$NON-NLS-1$
- }
- else {
- // the following is just an integrity check
- // we only need to check read, since read is what we
- // decremented above
- if (sharedObject.referenceCountForRead < 0) {
- throw new IllegalStateException(" ModelManagerImpl::releaseFromRead. read reference count found to be less than zero"); //$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * This is similar to the getModel method, except this method does not use
- * the cached version, but forces the cached version to be replaced with a
- * fresh, unchanged version. Note: this method does not change any
- * reference counts. Also, if there is not already a cached version of the
- * model, then this call is essentially ignored (that is, it does not put
- * a model in the cache) and returns null.
- *
- * @deprecated - will become protected, use reload directly on model
- */
- public synchronized IStructuredModel reloadModel(java.lang.Object id, java.io.InputStream inputStream) throws java.io.UnsupportedEncodingException {
-
- // get the existing model associated with this id
- IStructuredModel structuredModel = getExistingModel(id);
- // for the model to be null is probably an error (that is,
- // reload should not have been called, but we'll guard against
- // a null pointer example and return null if we are no longer managing
- // that model.
- if (structuredModel != null) {
- // get loader based on existing type
- // dmwTODO evaluate when reload should occur
- // with potentially new type (e.g. html 'save as' jsp).
- IModelHandler handler = structuredModel.getModelHandler();
- ModelLoader loader = handler.getModelLoader();
- // ask the loader to re-load
- loader.reload(Utilities.getMarkSupportedStream(inputStream), structuredModel);
- trace("re-loading model", id); //$NON-NLS-1$
- }
- return structuredModel;
- }
-
- public synchronized void removeModelManagerListener(IModelManagerListener listener) {
-
- if ((fModelManagerListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fModelManagerListeners, listener)) {
- int oldSize = fModelManagerListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fModelManagerListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fModelManagerListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fModelManagerListeners = newListeners;
- }
- }
- }
-
- public void saveModel(IFile iFile, String id, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject == null) {
- throw new SourceEditingRuntimeException(ResourceHandler1.getString("Program_Error__ModelManage_EXC_")); //$NON-NLS-1$ = "Program Error: ModelManagerImpl::saveModel. Model should be in the cache"
- }
- else {
- IStructuredModel model = sharedObject.theSharedObject;
- IStructuredDocument document = model.getStructuredDocument();
- saveStructuredDocument(document, iFile, encodingRule);
- trace("saving model", id); //$NON-NLS-1$
- }
- sharedObject.theSharedObject.setDirtyState(false);
- sharedObject.theSharedObject.setNewState(false);
- }
-
- /**
- * Saving the model really just means to save it's structured document.
- *
- * @param id
- * @param outputStream
- * @param encodingRule
- * @throws UnsupportedEncodingException
- * @throws IOException
- * @throws CoreException
- */
- public void saveModel(String id, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException, CoreException {
-
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject == null) {
- throw new SourceEditingRuntimeException(ResourceHandler1.getString("Program_Error__ModelManage_EXC_")); //$NON-NLS-1$ = "Program Error: ModelManagerImpl::saveModel. Model should be in the cache"
- }
- else {
- IFile iFile = getFileFor(sharedObject.theSharedObject);
- // ModelDumper dumper = null;
- // dumper =
- // sharedObject.theSharedObject.getModelHandler().getModelDumper();
- // dumper.dump(sharedObject.theSharedObject, outputStream,
- // encodingRule, iFile);
- IStructuredModel model = sharedObject.theSharedObject;
- IStructuredDocument document = model.getStructuredDocument();
- saveStructuredDocument(document, iFile);
- trace("saving model", id); //$NON-NLS-1$
- }
- sharedObject.theSharedObject.setDirtyState(false);
- sharedObject.theSharedObject.setNewState(false);
- }
-
- /**
- * @deprecated - this method is less efficient than IFile form, since it
- * requires an extra "copy" of byte array, and should be avoid
- * in favor of the IFile form.
- */
- public void saveModel(String id, OutputStream outputStream, EncodingRule encodingRule) throws UnsupportedEncodingException, CoreException, IOException {
-
- // let's see if we already have it in our cache
- SharedObject sharedObject = (SharedObject) getManagedObjects().get(id);
- if (sharedObject == null) {
- throw new SourceEditingRuntimeException(ResourceHandler1.getString("Program_Error__ModelManage_EXC_")); //$NON-NLS-1$ = "Program Error: ModelManagerImpl::saveModel. Model should be in the cache"
- }
- else {
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- codedStreamCreator.set(sharedObject.theSharedObject.getId(), new DocumentReader(sharedObject.theSharedObject.getStructuredDocument()));
- codedStreamCreator.setPreviousEncodingMemento(sharedObject.theSharedObject.getStructuredDocument().getEncodingMemento());
- ByteArrayOutputStream byteArrayOutputStream = codedStreamCreator.getCodedByteArrayOutputStream(encodingRule);
- byte[] outputBytes = byteArrayOutputStream.toByteArray();
- outputStream.write(outputBytes);
- trace("saving model", id); //$NON-NLS-1$
- }
- sharedObject.theSharedObject.setDirtyState(false);
- sharedObject.theSharedObject.setNewState(false);
- }
-
- public void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile) throws UnsupportedEncodingException, CoreException, IOException {
-
- //IModelHandler handler = calculateType(iFile);
- //IDocumentDumper dumper = handler.getDocumentDumper();
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- String filename = iFile.getName();
- Reader reader = new DocumentReader(structuredDocument);
- codedStreamCreator.set(filename, reader);
- ByteArrayOutputStream codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream(EncodingRule.CONTENT_BASED);
- InputStream codedStream = new ByteArrayInputStream(codedByteStream.toByteArray());
- if (iFile.exists())
- iFile.setContents(codedStream, true, true, null);
- else
- iFile.create(codedStream, false, null);
- codedByteStream.close();
- codedStream.close();
- }
-
- public void saveStructuredDocument(IStructuredDocument structuredDocument, IFile iFile, EncodingRule encodingRule) throws UnsupportedEncodingException, CoreException, IOException {
-
- //IModelHandler handler = calculateType(iFile);
- //IDocumentDumper dumper = handler.getDocumentDumper();
- CodedStreamCreator codedStreamCreator = new CodedStreamCreator();
- String filename = iFile.getName();
- Reader reader = new DocumentReader(structuredDocument);
- codedStreamCreator.set(filename, reader);
- codedStreamCreator.setPreviousEncodingMemento(structuredDocument.getEncodingMemento());
- ByteArrayOutputStream codedByteStream = codedStreamCreator.getCodedByteArrayOutputStream(encodingRule);
- InputStream codedStream = new ByteArrayInputStream(codedByteStream.toByteArray());
- if (iFile.exists())
- iFile.setContents(codedStream, true, true, null);
- else
- iFile.create(codedStream, false, null);
- codedByteStream.close();
- codedStream.close();
- }
-
- /**
- * Common trace method
- */
- private void trace(String msg, Object id) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- Logger.trace("IModelManager", msg + " " + Utilities.makeShortId(id)); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- /**
- * Common trace method
- */
- private void trace(String msg, Object id, int value) {
- org.eclipse.wst.sse.core.util.Assert.isNotNull(id, "id parameter can not be null"); //$NON-NLS-1$
- Logger.trace("IModelManager", msg + Utilities.makeShortId(id) + " (" + value + ")"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java
deleted file mode 100644
index 2b81a0dd6e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelPlugin.java
+++ /dev/null
@@ -1,215 +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.core;
-
-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.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.builder.StructuredDocumentBuilder;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.internal.nls.ResourceHandler;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-
-
-/**
- * This model manager plugin helper is used to return the model manager
- * desired to be used for creating a new model manager, for managing (add or
- * remove) model loaders and model dumpers, and for managing (get, release,
- * save, and save as) models. Here is an example on on how to use it. Under
- * the subdirectory named after your package which contains your
- * implementation of the model manager (e.g. "org.eclipse.wst.sse.core") in the
- * "project_resources\plugins" directory, create a "plugin.xml" file. In this
- * file ("projectproject_resources\plugins\org.eclipse.wst.sse.core\plugin.xml")
- * enter: <?xml version="1.0"?> <plugin name="IBM Web Tooling Model Manager
- * Plugin" id="org.eclipse.wst.sse.core" version="1.0" vendor-name="RTP"
- * class="org.eclipse.wst.sse.core.ModelManagerPlugin"> <!-- The XML package:
- * org.eclipse.wst.etools.b2bxmlrt, is required before the others to give precedence
- * to DOM2 APIs, instead of the DOM1 (used by others, such as the desktop
- * ("org.eclipse.*")) --> <requires><import
- * plugin="org.eclipse.wst.b2bxmlrt" export="true"/> <import
- * plugin="org.eclipse.wst.contentmodel" export="true"/> </requires> <runtime>
- * <library name="runtime/sedmodel.jar"> <export name="*"/> </library>
- * </runtime> </plugin> to tell the workbench the model manager plugin ID and
- * where to find this model manager plugin class. Then in the getModelManager
- * method of this model manager plugin class, create and return the model
- * manager desired to be used. In the client code that requests the model
- * manager, the following code should be used to access the model manager via
- * the plugin: // get the model manager from the plugin ModelManagerPlugin
- * plugin = (ModelManagerPlugin) Platform.getPlugin(ModelManagerPlugin.ID);
- * fModelManager = plugin.getModelManager(); Note that the
- * wb.getPluginRegistry().getPluginDescriptor() method expects the plugin ID
- * as a parameter ("org.eclipse.wst.sse.core" in the above example).
- */
-public class ModelPlugin extends Plugin implements IModelManagerPlugin {
- protected class ProjectChangeListener implements IResourceChangeListener, IResourceDeltaVisitor {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceChangeListener#resourceChanged(org.eclipse.core.resources.IResourceChangeEvent)
- */
- public void resourceChanged(IResourceChangeEvent event) {
- IResourceDelta delta = event.getDelta();
- if (delta.getResource() != null) {
- int resourceType = delta.getResource().getType();
- if (resourceType == IResource.PROJECT || resourceType == IResource.ROOT) {
- try {
- delta.accept(this);
- }
- catch (CoreException e) {
- Logger.logException("Exception managing buildspec list", e); //$NON-NLS-1$
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IResourceDeltaVisitor#visit(org.eclipse.core.resources.IResourceDelta)
- */
- public boolean visit(IResourceDelta delta) throws CoreException {
- IResource resource = delta.getResource();
- if (resource != null) {
- if (resource.getType() == IResource.ROOT)
- return true;
- else if (resource.getType() == IResource.PROJECT) {
- if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {
- StructuredDocumentBuilder.add(new NullProgressMonitor(), (IProject) resource);
- }
- return false;
- }
- }
- return false;
- }
- }
-
- private static final boolean _debugResourceChangeListener = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/resourcechangehandling")); //$NON-NLS-1$ //$NON-NLS-2$
-
- // private static final String FN_PREF_STORE = "pref_store.ini";
- // //$NON-NLS-1$
-
- protected static ModelPlugin instance = null;
-
- public static final String STRUCTURED_BUILDER = "org.eclipse.wst.sse.core.structuredbuilder"; //$NON-NLS-1$
-
- public static ModelPlugin getDefault() {
- return instance;
- }
-
- public static String getID() {
- return getDefault().getBundle().getSymbolicName();
- }
-
- private ProjectChangeListener changeListener;
-
- public ModelPlugin() {
- super();
- instance = this;
- }
-
- public ModelPlugin(IPluginDescriptor descriptor) {
- super(descriptor);
- instance = this;
-
- }
-
- public ModelHandlerRegistry getModelHandlerRegistry() {
- return ModelHandlerRegistry.getInstance();
- }
-
- public IModelManager getModelManager() {
- return ModelManagerImpl.getInstance();
- }
-
- /**
- * Set default non-UI
- */
- protected void initializeDefaultPluginPreferences() {
- super.initializeDefaultPluginPreferences();
- Preferences prefs = getDefault().getPluginPreferences();
- // set model preference defaults
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_TAG_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.CLEANUP_ATTR_NAME_CASE, CommonModelPreferenceNames.ASIS);
- prefs.setDefault(CommonModelPreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_REQUIRED_ATTRS, true);
- prefs.setDefault(CommonModelPreferenceNames.INSERT_MISSING_TAGS, true);
- prefs.setDefault(CommonModelPreferenceNames.QUOTE_ATTR_VALUES, true);
- prefs.setDefault(CommonModelPreferenceNames.FORMAT_SOURCE, true);
- prefs.setDefault(CommonModelPreferenceNames.CONVERT_EOL_CODES, false);
- prefs.setDefault(CommonModelPreferenceNames.INPUT_CODESET, CommonModelPreferenceNames.UTF_8);
- prefs.setDefault(CommonModelPreferenceNames.OUTPUT_CODESET, CommonModelPreferenceNames.UTF_8);
- prefs.setDefault(CommonModelPreferenceNames.END_OF_LINE_CODE, new String());
- prefs.setDefault(CommonModelPreferenceNames.TAB_WIDTH, CommonModelPreferenceNames.DEFAULT_TAB_WIDTH);
- prefs.setDefault(CommonModelPreferenceNames.FORMATTING_SUPPORTED, false);
- prefs.setDefault(CommonModelPreferenceNames.LINE_WIDTH, 72);
- prefs.setDefault(CommonModelPreferenceNames.SPLIT_MULTI_ATTRS, false);
- prefs.setDefault(CommonModelPreferenceNames.INDENT_USING_TABS, true);
- prefs.setDefault(CommonModelPreferenceNames.CLEAR_ALL_BLANK_LINES, false);
- prefs.setDefault(CommonModelPreferenceNames.PREFERRED_MARKUP_CASE_SUPPORTED, false);
- prefs.setDefault(CommonModelPreferenceNames.TAG_NAME_CASE, CommonModelPreferenceNames.UPPER);
- prefs.setDefault(CommonModelPreferenceNames.ATTR_NAME_CASE, CommonModelPreferenceNames.LOWER);
- prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_TAGS, "TODO,FIXME,XXX"); //$NON-NLS-1$
- prefs.setDefault(CommonModelPreferenceNames.TASK_TAG_PRIORITIES, "1,2,1"); //$NON-NLS-1$
- }
-
- public void shutdown() throws CoreException {
- super.shutdown();
- savePluginPreferences();
- // Remove the listener from the workspace
- IWorkspace workspace = ResourcesPlugin.getWorkspace();
- if (changeListener != null && workspace != null) {
- workspace.removeResourceChangeListener(changeListener);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.Plugin#startup()
- */
- public void startup() throws CoreException {
- super.startup();
- // Register the ProjectChangeListener so that it can add the builder
- // to projects as needed
- changeListener = new ProjectChangeListener();
- Job adder = new Job(ResourceHandler.getString("ModelPlugin.0")) { //$NON-NLS-1$
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.jobs.Job#run(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IStatus run(IProgressMonitor monitor) {
- StructuredDocumentBuilder.add(monitor, ResourcesPlugin.getWorkspace().getRoot());
- return Status.OK_STATUS;
- }
- };
- adder.schedule(2000);
- ResourcesPlugin.getWorkspace().addResourceChangeListener(changeListener, IResourceChangeEvent.PRE_BUILD);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java
deleted file mode 100644
index 42b21397f8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/ModelStateMemento.java
+++ /dev/null
@@ -1,93 +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.core;
-
-
-
-import org.eclipse.core.resources.IResource;
-
-/**
- * Used my AbstractStructuredModel to keep track of what state it should be in, when
- * restoreState(memento) is called. See also getMemento.
- */
-class ModelStateMemento implements IStateMemento {
-
- /** the resource used in 'getMemento'. Eventually (V2) will be part of the Model itself */
- private IResource underlyingResource;
- /** datesInSynch records whether or not the resource modification date, and synchronization date
- are the same when getMemento is called. If so, they should be forced to be the same in restoreState */
- private boolean datesInSync;
- /** dirty State when 'getMemento' called. restoreState should set it back to this value. */
- private boolean dirtyState;
-
- /**
- * ModelStateMemento constructor comment.
- */
- ModelStateMemento() {
- super();
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (9/7/2001 1:15:06 PM)
- * @return org.eclipse.core.resources.IResource
- */
- org.eclipse.core.resources.IResource getUnderlyingResource() {
- return underlyingResource;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (9/7/2001 2:18:03 PM)
- * @return boolean
- */
- boolean isDatesInSync() {
- return datesInSync;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (9/7/2001 1:15:06 PM)
- * @return boolean
- */
- boolean isDirtyState() {
- return dirtyState;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (9/7/2001 2:18:03 PM)
- * @param newDatesInSync boolean
- */
- void setDatesInSync(boolean newDatesInSync) {
- datesInSync = newDatesInSync;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (9/7/2001 1:15:06 PM)
- * @param newDirtyState boolean
- */
- void setDirtyState(boolean newDirtyState) {
- dirtyState = newDirtyState;
- }
-
- /**
- * Insert the method's description here.
- * Creation date: (9/7/2001 1:15:06 PM)
- * @param newUnderlyingResource org.eclipse.core.resources.IResource
- */
- void setUnderlyingResource(org.eclipse.core.resources.IResource newUnderlyingResource) {
- underlyingResource = newUnderlyingResource;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.java
deleted file mode 100644
index 8ecfa6ccf7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapter.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.core;
-
-import java.util.List;
-
-
-
-public interface PropagatingAdapter extends org.eclipse.wst.sse.core.INodeAdapter {
- // dmw: should have getFactoryFor?
- void release();
-
- void addAdaptOnCreateFactory(AdapterFactory factory);
-
- List getAdaptOnCreateFactories();
-
- /**
- * This method should be called immediately after adding a factory,
- * typically on the document (top level) node, so all nodes can be
- * adapted, if needed. This is needed for those occasions when a
- * factory is addeded after some nodes may have already been created
- * at the time the factory is added.
- */
- void initializeForFactory(AdapterFactory factory, INodeNotifier node);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.java
deleted file mode 100644
index df07fab764..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/PropagatingAdapterFactory.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.core;
-
-
-
-import java.util.ArrayList;
-
-
-
-public interface PropagatingAdapterFactory extends AdapterFactory {
-
- void setContributedFactories(ArrayList list);
-
- void addContributedFactories(AdapterFactory factory);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.java
deleted file mode 100644
index 3b351a16dd..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderDelegate.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.core.builder;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-
-/**
- * Delegates for the Structured Builder. Delegates may be contributed using
- * the org.eclipse.wst.sse.core.builderdelegate extension point. For resources and
- * resource deltas with matching content types, the builder will first call
- * the startup() method, build(), and shutdown in sequence. Participant
- * instances will be reused across projects but are not shared per content
- * type. Participants should not hold on to references to models or resources
- * after shutdown().
- */
-public interface IBuilderDelegate {
- IStatus build(IFile file, int kind, Map args, IProgressMonitor monitor);
-
- /**
- * Notifies the participant that building is done for now. Resources held
- * from startup should now be released.
- */
- void shutdown(IProject project);
-
- /**
- * Notifies the participant that a sequence of builds is about to be
- * called. Ideally the time to load preferences and perform any expensive
- * configuration for the given project.
- *
- * @param project -
- * the project that's about to be built
- * @param kind -
- * the kind of build being done; possible values are
- * IncrementalProjectBuilder.AUTO_BUILD,
- * IncrementalProjectBuilder.FULL_BUILD, or
- * IncrementalProjectBuilder.INCREMENTAL_BUILD
- * @param args
- * the table of builder-specific arguments sent to the
- * Structured Document Builder, keyed by argument name (key
- * type: <code>String</code>, value type:
- * <code>String</code>);<code>null</code> is equivalent
- * to an empty map
- */
- void startup(IProject project, int kind, Map args);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.java
deleted file mode 100644
index e4183083b6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderModelProvider.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.core.builder;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-/**
- * Model provider for IBuilderParticipants - provides Structured Documents and
- * Models to participants. Clients should not implement. Models for any
- * resource may be requested, not just for the current delta. The same
- * document and model instances are NOT guaranteed to be returned with each
- * call.
- */
-
-public interface IBuilderModelProvider {
- /**
- * @param file
- * @return an IStructuredDocument with the file's contents if the file's
- * Content Type is supported, null if not
- */
- IStructuredDocument getDocument(IFile file);
-
- /**
- * @param file
- * @return an IStructuredModel with the file's contents if the file's
- * Content Type is supported, null if not
- */
- IStructuredModel getModel(IFile file);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java
deleted file mode 100644
index 92be37eaf2..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/IBuilderParticipant.java
+++ /dev/null
@@ -1,120 +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.core.builder;
-
-import java.util.Map;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-/**
- * Participants in the Structured building process. Participants may be
- * contributed using the org.eclipse.wst.sse.core.builderparticipant extension
- * point. For resources and resource deltas with matching content types, the
- * builder will first call the build() method and then the cleanup() method
- * in sequence. Participant instances will be reused across projects but are
- * not shared per content type. Participants should not hold on to references
- * to models or resources after cleanup().
- */
-public interface IBuilderParticipant {
- /**
- * Notifies the participant that a sequence of builds is about to be
- * called. Ideally the time to load preferences and perform any expensive
- * configuration for the given project.
- *
- * @param project -
- * the project that's about to be built
- * @param kind -
- * the kind of build being done; possible values are
- * IncrementalProjectBuilder.AUTO_BUILD,
- * IncrementalProjectBuilder.FULL_BUILD, or
- * IncrementalProjectBuilder.INCREMENTAL_BUILD
- * @param args
- * the table of builder-specific arguments sent to the
- * Structured Document Builder, keyed by argument name (key
- * type: <code>String</code>, value type: <code>String</code>);
- * <code>null</code> is equivalent to an empty map
- */
- void startup(IProject project, int kind, Map args);
-
- /**
- * Perform an incremental build. May be called multiple times between
- * startup and shutdown.
- *
- * @param delta -
- * the IResourceDelta to examine for building
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this delta's resource
- * @param monitor
- * @return
- */
- boolean build(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
-
- /**
- * Perform a build for the given resources within this project. May be
- * called multiple times between startup and shutdown.
- *
- * @param resources -
- * an IResource list of resources in this project with the
- * correct content type
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this project
- * @param monitor
- * @return
- */
- boolean build(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
- /**
- * Do any post-build cleanup from building a resource delta. Called once
- * for every matching build() call.
- *
- * @param delta -
- * the IResourceDelta to examine for building
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this delta's resource
- * @param monitor
- * @return
- */
- boolean cleanup(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
- /**
- * Do any post-build cleanup from a full build for a project. Called once
- * for every matching build() call.
- *
- * @param resources -
- * the IResource list of resources in this project with the
- * correct content type
- * @param project -
- * the project on which this participant is operating
- * @param provider -
- * a model provider for this delta's resource
- * @param monitor
- * @return
- */
- boolean cleanup(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor);
-
- /**
- * Notifies the participant that building is done for now. Resources held
- * from startup should now be released.
- */
- void shutdown(IProject project);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/AbstractBuilderParticipant.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/AbstractBuilderParticipant.java
deleted file mode 100644
index 079f0fa732..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/AbstractBuilderParticipant.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.core.builder.participants;
-
-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.IResourceDelta;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.sse.core.builder.IBuilderModelProvider;
-import org.eclipse.wst.sse.core.builder.IBuilderParticipant;
-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;
-
-
-/**
- * Publically usable implementor of IBuilderParticipant. Includes pre- and
- * post-build hooks and iteration through the Structured Document
- */
-
-public class AbstractBuilderParticipant implements IBuilderParticipant {
-
- private IFile fCurrentFile;
- private IBuilderModelProvider fModelProvider;
-
- public AbstractBuilderParticipant() {
- super();
- }
-
- protected boolean build(IFile file, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- preBuild(file, provider, monitor);
- if (getCurrentFile().isAccessible() && !monitor.isCanceled()) {
- IStructuredDocument document = provider.getDocument(getCurrentFile());
- if (document != null) {
- IStructuredDocumentRegion region = document.getFirstStructuredDocumentRegion();
- while (region != null && !monitor.isCanceled()) {
- build(region);
- region = region.getNext();
- }
- }
- }
- postBuild(file, provider, monitor);
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean build(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- for (int i = 0; i < resources.length; i++) {
- if (!monitor.isCanceled()) {
- build((IFile) resources[i], project, provider, monitor);
- }
- }
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean build(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- return build((IFile) delta.getResource(), project, provider, monitor);
- }
-
- protected void build(IStructuredDocumentRegion region) {
- doBuildFor(region);
- ITextRegionList list = region.getRegions();
- for (int i = 0; i < list.size(); i++) {
- doBuildFor(region, list.get(i));
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean cleanup(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean cleanup(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- return false;
- }
-
- protected void doBuildFor(IStructuredDocumentRegion region) {
- }
-
- protected void doBuildFor(IStructuredDocumentRegion region, ITextRegion textRegion) {
- }
-
- /**
- * @return Returns the currentFile.
- */
- public IFile getCurrentFile() {
- return fCurrentFile;
- }
-
- /**
- * @return Returns the modelProvider.
- */
- public IBuilderModelProvider getModelProvider() {
- return fModelProvider;
- }
-
- protected void postBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- setCurrentFile(null);
- setModelProvider(null);
- }
-
- protected void preBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- setCurrentFile(file);
- setModelProvider(provider);
- }
-
- /**
- * @param currentFile
- * The currentFile to set.
- */
- protected void setCurrentFile(IFile currentFile) {
- fCurrentFile = currentFile;
- }
-
- /**
- * @param modelProvider
- * The modelProvider to set.
- */
- protected void setModelProvider(IBuilderModelProvider modelProvider) {
- fModelProvider = modelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void shutdown(IProject project) {
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void startup(IProject project, int kind, Map args) {
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/MarkerParticipant.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/MarkerParticipant.java
deleted file mode 100644
index da7c00338f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/MarkerParticipant.java
+++ /dev/null
@@ -1,137 +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.core.builder.participants;
-
-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.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.wst.sse.core.builder.IBuilderModelProvider;
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-/**
- * A Builder Participant that updates a set of Markers for a given resource
- * on each build by removing all of the existing Markers. It collects the
- * existing markers in prebuild and deletes them in postbuild. Subclasses may
- * create new markers during the build itself.
- */
-
-public abstract class MarkerParticipant extends AbstractBuilderParticipant {
- List oldMarkers = null;
-
- public MarkerParticipant() {
- super();
- }
-
- /**
- * Returns the attributes with which a newly created marker will be
- * initialized. Modified from the method in MarkerRulerAction
- *
- * @return the initial marker attributes
- */
- protected Map createInitialMarkerAttributes(String text, int documentLine, int startOffset, int length, int priority) {
- Map attributes = new HashMap(6);
- // marker line numbers are 1-based
- attributes.put(IMarker.LINE_NUMBER, new Integer(documentLine + 1));
- attributes.put(IMarker.CHAR_START, new Integer(startOffset));
- attributes.put(IMarker.CHAR_END, new Integer(startOffset + length));
- attributes.put(IMarker.MESSAGE, text);
- attributes.put(getParticipantMarkerType(), Boolean.TRUE);
- attributes.put(IMarker.USER_EDITABLE, Boolean.FALSE);
-
- switch (priority) {
- case IMarker.PRIORITY_HIGH :
- {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_HIGH));
- }
- break;
- case IMarker.PRIORITY_LOW :
- {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_LOW));
- }
- break;
- default :
- {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_NORMAL));
- }
- }
-
- return attributes;
- }
-
- /**
- * @return - The IMarker type (ex.: IMarker.TASK) manipulated by this
- * participant
- */
- protected abstract String getMarkerType();
-
- /**
- * Returns an extra attribute name to indicate that the IMarker type was
- * created by this participant, an "owner" ID.
- */
- protected String getParticipantMarkerType() {
- return getClass().getName();
- }
-
- protected void postBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- IWorkspaceRunnable r = new IWorkspaceRunnable() {
- public void run(IProgressMonitor progressMonitor) throws CoreException {
- Iterator i = oldMarkers.iterator();
- while (i.hasNext()) {
- ((IMarker) i.next()).delete();
- }
- }
- };
- try {
- if (file.isAccessible()) {
- file.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, null);
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- super.postBuild(file, provider, monitor);
- }
-
- protected void preBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- super.preBuild(file, provider, monitor);
- oldMarkers = new ArrayList(0);
- IMarker[] markers = null;
- try {
- // can't use deleteMarkers--not specific enough
- if (file.isAccessible()) {
- markers = file.findMarkers(getMarkerType(), true, IResource.DEPTH_INFINITE);
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- if (markers != null) {
- for (int i = 0; i < markers.length; i++) {
- if (markers[i].getResource().equals(file) && markers[i].getAttribute(getParticipantMarkerType(), true)) {
- oldMarkers.add(markers[i]);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagParticipant.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagParticipant.java
deleted file mode 100644
index 6f79de5010..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagParticipant.java
+++ /dev/null
@@ -1,280 +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.core.builder.participants;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.sse.core.ModelPlugin;
-import org.eclipse.wst.sse.core.builder.IBuilderModelProvider;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.util.StringUtils;
-
-
-/**
- * A participant to update IMarker.TASKs for "TODO" and similiar comments.
- */
-public abstract class TaskTagParticipant extends MarkerParticipant {
-
-
- public class TaskTag {
- public int priority;
- public String text;
-
- public TaskTag(String taskText, int taskPriority) {
- this.text = taskText;
- this.priority = taskPriority;
- }
- }
-
- private static final boolean _debug = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/participant/tasktag")); //$NON-NLS-1$ //$NON-NLS-2$
-
- protected List fNewMarkerAttributes = null;
-
- private TaskTag[] fTaskTags = null;
-
- public TaskTagParticipant() {
- super();
- if (_debug) {
- System.out.println(getClass().getName() + " created"); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean build(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- if (_debug) {
- StringBuffer s = new StringBuffer();
- for (int i = 0; i < resources.length; i++) {
- s.append(resources[i].getFullPath());
- if (i < resources.length - 1)
- s.append(", "); //$NON-NLS-1$
- }
- System.out.println(this + " build for " + resources.length + " resources: " + s.toString()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- boolean result = super.build(resources, project, provider, monitor);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean build(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- if (_debug) {
- System.out.println(this + " building delta " + delta.getResource()); //$NON-NLS-1$
- }
- boolean result = super.build(delta, project, provider, monitor);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean cleanup(IResource[] resources, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- if (_debug) {
- System.out.println(this + " cleanup for " + resources.length + " resources"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- boolean result = super.cleanup(resources, project, provider, monitor);
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean cleanup(IResourceDelta delta, IProject project, IBuilderModelProvider provider, IProgressMonitor monitor) {
- if (_debug) {
- System.out.println(this + " cleanup for delta " + delta.getResource()); //$NON-NLS-1$
- }
- boolean result = super.cleanup(delta, project, provider, monitor);
- return result;
- }
-
- protected void createTasks(IStructuredDocumentRegion region, ITextRegion textRegion) {
- IDocument document = getModelProvider().getDocument(getCurrentFile());
- int startOffset = region.getStartOffset(textRegion);
- int endOffset = region.getTextEndOffset(textRegion);
- try {
- int startLine = document.getLineOfOffset(startOffset);
- int endLine = document.getLineOfOffset(endOffset);
- for (int lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
- IRegion line = document.getLineInformation(lineNumber);
- int begin = Math.max(startOffset, line.getOffset());
- int end = Math.min(endOffset, line.getOffset() + line.getLength());
- String commentedText = document.get(begin, end - begin);
- for (int i = 0; i < fTaskTags.length; i++) {
- int tagIndex = commentedText.indexOf(fTaskTags[i].text);
- if (tagIndex >= 0) {
- String markerDescription = commentedText.substring(tagIndex);
- int offset = begin + tagIndex;
- int length = end - offset;
- // defer marker creation until postBuild so we only
- // have one workspace runnable
- fNewMarkerAttributes.add(createInitialMarkerAttributes(markerDescription, lineNumber, offset, length, fTaskTags[i].priority));
- break;
- }
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
-
- protected void doBuildFor(IStructuredDocumentRegion region, ITextRegion textRegion) {
- super.doBuildFor(region, textRegion);
- if (isCommentRegion(region, textRegion)) {
- createTasks(region, textRegion);
- }
- }
-
- protected String getMarkerType() {
- return IMarker.TASK;
- }
-
- /**
- * @param region2
- * @return
- */
- protected abstract boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion);
-
- private void loadPreference() {
- if (_debug) {
- System.out.println(this + " loadPreference()"); //$NON-NLS-1$
- }
- String tagsString = ModelPlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_TAGS);
- String prioritiesString = ModelPlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_PRIORITIES);
-
- StringTokenizer toker = new StringTokenizer(tagsString, ","); //$NON-NLS-1$
- List list = new ArrayList();
- while (toker.hasMoreTokens()) {
- // since we're separating the values with ',', escape ',' in the
- // values
- list.add(StringUtils.replace(toker.nextToken(), "&comma;", ",").trim()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- String[] tags = (String[]) list.toArray(new String[0]);
- list.clear();
-
- toker = new StringTokenizer(prioritiesString, ","); //$NON-NLS-1$
- int i = 0;
- while (toker.hasMoreTokens()) {
- Integer number = null;
- try {
- number = Integer.valueOf(toker.nextToken().trim());
- }
- catch (NumberFormatException e) {
- number = new Integer(IMarker.PRIORITY_NORMAL);
- }
- if (i < tags.length) {
- list.add(new TaskTag(tags[i++], number.intValue()));
- }
- }
- fTaskTags = (TaskTag[]) list.toArray(new TaskTag[0]);
-/*// commenting out - the order is important
- * Arrays.sort(fTaskTags, new Comparator() {
- public boolean equals(Object obj) {
- return false;
- }
-
- public int compare(Object o1, Object o2) {
- TaskTag t1 = (TaskTag) o1;
- TaskTag t2 = (TaskTag) o2;
- // reverse the priority so that HIGH > LOW
- if (t1.priority != t2.priority)
- return t2.priority - t1.priority;
- return Collator.getInstance().compare(t1.text, t2.text);
- }
- });
-*/
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected void postBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- final IFile postBuildFile = file;
- if (postBuildFile.isAccessible()) {
- try {
- IWorkspaceRunnable r = new IWorkspaceRunnable() {
- public void run(IProgressMonitor progressMonitor) throws CoreException {
- for (int i = 0; i < fNewMarkerAttributes.size(); i++) {
- IMarker marker = postBuildFile.createMarker(IMarker.TASK);
- marker.setAttributes((Map) fNewMarkerAttributes.get(i));
- }
- }
- };
- postBuildFile.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, monitor);
- fNewMarkerAttributes = null;
- }
- catch (CoreException e1) {
- Logger.logException(e1);
- }
- }
- super.postBuild(file, provider, monitor);
- }
-
- /*
- * (non-Javadoc)
- *
- */
- protected void preBuild(IFile file, IBuilderModelProvider provider, IProgressMonitor monitor) {
- super.preBuild(file, provider, monitor);
- fNewMarkerAttributes = new ArrayList();
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void shutdown(IProject project) {
- super.shutdown(project);
- if (_debug) {
- System.out.println(this + " shutdown for " + project.getName()); //$NON-NLS-1$
- }
- fTaskTags = null;
- }
-
- /*
- * (non-Javadoc)
- */
- public void startup(IProject project, int kind, Map args) {
- super.startup(project, kind, args);
- if (_debug) {
- System.out.println(this + " startup for " + project.getName()); //$NON-NLS-1$
- }
- loadPreference();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagSeeker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagSeeker.java
deleted file mode 100644
index 4e987138c0..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/builder/participants/TaskTagSeeker.java
+++ /dev/null
@@ -1,424 +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.core.builder.participants;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IMarker;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IWorkspace;
-import org.eclipse.core.resources.IWorkspaceRunnable;
-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.Platform;
-import org.eclipse.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.sse.core.ModelPlugin;
-import org.eclipse.wst.sse.core.builder.IBuilderDelegate;
-import org.eclipse.wst.sse.core.document.DocumentReader;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.modelhandler.ModelHandlerRegistry;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandler;
-import org.eclipse.wst.sse.core.parser.StructuredDocumentRegionParser;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-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.core.util.StringUtils;
-
-
-/**
- * A participant to create IMarker.TASKs for "todos" and similiar comments.
- * Clients should not subclass.
- */
-public abstract class TaskTagSeeker implements IBuilderDelegate {
-
- public class TaskTag {
- public int priority;
- public String text;
-
- public TaskTag(String taskText, int taskPriority) {
- this.text = taskText;
- this.priority = taskPriority;
- }
- }
-
- private static final boolean _debug = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/participant/tasktag")); //$NON-NLS-1$ //$NON-NLS-2$
- protected static final boolean _debugBuilderPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/time")); //$NON-NLS-1$ //$NON-NLS-2$
-
- // the list of attributes for the new tasks for the current file
- protected List fNewMarkerAttributes = null;
-
- private TaskTag[] fTaskTags = null;
- List oldMarkers = null;
- private long time0;
-
- public TaskTagSeeker() {
- super();
- fNewMarkerAttributes = new ArrayList();
- if (_debug) {
- System.out.println(getClass().getName() + " instance created"); //$NON-NLS-1$
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IStatus build(IFile file, int kind, Map args, IProgressMonitor monitor) {
- if (monitor.isCanceled()) {
- return Status.OK_STATUS;
- }
- if (_debugBuilderPerf) {
- time0 = System.currentTimeMillis();
- }
- // Delete old Task markers
- try {
- file.deleteMarkers(getMarkerType(), true, IResource.DEPTH_ZERO);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
-
- // on a clean build, don't add new tasks
- if (kind != IncrementalProjectBuilder.CLEAN_BUILD) {
- findTasks(file, monitor);
- createNewMarkers(file, monitor);
- }
- if (_debugBuilderPerf) {
- System.out.println("" + (System.currentTimeMillis() - time0) + "ms for " + file.getLocation()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return Status.OK_STATUS;
- }
-
- /**
- * Returns the attributes with which a newly created marker will be
- * initialized. Modified from the method in MarkerRulerAction
- *
- * @return the initial marker attributes
- */
- protected Map createInitialMarkerAttributes(String text, int documentLine, int startOffset, int length, int priority) {
- Map attributes = new HashMap(6);
- // marker line numbers are 1-based
- attributes.put(IMarker.LINE_NUMBER, new Integer(documentLine + 1));
- attributes.put(IMarker.CHAR_START, new Integer(startOffset));
- attributes.put(IMarker.CHAR_END, new Integer(startOffset + length));
- attributes.put(IMarker.MESSAGE, text);
- attributes.put(IMarker.USER_EDITABLE, Boolean.FALSE);
-
- switch (priority) {
- case IMarker.PRIORITY_HIGH : {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_HIGH));
- }
- break;
- case IMarker.PRIORITY_LOW : {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_LOW));
- }
- break;
- default : {
- attributes.put(IMarker.PRIORITY, new Integer(IMarker.PRIORITY_NORMAL));
- }
- }
-
- return attributes;
- }
-
- protected void createNewMarkers(IFile file, IProgressMonitor monitor) {
- final IFile finalFile = file;
- if (file.isAccessible() && fNewMarkerAttributes.size() > 0) {
- if (_debug) {
- System.out.println("" + fNewMarkerAttributes.size() + " tasks for " + file.getFullPath()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- try {
- IWorkspaceRunnable r = new IWorkspaceRunnable() {
- public void run(IProgressMonitor progressMonitor) throws CoreException {
- for (int i = 0; i < fNewMarkerAttributes.size(); i++) {
- IMarker marker = finalFile.createMarker(getMarkerType());
- marker.setAttributes((Map) fNewMarkerAttributes.get(i));
- }
- }
- };
- finalFile.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, monitor);
- fNewMarkerAttributes.clear();
- }
- catch (CoreException e1) {
- Logger.logException(e1);
- }
- }
- }
-
- private String detectCharset(IFile file) {
- if (file.getType() == IResource.FILE && file.isAccessible()) {
- IContentDescription d = null;
- try {
- // optimized description lookup, might not succeed
- d = file.getContentDescription();
- if (d != null)
- return d.getCharset();
- }
- catch (CoreException e) {
- // should not be possible given the accessible and file type
- // check above
- }
- try {
- InputStream contents = file.getContents();
- IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(contents, file.getName(), new QualifiedName[]{IContentDescription.CHARSET});
- contents.close();
- if (description != null) {
- return description.getCharset();
- }
- }
- catch (IOException e) {
- // don't care
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- return ResourcesPlugin.getEncoding();
- }
-
- /**
- * @param document
- * @param documentRegion
- * @param comment
- */
- protected void findTasks(IDocument document, IStructuredDocumentRegion documentRegion, ITextRegion comment) {
- if (isCommentRegion(documentRegion, comment)) {
- int startOffset = documentRegion.getStartOffset(comment);
- int endOffset = documentRegion.getTextEndOffset(comment);
- try {
- int startLine = document.getLineOfOffset(startOffset);
- int endLine = document.getLineOfOffset(endOffset);
- for (int lineNumber = startLine; lineNumber <= endLine; lineNumber++) {
- IRegion line = document.getLineInformation(lineNumber);
- int begin = Math.max(startOffset, line.getOffset());
- int end = Math.min(endOffset, line.getOffset() + line.getLength());
- int length = end - begin;
- String commentedText = getCommentedText(document, begin, length);
- for (int i = 0; i < fTaskTags.length; i++) {
- int tagIndex = commentedText.indexOf(fTaskTags[i].text);
- if (tagIndex >= 0) {
- String markerDescription = commentedText.substring(tagIndex);
- int markerOffset = begin + tagIndex;
- int markerLength = end - markerOffset;
- fNewMarkerAttributes.add(createInitialMarkerAttributes(markerDescription, lineNumber, markerOffset, markerLength, fTaskTags[i].priority));
- break;
- }
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
- }
-
- private void findTasks(IFile file, IProgressMonitor monitor) {
- try {
- IModelHandler handler = ModelHandlerRegistry.getInstance().getHandlerFor(file);
-
- // records if the optimized streamish parse was possible
- boolean didStreamParse = false;
- final IProgressMonitor progressMonitor = monitor;
- final IEncodedDocument defaultDocument = handler.getDocumentLoader().createNewStructuredDocument();
- if (defaultDocument instanceof IStructuredDocument) {
- RegionParser parser = ((IStructuredDocument) defaultDocument).getParser();
- if (parser instanceof StructuredDocumentRegionParser) {
- didStreamParse = true;
- String charset = detectCharset(file);
- StructuredDocumentRegionParser documentParser = (StructuredDocumentRegionParser) parser;
- final IDocument textDocument = new Document();
- setDocumentContent(textDocument, file.getContents(true), charset);
- documentParser.reset(new DocumentReader(textDocument));
- documentParser.addStructuredDocumentRegionHandler(new StructuredDocumentRegionHandler() {
- /**
- * @see org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandler#nodeParsed(org.eclipse.wst.sse.core.text.IStructuredDocumentRegion)
- */
- public void nodeParsed(IStructuredDocumentRegion documentRegion) {
- ITextRegionList regions = documentRegion.getRegions();
- for (int j = 0; j < regions.size(); j++) {
- ITextRegion comment = regions.get(j);
- findTasks(textDocument, documentRegion, comment);
- }
- // disconnect the document regions
- if (documentRegion.getPrevious() != null) {
- documentRegion.getPrevious().setPrevious(null);
- documentRegion.getPrevious().setNext(null);
- }
- if (progressMonitor.isCanceled()) {
- textDocument.set(""); //$NON-NLS-1$
- }
- }
-
- /**
- * @see org.eclipse.wst.sse.core.parser.StructuredDocumentRegionHandler#resetNodes()
- */
- public void resetNodes() {
- }
- });
- documentParser.getDocumentRegions();
- }
- }
- if (!didStreamParse) {
- // Use a StructuredDocument
- IEncodedDocument document = handler.getDocumentLoader().createNewStructuredDocument(file);
- if (document instanceof IStructuredDocument) {
- IStructuredDocumentRegion documentRegion = ((IStructuredDocument) document).getFirstStructuredDocumentRegion();
- while (documentRegion != null) {
- ITextRegionList regions = documentRegion.getRegions();
- for (int j = 0; j < regions.size(); j++) {
- ITextRegion comment = regions.get(j);
- findTasks(document, documentRegion, comment);
- }
- documentRegion = documentRegion.getNext();
- }
- }
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- catch (IOException e) {
- Logger.logException(e);
- }
- }
-
-
- /**
- * @param document
- * @param begin
- * @param length
- * @return
- * @throws BadLocationException
- */
- protected String getCommentedText(IDocument document, int begin, int length) throws BadLocationException {
- return document.get(begin, length);
- }
-
-
- final protected String getMarkerType() {
- return ModelPlugin.getID() + ".task"; //$NON-NLS-1$
- }
-
- /**
- * @param region2
- * @return
- */
- protected abstract boolean isCommentRegion(IStructuredDocumentRegion region, ITextRegion textRegion);
-
- private void loadPreference() {
- if (_debug) {
- System.out.println(this + " loadPreference()"); //$NON-NLS-1$
- }
- String tagsString = ModelPlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_TAGS);
- String prioritiesString = ModelPlugin.getDefault().getPluginPreferences().getString(CommonModelPreferenceNames.TASK_TAG_PRIORITIES);
-
- StringTokenizer toker = new StringTokenizer(tagsString, ","); //$NON-NLS-1$
- List list = new ArrayList();
- while (toker.hasMoreTokens()) {
- // since we're separating the values with ',', escape ',' in the
- // values
- list.add(StringUtils.replace(toker.nextToken(), "&comma;", ",").trim()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- String[] tags = (String[]) list.toArray(new String[0]);
- list.clear();
-
- toker = new StringTokenizer(prioritiesString, ","); //$NON-NLS-1$
- int i = 0;
- while (toker.hasMoreTokens()) {
- Integer number = null;
- try {
- number = Integer.valueOf(toker.nextToken().trim());
- }
- catch (NumberFormatException e) {
- number = new Integer(IMarker.PRIORITY_NORMAL);
- }
- if (i < tags.length) {
- list.add(new TaskTag(tags[i++], number.intValue()));
- }
- }
- fTaskTags = (TaskTag[]) list.toArray(new TaskTag[0]);
- }
-
- protected void setDocumentContent(IDocument document, InputStream contentStream, String charset) {
- Reader in = null;
- try {
- in = new BufferedReader(new InputStreamReader(contentStream, charset), 2048);
- StringBuffer buffer = new StringBuffer(2048);
- char[] readBuffer = new char[2048];
- int n = in.read(readBuffer);
- while (n > 0) {
- buffer.append(readBuffer, 0, n);
- n = in.read(readBuffer);
- }
- document.set(buffer.toString());
- }
- catch (IOException x) {
- }
- finally {
- if (in != null) {
- try {
- in.close();
- }
- catch (IOException x) {
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void shutdown(IProject project) {
- if (_debug) {
- System.out.println(this + " shutdown for " + project.getName()); //$NON-NLS-1$
- }
- fTaskTags = null;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void startup(IProject project, int kind, Map args) {
- if (_debug) {
- System.out.println(this + " startup for " + project.getName()); //$NON-NLS-1$
- }
- loadPreference();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java
deleted file mode 100644
index a602938c6b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractCleanupProcessor.java
+++ /dev/null
@@ -1,271 +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.core.cleanup;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-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.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-/**
- * @deprecated renamed to AbstractStructuredCleanupProcessor
- *
- * TODO will delete in C5
- */
-abstract public class AbstractCleanupProcessor implements CleanupProcessor {
- public String cleanupContent(String input) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public String cleanupContent(String input, int start, int length) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- }
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file, int start, int length) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- }
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- //TODO I don't think we should be turning any of these into runtime
- // exceptions
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (FileNotFoundException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName, int start, int length) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- //TODO I don't think we should be turning any of these into runtime
- // exceptions
-
- catch (CoreException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (FileNotFoundException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (UnsupportedEncodingException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- catch (IOException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- abstract public void cleanupModel(IStructuredModel structuredModel);
-
- abstract public void cleanupModel(IStructuredModel structuredModel, int start, int length);
-
- protected void ensureClosed(OutputStream outputStream, InputStream inputStream) {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- }
-
- private IModelManager getModelManager() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- /**
- * The content type string is case insensitive. It may be "XML" for XML,
- * "CSS" for CSS, and "HTML", "JSP", "JHTML", "SHTML", "SHTM", "HTML-SS",
- * "XHTML", "HTM" for HTML.
- * <p>
- * This is needed for creating a temporary model when the
- * cleanupContent(String input) form of CleanupProcessor is called.
- */
- protected abstract String getContentType();
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java
deleted file mode 100644
index 08e3462fa6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/AbstractStructuredCleanupProcessor.java
+++ /dev/null
@@ -1,480 +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.core.cleanup;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-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.IRegion;
-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.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.preferences.CommonModelPreferenceNames;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-
-public abstract class AbstractStructuredCleanupProcessor implements IStructuredCleanupProcessor {
- public boolean refreshCleanupPreferences = true; // special flag for JUnit tests to skip refresh of cleanup preferences when it's set to false
-
- public String cleanupContent(String input) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public String cleanupContent(String input, int start, int length) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + getContentType();
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupDocument(IDocument document) throws IOException, CoreException {
- if (document == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = getModelManager().getExistingModelForEdit(document);
-
- // cleanup
- cleanupModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void cleanupDocument(IDocument document, int start, int length) throws IOException, CoreException {
- if (document == null)
- return;
-
- if (start >= 0 && length >= 0 && start + length <= document.getLength()) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if
- // model changed.
- structuredModel = getModelManager().getExistingModelForEdit(document);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
- }
-
- public void cleanupFile(IFile file) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFile(IFile file, int start, int length) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- structuredModel = getModelManager().getModelForRead(file);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new
- // FileOutputStream(file.getLocation().toString());
- structuredModel.save(file);
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, 0, structuredModel.getStructuredDocument().getLength());
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupFileName(String fileName, int start, int length) throws IOException, CoreException {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForRead(fileName, inputStream, null);
-
- // cleanup
- cleanupModel(structuredModel, start, length);
-
- // save output to file
- //outputStream = new FileOutputStream(fileName);
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public void cleanupModel(IStructuredModel structuredModel) {
-
- int start = 0;
- int length = structuredModel.getStructuredDocument().getLength();
- cleanupModel(structuredModel, start, length);
- }
-
- public void cleanupModel(IStructuredModel structuredModel, int start, int length) {
-
- if (structuredModel != null) {
- if ((start >= 0) && (length <= structuredModel.getStructuredDocument().getLength())) {
- Vector activeNodes = getActiveNodes(structuredModel, start, length);
- if (activeNodes.size() > 0) {
- Node firstNode = (Node) activeNodes.firstElement();
- Node lastNode = (Node) activeNodes.lastElement();
- boolean done = false;
- Node eachNode = firstNode;
- Node nextNode = null;
- while (!done) {
- // update "done"
- done = (eachNode == lastNode);
-
- // get next sibling before cleanup because eachNode
- // may
- // be deleted,
- // for example when it's an empty text node
- nextNode = eachNode.getNextSibling();
-
- // cleanup selected node(s)
- cleanupNode(eachNode);
-
- // update each node
- if (nextNode != null && nextNode.getParentNode() == null)
- // nextNode is deleted during cleanup
- eachNode = eachNode.getNextSibling();
- else
- eachNode = nextNode;
-
- // This should not be needed, but just in case
- // something went wrong with with eachNode.
- // We don't want an infinite loop here.
- if (eachNode == null)
- done = true;
- }
-
- // format source
- if (getFormatSourcePreference(structuredModel)) {
- // format the document
- IStructuredFormatProcessor formatProcessor = getFormatProcessor();
- formatProcessor.formatModel(structuredModel);
- }
-
- // convert EOL codes
- if (getConvertEOLCodesPreference(structuredModel)) {
- IDocument document = structuredModel.getStructuredDocument();
- String endOfLineCode = getEOLCodePreference(structuredModel);
- String endOfLineCodeString = null;
- if (endOfLineCode.compareTo(CommonModelPreferenceNames.LF) == 0)
- endOfLineCodeString = CommonModelPreferenceNames.STRING_LF;
- else if (endOfLineCode.compareTo(CommonModelPreferenceNames.CR) == 0)
- endOfLineCodeString = CommonModelPreferenceNames.STRING_CR;
- else if (endOfLineCode.compareTo(CommonModelPreferenceNames.CRLF) == 0)
- endOfLineCodeString = CommonModelPreferenceNames.STRING_CRLF;
- if (endOfLineCodeString != null) {
- convertLineDelimiters(document, endOfLineCodeString);
- // DMW: 8/24/2002 setting line delimiter in
- // document allows
- // subsequent editing to insert the same line
- // delimiter.
- if (document instanceof IStructuredDocument) {
- ((IStructuredDocument) document).setLineDelimiter(endOfLineCodeString);
- }
- structuredModel.setDirtyState(true);
- }
- }
- }
- }
- }
- }
-
- public void cleanupNode(Node node) {
- if (node != null) {
- Node cleanupNode = node;
-
- // cleanup the owner node if it's an attribute node
- if (cleanupNode.getNodeType() == Node.ATTRIBUTE_NODE)
- cleanupNode = ((Attr) cleanupNode).getOwnerElement();
-
- // refresh cleanup preferences before getting cleanup handler
- if (refreshCleanupPreferences)
- refreshCleanupPreferences();
-
- // get cleanup handler
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler(cleanupNode);
- if (cleanupHandler != null) {
- // cleanup each node
- cleanupHandler.cleanup(cleanupNode);
- }
- }
- }
-
- protected void ensureClosed(OutputStream outputStream, InputStream inputStream) {
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- }
-
- private IModelManager getModelManager() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- protected Vector getActiveNodes(IStructuredModel structuredModel, int startNodeOffset, int length) {
- Vector activeNodes = new Vector();
-
- if (structuredModel != null) {
- Node startNode = (Node) structuredModel.getIndexedRegion(startNodeOffset);
- Node endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
-
- // make sure it's an non-empty document
- if (startNode != null) {
- while (isSiblingOf(startNode, endNode) == false) {
- if (endNode != null)
- endNode = endNode.getParentNode();
- if (endNode == null) {
- startNode = startNode.getParentNode();
- endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
- }
- }
-
- while (startNode != endNode) {
- activeNodes.addElement(startNode);
- startNode = startNode.getNextSibling();
- }
- if (startNode != null)
- activeNodes.addElement(startNode);
- }
- }
-
- return activeNodes;
- }
-
- protected boolean isSiblingOf(Node node, Node endNode) {
- if (endNode == null) {
- return true;
- }
- else {
- Node siblingNode = node;
- while (siblingNode != null) {
- if (siblingNode == endNode)
- return true;
- else
- siblingNode = siblingNode.getNextSibling();
- }
- return false;
- }
- }
-
- protected boolean getFormatSourcePreference(IStructuredModel structuredModel) {
-
- boolean formatSource = true;
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler((Node) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- IStructuredCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- formatSource = cleanupPreferences.getFormatSource();
- }
- return formatSource;
- }
-
- protected boolean getConvertEOLCodesPreference(IStructuredModel structuredModel) {
-
- boolean convertEOLCodes = true;
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler((Node) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- IStructuredCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- convertEOLCodes = cleanupPreferences.getConvertEOLCodes();
- }
- return convertEOLCodes;
- }
-
- protected String getEOLCodePreference(IStructuredModel structuredModel) {
-
- String eolCode = System.getProperty("line.separator"); //$NON-NLS-1$
-
- IStructuredCleanupHandler cleanupHandler = getCleanupHandler((Node) structuredModel.getIndexedRegion(0));
- if (cleanupHandler != null) {
- IStructuredCleanupPreferences cleanupPreferences = cleanupHandler.getCleanupPreferences();
- eolCode = cleanupPreferences.getEOLCode();
- }
- return eolCode;
- }
-
- protected void convertLineDelimiters(IDocument document, String newDelimiter) {
-
- final int lineCount = document.getNumberOfLines();
- IDocumentPartitioner partitioner = document.getDocumentPartitioner();
- if (partitioner != null) {
- partitioner.disconnect();
- document.setDocumentPartitioner(null);
- }
- try {
- for (int i = 0; i < lineCount; i++) {
- final String delimiter = document.getLineDelimiter(i);
- if (delimiter != null && delimiter.length() > 0 && !delimiter.equals(newDelimiter)) {
- IRegion region = document.getLineInformation(i);
- document.replace(region.getOffset() + region.getLength(), delimiter.length(), newDelimiter);
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- finally {
- if (partitioner != null) {
- partitioner.connect(document);
- document.setDocumentPartitioner(partitioner);
- }
- }
- }
-
- abstract protected String getContentType();
-
- abstract protected IStructuredCleanupHandler getCleanupHandler(Node node);
-
- abstract protected IStructuredFormatProcessor getFormatProcessor();
-
- abstract protected void refreshCleanupPreferences();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.java
deleted file mode 100644
index 128375f857..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/CleanupProcessor.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.core.cleanup;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-
-/**
- * @deprecated renamed to IStructuredCleanupProcessor
- *
- * TODO will delete in C5
- */
-public interface CleanupProcessor {
- /**
- * This form of the CleanupProcessor takes an input string as input, creates
- * an InputStream from the input string, create a temporary model of the
- * content type specified, cleanups the whole model, then returns the
- * cleaned up input string.
- */
- String cleanupContent(String content);
-
- /**
- * This form of the CleanupProcessor takes an input string as input, creates
- * an InputStream from the input string, create a temporary model of the
- * content type specified, cleanups the model within start and length, then
- * returns the cleaned up input string.
- */
- String cleanupContent(String content, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the whole model, then releases the model. The IFile is
- * updated when the last reference of the model is released in the model
- * manager.
- */
- void cleanupFile(IFile file);
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the model within start and length, then releases the
- * model. The IFile is updated when the last reference of the model is
- * released in the model manager.
- */
- void cleanupFile(IFile file, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the whole model,
- * then releases the model. The file is updated when the last reference of
- * the model is released in the model manager.
- */
- void cleanupFileName(String fileName);
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the model within
- * start and length, then releases the model. The file is updated when the
- * last reference of the model is released in the model manager.
- */
- void cleanupFileName(String fileName, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups the
- * whole model.
- */
- void cleanupModel(IStructuredModel structuredModel);
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups the
- * model within start and length.
- */
- void cleanupModel(IStructuredModel structuredModel, int start, int length);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.java
deleted file mode 100644
index f3eda5ac4f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupHandler.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.core.cleanup;
-
-import org.w3c.dom.Node;
-
-public interface IStructuredCleanupHandler {
- Node cleanup(Node node);
-
- void setCleanupPreferences(IStructuredCleanupPreferences cleanupPreferences);
-
- IStructuredCleanupPreferences getCleanupPreferences();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java
deleted file mode 100644
index 0c61e8348b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupPreferences.java
+++ /dev/null
@@ -1,55 +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.core.cleanup;
-
-import org.eclipse.core.runtime.Preferences;
-
-public interface IStructuredCleanupPreferences {
- int getTagNameCase();
-
- int getAttrNameCase();
-
- boolean getCompressEmptyElementTags();
-
- boolean getInsertRequiredAttrs();
-
- boolean getInsertMissingTags();
-
- boolean getQuoteAttrValues();
-
- boolean getFormatSource();
-
- boolean getConvertEOLCodes();
-
- String getEOLCode();
-
- void setTagNameCase(int tagNameCase);
-
- void setAttrNameCase(int attrNameCase);
-
- void setCompressEmptyElementTags(boolean compressEmptyElementTags);
-
- void setInsertRequiredAttrs(boolean insertRequiredAttrs);
-
- void setInsertMissingTags(boolean insertMissingTags);
-
- void setQuoteAttrValues(boolean quoteAttrValues);
-
- void setFormatSource(boolean formatSource);
-
- void setConvertEOLCodes(boolean convertEOLCodes);
-
- void setEOLCode(String EOLCode);
-
- void setPreferences(Preferences preferences);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.java
deleted file mode 100644
index e2590bee99..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/IStructuredCleanupProcessor.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.core.cleanup;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.w3c.dom.Node;
-
-
-public interface IStructuredCleanupProcessor {
- /**
- * This form of the CleanupProcessor takes an input string as input, creates
- * an InputStream from the input string, create a temporary model of the
- * content type specified, cleanups the whole model, then returns the
- * cleaned up input string.
- */
- String cleanupContent(String content) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an input string as input, creates
- * an InputStream from the input string, create a temporary model of the
- * content type specified, cleanups the model within start and length, then
- * returns the cleaned up input string.
- */
- String cleanupContent(String content, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IDocument as input, creates a
- * temporary model of content type calculated using the IDocument's file
- * extension, cleanups the whole model, then releases the model.
- */
- void cleanupDocument(IDocument document) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IDocument as input, creates a
- * temporary model of content type calculated using the IDocument's file
- * extension, cleanups the model within start and length, then releases the
- * model.
- */
- void cleanupDocument(IDocument document, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the whole model, then releases the model. The IFile is
- * updated when the last reference of the model is released in the model
- * manager.
- */
- void cleanupFile(IFile file) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, cleanups the model within start and length, then releases the
- * model. The IFile is updated when the last reference of the model is
- * released in the model manager.
- */
- void cleanupFile(IFile file, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the whole model,
- * then releases the model. The file is updated when the last reference of
- * the model is released in the model manager.
- */
- void cleanupFileName(String fileName) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, cleanups the model within
- * start and length, then releases the model. The file is updated when the
- * last reference of the model is released in the model manager.
- */
- void cleanupFileName(String fileName, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups the
- * whole model.
- */
- void cleanupModel(IStructuredModel structuredModel);
-
- /**
- * This form of the CleanupProcessor takes a model as input, and cleanups the
- * model within start and length.
- */
- void cleanupModel(IStructuredModel structuredModel, int start, int length);
-
- /**
- * This form of the CleanupProcessor takes a node as input, and formats the
- * node and all its children.
- */
- void cleanupNode(Node node);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.java
deleted file mode 100644
index 30b860603f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredCleanupPreferences.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.core.cleanup;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-
-
-public class StructuredCleanupPreferences implements IStructuredCleanupPreferences {
-
- private int fTagNameCase;
- private int fAttrNameCase;
- private boolean fCompressEmptyElementTags;
- private boolean fInsertRequiredAttrs;
- private boolean fInsertMissingTags;
- private boolean fQuoteAttrValues;
- private boolean fFormatSource;
- private boolean fConvertEOLCodes;
- private String fEOLCode;
- //private IPreferenceStore fPreferenceStore = null;
- private Preferences fPreferences = null;
-
- public int getTagNameCase() {
-
- return fTagNameCase;
- }
-
- public int getAttrNameCase() {
-
- return fAttrNameCase;
- }
-
- public boolean getCompressEmptyElementTags() {
-
- return fCompressEmptyElementTags;
- }
-
- public boolean getInsertRequiredAttrs() {
-
- return fInsertRequiredAttrs;
- }
-
- public boolean getInsertMissingTags() {
-
- return fInsertMissingTags;
- }
-
- public boolean getQuoteAttrValues() {
-
- return fQuoteAttrValues;
- }
-
- public boolean getFormatSource() {
-
- return fFormatSource;
- }
-
- public boolean getConvertEOLCodes() {
-
- return fConvertEOLCodes;
- }
-
- public String getEOLCode() {
-
- return fEOLCode;
- }
-
- public void setTagNameCase(int tagNameCase) {
-
- fTagNameCase = tagNameCase;
- }
-
- public void setAttrNameCase(int attrNameCase) {
-
- fAttrNameCase = attrNameCase;
- }
-
- public void setCompressEmptyElementTags(boolean compressEmptyElementTags) {
-
- fCompressEmptyElementTags = compressEmptyElementTags;
- }
-
- public void setInsertRequiredAttrs(boolean insertRequiredAttrs) {
-
- fInsertRequiredAttrs = insertRequiredAttrs;
- }
-
- public void setInsertMissingTags(boolean insertMissingTags) {
-
- fInsertMissingTags = insertMissingTags;
- }
-
- public void setQuoteAttrValues(boolean quoteAttrValues) {
-
- fQuoteAttrValues = quoteAttrValues;
- }
-
- public void setFormatSource(boolean formatSource) {
-
- fFormatSource = formatSource;
- }
-
- public void setConvertEOLCodes(boolean convertEOLCodes) {
-
- fConvertEOLCodes = convertEOLCodes;
- }
-
- public void setEOLCode(String EOLCode) {
-
- fEOLCode = EOLCode;
- }
-
- public Preferences getPreferences() {
-
- if (fPreferences == null) {
- fPreferences = getModelManagerPlugin().getPluginPreferences();
- }
- return fPreferences;
- }
-
- private IModelManagerPlugin getModelManagerPlugin() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- public void setPreferences(Preferences prefs) {
-
- fPreferences = prefs;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.java
deleted file mode 100644
index 28527e53ec..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandler.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.core.cleanup;
-
-public interface StructuredContentCleanupHandler {
- void setCleanupProcessor(IStructuredCleanupProcessor cleanupProcessor, String contentType);
-
- IStructuredCleanupProcessor getCleanupProcessor(String contentType);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.java
deleted file mode 100644
index c7ac485578..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/cleanup/StructuredContentCleanupHandlerImpl.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.core.cleanup;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.jface.text.Assert;
-
-public class StructuredContentCleanupHandlerImpl implements StructuredContentCleanupHandler {
- protected Map fCleanupProcessors;
-
- /**
- */
- public void setCleanupProcessor(IStructuredCleanupProcessor cleanupProcessor, String contentType) {
- Assert.isNotNull(contentType);
-
- if (fCleanupProcessors == null)
- fCleanupProcessors = new HashMap();
-
- if (fCleanupProcessors == null)
- fCleanupProcessors.remove(contentType);
- else
- fCleanupProcessors.put(contentType, cleanupProcessor);
- }
-
- /**
- */
- public IStructuredCleanupProcessor getCleanupProcessor(String contentType) {
- Assert.isNotNull(contentType);
-
- if (fCleanupProcessors == null)
- return null;
-
- return (IStructuredCleanupProcessor) fCleanupProcessors.get(contentType);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.java
deleted file mode 100644
index dbef66512f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocType.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.core.contentmodel;
-
-
-public interface CMDocType {
- public final static String HTML_DOC_TYPE = "HTML";//$NON-NLS-1$
- public final static String CHTML_DOC_TYPE = "CHTML";//$NON-NLS-1$
- public final static String JSP11_DOC_TYPE = "JSP11";//$NON-NLS-1$
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.java
deleted file mode 100644
index 4ce5b5074f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMDocumentTracker.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.core.contentmodel;
-
-
-
-import org.eclipse.wst.contentmodel.CMDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-
-/**
- * Position dependent CMDocument tracker. A tracker matches
- * a IStructuredDocumentRegion with a CMDocument that it enables allowing
- * for position-dependent content models
- */
-public interface CMDocumentTracker {
-
- CMDocument getDocument();
-
- IStructuredDocumentRegion getStructuredDocumentRegion();
-}
-
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.java
deleted file mode 100644
index 5fa5b502e8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/CMNodeWrapper.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.core.contentmodel;
-
-
-
-import org.eclipse.wst.contentmodel.CMNode;
-
-public interface CMNodeWrapper extends CMNode {
- CMNode getOriginNode();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java
deleted file mode 100644
index 2916e3824b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/ContentModelAdapter.java
+++ /dev/null
@@ -1,51 +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.core.contentmodel;
-
-
-
-import org.eclipse.wst.contentmodel.CMDocument;
-import org.eclipse.wst.contentmodel.CMNode;
-
-/**
- * ContentModelAdapter interface
- */
-public interface ContentModelAdapter extends org.eclipse.wst.sse.core.INodeAdapter {
-
- /**
- * getCMDocument method
- * @return CMDocument
- *
- * Returns CMDocument associated to the adapting node.
- * For exampl :
- * HTML CMDocument is associated to HTML Document node,
- * DTD CMDocument is associated to DocumentType node,
- * DTD/Schema CMDocument is associated to Element node
- * (sometime with namespace), and
- * taglib CMDocument is associated to taglib directive Element node.
- *
- * INodeNotifier is passed for stateless (singleton) INodeAdapter implementation.
- */
- CMDocument getCMDocument(org.eclipse.wst.sse.core.INodeNotifier notifier);
-
- /**
- * getDeclaration method
- * @return CMNode
- *
- * Returns ElementDefinition or AttributeDefinition
- * for the adapting node.
- *
- * INodeNotifier is passed for stateless (singleton) INodeAdapter implementation.
- */
- CMNode getDeclaration(org.eclipse.wst.sse.core.INodeNotifier notifier);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.java
deleted file mode 100644
index 0330abcd68..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/contentmodel/NullContentModel.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.core.contentmodel;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.wst.contentmodel.CMDocument;
-import org.eclipse.wst.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.contentmodel.CMNamespace;
-import org.eclipse.wst.contentmodel.CMNode;
-
-/**
- * This class can be used to intialize specific
- * variables that need a content model, until the
- * true content model is available. This prevents
- * having to do lots of null checks.
- */
-public class NullContentModel implements CMDocument {
-
- private class NullCMNamedNodeMap implements CMNamedNodeMap {
- public int getLength() {
- return 0;
- }
-
- public CMNode getNamedItem(String name) {
- return null;
- }
-
- public CMNode item(int index) {
- return null;
- }
-
- public Iterator iterator() {
- return new NullIterator();
- }
-
- }
-
- private class NullIterator implements Iterator {
- public NullIterator() {
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException("can not remove regions via iterator"); //$NON-NLS-1$
-
- }
-
- }
-
- public NullContentModel() {
- super();
- }
-
- public CMNamedNodeMap getElements() {
- return new NullCMNamedNodeMap();
- }
-
- public CMNamedNodeMap getEntities() {
- return new NullCMNamedNodeMap();
- }
-
- public CMNamespace getNamespace() {
- return null;
- }
-
- public String getNodeName() {
- return null;
- }
-
- public int getNodeType() {
- return 0;
- }
-
- public Object getProperty(String propertyName) {
- return null;
- }
-
- public boolean supports(String propertyName) {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java
deleted file mode 100644
index cba7b306c9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/AbstractDocumentLoader.java
+++ /dev/null
@@ -1,391 +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.core.document;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.MalformedInputException;
-import java.nio.charset.UnmappableCharacterException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.encoding.CodedIO;
-import org.eclipse.wst.encoding.CodedReaderCreator;
-import org.eclipse.wst.encoding.ContentTypeEncodingPreferences;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.encoding.EncodingRule;
-import org.eclipse.wst.encoding.exceptions.MalformedInputExceptionWithDetail;
-import org.eclipse.wst.sse.core.internal.document.NullStructuredDocumentPartitioner;
-import org.eclipse.wst.sse.core.internal.document.TextUtilities;
-
-
-
-/**
- * This class reads a file and creates an Structured Model.
- */
-public abstract class AbstractDocumentLoader implements IDocumentLoader {
- private boolean fPropertiesObtained;
-
- protected EncodingMemento fEncodingMemento;
- protected IDocumentCharsetDetector fDocumentEncodingDetector;
- protected Reader fFullPreparedReader;
-
- private CodedReaderCreator fCodedReaderCreator;
-
- /**
- * AbstractLoader constructor also initializes encoding converter/mapper
- */
- public AbstractDocumentLoader() {
- super();
- }
-
- /**
- * This method must return a new instance of IEncodedDocument, that has
- * been initialized with appropriate parser. For many loaders, the
- * (default) parser used is known for any input. For others, the correct
- * parser (and its initialization) is normally dependent on the content of
- * the file. This no-argument method should assume "empty input" and would
- * therefore return the default parser for the default contentType.
- */
- public IEncodedDocument createNewStructuredDocument() {
- IEncodedDocument structuredDocument = newEncodedDocument();
- // make sure every structuredDocument has an encodoing memento,
- // which is the default one for "empty" structuredDocuments
- String charset = ContentTypeEncodingPreferences.useDefaultNameRules(getDocumentEncodingDetector());
- String specDefaultCharset = getDocumentEncodingDetector().getSpecDefaultEncoding();
- structuredDocument.setEncodingMemento(CodedIO.createEncodingMemento(charset, EncodingMemento.DEFAULTS_ASSUMED_FOR_EMPTY_INPUT, specDefaultCharset));
- structuredDocument.setDocumentPartitioner(getDefaultDocumentPartitioner());
- return structuredDocument;
- }
-
- /**
- * This abstract version should handle most cases, but won't if
- * contentType is sensitive to encoding, and/or embedded types
- */
- public IEncodedDocument createNewStructuredDocument(IFile iFile) throws IOException, CoreException {
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- try {
-
- CodedReaderCreator creator = getCodedReaderCreator();
- creator.set(iFile);
- fEncodingMemento = creator.getEncodingMemento();
- structuredDocument.setEncodingMemento(fEncodingMemento);
- fFullPreparedReader = getCodedReaderCreator().getCodedReader();
-
- setDocumentContentsFromReader(structuredDocument, fFullPreparedReader);
- }
- finally {
- if (fFullPreparedReader != null) {
- fFullPreparedReader.close();
- }
- }
- return structuredDocument;
- }
-
- public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream) throws UnsupportedEncodingException, IOException {
- return createNewStructuredDocument(filename, inputStream, EncodingRule.CONTENT_BASED);
- }
-
- public IEncodedDocument createNewStructuredDocument(String filename, InputStream inputStream, EncodingRule encodingRule) throws UnsupportedEncodingException, IOException {
- if (filename == null && inputStream == null) {
- throw new IllegalArgumentException("can not have both null filename and inputstream"); //$NON-NLS-1$
- }
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- CodedReaderCreator codedReaderCreator = getCodedReaderCreator();
- try {
- codedReaderCreator.set(filename, inputStream);
- codedReaderCreator.setEncodingRule(encodingRule);
- fEncodingMemento = codedReaderCreator.getEncodingMemento();
- fFullPreparedReader = codedReaderCreator.getCodedReader();
- structuredDocument.setEncodingMemento(fEncodingMemento);
- setDocumentContentsFromReader(structuredDocument, fFullPreparedReader);
- }
- catch (CoreException e) {
- // impossible in this context
- throw new Error(e);
- }
- finally {
- if (fFullPreparedReader != null) {
- fFullPreparedReader.close();
- }
- }
-
- return structuredDocument;
- }
-
- protected void setDocumentContentsFromReader(IEncodedDocument structuredDocument, Reader reader) throws IOException {
-
- StringBuffer allText = readInputStream(reader);
- structuredDocument.set(allText.toString());
- }
-
- public IEncodedDocument createNewStructuredDocument(Reader reader) throws UnsupportedEncodingException, IOException {
- IEncodedDocument structuredDocument = createNewStructuredDocument();
- StringBuffer allText = readInputStream(fFullPreparedReader);
- structuredDocument.set(allText.toString());
- return structuredDocument;
- }
-
- /**
- * Method getDefaultDocumentPartitioner.
- *
- * @return IDocumentPartitioner
- */
- public IDocumentPartitioner getDefaultDocumentPartitioner() {
- // be default, we'll provide XML (though could be NOOP?
- // 7/2003 .... changed during re-org ... to be Null instead of XML,
- // so there would be no minor dependancies from higher plugins.
- return new NullStructuredDocumentPartitioner();
- }
-
- /**
- * Returns the encodingMemento.
- *
- * @return EncodingMemento
- */
- public EncodingMemento getEncodingMemento() {
- if (fEncodingMemento == null) {
- throw new IllegalStateException("Program Error: encodingMemento was accessed before it was set"); //$NON-NLS-1$
- }
- return fEncodingMemento;
- }
-
- /**
- * If subclass doesn't implement, return null
- */
- protected String getPreferredNewLineDelimiter() {
- return null;
- }
-
- /**
- * A utility method, but depends on subclasses to impliment the preferred
- * end of line for a particular content type. Note: subclasses should not
- * re-implement this method (there's no reason to, even though its part of
- * interface). This method not only converts end-of-line characters, if
- * needed, but sets the correct end-of-line delimiter in
- * structuredDocument. Minor note: can't use this exact method in dumpers,
- * since the decision to change or not is a little different, and since
- * there we have to change text of structuredDocument if found to need
- * conversion. (Where as for loading, we assume we haven't yet set text in
- * structuredDocument, but will be done by other method just a tiny biy
- * later). Needs to be public to handle interface. It is in the interface
- * just so ModelManagerImpl can use it in a special circumstance. TODO
- * need to handle line delimiters so Marker Positions are updated
- */
- public StringBuffer handleLineDelimiter(StringBuffer originalString, IEncodedDocument theFlatModel) {
- StringBuffer convertedText = null;
- // based on text, make a guess on what's being used as
- // line delimiter
- String probableLineDelimiter = TextUtilities.determineLineDelimiter(originalString, theFlatModel.getLegalLineDelimiters(), System.getProperty("line.separator")); //$NON-NLS-1$
- String preferredLineDelimiter = getPreferredNewLineDelimiter();
- if (preferredLineDelimiter == null) {
- // when preferredLineDelimiter is null, it means "leave alone"
- // so no conversion needed.
- // set here, only if null (should already be set, but if not,
- // we'll set so any subsequent editing inserts what we're
- // assuming)
- if (!theFlatModel.getLineDelimiter().equals(probableLineDelimiter)) {
- theFlatModel.setLineDelimiter(probableLineDelimiter);
- }
- convertedText = originalString;
- }
- else {
- if (!preferredLineDelimiter.equals(probableLineDelimiter)) {
- // technically, wouldn't have to convert line delimiters
- // here at beginning, but when we save, if the preferred
- // line delimter is "leave alone" then we do leave alone,
- // so best to be right from beginning.
- convertedText = convertLineDelimiters(originalString, preferredLineDelimiter);
- theFlatModel.setLineDelimiter(preferredLineDelimiter);
- }
- else {
- // they are already the same, no conversion needed
- theFlatModel.setLineDelimiter(preferredLineDelimiter);
- convertedText = originalString;
- }
- }
- return convertedText;
- }
-
- /**
- * Very mechanical method, just to read the characters, once the reader is
- * correctly created. Can throw MalFormedInputException.
- */
- private StringBuffer readInputStream(Reader reader) throws IOException {
-
- int fBlocksRead = 0;
- StringBuffer buffer = new StringBuffer();
- int numRead = 0;
- try {
- char tBuff[] = new char[CodedIO.MAX_BUF_SIZE];
- while ((numRead = reader.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- fBlocksRead++;
- }
- }
- catch (MalformedInputException e) {
- throw new MalformedInputExceptionWithDetail(fEncodingMemento.getJavaCharsetName(), fBlocksRead * CodedIO.MAX_BUF_SIZE + numRead + e.getInputLength());
- }
- catch (UnmappableCharacterException e) {
- throw new MalformedInputExceptionWithDetail(fEncodingMemento.getJavaCharsetName(), fBlocksRead * CodedIO.MAX_BUF_SIZE + numRead + e.getInputLength());
-
- }
- return buffer;
- }
-
- protected final StringBuffer convertLineDelimiters(StringBuffer allTextBuffer, String lineDelimiterToUse) {
- // TODO: avoid use of String instance
- String allText = allTextBuffer.toString();
- IDocument tempDoc = new Document(allText);
- if (lineDelimiterToUse == null)
- lineDelimiterToUse = System.getProperty("line.separator"); //$NON-NLS-1$
- StringBuffer newText = new StringBuffer();
- int lineCount = tempDoc.getNumberOfLines();
- for (int i = 0; i < lineCount; i++) {
- try {
- org.eclipse.jface.text.IRegion lineInfo = tempDoc.getLineInformation(i);
- int lineStartOffset = lineInfo.getOffset();
- int lineLength = lineInfo.getLength();
- int lineEndOffset = lineStartOffset + lineLength;
- newText.append(allText.substring(lineStartOffset, lineEndOffset));
- if ((i < lineCount - 1) && (tempDoc.getLineDelimiter(i) != null))
- newText.append(lineDelimiterToUse);
- }
- catch (org.eclipse.jface.text.BadLocationException exception) {
- // should fix up to either throw nothing, or the right thing,
- // but
- // in the course of refactoring, this was easiest "quick fix".
- throw new RuntimeException(exception);
- }
- }
- return newText;
- }
-
- public void reload(IEncodedDocument encodedDocument, Reader inputStreamReader) throws IOException {
- if (inputStreamReader == null) {
- throw new IllegalArgumentException("stream reader can not be null"); //$NON-NLS-1$
- }
- int READ_BUFFER_SIZE = 8192;
- int MAX_BUFFERED_SIZE_FOR_RESET_MARK = 200000;
- // temp .... eventually we'lll only read as needed
- BufferedReader bufferedReader = new BufferedReader(inputStreamReader, MAX_BUFFERED_SIZE_FOR_RESET_MARK);
- bufferedReader.mark(MAX_BUFFERED_SIZE_FOR_RESET_MARK);
- StringBuffer buffer = new StringBuffer();
- try {
- int numRead = 0;
- char tBuff[] = new char[READ_BUFFER_SIZE];
- while ((numRead = bufferedReader.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- }
- // remember -- we didn't open stream ... so we don't close it
- }
- catch (MalformedInputException e) {
- int pos = e.getInputLength();
- EncodingMemento localEncodingMemento = getEncodingMemento();
- boolean couldReset = true;
- String encodingNameInError = localEncodingMemento.getJavaCharsetName();
- if (encodingNameInError == null) {
- encodingNameInError = localEncodingMemento.getDetectedCharsetName();
- }
- try {
- bufferedReader.reset();
- }
- catch (IOException resetException) {
- // the only errro that can occur during reset is an
- // IOException
- // due to already being past the rest mark. In that case, we
- // throw more generic message
- couldReset = false;
- }
- // -1 can be used by UI layer as a code that "position could not
- // be
- // determined"
- int charPostion = -1;
- if (couldReset) {
-
- charPostion = getCharPostionOfFailure(bufferedReader);
- //getCharPostionOfFailure(new InputStreamReader(inStream,
- // javaEncodingNameInError));
- }
- // all of that just to throw more accurate error
- // note: we do the conversion to ianaName, instead of using the
- // local
- // variable,
- // because this is ultimately only for the user error message
- // (that
- // is,
- // the error occurred
- // in context of javaEncodingName no matter what ianaEncodingName
- // is
- throw new MalformedInputExceptionWithDetail(encodingNameInError, CodedIO.getAppropriateJavaCharset(encodingNameInError), charPostion, !couldReset, MAX_BUFFERED_SIZE_FOR_RESET_MARK);
- }
- StringBuffer stringbuffer = buffer;
- encodedDocument.set(stringbuffer.toString());
-
- }
-
- private int getCharPostionOfFailure(BufferedReader inputStream) {
- int charPosition = 1;
- int charRead = -1;
- boolean errorFound = false;
- do {
- try {
- charRead = inputStream.read();
- charPosition++;
- }
- catch (IOException e) {
- // this is expected, since we're expecting failure,
- // so no need to do anything.
- errorFound = true;
- break;
- }
- }
- while (!(charRead == -1 || errorFound));
-
- if (errorFound)
- // dmw, blindly modified to +1 to get unit tests to work, moving
- // from Java 1.3, to 1.4
- // not sure how/why this behavior would have changed. (Its as if
- // 'read' is reporting error
- // one character early).
- return charPosition + 1;
- else
- return -1;
- }
-
- /**
- * @return Returns the fullPreparedReader.
- */
- protected Reader getFullPreparedReader() throws UnsupportedEncodingException, CoreException, IOException {
- if (fFullPreparedReader == null) {
- fFullPreparedReader = getCodedReaderCreator().getCodedReader();
- }
- return fFullPreparedReader;
- }
-
- /**
- * @return Returns the codedReaderCreator.
- */
- protected CodedReaderCreator getCodedReaderCreator() {
- if (fCodedReaderCreator == null) {
- fCodedReaderCreator = new CodedReaderCreator();
- }
- return fCodedReaderCreator;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java
deleted file mode 100644
index 12d8ac30b4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/DocumentReader.java
+++ /dev/null
@@ -1,120 +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.core.document;
-
-import java.io.IOException;
-import java.io.Reader;
-
-import org.eclipse.jface.text.IDocument;
-
-/**
- * A java.io.Reader that can operate off of an IDocument.
- */
-public class DocumentReader extends Reader {
- private IDocument fDocument = null;
- private int position = 0;
- private int mark = 0;
-
- public DocumentReader() {
- super();
- }
-
- public DocumentReader(IDocument document) {
- this(document, 0);
- }
-
- public DocumentReader(IDocument document, int initialPosition) {
- super();
- fDocument = document;
- position = initialPosition;
- }
-
- public void close() throws IOException {
- // do nothing
- }
-
- /**
- * @return
- */
- public IDocument getDocument() {
- return fDocument;
- }
-
- public int read(char[] cbuf, int off, int len) throws IOException {
- char[] readChars = null;
- try {
- if (position >= fDocument.getLength())
- return -1;
- // the IDocument is likely using a GapTextStore, so we can't
- // retrieve a char[] directly
- if (position + len > fDocument.getLength())
- readChars = fDocument.get(position, fDocument.getLength() - position).toCharArray();
- else
- readChars = fDocument.get(position, len).toCharArray();
- System.arraycopy(readChars, 0, cbuf, off, readChars.length);
- // System.out.println("" + position + ":" + readChars.length + " "
- // + StringUtils.escape(new String(readChars)));
- position += readChars.length;
- return readChars.length;
- }
- catch (Exception e) {
- throw new IOException("Exception while reading from IDocument: " + e); //$NON-NLS-1$
- }
- }
-
- public void reset(IDocument document, int initialPosition) {
- fDocument = document;
- position = initialPosition;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.Reader#skip(long)
- */
- public long skip(long n) throws IOException {
- long skipped = n;
- if (position + n > fDocument.getLength()) {
- skipped = fDocument.getLength() - position;
- position = fDocument.getLength();
- }
- else {
- position += n;
- }
- return skipped;
- }
-
- public boolean markSupported() {
- return true;
- }
-
- /* (non-Javadoc)
- * @see java.io.Reader#mark(int)
- */
- public void mark(int readAheadLimit) throws IOException {
- mark = position;
- }
-
- /* (non-Javadoc)
- * @see java.io.Reader#reset()
- */
- public void reset() throws IOException {
- position = mark;
- }
- /* (non-Javadoc)
- * @see java.io.Reader#reset()
- */
- public void reset(int pos) throws IOException {
- position = pos;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.java
deleted file mode 100644
index 909ea91ee2..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentCharsetDetector.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.core.document;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.encoding.IResourceCharsetDetector;
-
-
-public interface IDocumentCharsetDetector extends IResourceCharsetDetector {
- void set(IDocument document);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java
deleted file mode 100644
index b8539473d8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoader.java
+++ /dev/null
@@ -1,81 +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.core.document;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.io.UnsupportedEncodingException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.encoding.EncodingRule;
-
-public interface IDocumentLoader {
- /**
- * This API is like createNewStructuredDocument, except it should populate
- * the structuredDocument with the contents of IFile. Also, those
- * StructuredDocuments which are sensitive to the input (that is, the
- * parser or parser initialization my require the input) should
- * additionally initialize the parser, etc., appropriate to the input.
- *
- * As always, the appropriate decoding should be used.
- */
- IEncodedDocument createNewStructuredDocument(IFile iFile) throws java.io.IOException, CoreException;
-
- /**
- * This method must return a new instance of IEncodedDocument, that has
- * been initialized with appropriate parser. For many loaders, the
- * (default) parser used is known for any input. For others, the correct
- * parser (and its initialization) is normally dependent on the content of
- * the file. This no-argument method should assume "empty input" and would
- * therefore return the default parser for the default contentType.
- */
- IEncodedDocument createNewStructuredDocument(String filename, InputStream istream) throws java.io.IOException;
-
- IEncodedDocument createNewStructuredDocument(String filename, InputStream istream, EncodingRule encodingRule) throws java.io.IOException;
-
- IEncodedDocument createNewStructuredDocument();
-
- IDocumentCharsetDetector getDocumentEncodingDetector();
-
- IDocumentPartitioner getDefaultDocumentPartitioner();
-
- /**
- * A utility method, but depends on subclasses to impliment the preferred
- * end of line for a particular content type. Note: subclasses should not
- * re-implement this method (there's no reason to, even though its part of
- * interface). This method not only converts end-of-line characters, if
- * needed, but sets the correct end-of-line delimiter in
- * structuredDocument. The returned value is either the original string, if
- * no conversion is needed, or a new string with end-of-lines converted.
- */
- StringBuffer handleLineDelimiter(StringBuffer originalString, IEncodedDocument theStructuredDocument);
-
- /**
- * @deprecated - seems never used
- * @return
- */
- IEncodedDocument newEncodedDocument();
-
- /**
- * @deprecated - I think can be deprecated. Will need to be sure.
- * @return
- */
- EncodingMemento getEncodingMemento();
-
- void reload(IEncodedDocument document, Reader reader) throws IOException;
- IEncodedDocument createNewStructuredDocument(Reader reader) throws UnsupportedEncodingException, IOException;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java
deleted file mode 100644
index 98ed057d21..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IDocumentLoaderForFileBuffers.java
+++ /dev/null
@@ -1,26 +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.core.document;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-
-public interface IDocumentLoaderForFileBuffers extends IDocumentLoader {
-
-
- void release(IFile iFile, IProgressMonitor monitor) throws CoreException;
- IEncodedDocument createNewStructuredDocument(IFile iFile, IProgressMonitor monitor) throws IOException, CoreException;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.java
deleted file mode 100644
index 9d8917f986..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/IEncodedDocument.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.core.document;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.encoding.EncodingMemento;
-
-
-
-public interface IEncodedDocument extends IDocument {
-
- String getLineDelimiter();
-
- void setLineDelimiter(String probableLineDelimiter);
-
- EncodingMemento getEncodingMemento();
-
- void setEncodingMemento(EncodingMemento localEncodingMemento);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.java
deleted file mode 100644
index 71b2db9a60..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/document/StructuredDocumentLoader.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.core.document;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.Reader;
-import java.nio.charset.MalformedInputException;
-
-import org.eclipse.core.filebuffers.FileBuffers;
-import org.eclipse.core.filebuffers.ITextFileBuffer;
-import org.eclipse.core.filebuffers.ITextFileBufferManager;
-import org.eclipse.core.resources.IFile;
-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.core.runtime.QualifiedName;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.encoding.CodedIO;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.encoding.IContentDescriptionExtended;
-import org.eclipse.wst.encoding.exceptions.MalformedInputExceptionWithDetail;
-
-public class StructuredDocumentLoader {
-
- private ITextFileBufferManager fBufferManager;
-
- public IEncodedDocument createNewStructuredDocument(IFile iFile, IProgressMonitor monitor) throws IOException, CoreException {
- IDocument document = null;
- IPath locationPath = iFile.getFullPath();
-
- if (iFile.exists()) {
-
- getBufferManager().connect(locationPath, monitor);
- ITextFileBuffer buffer = getBufferManager().getTextFileBuffer(locationPath);
- document = buffer.getDocument();
- }
- else {
- document = getBufferManager().createEmptyDocument(locationPath);
- }
-
- return (IEncodedDocument) document;
- }
-
- /**
- * @return
- */
- protected ITextFileBufferManager getBufferManager() {
- if (fBufferManager == null) {
- fBufferManager = FileBuffers.getTextFileBufferManager();
- }
- return fBufferManager;
- }
-
- /**
- * @see org.eclipse.wst.sse.core.document.IDocumentLoader#createNewStructuredDocument(org.eclipse.core.resources.IFile)
- * @deprecated - use form with progress monitor
- */
- public IEncodedDocument createNewStructuredDocument(IFile iFile) throws IOException, CoreException {
- return createNewStructuredDocument(iFile, null);
- }
-
- public IEncodedDocument createNewStructuredDocument(IPath locationPath, IProgressMonitor monitor) throws IOException, CoreException {
- IDocument document = null;
- File file = null;
- file = FileBuffers.getSystemFileAtLocation(locationPath);
- if (file.exists()) {
- getBufferManager().connect(locationPath, monitor);
- ITextFileBuffer buffer = getBufferManager().getTextFileBuffer(locationPath);
- document = buffer.getDocument();
- }
- else {
- document = getBufferManager().createEmptyDocument(locationPath);
- }
- return (IEncodedDocument) document;
- }
-
- public void release(IFile iFile, IProgressMonitor monitor) throws CoreException {
- IPath locationPath = iFile.getFullPath();
- getBufferManager().disconnect(locationPath, monitor);
-
- }
-
- /**
- * @param reader
- * @return @throws
- * IOException
- */
- private EncodingMemento getEncodingMemento(Reader reader) throws IOException {
- IContentDescription description = Platform.getContentTypeManager().getDescriptionFor(reader, null, new QualifiedName[]{IContentDescriptionExtended.ENCODING_MEMENTO});
- EncodingMemento encodingMemento = null;
- if (description != null) {
- encodingMemento = (EncodingMemento) description.getProperty(IContentDescriptionExtended.ENCODING_MEMENTO);
- }
- return encodingMemento;
- }
-
- /**
- * Very mechanical method, just to read the characters, once the reader is
- * correctly created. Can throw MalFormedInputException.
- */
- protected StringBuffer readInputStream(Reader reader) throws IOException {
-
- int fBlocksRead = 0;
- StringBuffer buffer = new StringBuffer();
- int numRead = 0;
- try {
- char tBuff[] = new char[CodedIO.MAX_BUF_SIZE];
- while ((numRead = reader.read(tBuff, 0, tBuff.length)) != -1) {
- buffer.append(tBuff, 0, numRead);
- fBlocksRead++;
- }
- }
- catch (MalformedInputException e) {
- EncodingMemento encodingMemento = getEncodingMemento(reader);
- throw new MalformedInputExceptionWithDetail(encodingMemento.getJavaCharsetName(), fBlocksRead * CodedIO.MAX_BUF_SIZE + e.getInputLength());
- }
- return buffer;
- }
-
- protected void setDocumentContentsFromReader(IEncodedDocument structuredDocument, Reader reader) throws IOException {
-
- StringBuffer allText = readInputStream(reader);
- structuredDocument.set(allText.toString());
- }
-
- public void reload(IEncodedDocument document, Reader reader) throws IOException {
- setDocumentContentsFromReader(document, reader);
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.java
deleted file mode 100644
index 89e8f81bd5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/AboutToBeChangeEvent.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.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * This event is send to "StructuredDocumentAboutToChange listners". Its perfectly analagous to the
- * jface DocumentEvent and is provided simply to allow clients to take a pure model point of view,
- * instead of using the document event.
- */
-public class AboutToBeChangeEvent extends StructuredDocumentEvent {
-
-
- public AboutToBeChangeEvent(IStructuredDocument source, Object originalSource, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java
deleted file mode 100644
index 07fc3c3645..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IModelAboutToBeChangedListener.java
+++ /dev/null
@@ -1,25 +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.core.events;
-
-
-
-/**
- * Clients can implement this interface, and register with the structuredDocument using addAboutToBeChangedListner
- * to be notified that the structuredDocument is about to be changed, but hasn't been changed at the time
- * this event is fired.
- */
-public interface IModelAboutToBeChangedListener {
-
- void modelAboutToBeChanged(AboutToBeChangeEvent structuredDocumentEvent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.java
deleted file mode 100644
index 4c3491d266..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/IStructuredDocumentListener.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.core.events;
-
-
-
-public interface IStructuredDocumentListener {
-
- public void newModel(NewModelEvent structuredDocumentEvent);
-
- public void noChange(NoChangeEvent structuredDocumentEvent);
-
- public void nodesReplaced(StructuredDocumentRegionsReplacedEvent structuredDocumentEvent);
-
- public void regionChanged(RegionChangedEvent structuredDocumentEvent);
-
- public void regionsReplaced(RegionsReplacedEvent structuredDocumentEvent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java
deleted file mode 100644
index 33f2cfa925..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NewModelEvent.java
+++ /dev/null
@@ -1,81 +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.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * The NewModelEvent is fired when an instance of a IStructuredDocument sets or
- * replaces all of its text. So, in the case of replacement, its a new model,
- * conceptually and practically, even though it is technically the same
- * instance of the IStructuredDocument.
- */
-public class NewModelEvent extends StructuredDocumentEvent {
- public NewModelEvent(IStructuredDocument source, Object originalSource) {
- super(source, originalSource);
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument Events
- * in the super class. All the text of the new model is returned.
- *
- * @deprecated - use getText()
- */
- public String getOriginalChanges() {
- String results = null;
- results = getStructuredDocument().getText();
- return results;
- }
-
- public String getText() {
- String results = getStructuredDocument().getText();
- return results;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument Events
- * in the super class. Since we have, basically no knowledge of what we are
- * replacing ... so we'll return zero.
- *
- * @deprecated
- */
- public int getOriginalLength() {
- return fLength;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument Events
- * in the super class.
- */
- public int getLength() {
- return fLength;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument Events
- * in the super class. It always will return zero.
- *
- * @deprecated
- */
- public int getOriginalStart() {
- return 0;
- }
-
- /**
- * This doesn't mean quite the same thing as the IStructuredDocument Events
- * in the super class. It always will return zero.
- */
- public int getOffset() {
- return 0;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.java
deleted file mode 100644
index cbc2bca0dc..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/NoChangeEvent.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.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-/**
- * this event is thrown if, after analysis, it is found there is no reason to
- * change the structuredDocument. This might occur, for example, if someone
- * pastes in the exact same text that they are replacing, or if someone tries
- * to change a read-only region.
- *
- * This might be important, for example, if some state variables are set on an
- * "about the change" event. then if there is no change (i.e.no other event is
- * fired), those state variables could reset, or whatever, upon receiving this
- * event.
- */
-public class NoChangeEvent extends StructuredDocumentEvent {
- public final static int NO_CONTENT_CHANGE = 2;
- public final static int READ_ONLY_STATE_CHANGE = 4;
- public int reason = 0;
-
- /**
- * NoChangeEvent constructor comment. This event can occur if there really
- * is not change in content ... in which case use NO_CONTENT_CHANAGE flag
- * in 'reason' field.. It does "double duty, however, in that some changes,
- * such as changes in state of read-only regions results in a change that
- * others may need to know about, but still do not signify content change.
- *
- * @param source
- * IStructuredDocument
- * @param originalSource
- * java.lang.Object
- * @param changes
- * java.lang.String
- * @param offset
- * int
- * @param lengthToReplace
- * int
- */
- public NoChangeEvent(IStructuredDocument source, Object originalSource, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java
deleted file mode 100644
index 83ee8a8bfc..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionChangedEvent.java
+++ /dev/null
@@ -1,48 +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.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-/**
- * This event is used when a node changes in a non-structural way.
- * Non-structural, that is, as far as the IStructuredDocument is concerned. The
- * whole node, along with the new text is sent, just in case a listener (e.g. a
- * tree model) might make its own determination of what to do, and need the
- * whole node to act appropriately.
- *
- * Note: users should not make assumptions about whether the node is literally
- * the same instance or not -- it is currently a different instance that is
- * identical to the old except for the changed region, but this implementation
- * may change.
- */
-public class RegionChangedEvent extends StructuredDocumentEvent {
- private IStructuredDocumentRegion fStructuredDocumentRegion;
- private ITextRegion fChangedRegion;
-
- public RegionChangedEvent(IStructuredDocument source, Object originalSource, IStructuredDocumentRegion flatNode, ITextRegion changedRegion, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- fStructuredDocumentRegion = flatNode;
- fChangedRegion = changedRegion;
- }
-
- public IStructuredDocumentRegion getStructuredDocumentRegion() {
- return fStructuredDocumentRegion;
- }
-
- public ITextRegion getRegion() {
- return fChangedRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java
deleted file mode 100644
index cfb19d569f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/RegionsReplacedEvent.java
+++ /dev/null
@@ -1,48 +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.core.events;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-
-/**
- * This event is used when a node's regions change, but the node itself
- * doesn't. This says nothing about the semantics of the node, that may still
- * have changed. Also, its assumed/required that ALL the regions are replaced
- * (even those that may not have changed).
- */
-public class RegionsReplacedEvent extends StructuredDocumentEvent {
- private IStructuredDocumentRegion fStructuredDocumentRegion;
- private ITextRegionList fOldRegions;
- private ITextRegionList fNewRegions;
-
- public RegionsReplacedEvent(IStructuredDocument source, Object originalSource, IStructuredDocumentRegion flatNode, ITextRegionList oldRegions, ITextRegionList newRegions, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- fStructuredDocumentRegion = flatNode;
- fOldRegions = oldRegions;
- fNewRegions = newRegions;
- }
-
- public IStructuredDocumentRegion getStructuredDocumentRegion() {
- return fStructuredDocumentRegion;
- }
-
- public ITextRegionList getNewRegions() {
- return fNewRegions;
- }
-
- public ITextRegionList getOldRegions() {
- return fOldRegions;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java
deleted file mode 100644
index 0493ba73bf..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentEvent.java
+++ /dev/null
@@ -1,141 +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.core.events;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-/**
- * IStructuredDocument events are generated by the IStructuredDocument, after
- * the IStructuredDocument acts on a request.
- */
-public abstract class StructuredDocumentEvent extends DocumentEvent {
-
- public IStructuredDocument fStructuredDocument;
- protected Object fOriginalRequester;
- protected String fDeletedText;
-
- //public int fOffset;
- //public int fLength;
- //public String fText;
- /**
- * We assume that IStructuredDocument's are ALWAYS the source of
- * IStructuredDocument events
- */
- protected StructuredDocumentEvent(IStructuredDocument source) {
- super();
- if (source == null)
- throw new IllegalArgumentException("null source"); //$NON-NLS-1$
- fDocument = source;
- fStructuredDocument = source;
- }
-
- protected StructuredDocumentEvent(IStructuredDocument source, Object originalSource) {
- this(source);
- fOriginalRequester = originalSource;
- }
-
- protected StructuredDocumentEvent(IStructuredDocument source, Object originalSource, String changes, int offset, int lengthToReplace) {
- this(source);
- fOriginalRequester = originalSource;
- fText = changes;
- fOffset = offset;
- fLength = lengthToReplace;
- }
-
- /**
- * @return java.lang.String
- */
- public java.lang.String getDeletedText() {
- return fDeletedText;
- }
-
- /**
- * This method is equivalent to 'getSource' except it returns an object of
- * the appropriate type (namely, a IStructuredDocument, instead of Object).
- */
- public IStructuredDocument getStructuredDocument() {
- // a safe case, since constructor can only be called with a
- // IStructuredDocument
- return fStructuredDocument;
- }
-
- /**
- * @deprecated
- * @return
- */
- public String getOriginalChanges() {
- return fText;
- }
-
- /**
- * @deprecated
- */
- public int getOriginalLength() {
- return fLength;
- }
-
- /**
- * This method returns the object that originally caused the event to fire.
- * This is typically not the object that created the event (the
- * IStructuredDocument) but instead the object object that made a request
- * to the IStructuredDocument.
- *
- * @return java.lang.Object
- */
- public java.lang.Object getOriginalSource() {
- return fOriginalRequester;
- }
-
- public int getOriginalStart() {
- return fOffset;
- }
-
- /**
- * @param newDeletedText
- * java.lang.String
- */
- public void setDeletedText(java.lang.String newDeletedText) {
- fDeletedText = newDeletedText;
- }
-
- /**
- * returns the classname, but not the 'source=' (as super does).
- */
- public String toString() {
- //return getClass().getName() + "[source=" + source + "]";
- return getClass().getName();
- }
-
- public IDocument getDocument() {
-
- return fStructuredDocument;
- }
-
- public int getLength() {
-
- return fLength;
- }
-
- public int getOffset() {
-
- return getOriginalStart();
- }
-
- public String getText() {
-
- return fText;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.java
deleted file mode 100644
index 323c7499ce..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/events/StructuredDocumentRegionsReplacedEvent.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.core.events;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-
-/**
- * This event is used when a IStructuredDocumentRegion is deleted, or replaced with more than one IStructuredDocumentRegion,
- * or when simply more than one IStructuredDocumentRegion changes.
- */
-
-public class StructuredDocumentRegionsReplacedEvent extends StructuredDocumentEvent {
-
- private IStructuredDocumentRegionList fNewStructuredDocumentRegions;
- private IStructuredDocumentRegionList fOldStructuredDocumentRegions;
-
- public StructuredDocumentRegionsReplacedEvent(IStructuredDocument source, Object originalSource, IStructuredDocumentRegionList oldStructuredDocumentRegions, IStructuredDocumentRegionList newStructuredDocumentRegions, String changes, int offset, int lengthToReplace) {
- super(source, originalSource, changes, offset, lengthToReplace);
- fOldStructuredDocumentRegions = oldStructuredDocumentRegions;
- fNewStructuredDocumentRegions = newStructuredDocumentRegions;
- }
-
- public IStructuredDocumentRegionList getNewStructuredDocumentRegions() {
- return fNewStructuredDocumentRegions;
- }
-
- public IStructuredDocumentRegionList getOldStructuredDocumentRegions() {
- return fOldStructuredDocumentRegions;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.java
deleted file mode 100644
index 3d5325b682..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceAlreadyExists.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.core.exceptions;
-
-
-
-public class ResourceAlreadyExists extends Exception {
-
- /**
- * ResourceAlreadyExists constructor comment.
- */
- public ResourceAlreadyExists() {
- super();
- }
-
- /**
- * ResourceAlreadyExists constructor comment.
- * @param s java.lang.String
- */
- public ResourceAlreadyExists(String s) {
- super(s);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.java
deleted file mode 100644
index d9d5bdf800..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/ResourceInUse.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.core.exceptions;
-
-
-
-public class ResourceInUse extends Exception {
-
- /**
- * ResourceAlreadyExists constructor comment.
- */
- public ResourceInUse() {
- super();
- }
-
- /**
- * ResourceAlreadyExists constructor comment.
- * @param s java.lang.String
- */
- public ResourceInUse(String s) {
- super(s);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.java
deleted file mode 100644
index a0a1aae4e1..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingException.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.core.exceptions;
-
-
-
-import org.eclipse.wst.sse.core.internal.nls.ResourceHandler;
-
-/**
- * The SourceEditingException is often thrown by Source Editor methods in order to
- * have a predictable, uniform interface to the Source Editing APIs.
- * If the OriginalException is not null, then it must be examined to determine the
- * true cause of the exception.
- */
-public class SourceEditingException extends Exception {
-
- private Throwable originalException;
-
- public SourceEditingException() {
- super();
- }
-
- public SourceEditingException(String s) {
- super(s);
- }
-
- /**
- * This form of the constructor is used to wrapper another exception.
- */
- public SourceEditingException(Throwable t) {
- super();
- originalException = t;
- }
-
- /**
- * This form of the constructor is used to wrapper another exception, but still
- * provide a new descriptive message.
- */
- public SourceEditingException(Throwable t, String s) {
- super(s);
- originalException = t;
- }
-
- /**
- * The message depends on if this is a case that has an embedded exception.
- */
- public String getMessage() {
- String result = null;
- if (originalException != null) {
- result = originalException.getMessage();
- }
- else {
- result = super.getMessage();
- }
- return result;
- }
-
- public Throwable getOriginalException() {
- return originalException;
- }
-
- public String toString() {
- // we don't put super.toString to "hide" that it was a
- // sourceEditing exception
- String s = null; //super.toString();
- String originalError = ResourceHandler.getString("Original_Error__UI_"); //$NON-NLS-1$ = "Original Error:"
-
- if (originalException != null) {
- s = originalError + " " + originalException.toString(); //$NON-NLS-1$
- }
- return s;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.java
deleted file mode 100644
index 5746e9540f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/exceptions/SourceEditingRuntimeException.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.core.exceptions;
-
-import org.eclipse.wst.sse.core.internal.nls.ResourceHandler;
-
-
-
-/**
- * The SourceEditingRuntimeException is often thrown by Source Editor methods when
- * a service we use throws a checked exception, but we want to convert and treat
- * as a runtime exception. (Such as BadLocationException is a common example).
- */
-public class SourceEditingRuntimeException extends RuntimeException {
-
- private Throwable originalException;
-
- public SourceEditingRuntimeException() {
- super();
- }
-
- public SourceEditingRuntimeException(String s) {
- super(s);
- }
-
- /**
- * This form of the constructor is used to wrapper another exception.
- */
- public SourceEditingRuntimeException(Throwable t) {
- super();
- originalException = t;
- }
-
- /**
- * This form of the constructor is used to wrapper another exception, but still
- * provide a new descriptive message.
- */
- public SourceEditingRuntimeException(Throwable t, String s) {
- super(s);
- 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("Original_Error__UI_"); //$NON-NLS-1$ = "Original Error:"
- 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();
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.java
deleted file mode 100644
index 6bfbe8c717..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/filebuffers/BasicStructuredDocumentFactory.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.core.filebuffers;
-
-import org.eclipse.core.filebuffers.IDocumentFactory;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-
-/**
- *
- * @deprecated - no need for abstract class here (they are each pretty simple).
- *
- */
-public abstract class BasicStructuredDocumentFactory implements IDocumentFactory {
- /**
- *
- */
- public BasicStructuredDocumentFactory() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.filebuffers.IDocumentFactory#createDocument()
- */
- public IDocument createDocument() {
- IModelManagerPlugin mgr = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- IModelHandler handler = mgr.getModelHandlerRegistry().getHandlerForContentTypeId(getContentTypeIdentifier());
- IEncodedDocument document = handler.getDocumentLoader().createNewStructuredDocument();
- document.setDocumentPartitioner(handler.getDocumentLoader().getDefaultDocumentPartitioner());
- return document;
- }
-
- /**
- * @return
- */
- protected abstract String getContentTypeIdentifier();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.java
deleted file mode 100644
index b7dd5f5de4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/AbstractStructuredFormatProcessor.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.core.format;
-
-import java.io.ByteArrayInputStream;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-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.internal.Logger;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-
-public abstract class AbstractStructuredFormatProcessor implements IStructuredFormatProcessor {
- protected IStructuredFormatContraints fFormatContraints = null;
- protected IProgressMonitor fProgressMonitor = null;
- public boolean refreshFormatPreferences = true; // special flag for JUnit tests to skip refresh of format preferences when it's set to false
-
- private IModelManager getModelManager() {
-
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin.getModelManager();
- }
-
- protected void ensureClosed(OutputStream outputStream, InputStream inputStream) {
-
- try {
- if (inputStream != null) {
- inputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- try {
- if (outputStream != null) {
- outputStream.close();
- }
- }
- catch (IOException e) {
- Logger.logException(e); // hopeless
- }
- }
-
- public String formatContent(String input) throws IOException, CoreException {
- if (input == null)
- return input;
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for read. Will return formatted
- // string and NOT save model.
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + "." + getFileExtension(); //$NON-NLS-1$
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // format
- formatModel(structuredModel);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
-
- public String formatContent(String input, int start, int length) throws IOException, CoreException {
- if (input == null)
- return input;
-
- if (start >= 0 && length >= 0 && start + length <= input.length()) {
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for read. Will return formatted
- // string and NOT save model.
- inputStream = new ByteArrayInputStream(input.getBytes("UTF8")); //$NON-NLS-1$
- String id = inputStream.toString() + "." + getFileExtension(); //$NON-NLS-1$
- structuredModel = getModelManager().getModelForRead(id, inputStream, null);
-
- // format
- formatModel(structuredModel, start, length);
-
- // return output
- return structuredModel.getStructuredDocument().get();
- }
- finally {
- ensureClosed(null, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromRead();
- }
- }
- else
- return input;
- }
-
- public void formatDocument(IDocument document) throws IOException, CoreException {
- if (document == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = getModelManager().getExistingModelForEdit(document);
-
- // format
- formatModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatDocument(IDocument document, int start, int length) throws IOException, CoreException {
- if (document == null)
- return;
-
- if (start >= 0 && length >= 0 && start + length <= document.getLength()) {
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if
- // model changed.
- structuredModel = getModelManager().getExistingModelForEdit(document);
-
- // format
- formatModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
- }
-
- public void formatFile(IFile file) throws IOException, CoreException {
- if (file == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = getModelManager().getModelForEdit(file);
-
- // format
- formatModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatFile(IFile file, int start, int length) throws IOException, CoreException {
- if (file == null)
- return;
-
- IStructuredModel structuredModel = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- structuredModel = getModelManager().getModelForEdit(file);
-
- // format
- formatModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, null);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatFileName(String fileName) throws IOException, CoreException {
- if (fileName == null)
- return;
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForEdit(fileName, inputStream, null);
-
- // format
- formatModel(structuredModel);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatFileName(String fileName, int start, int length) throws IOException, CoreException {
- if (fileName == null)
- return;
-
- IStructuredModel structuredModel = null;
- InputStream inputStream = null;
- //OutputStream outputStream = null;
- try {
- // setup structuredModel
- // Note: We are getting model for edit. Will save model if model
- // changed.
- inputStream = new FileInputStream(fileName);
- structuredModel = getModelManager().getModelForEdit(fileName, inputStream, null);
-
- // format
- formatModel(structuredModel, start, length);
-
- // save model if needed
- if (!structuredModel.isSharedForEdit() && structuredModel.isSaveNeeded())
- structuredModel.save();
- }
- finally {
- //ensureClosed(outputStream, inputStream);
- // release from model manager
- if (structuredModel != null)
- structuredModel.releaseFromEdit();
- }
- }
-
- public void formatModel(IStructuredModel structuredModel) {
- int start = 0;
- int length = structuredModel.getStructuredDocument().getLength();
-
- formatModel(structuredModel, start, length);
- }
-
- public void formatModel(IStructuredModel structuredModel, int start, int length) {
- if (structuredModel != null) {
- if (start == 0 && length == structuredModel.getStructuredDocument().getLength())
- setFormatWithSiblingIndent(structuredModel, false);
- else
- setFormatWithSiblingIndent(structuredModel, true);
-
- if (start >= 0 && length >= 0 && start + length <= structuredModel.getStructuredDocument().getLength()) {
- Vector activeNodes = getActiveNodes(structuredModel, start, length);
- if (activeNodes.size() > 0) {
- Node firstNode = (Node) activeNodes.firstElement();
- Node lastNode = (Node) activeNodes.lastElement();
-
- boolean done = false;
- Node eachNode = firstNode;
- Node nextNode = null;
- while (!done) {
- // update "done"
- done = (eachNode == lastNode);
-
- // get next sibling before format because eachNode may
- // be deleted,
- // for example when it's an empty text node
- nextNode = eachNode.getNextSibling();
-
- // format each node
- formatNode(eachNode);
-
- // update each node
- if (nextNode != null && nextNode.getParentNode() == null)
- // nextNode is deleted during format
- eachNode = eachNode.getNextSibling();
- else
- eachNode = nextNode;
-
- // This should not be needed, but just in case
- // something went wrong with with eachNode.
- // We don't want an infinite loop here.
- if (eachNode == null)
- done = true;
- }
- }
- }
- }
- }
-
- public void formatNode(Node node) {
- if (node != null) {
- Node newNode = node;
-
- // format the owner node if it's an attribute node
- if (node.getNodeType() == Node.ATTRIBUTE_NODE)
- newNode = ((Attr) node).getOwnerElement();
-
- // refresh format preferences before getting formatter
- if (refreshFormatPreferences)
- refreshFormatPreferences();
-
- // get formatter and format contraints
- IStructuredFormatter formatter = getFormatter(newNode);
- IStructuredFormatContraints formatContraints = formatter.getFormatContraints();
- formatContraints.setFormatWithSiblingIndent(true);
-
- if (formatter != null)
- // format each node
- formatter.format(newNode, formatContraints);
- }
- }
-
- protected void setFormatWithSiblingIndent(IStructuredModel structuredModel, boolean formatWithSiblingIndent) {
- // 262135 - NPE during format of empty document
- IStructuredFormatContraints formatContraints = getFormatContraints(structuredModel);
-
- if (formatContraints != null)
- formatContraints.setFormatWithSiblingIndent(formatWithSiblingIndent);
- }
-
- protected IStructuredFormatContraints getFormatContraints(IStructuredModel structuredModel) {
- // 262135 - NPE during format of empty document
- if (fFormatContraints == null && structuredModel != null) {
- Node node = (Node) structuredModel.getIndexedRegion(0);
-
- if (node != null) {
- IStructuredFormatter formatter = getFormatter(node);
- if (formatter != null) {
- fFormatContraints = formatter.getFormatContraints();
- }
- }
- }
-
- return fFormatContraints;
- }
-
- protected Vector getActiveNodes(IStructuredModel structuredModel, int startNodeOffset, int length) {
- Vector activeNodes = new Vector();
-
- if (structuredModel != null) {
- Node startNode = (Node) structuredModel.getIndexedRegion(startNodeOffset);
- Node endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
-
- // make sure it's an non-empty document
- if (startNode != null) {
- while (isSiblingOf(startNode, endNode) == false) {
- if (endNode != null)
- endNode = endNode.getParentNode();
- if (endNode == null) {
- startNode = startNode.getParentNode();
- endNode = (Node) structuredModel.getIndexedRegion(startNodeOffset + length);
- }
- }
-
- while (startNode != endNode) {
- activeNodes.addElement(startNode);
- startNode = startNode.getNextSibling();
- }
- if (startNode != null)
- activeNodes.addElement(startNode);
- }
- }
-
- return activeNodes;
- }
-
- protected boolean isSiblingOf(Node node, Node endNode) {
- if (endNode == null) {
- return true;
- }
- else {
- Node siblingNode = node;
- while (siblingNode != null) {
- if (siblingNode == endNode)
- return true;
- else
- siblingNode = siblingNode.getNextSibling();
- }
- return false;
- }
- }
-
- public void setProgressMonitor(IProgressMonitor monitor) {
- fProgressMonitor = monitor;
- }
-
- /**
- * @deprecated renamed to getFileExtension()
- * TODO will delete in C5
- */
- abstract protected String getContentType();
-
- abstract protected String getFileExtension();
-
- abstract protected IStructuredFormatter getFormatter(Node node);
-
- abstract protected void refreshFormatPreferences();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.java
deleted file mode 100644
index 4360031637..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredContentFormatter.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.core.format;
-
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-public interface IStructuredContentFormatter {
- void setModel(IStructuredModel model);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.java
deleted file mode 100644
index 7b4b1ff1a2..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatContraints.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.core.format;
-
-public interface IStructuredFormatContraints {
- boolean getClearAllBlankLines();
-
- String getCurrentIndent();
-
- boolean getFormatWithSiblingIndent();
-
- void setClearAllBlankLines(boolean clearAllBlankLines);
-
- void setCurrentIndent(String currentIndent);
-
- void setFormatWithSiblingIndent(boolean formatWithSiblingIndent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.java
deleted file mode 100644
index c7a4ac18db..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatPreferences.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.core.format;
-
-public interface IStructuredFormatPreferences {
- boolean getClearAllBlankLines();
-
- String getIndent();
-
- int getLineWidth();
-
- void setClearAllBlankLines(boolean clearAllBlankLines);
-
- void setIndent(String indent);
-
- void setLineWidth(int lineWidth);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.java
deleted file mode 100644
index b0792f9b02..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatProcessor.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.core.format;
-
-import java.io.IOException;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.w3c.dom.Node;
-
-
-public interface IStructuredFormatProcessor {
- /**
- * This form of the FormatProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, formats the whole model, then returns
- * the formatted input string.
- */
- String formatContent(String content) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an input string as input,
- * creates an InputStream from the input string, create a temporary model
- * of the content type specified, formats the model within start and
- * length, then returns the formatted input string.
- */
- String formatContent(String content, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IDocument as input, creates a
- * temporary model of content type calculated using the IDocument's file
- * extension, formats the whole model, then releases the model.
- */
- void formatDocument(IDocument document) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IDocument as input, creates a
- * temporary model of content type calculated using the IDocument's file
- * extension, formats the model within start and length, then releases the
- * model.
- */
- void formatDocument(IDocument document, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, formats the whole model, then releases the model.
- */
- void formatFile(IFile file) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes an IFile as input, creates a
- * temporary model of content type calculated using the IFile's file
- * extension, formats the model within start and length, then releases the
- * model.
- */
- void formatFile(IFile file, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, formats the whole
- * model, then releases the model.
- */
- void formatFileName(String fileName) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes a file name as input,creates an
- * InputStream from the file, create a temporary model of content type
- * calculated using the file name's file extension, formats the model
- * within start and length, then releases the model.
- */
- void formatFileName(String fileName, int start, int length) throws IOException, CoreException;
-
- /**
- * This form of the FormatProcessor takes a model as input, and formats
- * the whole model.
- */
- void formatModel(IStructuredModel structuredModel);
-
- /**
- * This form of the FormatProcessor takes a model as input, and formats
- * the model within start and length.
- */
- void formatModel(IStructuredModel structuredModel, int start, int length);
-
- /**
- * This form of the FormatProcessor takes a node as input, and formats the
- * node and all its children.
- */
- void formatNode(Node node);
-
- void setProgressMonitor(IProgressMonitor monitor);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.java
deleted file mode 100644
index 7cd0f2c522..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormatter.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.core.format;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.w3c.dom.Node;
-
-public interface IStructuredFormatter {
- void format(Node node);
-
- void format(Node node, IStructuredFormatContraints formatContraints);
-
- void setFormatPreferences(IStructuredFormatPreferences formatPreferences);
-
- IStructuredFormatPreferences getFormatPreferences();
-
- IStructuredFormatContraints getFormatContraints();
-
- void setProgressMonitor(IProgressMonitor monitor);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormattingStrategy.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormattingStrategy.java
deleted file mode 100644
index f345aed887..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/IStructuredFormattingStrategy.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.core.format;
-
-import org.eclipse.jface.text.formatter.IFormattingStrategy;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-
-public interface IStructuredFormattingStrategy extends IFormattingStrategy {
- void format(IStructuredModel model, int start, int length, boolean isLineStart, String indentation, int[] positions);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.java
deleted file mode 100644
index f0ab4dc00e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatContraints.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.core.format;
-
-public class StructuredFormatContraints implements IStructuredFormatContraints {
- protected int fAvailableLineWidth;
- protected boolean fClearAllBlankLines;
- protected String fCurrentIndent = ""; //$NON-NLS-1$
- protected boolean fFormatWithSiblingIndent = false;
-
- public boolean getClearAllBlankLines() {
- return fClearAllBlankLines;
- }
-
- public String getCurrentIndent() {
- return fCurrentIndent;
- }
-
- public boolean getFormatWithSiblingIndent() {
- return fFormatWithSiblingIndent;
- }
-
- public void setClearAllBlankLines(boolean clearAllBlankLines) {
- fClearAllBlankLines = clearAllBlankLines;
- }
-
- public void setCurrentIndent(String currentIndent) {
- fCurrentIndent = currentIndent;
- }
-
- public void setFormatWithSiblingIndent(boolean formatWithSiblingIndent) {
- fFormatWithSiblingIndent = formatWithSiblingIndent;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.java
deleted file mode 100644
index b784c57f55..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormatPreferences.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.core.format;
-
-public class StructuredFormatPreferences implements IStructuredFormatPreferences {
- private boolean fClearAllBlankLines;
- private String fIndent;
- private int fLineWidth;
-
- public String getIndent() {
- return fIndent;
- }
-
- public int getLineWidth() {
- return fLineWidth;
- }
-
- public boolean getClearAllBlankLines() {
- return fClearAllBlankLines;
- }
-
- public void setIndent(String indent) {
- fIndent = indent;
- }
-
- public void setLineWidth(int lineWidth) {
- fLineWidth = lineWidth;
- }
-
- public void setClearAllBlankLines(boolean clearAllBlankLines) {
- fClearAllBlankLines = clearAllBlankLines;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormattingStrategy.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormattingStrategy.java
deleted file mode 100644
index 06b006e2c3..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/format/StructuredFormattingStrategy.java
+++ /dev/null
@@ -1,95 +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.core.format;
-
-import java.io.IOException;
-import java.util.LinkedList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TypedPosition;
-import org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy;
-import org.eclipse.jface.text.formatter.FormattingContextProperties;
-import org.eclipse.jface.text.formatter.IFormattingContext;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-
-
-public class StructuredFormattingStrategy extends ContextBasedFormattingStrategy {
-
- /** Documents to be formatted by this strategy */
- private final LinkedList fDocuments = new LinkedList();
- /** Partitions to be formatted by this strategy */
- private final LinkedList fPartitions = new LinkedList();
- private IStructuredFormatProcessor fFormatProcessor;
- private IRegion fRegion;
-
- /**
- * @param formatProcessor
- */
- public StructuredFormattingStrategy(IStructuredFormatProcessor formatProcessor) {
- super();
-
- fFormatProcessor = formatProcessor;
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#format()
- */
- public void format() {
- super.format();
-
- final IDocument document = (IDocument) fDocuments.removeFirst();
- final TypedPosition partition = (TypedPosition) fPartitions.removeFirst();
-
- if (document != null && partition != null && fRegion != null && fFormatProcessor != null) {
- try {
- fFormatProcessor.formatDocument(document, fRegion.getOffset(), fRegion.getLength());
- }
- catch (IOException e) {
- throw new SourceEditingRuntimeException(e);
- }
- catch (CoreException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStarts(org.eclipse.jface.text.formatter.IFormattingContext)
- */
- public void formatterStarts(final IFormattingContext context) {
- super.formatterStarts(context);
-
- fPartitions.addLast(context.getProperty(FormattingContextProperties.CONTEXT_PARTITION));
- fDocuments.addLast(context.getProperty(FormattingContextProperties.CONTEXT_MEDIUM));
- fRegion = (IRegion) context.getProperty(FormattingContextProperties.CONTEXT_REGION);
- }
-
- /*
- * @see org.eclipse.jface.text.formatter.ContextBasedFormattingStrategy#formatterStops()
- */
- public void formatterStops() {
- super.formatterStops();
-
- fPartitions.clear();
- fDocuments.clear();
- }
-
- protected static IModelManager getModelManager() {
- return ((IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID)).getModelManager();
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.java
deleted file mode 100644
index c3fa8fb472..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/JSPAwareAdapterFactory.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.core.internal;
-
-import org.eclipse.wst.sse.core.AdapterFactory;
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-
-
-public interface JSPAwareAdapterFactory extends AdapterFactory {
-
- void initializeWith(EmbeddedTypeHandler embeddedContentType);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java
deleted file mode 100644
index 8f472b5b2e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/Logger.java
+++ /dev/null
@@ -1,169 +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.core.internal;
-
-
-
-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;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-
-
-/**
- * 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;
- private static String fPluginId;
-
- 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, getPluginId(), severity, message, exception);
- getPlugin().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, getPluginId(), IStatus.OK, message, exception);
- getPlugin().getLog().log(statusObj);
- }
- }
-
- /**
- * @return true if the plugin for this logger is debugging
- */
- public static boolean isDebugging() {
- return getPlugin().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(getPluginId() + 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);
- }
-
- private static IModelManagerPlugin getModelManagerPlugin() {
- IModelManagerPlugin plugin = (IModelManagerPlugin) Platform.getPlugin(IModelManagerPlugin.ID);
- return plugin;
- }
-
- public static Plugin getPlugin() {
-
- if (fPlugin == null) {
- fPlugin = (Plugin) getModelManagerPlugin();
- }
- return fPlugin;
- }
-
- public static String getPluginId() {
-
- if (fPluginId == null) {
- fPluginId = ((Plugin) getModelManagerPlugin()).getDescriptor().getUniqueIdentifier();
- }
- return fPluginId;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.java
deleted file mode 100644
index 964631e97e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/ModelManagerPluginRegistryReader.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.core.internal;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IExtensionRegistry;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.wst.sse.core.AdapterFactory;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-
-public class ModelManagerPluginRegistryReader {
-
- protected final String EXTENSION_POINT_ID = "adaptOnCreateFactory"; //$NON-NLS-1$
- protected final String TAG_NAME = "AdaptOnCreateFactory"; //$NON-NLS-1$
- protected final String ATTR_CLASS = "class"; //$NON-NLS-1$
- protected final String ATTR_CONTENTTYPE = "type"; //$NON-NLS-1$
- protected final String ATTR_ADAPTERKEY = "adapterKeyClass"; //$NON-NLS-1$
- protected final String ATTR_REGISTERADAPTER = "registerAdapters"; //$NON-NLS-1$
- private static ModelManagerPluginRegistryReader reader = null;
-
- /**
- * XMLEditorPluginRegistryReader constructor comment.
- */
- protected ModelManagerPluginRegistryReader() {
- super();
- }
-
- public List getFactories(String type) {
- return loadRegistry(type);
- }
-
- public List getFactories(IDocumentTypeHandler handler) {
- return loadRegistry(handler.getId());
- }
-
- public synchronized static ModelManagerPluginRegistryReader getInstance() {
- if (reader == null) {
- reader = new ModelManagerPluginRegistryReader();
- }
- return reader;
- }
-
- protected AdapterFactory loadFactoryFromConfigurationElement(IConfigurationElement element, Object requesterType) {
- AdapterFactory factory = null;
- if (element.getName().equals(TAG_NAME)) {
- String contentType = element.getAttribute(ATTR_CONTENTTYPE);
- if (!contentType.equals(requesterType))
- return null;
- String className = element.getAttribute(ATTR_CLASS);
- String adapterKeyClass = element.getAttribute(ATTR_ADAPTERKEY);
- String registerAdapters = element.getAttribute(ATTR_REGISTERADAPTER);
-
- // if className is null, then no one defined the extension point
- // for adapter factories
- if (className != null) {
- Plugin plugin = null;
- IPluginDescriptor descriptor = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- try {
- plugin = descriptor.getPlugin();
- }
- catch (CoreException e) {
- // if an error occurs here, its probably that the plugin
- // could not be found/loaded
- Logger.logException("Could not find plugin: " + descriptor, e); //$NON-NLS-1$
-
- }
- if (plugin != null) {
- boolean useExtendedConstructor = false;
- boolean doRegisterAdapters = false;
- Object adapterKey = null;
-
- if (registerAdapters != null && registerAdapters.length() > 0 && Boolean.valueOf(registerAdapters).booleanValue()) {
- doRegisterAdapters = true;
- }
- if (adapterKeyClass != null) {
- try {
- ClassLoader classLoader = plugin.getClass().getClassLoader();
- Class aClass = classLoader != null ? classLoader.loadClass(adapterKeyClass) : Class.forName(adapterKeyClass);
- if (aClass != null) {
- useExtendedConstructor = true;
- adapterKey = aClass;
- }
- else {
- adapterKey = adapterKeyClass;
- }
- }
- catch (Throwable anyErrors) {
- adapterKey = adapterKeyClass;
- }
- }
-
- try {
- ClassLoader classLoader = plugin.getClass().getClassLoader();
- Class theClass = classLoader != null ? classLoader.loadClass(className) : Class.forName(className);
- if (useExtendedConstructor) {
- java.lang.reflect.Constructor[] ctors = theClass.getConstructors();
- for (int i = 0; i < ctors.length; i++) {
- Class[] paramTypes = ctors[i].getParameterTypes();
- if (ctors[i].isAccessible() && paramTypes.length == 2 && paramTypes[0].equals(Object.class) && paramTypes[1].equals(boolean.class)) {
- try {
- factory = (AdapterFactory) ctors[i].newInstance(new Object[]{adapterKey, new Boolean(doRegisterAdapters)});
- }
- catch (IllegalAccessException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- catch (IllegalArgumentException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- catch (InstantiationException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- catch (InvocationTargetException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- catch (ExceptionInInitializerError e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- }
- }
- }
- if (factory == null) {
- factory = (AdapterFactory) element.createExecutableExtension(ATTR_CLASS);
- }
- }
- catch (ClassNotFoundException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- catch (CoreException e) {
- throw new org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException(e);
- }
- }
- }
- }
- return factory;
- }
-
- protected List loadRegistry(Object contentType) {
- List factoryList = new Vector();
- IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
- IExtensionPoint point = extensionRegistry.getExtensionPoint(IModelManagerPlugin.ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- for (int i = 0; i < elements.length; i++) {
- AdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
- if (factory != null)
- factoryList.add(factory);
- }
- }
- return factoryList;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.java
deleted file mode 100644
index 90061e4706..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/NotImplementedException.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.core.internal;
-
-
-public class NotImplementedException extends RuntimeException {
- public NotImplementedException() {
- super();
- }
-
- public NotImplementedException(String message) {
- super(message);
- }
-
- public NotImplementedException(Throwable cause) {
- super(cause);
- }
-
- public NotImplementedException(String message, Throwable cause) {
- super(message, cause);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.java
deleted file mode 100644
index dd4b2b5bb3..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderModelProvider.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.core.internal.builder;
-
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.IModelManager;
-import org.eclipse.wst.sse.core.IStructuredModel;
-import org.eclipse.wst.sse.core.builder.IBuilderModelProvider;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.text.IStructuredDocument;
-
-
-public class BuilderModelProvider implements IBuilderModelProvider {
-
- private Map fDocuments = null;
- private IModelManager fModelManager;
- private Map fModels = null;
- private static final boolean _debug = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/modelprovider")); //$NON-NLS-1$ //$NON-NLS-2$
-
- public BuilderModelProvider(IModelManager manager) {
-
- super();
- fModelManager = manager;
- }
-
- /**
- * Creates the document for this file; current done by retrieving it from an IStructuredModel
- *
- * @param file
- * @return
- * @todo Generated comment
- */
- private IStructuredDocument createDocument(IFile file) {
-
- // For now, we have to retrieve the IStructuredDocument from the
- // IStructuredModel.
- IStructuredModel model = getModel(file);
- if (model != null) {
- if (_debug) {
- System.out.println(getClass().getName() + " created IStructuredDocument for " + file.getFullPath().toString()); //$NON-NLS-1$
- }
- return model.getStructuredDocument();
- }
- return null;
- }
-
-
- /**
- * Creates the model for this file. Currently, does it using the IModelManager from scratch.
- * TODO: C4, create the model using the document (creating the document if needed, first)
- *
- * @param file
- * @return
- * @todo Generated comment
- */
- private IStructuredModel createModel(IFile file) {
-
- IStructuredModel model = null;
- try {
- if (_debug) {
- System.out.println(getClass().getName() + " created IStructuredModel for " + file.getFullPath().toString()); //$NON-NLS-1$
- }
- model = getModelManager().getExistingModelForRead(file);
- if (model != null) {
- // we have our reference, allow the
- // IModelManager to dispose if needed
- model.releaseFromRead();
- }
- else {
- model = getModelManager().createUnManagedStructuredModelFor(file);
- }
- return model;
- }
- catch (OutOfMemoryError e) {
- // This catch of no memory only marginally helps problem,
- // but thought I'd leave it in for now, just to see how
- // often its detected and recovers. The problem is that in only
- // helps
- // if occurs in this code. If instead it consumes most, but not
- // all of
- // memory, then the exception occurs elsewhere.
-
- // set the memory hoggers to null before doing
- // anything else.
- releaseAll();
- fModels = null;
- fDocuments = null;
- Logger.logException("Out of Memory Exception caught and models cleared for " + file.getFullPath(), e); //$NON-NLS-1$
-
- }
- // catch 'em all
- catch (Throwable t) {
- Logger.log(Logger.WARNING, "Exception caught creating IStructuredModel for file " + file.getFullPath().toOSString() + ":" + t); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IStructuredDocument getDocument(IFile file) {
-
- if (file == null) {
- return null;
- }
- IStructuredDocument document = (IStructuredDocument) getDocuments().get(file);
- if (document == null) {
- document = createDocument(file);
- if (document != null) {
- getDocuments().put(file, document);
- }
- }
- return document;
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public IStructuredModel getModel(IFile file) {
-
- if (file == null) {
- return null;
- }
- IStructuredModel model = (IStructuredModel) getModels().get(file);
- if (model == null) {
- model = createModel(file);
- if (model != null) {
- getModels().put(file, model);
- }
- }
- return model;
- }
-
- protected IModelManager getModelManager() {
-
- return fModelManager;
- }
-
- public void release(IFile file) {
-
- if (_debug) {
- System.out.println(getClass().getName() + " released resources for " + file.getProjectRelativePath().toString()); //$NON-NLS-1$
- }
- getDocuments().remove(file);
- getModels().remove(file);
- }
-
- public void releaseAll() {
-
- if (_debug) {
- System.out.println(getClass().getName() + " released all resources"); //$NON-NLS-1$
- }
- getDocuments().clear();
- getModels().clear();
- }
-
- /**
- * @return Returns the documents.
- */
- public Map getDocuments() {
-
- if (fDocuments == null) {
- fDocuments = new WeakHashMap();
- }
- return fDocuments;
- }
-
- /**
- * @return Returns the models.
- */
- public Map getModels() {
-
- if (fModels == null) {
- fModels = new WeakHashMap();
- }
- return fModels;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java
deleted file mode 100644
index 5b86043881..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/BuilderParticipantRegistryReader.java
+++ /dev/null
@@ -1,152 +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.core.internal.builder;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.wst.sse.core.ModelPlugin;
-import org.eclipse.wst.sse.core.builder.IBuilderDelegate;
-import org.eclipse.wst.sse.core.builder.IBuilderParticipant;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.util.StringUtils;
-
-
-class BuilderParticipantRegistryReader {
-
- private static final boolean _debugReader = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/participantregistry")); //$NON-NLS-1$ //$NON-NLS-2$
- private String ATT_CLASS = "class"; //$NON-NLS-1$
- private String ATT_CONTENT_TYPE = "contentType"; //$NON-NLS-1$
-
- private String PARTICIPANT_EXTENSION_POINT_ID = ModelPlugin.getID() + ".builderparticipant"; //$NON-NLS-1$
-
- private String DELEGATE_EXTENSION_POINT_ID = ModelPlugin.getID() + ".builderdelegate"; //$NON-NLS-1$
-
- private final static String CONTENTTYPE_WILDCARD = "*"; //$NON-NLS-1$
-
- // all of the configuration elements for our extension point
- private IConfigurationElement[] fParticipantElements;
- private IConfigurationElement[] fDelegateElements;
-
- // a mapping of content types to IBuilderParticipant instances
- private Map fParticipantMap = null;
- // a mapping of content types to IBuilderDelegate instances
- private Map fDelegateMap = null;
-
- BuilderParticipantRegistryReader() {
- super();
- }
-
- public IBuilderParticipant[] getBuildParticipants(Object contentTypeID) {
- if (fParticipantElements == null) {
- readRegistry();
- }
- IBuilderParticipant[] participants = (IBuilderParticipant[]) fParticipantMap.get(contentTypeID);
- if (participants == null) {
- // fine the relevant extensions
- List elements = new ArrayList(0);
- IConfigurationElement[] participantElements = fParticipantElements;
- for (int j = 0; j < participantElements.length; j++) {
- String participantContentTypes = participantElements[j].getAttribute(ATT_CONTENT_TYPE);
- String[] participantContentType = StringUtils.unpack(participantContentTypes);
- for (int k = 0; k < participantContentType.length; k++) {
- // allow wildcards to be returned as well
- if (participantContentType[k].equals(contentTypeID) || CONTENTTYPE_WILDCARD.equals(participantContentType[k])) {
- elements.add(participantElements[j]);
- }
- }
- }
- // instantiate and save them
- List participantsList = new ArrayList(elements.size());
- for (int i = 0; i < elements.size(); i++) {
- try {
- IBuilderParticipant participant = (IBuilderParticipant) ((IConfigurationElement) elements.get(i)).createExecutableExtension(ATT_CLASS);
- if (participant != null) {
- participantsList.add(participant);
- }
- }
- catch (CoreException e) {
- Logger.logException("Exception creating builder participant for " + contentTypeID, e); //$NON-NLS-1$
- }
- }
- participants = (IBuilderParticipant[]) participantsList.toArray(new IBuilderParticipant[0]);
- fParticipantMap.put(contentTypeID, participants);
- if (_debugReader) {
- System.out.println("Created " + participants.length + " build participants for " + contentTypeID); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return participants;
- }
-
- public IBuilderDelegate[] getBuilderDelegates(Object contentTypeID) {
- if (fDelegateElements == null) {
- readRegistry();
- }
- IBuilderDelegate[] delegates = (IBuilderDelegate[]) fDelegateMap.get(contentTypeID);
- if (delegates == null) {
- // fine the relevant extensions
- List elements = new ArrayList(0);
- IConfigurationElement[] delegateElements = fDelegateElements;
- for (int j = 0; j < delegateElements.length; j++) {
- String contentTypes = delegateElements[j].getAttribute(ATT_CONTENT_TYPE);
- String[] contentType = StringUtils.unpack(contentTypes);
- for (int k = 0; k < contentType.length; k++) {
- // allow wildcards to be returned as well
- if (contentType[k].equals(contentTypeID)) {
- elements.add(delegateElements[j]);
- }
- }
- }
- // instantiate and save them
- List delegateList = new ArrayList(elements.size());
- for (int i = 0; i < elements.size(); i++) {
- try {
- IBuilderDelegate delegate = (IBuilderDelegate) ((IConfigurationElement) elements.get(i)).createExecutableExtension(ATT_CLASS);
- if (delegate != null) {
- delegateList.add(delegate);
- }
- }
- catch (CoreException e) {
- Logger.logException("Exception creating builder participant for " + contentTypeID, e); //$NON-NLS-1$
- }
- }
- delegates = (IBuilderDelegate[]) delegateList.toArray(new IBuilderDelegate[0]);
- fDelegateMap.put(contentTypeID, delegates);
- if (_debugReader) {
- System.out.println("Created " + delegates.length + " build participants for " + contentTypeID); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return delegates;
- }
-
- private void readRegistry() {
- fParticipantMap = new HashMap();
- fDelegateMap = new HashMap();
- // Just remember the elements, so plugins don't have to be activated,
- // unless extension attributes match those of interest
- IExtensionPoint point = Platform.getExtensionRegistry().getExtensionPoint(PARTICIPANT_EXTENSION_POINT_ID);
- if (point != null) {
- fParticipantElements = point.getConfigurationElements();
- }
- point = Platform.getExtensionRegistry().getExtensionPoint(DELEGATE_EXTENSION_POINT_ID);
- if (point != null) {
- fDelegateElements = point.getConfigurationElements();
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java
deleted file mode 100644
index 8d15e2eab9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/builder/StructuredDocumentBuilder.java
+++ /dev/null
@@ -1,377 +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.core.internal.builder;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.resources.ICommand;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IProjectDescription;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceDelta;
-import org.eclipse.core.resources.IResourceDeltaVisitor;
-import org.eclipse.core.resources.IResourceVisitor;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.IncrementalProjectBuilder;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExecutableExtension;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.NullProgressMonitor;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.builder.IBuilderDelegate;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.internal.nls.ResourceHandler;
-
-
-public class StructuredDocumentBuilder extends IncrementalProjectBuilder implements IExecutableExtension {
-
- protected static final boolean _debugBuilder = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder")); //$NON-NLS-1$ //$NON-NLS-2$
- protected static final boolean _debugBuilderContentTypeDetection = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/detection")); //$NON-NLS-1$ //$NON-NLS-2$
- protected static final boolean _debugBuilderPerf = "true".equalsIgnoreCase(Platform.getDebugOption("org.eclipse.wst.sse.core/builder/time")); //$NON-NLS-1$ //$NON-NLS-2$
-
- protected static IModelManagerPlugin fPlugin = null;
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.resources.IncrementalProjectBuilder#clean(org.eclipse.core.runtime.IProgressMonitor)
- */
- protected void clean(IProgressMonitor monitor) throws CoreException {
- super.clean(monitor);
- doFullBuild(IncrementalProjectBuilder.CLEAN_BUILD, new HashMap(0), monitor, getProject());
- }
-
- IContentType[] detectContentTypes(IResource resource) {
- IContentType[] types = null;
- if (resource.getType() == IResource.FILE && resource.isAccessible()) {
- IContentDescription d = null;
- try {
- // optimized description lookup, might not succeed
- d = ((IFile) resource).getContentDescription();
- if (d != null)
- types = new IContentType[]{d.getContentType()};
- }
- catch (CoreException e) {
- // should not be possible given the accessible and file type
- // check above
- }
- if (types == null) {
- types = Platform.getContentTypeManager().findContentTypesFor(resource.getName());
- }
- if (_debugBuilderContentTypeDetection) {
- if (types.length > 0) {
- if (types.length > 1) {
- System.out.println(resource.getFullPath() + ": " + "multiple based on name (probably hierarchical)"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- for (int i = 0; i < types.length; i++) {
- System.out.println(resource.getFullPath() + " matched: " + types[i].getId()); //$NON-NLS-1$
- }
- }
- }
- }
- return types;
- }
-
- public static IProgressMonitor monitorFor(IProgressMonitor monitor) {
- if (monitor == null)
- return new NullProgressMonitor();
- return monitor;
- }
-
- public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks);
- }
-
- public static IProgressMonitor subMonitorFor(IProgressMonitor monitor, int ticks, int style) {
- if (monitor == null)
- return new NullProgressMonitor();
- if (monitor instanceof NullProgressMonitor)
- return monitor;
- return new SubProgressMonitor(monitor, ticks, style);
- }
-
- protected List fActiveDelegates = null;
- protected BuilderParticipantRegistryReader registry = null;
- private String fName = "Structured Document Builder"; //$NON-NLS-1$
-
- private long time0;
-
- /**
- *
- */
- public StructuredDocumentBuilder() {
- super();
- registry = new BuilderParticipantRegistryReader();
- fActiveDelegates = new ArrayList();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.internal.events.InternalBuilder#build(int,
- * java.util.Map, org.eclipse.core.runtime.IProgressMonitor)
- */
- protected IProject[] build(int kind, Map args, IProgressMonitor monitor) throws CoreException {
- IProject currentProject = getProject();
- if (currentProject == null || !currentProject.isAccessible())
- return new IProject[]{currentProject};
-
- if (_debugBuilderPerf || _debugBuilder) {
- time0 = System.currentTimeMillis();
- }
- IResourceDelta delta = getDelta(currentProject);
- IProgressMonitor localMonitor = subMonitorFor(monitor, 1);
- localMonitor.beginTask(getDisplayName(), 1);
-
- if (!localMonitor.isCanceled()) {
- // check the kind of delta if one was given
- if (kind == FULL_BUILD || kind == CLEAN_BUILD || delta == null) {
- doFullBuild(kind, args, localMonitor, getProject());
- }
- else {
- doIncrementalBuild(kind, args, localMonitor);
- }
- }
- localMonitor.worked(1);
- shutdownDelegates();
- localMonitor.done();
- if (_debugBuilderPerf || _debugBuilder) {
- if (kind == FULL_BUILD || delta == null) {
- System.out.println(getClass().getName() + " finished FULL build of " + currentProject.getName() //$NON-NLS-1$
- + " in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- System.out.println(getClass().getName() + " finished INCREMENTAL/CLEAN/AUTO build of " + currentProject.getName() //$NON-NLS-1$
- + " in " + (System.currentTimeMillis() - time0) + "ms"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
- return new IProject[]{getProject()};
- }
-
- /**
- * Iterate through the list of resources and build each one
- *
- * @param monitor
- * @param resources
- */
- protected void doFullBuild(int kind, Map args, IProgressMonitor monitor, IProject project) {
- if (_debugBuilder) {
- System.out.println(getClass().getName() + " building project " + project.getName()); //$NON-NLS-1$
- }
-
- final IProgressMonitor subMonitor = subMonitorFor(monitor, IProgressMonitor.UNKNOWN);
- final int localKind = kind;
- final Map localArgs = args;
-
- final IProgressMonitor visitorMonitor = monitor;
- IResourceVisitor internalBuilder = new IResourceVisitor() {
- public boolean visit(IResource resource) throws CoreException {
- // for any supported file type, record the resource
- IContentType[] contentTypes = detectContentTypes(resource);
- if (contentTypes != null) {
- build(localKind, localArgs, resource, contentTypes, subMonitor);
- visitorMonitor.worked(1);
- }
- return true;
- }
-
- };
- try {
- project.accept(internalBuilder);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
-
- void build(int kind, Map args, IResource resource, IContentType[] types, IProgressMonitor monitor) {
- if (!monitor.isCanceled() && resource.getType() == IResource.FILE) {
- IBuilderDelegate[] delegates = null;
- List allDelegates = new ArrayList();
- for (int i = 0; i < types.length; i++) {
- IBuilderDelegate[] typeDelegates = registry.getBuilderDelegates(types[i].getId());
- if (typeDelegates != null && typeDelegates.length > 0) {
- allDelegates.addAll(Arrays.asList(typeDelegates));
- }
- }
- delegates = (IBuilderDelegate[]) allDelegates.toArray(new IBuilderDelegate[0]);
- for (int j = 0; delegates != null && j < delegates.length; j++) {
- if (kind != IncrementalProjectBuilder.CLEAN_BUILD) {
- monitor.subTask(getDisplayName() + " building " + resource.getFullPath()); //$NON-NLS-1$
- }
- try {
- if (!fActiveDelegates.contains(delegates[j]) && !monitor.isCanceled()) {
- delegates[j].startup(getProject(), kind, args);
- fActiveDelegates.add(delegates[j]);
- }
- delegates[j].build((IFile) resource, kind, args, subMonitorFor(monitor, 100));
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- }
- }
- }
-
- /**
- *
- */
- protected void doIncrementalBuild(int kind, Map args, IProgressMonitor monitor) {
- IResourceDelta projectDelta = getDelta(getProject());
- if (projectDelta == null) {
- throw new IllegalArgumentException("delta is null, should do a full build"); //$NON-NLS-1$
- }
- if (_debugBuilder) {
- if (projectDelta != null && projectDelta.getResource() != null) {
- System.out.println(getClass().getName() + " building " + projectDelta.getResource().getFullPath()); //$NON-NLS-1$
- }
- else {
- System.out.println(getClass().getName() + " building project " + getProject().getName()); //$NON-NLS-1$
- }
- }
-
- final Map localArgs = args;
- final int localKind = kind;
- final IProgressMonitor localMonitor = subMonitorFor(monitor, IProgressMonitor.UNKNOWN, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
- IResourceDeltaVisitor participantVisitor = new IResourceDeltaVisitor() {
- public boolean visit(IResourceDelta delta) throws CoreException {
- if (!localMonitor.isCanceled() && delta.getResource().getType() == IResource.FILE) {
- IContentType[] contentTypes = detectContentTypes(delta.getResource());
- if (contentTypes != null)
- build(localKind, localArgs, delta.getResource(), contentTypes, localMonitor);
- }
- return delta.getAffectedChildren().length > 0;
- }
- };
- try {
- projectDelta.accept(participantVisitor);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- monitor.worked(1);
- }
-
- private String getDisplayName() {
- return fName;
- }
-
- private static String getBuilderId() {
- return "org.eclipse.wst.sse.core.structuredbuilder"; //$NON-NLS-1$
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IExecutableExtension#setInitializationData(org.eclipse.core.runtime.IConfigurationElement,
- * java.lang.String, java.lang.Object)
- */
- public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException {
- if (config != null) {
- fName = config.getDeclaringExtension().getLabel();
- }
- }
-
- /**
- *
- */
- private void shutdownDelegates() {
- for (int j = 0; j < fActiveDelegates.size(); j++) {
- try {
- ((IBuilderDelegate) fActiveDelegates.get(j)).shutdown(getProject());
- }
- catch (Throwable e) {
- Logger.logException(e);
- }
- }
- fActiveDelegates = new ArrayList(1);
- }
-
- /**
- * Adds the StructuredBuilder to every project in the Workspace
- *
- * @param root
- */
- public synchronized static void add(IProgressMonitor monitor, IWorkspaceRoot root) {
- IProject[] allProjects = root.getProjects();
- IProgressMonitor localMonitor = subMonitorFor(monitor, allProjects.length);
- localMonitor.beginTask(ResourceHandler.getString("StructuredDocumentBuilder.0"), 1); //$NON-NLS-1$
- for (int i = 0; i < allProjects.length && !monitor.isCanceled(); i++) {
- add(localMonitor, allProjects[i]);
- localMonitor.worked(1);
- }
- localMonitor.done();
- }
-
- /**
- * Add the StructuredBuilder to the build spec of a single IProject
- *
- * @param project -
- * the IProject to add to, if needed
- */
- public static void add(IProgressMonitor monitor, IProject project) {
- if (project == null || !project.isAccessible()) {
- return;
- }
- boolean isBuilderPresent = false;
- try {
- IProjectDescription description = project.getDescription();
- ICommand[] commands = description.getBuildSpec();
- if (commands != null) {
- for (int i = 0; i < commands.length; i++) {
- String builderName = commands[i].getBuilderName();
- // builder name will be null if it has not been set
- if (builderName != null && builderName.equals(getBuilderId())) {
- isBuilderPresent = true;
- break;
- }
- }
- }
- if (!isBuilderPresent && !monitor.isCanceled()) {
- ICommand newCommand = description.newCommand();
- newCommand.setBuilderName(getBuilderId());
- ICommand[] newCommands = null;
- if (commands != null) {
- newCommands = new ICommand[commands.length + 1];
- System.arraycopy(commands, 0, newCommands, 0, commands.length);
- newCommands[commands.length] = newCommand;
- }
- else {
- newCommands = new ICommand[1];
- newCommands[0] = newCommand;
- }
- description.setBuildSpec(newCommands);
- project.setDescription(description, new NullProgressMonitor());
- }
- }
- catch (CoreException e) {
- // if we can't read the information, the project isn't open,
- // so it can't run auto-validate
- Logger.logException("Exception adding Model Builder", e); //$NON-NLS-1$
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java
deleted file mode 100644
index e4e78d2b43..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/NullStructuredDocumentPartitioner.java
+++ /dev/null
@@ -1,115 +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.core.internal.document;
-
-import org.eclipse.jface.text.DocumentEvent;
-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.TypedRegion;
-
-/**
- * To be used when no known partitioner is available.
- * Always returns the unknown type.
- */
-public class NullStructuredDocumentPartitioner implements IDocumentPartitioner {
-
- public class NullStructuredTypedRegion implements ITypedRegion {
-
- private int fOffset;
-
- private int fLength;
-
- private String fType;
-
- public void setType(String type) {
- fType = type;
- }
-
- public void setLength(int length) {
- fLength = length;
-
- }
-
- public void setOffset(int offset) {
- fOffset = offset;
- }
-
- public String getType() {
- return fType;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getOffset() {
- return fOffset;
- }
-
- }
-
- public final static String ST_UNKNOWN_PARTITION = "org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE"; //$NON-NLS-1$
- private final String[] legalTypes = new String[]{ST_UNKNOWN_PARTITION};
-
- public NullStructuredDocumentPartitioner() {
- super();
- }
-
- public void connect(IDocument document) {
- // nothing to do
- }
-
- public ITypedRegion createPartition(int offset, int length, String type) {
- ITypedRegion result = new TypedRegion(offset, length, type);
- return result;
- }
-
- public void disconnect() {
- // nothing to do
- }
-
- public String getDefault() {
- return ST_UNKNOWN_PARTITION;
- }
-
- public String[] getLegalContentTypes() {
- return legalTypes;
- }
-
- public String getPartitionType(IRegion region, int offset) {
- return ST_UNKNOWN_PARTITION;
- }
-
- public ITypedRegion[] computePartitioning(int offset, int length) {
- ITypedRegion[] alwaysOne = new ITypedRegion[]{createPartition(offset, length, ST_UNKNOWN_PARTITION)};
- return alwaysOne;
- }
-
- public void documentAboutToBeChanged(DocumentEvent event) {
- }
-
- public boolean documentChanged(DocumentEvent event) {
- return false;
- }
-
- public String getContentType(int offset) {
- return getDefault();
- }
-
- public ITypedRegion getPartition(int offset) {
- return createPartition(offset, 1, getDefault());
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.java
deleted file mode 100644
index c802fd6ad9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/document/TextUtilities.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.core.internal.document;
-
-
-/**
- * Collection of text functions.
- *
- * @deprecated - marked as deprecated to remind us to
- * phase this out (and/or move to "finished" version).
- */
-public class TextUtilities {
-
- /**
- * @deprecated if possible, its best to use IDocument.getLegalLineDelimiters()
- */
- public final static String[] fgDelimiters = new String[]{"\n", "\r", "\r\n"};//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
-
- /**
- * Determines which one of fgDelimiters appears first in the text. If none of them the
- * hint is returned.
- */
- public static String determineLineDelimiter(StringBuffer textBuffer, String[] possibles, String hint) {
- try {
- // TODO: avoid use of String instance
- String text = textBuffer.toString();
- int[] info = indexOf(possibles, text, 0);
- return possibles[info[1]];
- }
- catch (ArrayIndexOutOfBoundsException x) {
- }
- return hint;
- }
-
- /**
- * Returns the position in the string greater than offset
- * of the longest matching search string.
- */
- private static int[] indexOf(String[] searchStrings, String text, int offset) {
-
- int[] result = {-1, -1};
-
- for (int i = 0; i < searchStrings.length; i++) {
- int index = text.indexOf(searchStrings[i], offset);
- if (index >= 0) {
-
- if (result[0] == -1) {
- result[0] = index;
- result[1] = i;
- }
- else if (index < result[0]) {
- result[0] = index;
- result[1] = i;
- }
- else if (index == result[0] && searchStrings[i].length() > searchStrings[result[1]].length()) {
- result[0] = index;
- result[1] = i;
- }
- }
- }
-
- return result;
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.java
deleted file mode 100644
index f0a9730737..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistry.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.core.internal.modelhandler;
-
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-
-/**
- * The entries in this registry are, conceptually, singleton's
- * Since only one instance is created in the registry, and
- * then that instance returned when required.
- *
- * Note that there is intentionally no 'remove' method,
- * Since the registry itself is read it when once,
- * from the platform's plugin registry, and is not
- * intended to be modified after that. A change in
- * an extenstion in a plugin.xml will only take
- * effect when the workbench is re-started.
- *
- */
-public interface EmbeddedTypeRegistry {
-
- /**
- * Method to return the specific type for the specific mimetype.
- */
- public EmbeddedTypeHandler getTypeFor(String mimeType);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.java
deleted file mode 100644
index 914a9b2acc..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryImpl.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.core.internal.modelhandler;
-
-import java.util.HashSet;
-import java.util.Iterator;
-
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-
-/**
- *
- */
-public class EmbeddedTypeRegistryImpl implements EmbeddedTypeRegistry {
-
- private static EmbeddedTypeRegistry instance = null;
- private HashSet hashSet = null;
- private EmbeddedTypeHandler registryDefaultHandler = null;
-
- /*
- * @see ContentTypeRegistry#getTypeFor(String)
- */
- /**
- * Constructor for ContentTypeRegistryImpl.
- */
- private EmbeddedTypeRegistryImpl() {
- super();
- hashSet = new HashSet();
- new EmbeddedTypeRegistryReader().readRegistry(hashSet);
- }
-
- public synchronized static EmbeddedTypeRegistry getInstance() {
- if (instance == null) {
- instance = new EmbeddedTypeRegistryImpl();
- }
- return instance;
- }
-
- /**
- * Finds the contentTypeDescription based on literal id.
- * Its basically a "first found first returned". Note the
- * order is fairly unpredictable, so non-unique ids would
- * cause problems.
- */
- public EmbeddedTypeHandler getTypeFor(String mimeType) {
- // Note: the reason we have this precondition is that the
- // default is different inside the registry than when called,
- // for example, from the JSPLoader. For the JSPLoader, if there
- // is no mimetype, the default should be HTML. Here, if there is
- // some mimetype, but it is not recognized, we return a default
- // for XML. This is required for various voice xml types, etc.
- EmbeddedTypeHandler found = null;
- if (mimeType == null || mimeType.trim().length() == 0) {
- found = getJSPDefaultEmbeddedType();
- }
- else {
- Iterator it = hashSet.iterator();
- while ((found == null) && (it.hasNext())) { // safe cast since 'add' requires EmbeddedContentTypeDescription
- EmbeddedTypeHandler item = (EmbeddedTypeHandler) it.next();
- if ((item != null) && (item.getSupportedMimeTypes().contains(mimeType))) {
- found = item;
- break;
- }
- }
- }
- if (found == null) {
- found = getRegistryDefault();
- }
- return found;
- }
-
- /**
- * Method getRegistryDefault. We cache the default handler, since
- * can't change once plugin descriptors are loaded.
- * @return EmbeddedTypeHandler
- */
- private EmbeddedTypeHandler getRegistryDefault() {
- if (registryDefaultHandler == null) {
- Iterator it = hashSet.iterator();
- while ((registryDefaultHandler == null) && (it.hasNext())) { // safe cast since 'add' requires EmbeddedContentTypeDescription
- EmbeddedTypeHandler item = (EmbeddedTypeHandler) it.next();
- if ((item != null) && (item.isDefault())) {
- registryDefaultHandler = item;
- break;
- }
- }
- }
- return registryDefaultHandler;
- }
-
- /**
- * @see ContentTypeRegistry#add(ContentTypeDescription)
- */
- void add(IDocumentTypeHandler contentTypeDescription) {
- hashSet.add(contentTypeDescription);
- }
-
- private EmbeddedTypeHandler getJSPDefaultEmbeddedType() {
- return getTypeFor("text/html"); //$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.java
deleted file mode 100644
index 8ccff45262..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/EmbeddedTypeRegistryReader.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.core.internal.modelhandler;
-
-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.core.internal.Logger;
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.util.Assert;
-
-
-public class EmbeddedTypeRegistryReader {
-
-
- protected String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- protected String EXTENSION_POINT_ID = "embeddedTypeHandler"; //$NON-NLS-1$
- protected String TAG_NAME = "embeddedTypeHandler"; //$NON-NLS-1$
- protected String ATT_CLASS = "class"; //$NON-NLS-1$
-
- EmbeddedTypeRegistryReader() {
- super();
- }
-
- protected EmbeddedTypeHandler readElement(IConfigurationElement element) {
-
- EmbeddedTypeHandler contentTypeDescription = null;
- if (element.getName().equals(TAG_NAME)) {
- try {
- contentTypeDescription = (EmbeddedTypeHandler) element.createExecutableExtension(ATT_CLASS);
- }
- catch (Throwable e) {
- Logger.logException(e);
- }
- }
- Assert.isNotNull(contentTypeDescription, "Error reading content type description"); //$NON-NLS-1$
- return contentTypeDescription;
- }
-
- /**
- * We simply require an 'add' method, of what ever it is we are to read into
- */
- 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++) {
- EmbeddedTypeHandler embeddedContentType = readElement(elements[i]);
- // null can be returned if there's an error reading the element
- if (embeddedContentType != null) {
- set.add(embeddedContentType);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
deleted file mode 100644
index a9e5762e0f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistry.java
+++ /dev/null
@@ -1,287 +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.core.internal.modelhandler;
-
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.content.IContentDescription;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.core.runtime.content.IContentTypeManager;
-import org.eclipse.wst.encoding.CodedIO;
-import org.eclipse.wst.sse.core.internal.Logger;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-public class ModelHandlerRegistry {
- private ModelHandlerRegistryReader reader = new ModelHandlerRegistryReader();
- private static ModelHandlerRegistry instance = null;
- private IModelHandler defaultHandler = null;
-
- /*
- * @see ContentTypeRegistry#getTypeFor(String)
- */
- /**
- * Constructor for ContentTypeRegistryImpl.
- */
- protected ModelHandlerRegistry() {
- super();
- reader = new ModelHandlerRegistryReader().readRegistry();
- }
-
- /**
- */
- public synchronized static ModelHandlerRegistry getInstance() {
- if (instance == null) {
- instance = new ModelHandlerRegistry();
- }
- return instance;
- }
-
- /**
- * Finds the ModelHandler based on literal id. Its basically a "first
- * found first returned". Note the order is fairly unpredictable, so
- * non-unique ids would cause problems, and are not checked.
- */
- private IModelHandler getHandlerForID(String modelId) {
- IModelHandler found = null;
- IConfigurationElement[] elements = reader.elements;
- if (elements != null) {
- for (int i = 0; i < elements.length; i++) {
- String currentId = reader.getId(elements[i]);
- if (modelId.equals(currentId)) {
- IModelHandler item = reader.getInstance(elements[i]);
- found = item;
- }
- }
- }
- else {
- Logger.log(Logger.WARNING_DEBUG, "There were no Model Handler found in registry"); //$NON-NLS-1$
- }
- return found;
- }
-
- /**
- * Finds the ModelHandler based on literal content type id. This should
- * not normally be needed, in is in cases when a model needs to be
- * created, and there is no resource. Its basically a "first found first
- * returned". Note the order is fairly unpredictable, so non-unique ids
- * would cause problems, and are not checked.
- */
- public IModelHandler getHandlerForContentTypeId(String contentTypeId) {
- IContentType contentType = Platform.getContentTypeManager().getContentType(contentTypeId);
- return getHandlerForContentType(contentType);
- // IModelHandler found = null;
- // IConfigurationElement[] elements = reader.elements;
- // if (elements != null) {
- // for (int i = 0; i < elements.length; i++) {
- // String currentId = reader.getAssociatedContentTypeId(elements[i]);
- // if (contentTypeId.equals(currentId)) {
- // IModelHandler item = reader.getInstance(elements[i]);
- // found = item;
- // }
- // }
- // }
- // else {
- // Logger.log(Logger.WARNING_DEBUG, "There were no Model Handler found
- // in registry");
- // }
- // return found;
- }
-
- /**
- * Finds the contentTypeDescription based on outcome of the
- * ContentTypeDescription's canHandle(IResource) method.
- *
- * @throws CoreException
- */
- public IModelHandler getHandlerFor(IFile iFile) throws CoreException {
- IModelHandler modelHandler = null;
- IContentDescription contentDescription = null;
- IContentType contentType = null;
- boolean exists = iFile.exists();
- if (exists) {
- // try the optimized method first as the description may be cached
- contentDescription = iFile.getContentDescription();
- if (contentDescription != null) {
- // use the provided description
- contentType = contentDescription.getContentType();
- }
- else {
- // use the more thorough discovery method to get a description
- InputStream contents = null;
- try {
- contents = iFile.getContents(true);
- contentDescription = Platform.getContentTypeManager().getDescriptionFor(contents, iFile.getName(), IContentDescription.ALL);
- if (contentDescription != null) {
- contentType = contentDescription.getContentType();
- }
- }
- catch (IOException e) {
- // nothing further can be done, but will log for debugging
- Logger.logException(e);
- }
- finally {
- if (contents != null) {
- try {
- contents.close();
- }
- catch (IOException e1) {
- // nothing can be done
- }
- }
- }
- }
- }
-
- // if we couldn't get the content type from a description, try basing it on the filename
- if(contentType == null) {
- contentType = Platform.getContentTypeManager().findContentTypeFor(iFile.getName());
- }
-
- if (contentType != null) {
- modelHandler = getHandlerForContentType(contentType);
- }
- else {
- // temp hard coding for null content type
- modelHandler = getHandlerForID("org.eclipse.wst.sse.core.handler.xml"); //$NON-NLS-1$
- }
-
- return modelHandler;
- }
-
-
- /**
- * Gets registered modelHandlers for given content type. TODO: eventually
- * need to look at contentType's parent types to see if more general type
- * can handle (e.g. if we got xsl which was a subtype of xml).
- *
- * @param contentType
- * @return
- */
- private IModelHandler getHandlerForContentType(IContentType contentType) {
-
- IModelHandler found = null;
- // temp hard coding for null content type
- if (contentType == null) {
- found = getHandlerForID("org.eclipse.wst.sse.core.handler.xml"); //$NON-NLS-1$
- }
- else {
- //String associatedContentTypeId = contentType.getId();
- IConfigurationElement[] elements = reader.elements;
- if (elements != null) {
- for (int i = 0; i < elements.length; i++) {
- String currentId = reader.getAssociatedContentTypeId(elements[i]);
- IContentType modelContentType = Platform.getContentTypeManager().getContentType(currentId);
- if (contentType.isKindOf(modelContentType)) {
- IModelHandler item = reader.getInstance(elements[i]);
- found = item;
- }
- }
- }
- else {
- Logger.log(Logger.WARNING_DEBUG, "There were no Model Handler found in registry"); //$NON-NLS-1$
- }
- }
- return found;
- }
-
- private static IContentTypeManager getContentTypeRegistry() {
- IContentTypeManager registry = Platform.getContentTypeManager();
- return registry;
- }
-
- /**
- * @see ContentTypeRegistry#add(ContentTypeDescription)
- */
- // void add(IModelHandler contentTypeDescription) {
- // arrayList.add(contentTypeDescription);
- // }
- /*
- * @see ContentTypeRegistry#getModelFor(String)
- */
- /**
- * @throws IOException
- * @see ContentTypeRegistry#getTypeFor(String, InputStream)
- */
- public IModelHandler getHandlerFor(String filename, InputStream inputStream) throws IOException {
- InputStream iStream = Utilities.getMarkSupportedStream(inputStream);
- IModelHandler modelHandler = null;
- IContentType contentType = null;
- if (inputStream != null) {
- // XXX: NPE check is temporary for pre-M9 base
- try {
- iStream.mark(CodedIO.MAX_MARK_SIZE);
- contentType = getContentTypeRegistry().findContentTypeFor(Utilities.getLimitedStream(iStream), filename);
- }
- catch (NullPointerException e) {
- System.out.println(contentType);
- }
- // XXX: Remove when we build with the fix for Eclipse bug #63625
- catch (FileNotFoundException fnfe) {
- Logger.logException(fnfe);
- }
- finally {
- if (iStream != null && iStream.markSupported()) {
- iStream.reset();
- }
- }
-
- }
- if (contentType == null) {
- contentType = getContentTypeRegistry().findContentTypeFor(filename);
- }
- modelHandler = getHandlerForContentType(contentType);
- return modelHandler;
- }
-
- /**
- * Finds the default model handler. Note: we still go through the registry
- * to be sure to get the existing instance, but then we do remember it, so
- * subsequent requests will be faster. The first time through, we do check
- * the whole list, to be sure there is only one.
- *
- */
- final public IModelHandler getDefault() {
- if (defaultHandler == null) {
- IConfigurationElement[] elements = reader.elements;
- for (int i = 0; i < elements.length; i++) {
- boolean ofInterest = reader.isElementDefault(elements[i]);
- if (ofInterest) {
- // if, here within the search loop we've already found
- // one defaultHandler, then something is wrong!
- if (defaultHandler == null) {
- defaultHandler = reader.getInstance(elements[i]);
- }
- else {
- String errorString = "Program or configuration error. More than one default content handler found"; //$NON-NLS-1$
- Logger.log(Logger.ERROR, errorString);
- throw new IllegalStateException(errorString);
- }
- }
- }
- }
- if (defaultHandler == null) {
- String errorString = "Program or configuration error. No default content type handler found."; //$NON-NLS-1$
- Logger.log(Logger.ERROR, errorString);
- throw new IllegalStateException(errorString);
- }
- return defaultHandler;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java
deleted file mode 100644
index 276fa72810..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerRegistryReader.java
+++ /dev/null
@@ -1,105 +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.core.internal.modelhandler;
-
-import java.util.HashMap;
-
-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.core.modelhandler.AbstractModelHandler;
-import org.eclipse.wst.sse.core.modelhandler.IModelHandler;
-
-
-/**
- * This class just converts what's in the plugins registry
- * into a form more easily useable by others, the ContentTypeRegistry.
- */
-class ModelHandlerRegistryReader {
- private HashMap allReadyCreateInstances = new HashMap();
- IConfigurationElement[] elements;
- //
- protected String PLUGIN_ID = "org.eclipse.wst.sse.core"; //$NON-NLS-1$
- protected String EXTENSION_POINT_ID = "modelHandler"; //$NON-NLS-1$
- protected String TAG_NAME = "modelHandler"; //$NON-NLS-1$
- protected String ATT_ID = "id"; //$NON-NLS-1$
- protected String ATT_ASSOCIATED_CONTENT_TYPE = "associatedContentTypeId"; //$NON-NLS-1$
- protected String ATT_CLASS = "class"; //$NON-NLS-1$
- protected String ATT_DEFAULT = "default"; //$NON-NLS-1$
-
- //
- /**
- * ContentTypeRegistryReader constructor comment.
- */
- ModelHandlerRegistryReader() {
- super();
- }
-
- ModelHandlerRegistryReader readRegistry() {
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(PLUGIN_ID, EXTENSION_POINT_ID);
- if (point != null) {
- // just remember the elements, so plugins don't have to
- // be activated, unless extension matches those "of interest".
- elements = point.getConfigurationElements();
- }
- return this;
- }
-
- synchronized IModelHandler getInstance(IConfigurationElement element) {
- // May need to reconsider, but for now, we'll assume all clients must
- // subclass AbstractContentTypeIdentifier. Its easier and safer, for this
- // low level "system" object. (That is, we can check and set "package protected"
- // attributes.
- AbstractModelHandler modelHandler = (AbstractModelHandler) allReadyCreateInstances.get(getId(element));
- if (modelHandler == null) {
- try {
- modelHandler = (AbstractModelHandler) element.createExecutableExtension(ATT_CLASS);
- if (modelHandler != null) {
- allReadyCreateInstances.put(getId(element), modelHandler);
- String defaultValue = element.getAttribute(ATT_DEFAULT);
- if (defaultValue != null && "true".equals(defaultValue)) //$NON-NLS-1$
- modelHandler.setDefault(true);
- else
- modelHandler.setDefault(false);
- // TODO -- set and check attributes vs. created instance
- //contentTypeIdentifier.setOrCheckId(element.getAttribute(ATT_ID));
- }
- }
- catch (CoreException e) {
- org.eclipse.wst.sse.core.internal.Logger.logException(e);
- }
- }
- return modelHandler;
- }
-
- public boolean isElementDefault(IConfigurationElement element) {
- String defaultValue = element.getAttribute(ATT_DEFAULT);
- if (defaultValue != null && "true".equals(defaultValue)) //$NON-NLS-1$
- return true;
- else
- return false;
- }
-
- String getId(IConfigurationElement element) {
- String idValue = element.getAttribute(ATT_ID);
- return idValue;
- }
-
- String getAssociatedContentTypeId(IConfigurationElement element) {
- String value = element.getAttribute(ATT_ASSOCIATED_CONTENT_TYPE);
- return value;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.java
deleted file mode 100644
index fbd6bfafa7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/ModelHandlerUtility.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.core.internal.modelhandler;
-
-import org.eclipse.wst.sse.core.modelhandler.EmbeddedTypeHandler;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-/**
- *
- * Likely a temporary class to be replaced by plugin, eventually.
- */
-public class ModelHandlerUtility {
- public static EmbeddedTypeHandler getDefaultEmbeddedType() {
- return getEmbeddedContentTypeFor("text/html"); //$NON-NLS-1$
- }
-
- private static ModelHandlerRegistry contentTypeRegistry;
-
- public ModelHandlerUtility() {
- super();
- }
-
- private static ModelHandlerRegistry getContentTypeRegistry() {
- if (contentTypeRegistry == null) {
- contentTypeRegistry = ModelHandlerRegistry.getInstance();
- }
- return contentTypeRegistry;
- }
-
- public static IDocumentTypeHandler getContentTypeFor(String string) {
- return getContentTypeRegistry().getHandlerForContentTypeId(string);
- }
-
- public static EmbeddedTypeHandler getEmbeddedContentTypeFor(String string) {
- EmbeddedTypeHandler instance = null;
- instance = EmbeddedTypeRegistryImpl.getInstance().getTypeFor(string);
- return instance;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.java
deleted file mode 100644
index a7d03594d7..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/modelhandler/PluginContributedFactoryReader.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.core.internal.modelhandler;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IConfigurationElement;
-import org.eclipse.core.runtime.IExtensionPoint;
-import org.eclipse.core.runtime.IPluginDescriptor;
-import org.eclipse.core.runtime.IPluginRegistry;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Plugin;
-import org.eclipse.wst.sse.core.AdapterFactory;
-import org.eclipse.wst.sse.core.IModelManagerPlugin;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.modelhandler.IDocumentTypeHandler;
-
-
-public class PluginContributedFactoryReader {
-
- protected final String EXTENSION_POINT_ID = "contentTypeFactoryContribution"; //$NON-NLS-1$
- protected final String TAG_NAME = "factory"; //$NON-NLS-1$
- protected final String ATTR_CLASS = "class"; //$NON-NLS-1$
- protected final String ATTR_CONTENTTYPE = "contentTypeIdentiferId"; //$NON-NLS-1$
- protected final String ATTR_ADAPTERKEY = "adapterKeyClass"; //$NON-NLS-1$
- protected final String ATTR_REGISTERADAPTER = "registerAdapters"; //$NON-NLS-1$
- private static PluginContributedFactoryReader reader = null;
-
- protected PluginContributedFactoryReader() {
- super();
- }
-
- public List getFactories(String type) {
- return loadRegistry(type);
- }
-
- public List getFactories(IDocumentTypeHandler handler) {
- return loadRegistry(handler.getId());
- }
-
- public synchronized static PluginContributedFactoryReader getInstance() {
- if (reader == null) {
- reader = new PluginContributedFactoryReader();
- }
- return reader;
- }
-
- protected AdapterFactory loadFactoryFromConfigurationElement(IConfigurationElement element, Object requesterType) {
- AdapterFactory factory = null;
- if (element.getName().equals(TAG_NAME)) {
- String contentType = element.getAttribute(ATTR_CONTENTTYPE);
- if (!requesterType.equals(contentType))
- return null;
- String className = element.getAttribute(ATTR_CLASS);
- String adapterKeyClass = element.getAttribute(ATTR_ADAPTERKEY);
- String registerAdapters = element.getAttribute(ATTR_REGISTERADAPTER);
-
- // if className is null, then no one defined the extension point
- // for adapter factories
- if (className != null) {
- Plugin plugin = null;
- IPluginDescriptor descriptor = element.getDeclaringExtension().getDeclaringPluginDescriptor();
- try {
- plugin = descriptor.getPlugin();
- }
- catch (CoreException e) {
- // if an error occurs here, its probably that the plugin
- // could not be found/loaded
- org.eclipse.wst.sse.core.internal.Logger.logException("Could not find plugin: " + descriptor, e); //$NON-NLS-1$
-
- }
- if (plugin != null) {
- boolean useExtendedConstructor = false;
- boolean doRegisterAdapters = false;
- Object adapterKey = null;
-
- if (registerAdapters != null && registerAdapters.length() > 0 && Boolean.valueOf(registerAdapters).booleanValue()) {
- doRegisterAdapters = true;
- }
- if (adapterKeyClass != null) {
- try {
- ClassLoader classLoader = plugin.getClass().getClassLoader();
- Class aClass = classLoader != null ? classLoader.loadClass(adapterKeyClass) : Class.forName(adapterKeyClass);
- if (aClass != null) {
- useExtendedConstructor = true;
- adapterKey = aClass;
- }
- else {
- adapterKey = adapterKeyClass;
- }
- }
- catch (Throwable anyErrors) {
- adapterKey = adapterKeyClass;
- }
- }
-
- try {
- ClassLoader classLoader = plugin.getClass().getClassLoader();
- Class theClass = classLoader != null ? classLoader.loadClass(className) : Class.forName(className);
- if (useExtendedConstructor) {
- java.lang.reflect.Constructor[] ctors = theClass.getConstructors();
- for (int i = 0; i < ctors.length; i++) {
- Class[] paramTypes = ctors[i].getParameterTypes();
- if (ctors[i].isAccessible() && paramTypes.length == 2 && paramTypes[0].equals(Object.class) && paramTypes[1].equals(boolean.class)) {
- try {
- factory = (AdapterFactory) ctors[i].newInstance(new Object[]{adapterKey, new Boolean(doRegisterAdapters)});
- }
- catch (IllegalAccessException e) {
- throw new SourceEditingRuntimeException(e);
- }
- catch (IllegalArgumentException e) {
- throw new SourceEditingRuntimeException(e);
- }
- catch (InstantiationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- catch (InvocationTargetException e) {
- throw new SourceEditingRuntimeException(e);
- }
- catch (ExceptionInInitializerError e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
- }
- }
- if (factory == null) {
- factory = (AdapterFactory) element.createExecutableExtension(ATTR_CLASS);
- }
- }
- catch (ClassNotFoundException e) {
- throw new SourceEditingRuntimeException(e);
- }
- catch (CoreException e) {
- throw new SourceEditingRuntimeException(e);
- }
- }
- }
- }
- return factory;
- }
-
- protected List loadRegistry(Object contentType) {
- List factoryList = null; // new Vector();
- IPluginRegistry pluginRegistry = Platform.getPluginRegistry();
- IExtensionPoint point = pluginRegistry.getExtensionPoint(IModelManagerPlugin.ID, EXTENSION_POINT_ID);
- if (point != null) {
- IConfigurationElement[] elements = point.getConfigurationElements();
- if (elements.length > 0) {
- // this is called a lot, so don't create vector unless really
- // needed
- // TODO: could eventually cache in a hashtable, or something,
- // to avoid repeat processing
- factoryList = new Vector();
- for (int i = 0; i < elements.length; i++) {
- AdapterFactory factory = loadFactoryFromConfigurationElement(elements[i], contentType);
- if (factory != null)
- factoryList.add(factory);
- }
- }
- }
- return factoryList;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler.java
deleted file mode 100644
index ca224bc85e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler.java
+++ /dev/null
@@ -1,74 +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.core.internal.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("Models");//$NON-NLS-1$
- }
- catch (MissingResourceException e) {
- // does nothing - this method will return null and
- // getString(String) will return the key
- // it was called with
- }
- 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.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler1.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler1.java
deleted file mode 100644
index 00c99d6c00..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/nls/ResourceHandler1.java
+++ /dev/null
@@ -1,74 +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.core.internal.nls;
-
-
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-public class ResourceHandler1 {
-
-
- private static ResourceBundle fgResourceBundle;
-
- /**
- * Returns the resource bundle used by all classes in this Project
- */
- public static ResourceBundle getResourceBundle() {
- try {
- return ResourceBundle.getBundle("Models");//$NON-NLS-1$
- }
- catch (MissingResourceException e) {
- // does nothing - this method will return null and
- // getString(String) will return the key
- // it was called with
- }
- 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.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java
deleted file mode 100644
index d37036ed59..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ContextRegion.java
+++ /dev/null
@@ -1,211 +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.core.internal.parser;
-
-
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-
-/**
- * Regions of this class are intended specifically for XML/HTML/JSPs. Other languages
- * may need their own subclasses. (See the updateModel method).
- */
-public class ContextRegion implements ITextRegion {
-
- protected int fStart;
- protected int fLength;
- protected int fTextLength;
- protected String fType;
-
- protected ContextRegion() {
- super();
- }
-
- public ContextRegion(String newContext, int newStart, int newTextLength, int newLength) {
- fType = newContext;
- fStart = newStart;
- fTextLength = newTextLength;
- fLength = newLength;
- }
-
- protected boolean allLetterOrDigit(String changes) {
- boolean result = true;
- for (int i = 0; i < changes.length(); i++) {
- // TO_DO_FUTURE: check that a Java Letter or Digit is
- // the same thing as an XML letter or digit
- if (!(Character.isLetterOrDigit(changes.charAt(i)))) {
- result = false;
- break;
- }
- }
- return result;
- }
-
- protected boolean allWhiteSpace(String changes) {
- boolean result = true;
- for (int i = 0; i < changes.length(); i++) {
- if (!Character.isWhitespace(changes.charAt(i))) {
- result = false;
- break;
- }
- }
-
- return result;
- }
-
- protected boolean canHandleAsLetterOrDigit(String changes, int requestStart, int lengthToReplace) {
- boolean result = false;
- // Make sure we are in a non-white space area
- if ((requestStart <= (getTextEnd())) && (allLetterOrDigit(changes))) {
- result = true;
- }
- return result;
- }
-
- protected boolean canHandleAsWhiteSpace(String changes, int requestStart, int lengthToReplace) {
- boolean result = false;
- // if we are in the "white space" area of a region, then
- // we don't want to handle, a reparse is needed.
- // the white space region is consider anywhere that would
- // leave whitespace between this character and the text part.
- // and of course, we can insert whitespace in whitespace region
- //
- // if there is no whitespace in this region, no need to look further
- if (getEnd() > getTextEnd()) {
- // no need to add one to end of text, as we used to, since we
- // change definition of length to equate to offset plus one.
- if (requestStart > getTextEnd()) {
- // ok, we are in the whitespace region, so we can't handle, unless
- // we are just inserting whitespace.
- if (allWhiteSpace(changes)) {
- result = true;
- }
- else {
- result = false;
- }
-
- }
- }
-
- return result;
- }
-
- public StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace) {
- // the four types we used to handle here, have all been moved to
- // specific region classes.
- // XML_TAG_ATTRIBUTE_VALUE
- // XML_TAG_ATTRIBUTE_NAME
- // XML_CONTENT
- // XML_CDATA_TEXT
- return null;
- }
-
- public int getLength() {
- return fLength;
- }
-
- public int getStart() {
- return fStart;
- }
-
- public int getTextLength() {
- return fTextLength;
- }
-
- public String getType() {
- return fType;
- }
-
- public void setLength(int i) {
- fLength = i;
- }
-
- public void setStart(int i) {
- fStart = i;
- }
-
- public void setTextLength(int i) {
- fTextLength = i;
- }
-
- public void setType(String string) {
- fType = string;
- }
-
- /* (non-Javadoc)
- */
- public int getEnd() {
- return fStart + fLength;
- }
-
- /* (non-Javadoc)
- */
- public int getTextEnd() {
- return fStart + fTextLength;
- }
-
- /* (non-Javadoc)
- */
- public void adjust(int i) {
- fStart += i;
-
- }
-
- /* (non-Javadoc)
- */
- public void adjustLengthWith(int i) {
- fLength += i;
- }
-
- /* (non-Javadoc)
- */
- public void adjustStart(int i) {
- fStart += i;
- }
-
- /* (non-Javadoc)
- */
- public void equatePositions(ITextRegion region) {
- fStart = region.getStart();
- fLength = region.getLength();
- fTextLength = region.getTextLength();
- }
-
- /* (non-Javadoc)
- */
- public boolean contains(int position) {
-
- return fStart <= position && position < fStart + fLength;
- }
-
- public String toString() {
- String className = getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- // ==> // String resultText = null;
- String result = shortClassName + "--> " + getType() + ": " + getStart() + "-" + getTextEnd() + (getTextEnd() != getEnd() ? ("/" + getEnd()) : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- // NOTE: if the document held by any region has been updated and the region offsets have not
- // yet been updated, the output from this method invalid.
- return result;
- }
-
- /* (non-Javadoc)
- */
- public void adjustTextLength(int i) {
- fTextLength += i;
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.java
deleted file mode 100644
index d345c7a9ff..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/parser/ForeignRegion.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.core.internal.parser;
-
-
-
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-
-public class ForeignRegion extends ContextRegion {
-
- protected String language = null;
- protected String surroundingTag = null;
-
- /**
- * ForeignRegion constructor comment.
- */
- public ForeignRegion() {
- super();
- }
-
- public ForeignRegion(String newContext, int newStart, int newTextLength, int newLength) {
- super(newContext, newStart, newTextLength, newLength);
- }
-
- public ForeignRegion(String newContext, int newStart, int newTextLength, int newLength, String newLanguage) {
- super(newContext, newStart, newTextLength, newLength);
- setLanguage(newLanguage);
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String getLanguage() {
- return language;
- }
-
- /**
- * @return java.lang.String
- */
- public java.lang.String getSurroundingTag() {
- return surroundingTag;
- }
-
- /**
- *
- * @param newLanguage java.lang.String
- */
- public void setLanguage(java.lang.String newLanguage) {
- language = newLanguage;
- }
-
- /**
- * @param newSurroundingTag java.lang.String
- */
- public void setSurroundingTag(java.lang.String newSurroundingTag) {
- surroundingTag = newSurroundingTag;
- }
-
- public String toString() {
- return "FOREIGN: " + super.toString();//$NON-NLS-1$
- }
-
- public StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion flatnode, String changes, int requestStart, int lengthToReplace) {
- org.eclipse.wst.sse.core.events.RegionChangedEvent result = null;
- int lengthDifference = org.eclipse.wst.sse.core.util.Utilities.calculateLengthDifference(changes, lengthToReplace);
- fLength += lengthDifference;
- fTextLength += lengthDifference;
- result = new RegionChangedEvent(flatnode.getParentDocument(), requester, flatnode, this, changes, requestStart, lengthToReplace);
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java
deleted file mode 100644
index 3c106e5b8e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocument.java
+++ /dev/null
@@ -1,2126 +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.core.internal.text;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPartitioningException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.DocumentPartitioningChangedEvent;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentExtension;
-import org.eclipse.jface.text.IDocumentExtension3;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitionerExtension2;
-import org.eclipse.jface.text.IDocumentPartitioningListener;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension;
-import org.eclipse.jface.text.IDocumentPartitioningListenerExtension2;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TypedRegion;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.events.AboutToBeChangeEvent;
-import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
-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.internal.Logger;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-import org.eclipse.wst.sse.core.text.DeleteEqualPositionUpdater;
-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.IStructuredTextReParser;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.text.rules.StructuredTextPartitioner;
-import org.eclipse.wst.sse.core.util.Assert;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-/**
- * The standard implementation of structured document.
- */
-public class BasicStructuredDocument implements IStructuredDocument, IDocumentExtension, IDocumentExtension3 {
- /**
- * This NullDocumentEvent is used to complete the "aboutToChange" and
- * "changed" cycle, when in fact the original change is no longer valid.
- * The only known (valid) case of this is when a model re-initialize takes
- * place, which causes setText to be called in the middle of some previous
- * change. [This architecture will be improved in future].
- */
- public class NullDocumentEvent extends DocumentEvent {
- public NullDocumentEvent() {
- this(BasicStructuredDocument.this, 0, 0, ""); //$NON-NLS-1$
- }
-
- private NullDocumentEvent(IDocument doc, int offset, int length, String text) {
- super(doc, offset, length, text);
- }
- }
-
- class RegisteredReplace {
- /** The owner of this replace operation. */
- IDocumentListener fOwner;
- /** The replace operation */
- IDocumentExtension.IReplace fReplace;
-
- /**
- * Creates a new bundle object.
- *
- * @param owner
- * the document listener owning the replace operation
- * @param replace
- * the replace operation
- */
- RegisteredReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- fOwner = owner;
- fReplace = replace;
- }
- }
-
- private class ThreadLocalDocumentRegion extends ThreadLocal {
- protected Object initialValue() {
- IStructuredDocumentRegion structuredDocumentRegion = getFirstStructuredDocumentRegion();
- set(structuredDocumentRegion);
- return structuredDocumentRegion;
- }
- }
- /** The registered document partitioning listeners */
- private List fDocumentPartitioningListeners;
-
- /**
- * The registered document partitioners.
- * @since 3.0
- */
- private Map fDocumentPartitioners; private ThreadLocalDocumentRegion threadLocalDocumentRegion = this.new ThreadLocalDocumentRegion();
- private IStructuredDocumentRegion cachedDocumentRegion;
- private EncodingMemento encodingMemento;
- private boolean fAcceptPostNotificationReplaces = true;
- private DocumentEvent fDocumentEvent;
- private IDocumentListener[] fDocumentListeners;
- private IStructuredDocumentRegion firstDocumentRegion;
- private Object[] fModelAboutToBeChangedListeners;
- private Object[] fModelChangedListeners;
- private Object[] fModelChangingListeners;
- private RegionParser fParser;
- private List fPostNotificationChanges;
- private IDocumentListener[] fPrenotifiedDocumentListeners;
- private int fReentranceCount = 0;
- private IStructuredTextReParser fReParser;
- private int fStoppedCount = 0;
- private IStructuredDocumentRegion lastDocumentRegion;
- private NullDocumentEvent NULL_DOCUMENT_EVENT;
- private IDocument parentDocument;
- //
- /**
- * in case preferred delimiter is not set, we'll assume the platform
- * default Note: it is not final static to make sure it won't be inlined
- * by compiler.
- */
- private final String PlatformLineDelimiter = System.getProperty("line.separator"); //$NON-NLS-1$
- /**
- * theoretically, a document can contain mixed line delimiters
- */
- private String preferedDelimiter;
- private final String READ_ONLY_REGIONS_CATEGORY = "_READ_ONLY_REGIONS_CATEGORY_"; //$NON-NLS-1$
- /**
- * debug variable only
- *
- * @param parser
- */
- private long startStreamTime;
- /**
- * debug variable only
- *
- * @param parser
- */
- private long startTime;
- private static boolean USE_LOCAL_THREAD = false;
-
- public BasicStructuredDocument() {
- super();
- NULL_DOCUMENT_EVENT = new NullDocumentEvent();
- parentDocument = new Document();
- addPositionCategory(READ_ONLY_REGIONS_CATEGORY);
- addPositionUpdater(new DeleteEqualPositionUpdater(READ_ONLY_REGIONS_CATEGORY));
- }
-
- /**
- * This is the primary way to get a new structuredDocument. Its best to
- * use the factory methods in ModelManger to create a new
- * IStructuredDocument, since it will get and initialize the parser
- * according to the desired content type.
- */
- public BasicStructuredDocument(RegionParser parser) {
- super();
- Assert.isNotNull(parser, "Program Error: IStructuredDocument can not be created with null parser"); //$NON-NLS-1$
- NULL_DOCUMENT_EVENT = new NullDocumentEvent();
- parentDocument = new Document();
- addPositionCategory(READ_ONLY_REGIONS_CATEGORY);
- addPositionUpdater(new DeleteEqualPositionUpdater(READ_ONLY_REGIONS_CATEGORY));
- // go through setter in case there is side effects
- setParser(parser);
- }
-
- private void _clearDocumentEvent() {
- // no hard and fast requirement to null out ... just seems like
- // a good idea, since we are done with it.
- fDocumentEvent = null;
- }
-
- private void _fireDocumentAboutToChange(Object[] listeners) {
- if (fDocumentPartitioners != null) {
- Iterator e= fDocumentPartitioners.values().iterator();
- while (e.hasNext()) {
- IDocumentPartitioner p= (IDocumentPartitioner) e.next();
- p.documentAboutToBeChanged(fDocumentEvent);
- }
- }
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- // Note: the docEvent is created in replaceText API
- // fire
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IDocumentListener) holdListeners[i]).documentAboutToBeChanged(fDocumentEvent);
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireDocumentChanged(Object[] listeners, StructuredDocumentEvent event) {
- if (fDocumentPartitioners != null) {
- Iterator e= fDocumentPartitioners.values().iterator();
- while (e.hasNext()) {
- IDocumentPartitioner p= (IDocumentPartitioner) e.next();
- p.documentChanged(fDocumentEvent);
- }
- }
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- // NOTE: document event is created in replace Text API and setText
- // API
- // now fire
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- // Notes: fDocumentEvent can be "suddenly" null, if one of the
- // previous changes
- // caused a "setText" to be called. The only known case of
- // this
- // is a model reset
- // due to page directive changing. Eventually we should change
- // archetecture to have
- // event que and be able to "cancel" pending events, but for
- // now, we'll just pass a
- // NullDocumentEvent. By the way, it is important to send
- // something, since clients might
- // have indeterminant state due to "aboutToChange" being sent
- // earlier.
- if (fDocumentEvent == null) {
- ((IDocumentListener) holdListeners[i]).documentChanged(NULL_DOCUMENT_EVENT);
- }
- else {
- ((IDocumentListener) holdListeners[i]).documentChanged(fDocumentEvent);
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, NewModelEvent event) {
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).newModel(event);
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, NoChangeEvent event) {
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).noChange(event);
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, StructuredDocumentRegionsReplacedEvent event) {
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).nodesReplaced(event);
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, RegionChangedEvent event) {
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).regionChanged(event);
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireEvent(Object[] listeners, RegionsReplacedEvent event) {
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IStructuredDocumentListener) holdListeners[i]).regionsReplaced(event);
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- private void _fireModelAboutToBeChanged(Object[] listeners) {
- // 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
- if (listeners != null) {
- Object[] holdListeners = listeners;
- // Note: the docEvent is created in replaceText API
- // fire
- for (int i = 0; i < holdListeners.length; i++) {
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- startTime = System.currentTimeMillis();
- }
- // notice the AboutToBeChangedEvent is created from the
- // DocumentEvent, since it is (nearly)
- // the same information. ?What to do about originalRequester?
- AboutToBeChangeEvent aboutToBeChangedEvent = new AboutToBeChangeEvent(this, null, fDocumentEvent.getText(), fDocumentEvent.getOffset(), fDocumentEvent.getLength());
- // this is a safe cast, since addListners requires a
- // IStructuredDocumentListener
- ((IModelAboutToBeChangedListener) holdListeners[i]).modelAboutToBeChanged(aboutToBeChangedEvent);
- if (Debug.perfTest || Debug.perfTestStructuredDocumentEventOnly) {
- long stopTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t IStructuredDocument::fireStructuredDocumentEvent. Time was " + (stopTime - startTime) + " msecs to fire NewModelEvent to instance of " + holdListeners[i].getClass()); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- }
- }
-
- /**
- * We manage our own document listners, instead of delegating to our
- * parentDocument, so we can fire at very end (and not when the
- * parentDocument changes).
- */
- public synchronized void addDocumentListener(IDocumentListener listener) {
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (!Utilities.contains(fDocumentListeners, listener)) {
- int oldSize = 0;
- if (fDocumentListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fDocumentListeners.length;
- }
- int newSize = oldSize + 1;
- IDocumentListener[] newListeners = new IDocumentListener[newSize];
- if (fDocumentListeners != null) {
- System.arraycopy(fDocumentListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fDocumentListeners = newListeners;
- //
- }
- }
-
- /**
- * addModelAboutToBeChangedListener method comment.
- */
- public synchronized void addModelAboutToBeChangedListener(IModelAboutToBeChangedListener listener) {
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (!Utilities.contains(fModelAboutToBeChangedListeners, listener)) {
- int oldSize = 0;
- if (fModelAboutToBeChangedListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fModelAboutToBeChangedListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fModelAboutToBeChangedListeners != null) {
- System.arraycopy(fModelAboutToBeChangedListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fModelAboutToBeChangedListeners = newListeners;
- //
- }
- }
-
- /**
- * The StructuredDocumentListners and ModelChagnedListeners are very
- * similar. They both receive identical events. The difference is the
- * timing. The "pure" StructuredDocumentListners are notified after the
- * structuredDocument has been changed, but before other, related models
- * may have been changed such as the Structural Model. The Structural
- * model is in fact itself a "pure" StructuredDocumentListner. The
- * ModelChangedListeners can rest assured that all models and data have
- * been updated from the change by the tiem they are notified. This is
- * especially important for the text widget, for example, which may rely
- * on both structuredDocument and structural model information.
- */
- public synchronized void addModelChangedListener(IStructuredDocumentListener listener) {
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addModelChangedListener. Request to add an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (Utilities.contains(fModelChangedListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("IStructuredDocument::addModelChangedListener. listener " + listener + " was addeded more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addModelChangedListener. Adding an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fModelChangedListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fModelChangedListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fModelChangedListeners != null) {
- System.arraycopy(fModelChangedListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fModelChangedListeners = newListeners;
- //
- // when a listener is added,
- // send the new model event to that one particular listener, so it
- // can initialize itself with the current state of the model
- //listener.newModel(new NewModelEvent(this, listener));
- }
- }
-
- public synchronized void addModelChangingListener(IStructuredDocumentListener listener) {
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addStructuredDocumentListener. Request to add an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- // make sure listener is not already in listening
- // (and if it is, print a warning to aid debugging, if needed)
- if (Utilities.contains(fModelChangingListeners, listener)) {
- if (Debug.displayWarnings) {
- System.out.println("IStructuredDocument::addStructuredDocumentListener. listener " + listener + " was addeded more than once. "); //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- else {
- if (Debug.debugStructuredDocument) {
- System.out.println("IStructuredDocument::addStructuredDocumentListener. Adding an instance of " + listener.getClass() + " as a listener on structuredDocument."); //$NON-NLS-2$//$NON-NLS-1$
- }
- int oldSize = 0;
- if (fModelChangingListeners != null) {
- // normally won't be null, but we need to be sure, for first
- // time through
- oldSize = fModelChangingListeners.length;
- }
- int newSize = oldSize + 1;
- Object[] newListeners = new Object[newSize];
- if (fModelChangingListeners != null) {
- System.arraycopy(fModelChangingListeners, 0, newListeners, 0, oldSize);
- }
- // add listener to last position
- newListeners[newSize - 1] = listener;
- //
- // now switch new for old
- fModelChangingListeners = newListeners;
- //
- // when a listener is added,
- // send the new model event to that one particular listener, so it
- // can initialize itself with the current state of the model
- //listener.newModel(new NewModelEvent(this, listener));
- }
- }
-
- /**
- * Adds the position to the document's default position category. The
- * default category must be specified by the implementer. A position that
- * has been added to a position category is updated at each change applied
- * to the document.
- *
- * @exception BadLocationException
- * If position is not a valid range in the document
- */
- public void addPosition(Position position) throws BadLocationException {
- parentDocument.addPosition(position);
- }
-
- /**
- * @see IDocument#addPosition
- * @exception BadLocationException
- * If position is not a valid range in the document
- * @exception BadPositionCategoryException
- * If the category is not defined for the document
- */
- public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
- parentDocument.addPosition(category, position);
- }
-
- /**
- * @see IDocument#addPositionCategory
- */
- public void addPositionCategory(String category) {
- parentDocument.addPositionCategory(category);
- }
-
- /**
- * @see IDocument#addPositionUpdater
- */
- public void addPositionUpdater(IPositionUpdater updater) {
- parentDocument.addPositionUpdater(updater);
- }
-
- /**
- * Adds the given document listener as one which is notified before those
- * document listeners added with <code>addDocumentListener</code> are
- * notified. If the given listener is also registered using
- * <code>addDocumentListener</code> it will be notified twice. If the
- * listener is already registered nothing happens.
- * <p>
- *
- * This method is not for public use, it may only be called by
- * implementers of <code>IDocumentAdapter</code> and only if those
- * implementers need to implement <code>IDocumentListener</code>.
- *
- * @param documentAdapter
- * the listener to be added as prenotified document listener
- */
- public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- if (fPrenotifiedDocumentListeners != null) {
- int previousSize = fPrenotifiedDocumentListeners.length;
- IDocumentListener[] listeners = new IDocumentListener[previousSize + 1];
- System.arraycopy(fPrenotifiedDocumentListeners, 0, listeners, 0, previousSize);
- listeners[previousSize] = documentAdapter;
- fPrenotifiedDocumentListeners = listeners;
- }
- else {
- fPrenotifiedDocumentListeners = new IDocumentListener[1];
- fPrenotifiedDocumentListeners[0] = documentAdapter;
- }
- }
-
- /**
- * This method is used to adjust another readonly region, if a new request
- * has been found to overlap with an existing one.
- *
- * @param startOffset
- * @param length
- */
- private void adjustReadOnlyRegions(int startOffset, int length) {
- Position[] positions = null;
- try {
- positions = getPositions(READ_ONLY_REGIONS_CATEGORY);
- }
- catch (BadPositionCategoryException e) {
- // impossible to get due to the way we call
- // this method
- Logger.logException("impossible error", e); //$NON-NLS-1$
- }
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- // easiest to call overlapsWith first, since
- // it checks for deleted, etc. and allows
- // simpler logic below.
- if (position.overlapsWith(startOffset, length)) {
- // now that we know it overlaps, determine if new request is
- // completely
- // overlaped by region which is already readonly,
- // or ovlaped on left, or overlaped on right.
- // Note: following 4 if clauses are order sensitive
- int requestEnd = startOffset + length;
- int positionEnd = position.getOffset() + position.getLength();
- if (startOffset >= position.getOffset() && requestEnd <= positionEnd) {
- // request completly overlapped by existing one, nothing
- // to
- // do
- return;
- }
- if (startOffset >= position.getOffset() && requestEnd <= positionEnd) {
- // existing one completly overlapped by request, so simply
- // use new
- // offset and length.
- position.setLength(length);
- position.setOffset(startOffset);
- return;
- }
- if (startOffset <= positionEnd) {
- // then existing one is "to the left" of request, so we
- // just
- // need to adjust existing one's end
- int diff = requestEnd - positionEnd;
- int newLength = position.getLength() + diff;
- position.setLength(newLength);
- return;
- }
- if (requestEnd >= position.getOffset()) {
- // then existing one is "to the right" of request, so we
- // need to adjust existing one's start and adjust length
- int diff = requestEnd - positionEnd;
- int newLength = position.getLength() + diff;
- position.setOffset(startOffset);
- position.setLength(newLength);
- return;
- }
- // if found to overlap, should never get to here, so for
- // debugging purposes:
- Logger.log(Logger.ERROR, "program error in adjustReadOnlyRegions"); //$NON-NLS-1$
- break;
- }
- }
- }
-
- /**
- * This form of the API removes all read only positions, as should be done
- * we 'setText' is called. Note: an alternative algorithm may simply
- * remove the category (and it would get added back in later, if/when
- * readonly regions added.
- */
- private void clearReadOnly() {
- Position[] positions = null;
- try {
- positions = getPositions(READ_ONLY_REGIONS_CATEGORY);
- }
- catch (BadPositionCategoryException e) {
- Logger.logException("program error: should never occur", e); //$NON-NLS-1$
- }
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- // note we don't fire the "about to change" or "changed" events,
- // since presumably, text is all going away and being replaced
- // anyway.
- position.delete();
- }
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void clearReadOnly(int startOffset, int length) {
- // TODO DW I still need to implement smarter algorithm that
- // adust existing RO regions, if needed. For now, I'll just
- // remove any that overlap.
- try {
- Position[] positions = getPositions(READ_ONLY_REGIONS_CATEGORY);
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- if (position.overlapsWith(startOffset, length)) {
- String effectedText = this.get(startOffset, length);
- //fDocumentEvent = new DocumentEvent(this, startOffset,
- // length, effectedText);
- fireReadOnlyAboutToBeChanged();
- position.delete();
- NoChangeEvent noChangeEvent = new NoChangeEvent(this, null, effectedText, startOffset, length);
- noChangeEvent.reason = NoChangeEvent.READ_ONLY_STATE_CHANGE;
- fireReadOnlyStructuredDocumentEvent(noChangeEvent);
- }
- }
- }
- catch (BadPositionCategoryException e) {
- // just means no readonly regions been defined yet
- // so nothing to do.
- }
- }
-
- /**
- * Computes the index at which a <code>Position</code> with the
- * specified offset would be inserted into the given category. As the
- * ordering inside a category only depends on the offset, the index must
- * be choosen to be the first of all positions with the same offset.
- *
- * @param category
- * the category in which would be added
- * @param offset
- * the position offset to be considered
- * @return the index into the category
- * @exception BadLocationException
- * if offset is invalid in this document
- * @exception BadPositionCategoryException
- * if category is undefined in this document
- */
- public int computeIndexInCategory(String category, int offset) throws org.eclipse.jface.text.BadPositionCategoryException, org.eclipse.jface.text.BadLocationException {
- return parentDocument.computeIndexInCategory(category, offset);
- }
-
- /**
- * Computes the number of lines in the given text. For a given implementer
- * of this interface this method returns the same result as
- * <code>set(text); getNumberOfLines()</code>.
- *
- * @param text
- * the text whose number of lines should be computed
- * @return the number of lines in the given text
- */
- public int computeNumberOfLines(String text) {
- return parentDocument.computeNumberOfLines(text);
- }
-
- /**
- * Computes the partitioning of the given document range using the
- * document's partitioner.
- *
- * @param offset
- * the document offset at which the range starts
- * @param length
- * the length of the document range
- * @return a specification of the range's partitioning
- * @throws BadLocationException
- * @throws BadPartitioningException
- */
- public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException {
- ITypedRegion[] typedRegions = null;
- try {
- typedRegions = computePartitioning(IDocumentExtension3.DEFAULT_PARTITIONING, offset, length, false);
- }
- catch (BadPartitioningException e) {
- // impossible in this context
- throw new Error(e);
- }
- return typedRegions;
- }
-
- /**
- * @see IDocument#containsPosition
- */
- public boolean containsPosition(String category, int offset, int length) {
- return parentDocument.containsPosition(category, offset, length);
- }
-
- /**
- * @see IDocument#containsPositionCategory
- */
- public boolean containsPositionCategory(String category) {
- return parentDocument.containsPositionCategory(category);
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public boolean containsReadOnly(int startOffset, int length) {
- boolean result = false;
- try {
- Position[] positions = getPositions(READ_ONLY_REGIONS_CATEGORY);
- for (int i = 0; i < positions.length; i++) {
- Position position = positions[i];
- if (position.overlapsWith(startOffset, length)) {
- result = true;
- break;
- }
- }
- }
- catch (BadPositionCategoryException e) {
- // just means no readonly regions been defined yet
- // so obviously false
- result = false;
- }
- return result;
- }
-
- private boolean equivalentRegions(IStructuredDocumentRegion oldNode, IStructuredDocumentRegion newNode) {
- Iterator oldRegions = oldNode.getRegions().iterator();
- Iterator newRegions = newNode.getRegions().iterator();
- while (oldRegions.hasNext()) {
- ITextRegion oldRegion = (ITextRegion) oldRegions.next();
- ITextRegion newRegion = null;
- if (newRegions.hasNext()) {
- newRegion = (ITextRegion) newRegions.next();
- }
- else {
- //ran out of new before old
- return false;
- }
- if (oldRegion.getType() != newRegion.getType())
- return false;
- }
- // at this point, we've run out of oldRegions, let's
- // be sure we are also out of newRegions
- if (newRegions.hasNext())
- return false;
- return true;
- }
-
- private void executePostNotificationChanges() {
- if (fStoppedCount > 0)
- return;
- while (fPostNotificationChanges != null) {
- List changes = fPostNotificationChanges;
- fPostNotificationChanges = null;
- Iterator e = changes.iterator();
- while (e.hasNext()) {
- RegisteredReplace replace = (RegisteredReplace) e.next();
- replace.fReplace.perform(this, replace.fOwner);
- }
- }
- }
-
- private void fireModelAboutToBeChanged() {
- _fireModelAboutToBeChanged(fModelAboutToBeChangedListeners);
- // Note: the docEvent is created in replaceText API! (or set Text)
- _fireDocumentAboutToChange(fPrenotifiedDocumentListeners);
- _fireDocumentAboutToChange(fDocumentListeners);
- }
-
- /**
- * A temporary method of notifiying listeners that this document is new.
- */
- public void fireNewDocument(Object requester) {
- NewModelEvent result = new NewModelEvent(this, requester);
- fireStructuredDocumentEvent(result);
- }
-
- private void fireReadOnlyAboutToBeChanged() {
- _fireModelAboutToBeChanged(fModelAboutToBeChangedListeners);
- // Note: the docEvent is created in replaceText API! (or set Text)
- // _fireDocumentAboutToChange(fPrenotifiedDocumentListeners);
- // _fireDocumentAboutToChange(fDocumentListeners);
- }
-
- private void fireReadOnlyStructuredDocumentEvent(NoChangeEvent event) {
- // _fireEvent(fModelChangingListeners, event);
- _fireEvent(fModelChangedListeners, event);
- // _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- // _fireDocumentChanged(fDocumentListeners, event);
- // _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(NewModelEvent event) {
- _fireEvent(fModelChangingListeners, event);
- _fireEvent(fModelChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(NoChangeEvent event) {
- _fireEvent(fModelChangingListeners, event);
- _fireEvent(fModelChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(StructuredDocumentRegionsReplacedEvent event) {
- _fireEvent(fModelChangingListeners, event);
- _fireEvent(fModelChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(RegionChangedEvent event) {
- _fireEvent(fModelChangingListeners, event);
- _fireEvent(fModelChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- private void fireStructuredDocumentEvent(RegionsReplacedEvent event) {
- _fireEvent(fModelChangingListeners, event);
- _fireEvent(fModelChangedListeners, event);
- _fireDocumentChanged(fPrenotifiedDocumentListeners, event);
- _fireDocumentChanged(fDocumentListeners, event);
- _clearDocumentEvent();
- }
-
- /**
- * Returns the document's complete text.
- */
- public String get() {
- return parentDocument.get();
- }
-
- /**
- * Returns length characters from the document's text starting from the
- * specified position.
- *
- * @exception BadLocationException
- * If the range is not valid in the document
- */
- public String get(int offset, int length) {
- String result = null;
- try {
- result = parentDocument.get(offset, length);
- }
- catch (BadLocationException e) {
- // log and return empty String (This matters in adding bookmark
- // with the cursor
- // is right after the carrageReturn-lineFeed.
- Logger.log(Logger.ERROR, "BadLocationException in IStructuredDocument.get(" + offset + "+, " + length + ") -- not to worry if during addBookMark, addTask"); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- result = ""; //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- */
- synchronized IStructuredDocumentRegion getCachedDocumentRegion() {
- if (USE_LOCAL_THREAD) {
- return (IStructuredDocumentRegion) threadLocalDocumentRegion.get();
- }
- else {
- return cachedDocumentRegion;
- }
- }
-
- /**
- * @see IDocument#getChar
- * @exception BadLocationException
- * If position is not a valid range in the document
- */
- public char getChar(int pos) throws BadLocationException {
- return parentDocument.getChar(pos);
- }
-
- /**
- * Returns the type of the document partition containing the given
- * character position.
- */
- public String getContentType(int offset) throws BadLocationException {
- return getDocumentPartitioner().getContentType(offset);
- }
-
- /**
- * @deprecated - no longer used
- */
- public String[] getContentTypes() {
- // return parentDocument.getContentTypes();
- // Is this what was intended? -- Transitioning to TP5
- return getDocumentPartitioner().getLegalContentTypes();
- }
-
- /**
- * Returns the document's partitioner.
- *
- * @see IDocumentPartitioner
- */
- public IDocumentPartitioner getDocumentPartitioner() {
- return getDocumentPartitioner(IDocumentExtension3.DEFAULT_PARTITIONING);
- }
-
- /**
- */
- public EncodingMemento getEncodingMemento() {
- return encodingMemento;
- }
-
- public synchronized IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- // should we update cachedNode?
- // We should to keep consistent philosophy of remembering last
- // requested position,
- // for efficiency.
- setCachedDocumentRegion(firstDocumentRegion);
- return firstDocumentRegion;
- }
-
- public synchronized IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- // should we update cachedNode?
- // We should to keep consistent philosophy of remembering last
- // requested position,
- // for efficiency.
- setCachedDocumentRegion(lastDocumentRegion);
- return lastDocumentRegion;
- }
-
- /*
- * -------------------------- partitions
- * ----------------------------------
- */
- public String[] getLegalContentTypes() {
- String [] result = null;
- try {
- result = getLegalContentTypes(IDocumentExtension3.DEFAULT_PARTITIONING);
- }
- catch (BadPartitioningException e) {
- // impossible in this context
- throw new Error(e);
- }
- return result;
- }
-
- /*
- * ------------------ line delimiter conversion
- * ---------------------------
- */
- public String[] getLegalLineDelimiters() {
- return parentDocument.getLegalLineDelimiters();
- }
-
- /**
- * @see IDocument#getLength
- */
- public int getLength() {
- return parentDocument.getLength();
- }
-
- public String getLineDelimiter() {
- if (preferedDelimiter == null) {
- preferedDelimiter = PlatformLineDelimiter;
- }
- return preferedDelimiter;
- }
-
- /**
- * Returns the line delimiter of that line
- *
- * @exception BadLocationException
- * If the line number is invalid in the document
- */
- public String getLineDelimiter(int line) throws org.eclipse.jface.text.BadLocationException {
- return parentDocument.getLineDelimiter(line);
- }
-
- /**
- * Returns a description of the specified line. The line is described by
- * its offset and its length excluding the line's delimiter.
- *
- * @param line
- * the line of interest
- * @return a line description
- * @exception BadLocationException
- * if the line number is invalid in this document
- */
- public org.eclipse.jface.text.IRegion getLineInformation(int line) throws org.eclipse.jface.text.BadLocationException {
- return parentDocument.getLineInformation(line);
- }
-
- /**
- * Returns a description of the line at the given offset. The description
- * contains the offset and the length of the line excluding the line's
- * delimiter.
- *
- * @param offset
- * the offset whose line should be described
- * @return a region describing the line
- * @exception BadLocationException
- * if offset is invalid in this document
- */
- public org.eclipse.jface.text.IRegion getLineInformationOfOffset(int offset) throws org.eclipse.jface.text.BadLocationException {
- return parentDocument.getLineInformationOfOffset(offset);
- }
-
- /*
- * ---------------------- line information
- * --------------------------------
- */
- public int getLineLength(int line) throws org.eclipse.jface.text.BadLocationException {
- return parentDocument.getLineLength(line);
- }
-
- /**
- * Determines the offset of the first character of the given line.
- *
- * @param line
- * the line of interest
- * @return the document offset
- * @exception BadLocationException
- * if the line number is invalid in this document
- */
- public int getLineOffset(int line) throws org.eclipse.jface.text.BadLocationException {
- return parentDocument.getLineOffset(line);
- }
-
- public int getLineOfOffset(int offset) {
- int result = -1;
- try {
- result = parentDocument.getLineOfOffset(offset);
- }
- catch (BadLocationException e) {
- Logger.traceException("IStructuredDocument", "Dev. Program Info Only: IStructuredDocument::getLineOfOffset: offset out of range, zero assumed. offset = " + offset, e); //$NON-NLS-1$ //$NON-NLS-2$
- result = 0;
- }
- return result;
- }
-
- /**
- * Returns the number of lines in this document
- *
- * @return the number of lines in this document
- */
- public int getNumberOfLines() {
- return parentDocument.getNumberOfLines();
- }
-
- /**
- * Returns the number of lines which are occupied by a given text range.
- *
- * @param offset
- * the offset of the specified text range
- * @param length
- * the length of the specified text range
- * @return the number of lines occupied by the specified range
- * @exception BadLocationException
- * if specified range is invalid in this tracker
- */
- public int getNumberOfLines(int offset, int length) throws org.eclipse.jface.text.BadLocationException {
- return parentDocument.getNumberOfLines(offset, length);
- }
-
- /**
- * This is public, for use by tag lib classes.
- */
- public RegionParser getParser() {
- if (fParser == null) {
- throw new SourceEditingRuntimeException("IStructuredDocument::getParser. Parser needs to be set before use"); //$NON-NLS-1$
- //fParser = getParserFactory().createParser(fType);
- //System.out.println("Information:
- // IStructuredDocument::getParser.
- // XML Parser assumed.");
- //fParser = new XMLSourceParser();
- }
- return fParser;
- }
-
- /**
- * Returns the document partition in which the position is located. The
- * partition is specified as typed region.
- */
- public ITypedRegion getPartition(int offset) throws BadLocationException {
- ITypedRegion partition= null;
- try {
- partition = getPartition(IDocumentExtension3.DEFAULT_PARTITIONING, offset, false);
- } catch (BadPartitioningException e) {
- throw new Error(e);
- }
- if(partition == null) {
- throw new Error();
- }
- return partition;
- }
-
- /**
- * Partitions the given document section using the document's partitioner.
- * The partitioning is returned as a list of typed regions.
- *
- * @deprecated - naming collides with extension3
- */
- public TypedRegion[] getPartitioning(int offset, int length) throws org.eclipse.jface.text.BadLocationException {
- // for now, only, create typed regions from our regions
- IStructuredDocumentRegion startNode = getRegionAtCharacterOffset(offset);
- IStructuredDocumentRegion endNode = getRegionAtCharacterOffset(offset + length - 1);
- Vector holdRegions = new Vector();
- IStructuredDocumentRegionList nodeList = new CoreNodeList(startNode, endNode);
- Enumeration enum = nodeList.elements();
- while (enum.hasMoreElements()) {
- IStructuredDocumentRegion aNode = (IStructuredDocumentRegion) enum.nextElement();
- ITextRegionList v = aNode.getRegions();
- Iterator vEnum = v.iterator();
- while (vEnum.hasNext()) {
- ITextRegion region = (ITextRegion) vEnum.next();
- holdRegions.addElement(new TypedRegion(region.getStart(), region.getLength(), region.getType()));
- }
- }
- org.eclipse.jface.text.TypedRegion[] tRegions = new org.eclipse.jface.text.TypedRegion[holdRegions.size()];
- holdRegions.copyInto(tRegions);
- return tRegions;
- }
-
- /**
- * Returns all position categories added to this document.
- */
- public String[] getPositionCategories() {
- return parentDocument.getPositionCategories();
- }
-
- /**
- * Returns all Positions of the given position category.
- *
- * @exception BadPositionCategoryException
- * If category is not defined for the document
- */
- public Position[] getPositions(String category) throws org.eclipse.jface.text.BadPositionCategoryException {
- return parentDocument.getPositions(category);
- }
-
- /**
- * @see IDocument#getPositionUpdaters
- */
- public IPositionUpdater[] getPositionUpdaters() {
- return parentDocument.getPositionUpdaters();
- }
-
- /**
- * This method can return null, which is the case if the offset is just
- * before or just after the existing text. Compare with
- * getNodeAtCharacterOffset.
- */
- public synchronized IStructuredDocumentRegion getRegionAtCharacterOffset(int offset) {
- // cached node can be null when document is empty
- if (getCachedDocumentRegion() == null)
- return null;
- IStructuredDocumentRegion potentialCachedNode = getCachedDocumentRegion();
- // if we already have the right node, return that.
- if (!potentialCachedNode.containsOffset(offset)) {
- // first, find out what direction to go, relative to cachedNode.
- // negative means "towards the front" of the file, postitive means
- // towards the end.
- int direction = offset - potentialCachedNode.getStart();
- if (direction < 0) {
- // search towards beginning
- while (!potentialCachedNode.containsOffset(offset)) {
- IStructuredDocumentRegion tempNode = potentialCachedNode.getPrevious();
- if (tempNode == null) {
- break;
- }
- else {
- potentialCachedNode = tempNode;
- }
- }
- }
- else {
- // search towards end
- // There is a legitamat condition where the
- // offset will not be contained in any node,
- // which is if the offset is just past the last
- // character of text.
- // And, we must gaurd against setting cachedNode to
- // null!
- while (!potentialCachedNode.containsOffset(offset)) {
- IStructuredDocumentRegion tempNode = potentialCachedNode.getNext();
- if (tempNode == null)
- break;
- else
- potentialCachedNode = tempNode;
- }
- }
- }
- // just to be doubly sure we never assign null to cachedNode
- if (potentialCachedNode != null)
- setCachedDocumentRegion(potentialCachedNode);
- else
- Logger.log(Logger.ERROR, "Program Error: IStructuredDocument::getNodeAtCharacterOffset. no node to cache could be found."); //$NON-NLS-1$
- return potentialCachedNode;
- }
-
- public IStructuredDocumentRegionList getRegionList() {
- CoreNodeList result = null;
- if (getCachedDocumentRegion() == null)
- result = new CoreNodeList(null);
- else
- result = new CoreNodeList(getFirstStructuredDocumentRegion());
- return result;
- }
-
- /**
- * was made public for easier testing. Normally should never be used by
- * client codes.
- */
- public IStructuredTextReParser getReParser() {
- if (fReParser == null) {
- fReParser = new StructuredDocumentReParser();
- fReParser.setStructuredDocument(this);
- }
- return fReParser;
- }
-
- public String getText() {
- String result = parentDocument.get();
- return result;
- }
-
- void initializeFirstAndLastDocumentRegion() {
- // cached Node must also be first, at the initial point. Only valid
- // to call this method right after the first parse.
- //
- // when starting afresh, our cachedNode should be our firstNode,
- // so be sure to initialize the firstNode
- firstDocumentRegion = getCachedDocumentRegion();
- // be sure to use 'getNext' for this initial finding of the last node,
- // since the implementation of node.getLastNode may simply call
- // structuredDocument.getLastStructuredDocumentRegion!
- IStructuredDocumentRegion aNode = firstDocumentRegion;
- if (aNode == null) {
- // defect 254607: to handle empty documents right, if firstnode is
- // null, make sure last node is null too
- lastDocumentRegion = null;
- }
- else {
- while (aNode != null) {
- lastDocumentRegion = aNode;
- aNode = aNode.getNext();
- }
- }
- }
-
- /**
- * @see IDocument#insertPositionUpdater
- */
- public void insertPositionUpdater(IPositionUpdater updater, int index) {
- parentDocument.insertPositionUpdater(updater, index);
- }
-
- /*
- * (non-Javadoc)
- *
- */
- public void makeReadOnly(int startOffset, int length) {
- // doesn't make sense to have a readonly region of 0 length,
- // so we'll ignore those requests
- if (length <= 0)
- return;
- String affectedText = this.get(startOffset, length);
- // a document event for "read only" change ... must
- // be followed by "no change" structuredDocument event
- // fDocumentEvent = new DocumentEvent(this, startOffset, length,
- // affectedText);
- fireReadOnlyAboutToBeChanged();
- // if (containsReadOnly(startOffset, length)) {
- // adjustReadOnlyRegions(startOffset, length);
- // } else {
- // we can blindly add category, since no harm done if already
- // exists.
- addPositionCategory(READ_ONLY_REGIONS_CATEGORY);
- Position newPosition = new Position(startOffset, length);
- try {
- addPosition(READ_ONLY_REGIONS_CATEGORY, newPosition);
- NoChangeEvent noChangeEvent = new NoChangeEvent(this, null, affectedText, startOffset, length);
- noChangeEvent.reason = NoChangeEvent.READ_ONLY_STATE_CHANGE;
- fireReadOnlyStructuredDocumentEvent(noChangeEvent);
- }
- catch (BadLocationException e) {
- // for now, log and ignore. Perhaps later we
- // could adjust to handle some cases?
- Logger.logException(("could not create readonly region at " + startOffset + " to " + length), e); //$NON-NLS-1$ //$NON-NLS-2$
- }
- catch (BadPositionCategoryException e) {
- // should never occur, since we add category
- Logger.logException(e);
- }
- }
-
- /**
- */
- public IStructuredDocument newInstance() {
- BasicStructuredDocument newInstance = new BasicStructuredDocument(getParser().newInstance());
- newInstance.setReParser(getReParser().newInstance());
- if (getDocumentPartitioner() instanceof StructuredTextPartitioner) {
- newInstance.setDocumentPartitioner(((StructuredTextPartitioner) getDocumentPartitioner()).newInstance());
- }
- newInstance.setLineDelimiter(getLineDelimiter());
- if (getEncodingMemento() != null) {
- newInstance.setEncodingMemento((EncodingMemento) getEncodingMemento().clone());
- }
- return newInstance;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#registerPostNotificationReplace(org.eclipse.jface.text.IDocumentListener,
- * org.eclipse.jface.text.IDocumentExtension.IReplace)
- */
- public void registerPostNotificationReplace(IDocumentListener owner, IDocumentExtension.IReplace replace) {
- if (fAcceptPostNotificationReplaces) {
- if (fPostNotificationChanges == null)
- fPostNotificationChanges = new ArrayList(1);
- fPostNotificationChanges.add(new RegisteredReplace(owner, replace));
- }
- }
-
- public synchronized void removeDocumentListener(IDocumentListener listener) {
- if ((fDocumentListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fDocumentListeners, listener)) {
- int oldSize = fDocumentListeners.length;
- int newSize = oldSize - 1;
- IDocumentListener[] newListeners = new IDocumentListener[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fDocumentListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fDocumentListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fDocumentListeners = newListeners;
- }
- }
- }
-
- public synchronized void removeModelAboutToBeChangedListener(IModelAboutToBeChangedListener listener) {
- if ((fModelAboutToBeChangedListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fModelAboutToBeChangedListeners, listener)) {
- int oldSize = fModelAboutToBeChangedListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fModelAboutToBeChangedListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fModelAboutToBeChangedListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fModelAboutToBeChangedListeners = newListeners;
- }
- }
- }
-
- /**
- * removeModelChangedListener method comment.
- */
- public void removeModelChangedListener(IStructuredDocumentListener listener) {
- if ((fModelChangedListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fModelChangedListeners, listener)) {
- int oldSize = fModelChangedListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fModelChangedListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fModelChangedListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fModelChangedListeners = newListeners;
- }
- }
- }
-
- public synchronized void removeModelChangingListener(IStructuredDocumentListener listener) {
- if ((fModelChangingListeners != null) && (listener != null)) {
- // if its not in the listeners, we'll ignore the request
- if (Utilities.contains(fModelChangingListeners, listener)) {
- int oldSize = fModelChangingListeners.length;
- int newSize = oldSize - 1;
- Object[] newListeners = new Object[newSize];
- int index = 0;
- for (int i = 0; i < oldSize; i++) {
- if (fModelChangingListeners[i] == listener) { // ignore
- }
- else {
- // copy old to new if its not the one we are removing
- newListeners[index++] = fModelChangingListeners[i];
- }
- }
- // now that we have a new array, let's switch it for the old
- // one
- fModelChangingListeners = newListeners;
- }
- }
- }
-
- /**
- * Removes the given <code>Position</code> from the document's default
- * position category. The default position category is to be defined by
- * the implementers. If the position is not part of the document's default
- * category nothing happens.
- */
- public void removePosition(Position position) {
- parentDocument.removePosition(position);
- }
-
- /**
- * @see IDocument#removePosition
- * @exception BadPositionCategoryException
- * If the category is not defined for the document
- */
- public void removePosition(String category, Position position) throws BadPositionCategoryException {
- parentDocument.removePosition(category, position);
- }
-
- /**
- * @see IDocument#removePositionCategory
- * @exception BadPositionCategoryException
- * If the category is not defined for the document
- */
- public void removePositionCategory(String category) throws BadPositionCategoryException {
- parentDocument.removePositionCategory(category);
- }
-
- /**
- * @see IDocument#removePositionUpdater
- */
- public void removePositionUpdater(IPositionUpdater updater) {
- parentDocument.removePositionUpdater(updater);
- }
-
- /**
- * Removes the given document listener from teh document's list of
- * prenotified document listeners. If the listener is not registered with
- * the document nothing happens.
- * <p>
- *
- * This method is not for public use, it may only be called by
- * implementers of <code>IDocumentAdapter</code> and only if those
- * implementers need to implement <code>IDocumentListener</code>.
- *
- * @param documentAdapter
- * the listener to be removed
- *
- * @see #addPrenotifiedDocumentListener(IDocumentListener)
- */
- public void removePrenotifiedDocumentListener(org.eclipse.jface.text.IDocumentListener documentAdapter) {
- if (Utilities.contains(fPrenotifiedDocumentListeners, documentAdapter)) {
- int previousSize = fPrenotifiedDocumentListeners.length;
- if (previousSize > 1) {
- IDocumentListener[] listeners = new IDocumentListener[previousSize - 1];
- int previousIndex = 0;
- int newIndex = 0;
- while (previousIndex < previousSize) {
- if (fPrenotifiedDocumentListeners[previousIndex] != documentAdapter)
- listeners[newIndex++] = fPrenotifiedDocumentListeners[previousIndex];
- previousIndex++;
- }
- fPrenotifiedDocumentListeners = listeners;
- }
- else {
- fPrenotifiedDocumentListeners = null;
- }
- }
- }
-
- /**
- * @see IDocument#replace
- * @exception BadLocationException
- * If position is not a valid range in the document
- */
- public void replace(int pos, int length, String string) throws BadLocationException {
- if (Debug.displayWarnings) {
- System.out.println("Note: IStructuredDocument::replace(int, int, String) .... its better to use replaceText(source, string, int, int) API for structuredDocument updates"); //$NON-NLS-1$
- }
- replaceText(this, pos, length, string);
- }
-
- /**
- * Replace the text with "newText" starting at position "start" for a
- * length of "replaceLength".
- * <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
- * <p>
- * Implementors have to notify TextChanged listeners after the
- * content has been updated. The TextChangedEvent should be set
- * as follows:
- *
- * event.type = SWT.TextReplaced event.start = start of the replaced text
- * event.numReplacedLines = number of replaced lines event.numNewLines =
- * number of new lines event.replacedLength = length of the replaced text
- * event.newLength = length of the new text
- *
- * NOTE: numNewLines is the number of inserted lines and numReplacedLines
- * is the number of deleted lines based on the change that occurs
- * visually. For example:
- *
- * replacedText newText numReplacedLines numNewLines "" "\n" 0 1 "\n\n"
- * "a" 2 0 "a" "\n\n" 0 2
- */
- /**
- * One of the APIs to manipulate the IStructuredDocument in terms of text.
- */
- public StructuredDocumentEvent replaceText(Object requester, int start, int replacementLength, String changes) {
- stopPostNotificationProcessing();
- StructuredDocumentEvent result = null;
- if (changes == null)
- changes = ""; //$NON-NLS-1$
- //
- if (Debug.debugStructuredDocument)
- System.out.println(getClass().getName() + "::replaceText(" + start + "," + replacementLength + "," + changes + ")"); //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- if (Debug.perfTestStructuredDocumentOnly || Debug.perfTest || Debug.perfTestRawStructuredDocumentOnly) {
- startStreamTime = System.currentTimeMillis();
- }
- // Note: event must be computed before 'fire' method called
- fDocumentEvent = new DocumentEvent(this, start, replacementLength, changes);
- fireModelAboutToBeChanged();
- result = updateModel(requester, start, replacementLength, changes);
- if (Debug.perfTestRawStructuredDocumentOnly || Debug.perfTest) {
- long stopStreamTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t Time for IStructuredDocument raw replaceText: " + (stopStreamTime - startStreamTime)); //$NON-NLS-1$
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("event type returned by replaceTextWithNoDebuggingThread: " + result); //$NON-NLS-1$
- }
- // FUTURE_TO_DO: implement callback mechanism? to avoid instanceof and
- // casting
- if (result instanceof RegionChangedEvent) {
- fireStructuredDocumentEvent((RegionChangedEvent) result);
- }
- else {
- if (result instanceof RegionsReplacedEvent) {
- fireStructuredDocumentEvent((RegionsReplacedEvent) result);
- }
- else {
- if (result instanceof StructuredDocumentRegionsReplacedEvent) {
- fireStructuredDocumentEvent((StructuredDocumentRegionsReplacedEvent) result);
- }
- else {
- if (result instanceof NoChangeEvent) {
- fireStructuredDocumentEvent((NoChangeEvent) result);
- }
- else {
- throw new SourceEditingRuntimeException("Program Error: invalid flat model event: " + result); //$NON-NLS-1$
- }
- }
- }
- }
- if (Debug.perfTest || Debug.perfTestStructuredDocumentOnly) {
- long stopStreamTime = System.currentTimeMillis();
- System.out.println("\n\t\t\t\t Total Time for IStructuredDocument event signaling/processing in replaceText: " + (stopStreamTime - startStreamTime)); //$NON-NLS-1$
- }
- resumePostNotificationProcessing();
- return result;
- }
-
- void resetParser(int startOffset, int endOffset) {
- String newNodeText = null;
- RegionParser parser = getParser();
- newNodeText = get(startOffset, endOffset - startOffset);
- parser.reset(newNodeText, startOffset);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#resumePostNotificationProcessing()
- */
- public void resumePostNotificationProcessing() {
- --fStoppedCount;
- if (fStoppedCount == 0 && fReentranceCount == 0)
- executePostNotificationChanges();
- }
-
- /**
- * @deprecated - use a FindReplaceDocumentAdapter directly
- * @see IDocument#search
- */
- public int search(int startPosition, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException {
- int offset = -1;
- IRegion match = new FindReplaceDocumentAdapter(parentDocument).find(startPosition, findString, forwardSearch, caseSensitive, wholeWord, false);
- if (match != null) {
- offset = match.getOffset();
- }
- return offset;
- }
-
- /**
- * @see IDocument#setText
- */
- public void set(String string) {
- if (Debug.displayInfo) {
- System.out.println("Note: IStructuredDocument::setText(String) .... its better to use setText(source, string) API for structuredDocument updates"); //$NON-NLS-1$
- }
- setText(null, string);
- }
-
- /**
- * @param strcuturedRegion
- */
- public void setCachedDocumentRegion(IStructuredDocumentRegion structuredRegion) {
- if (USE_LOCAL_THREAD) {
- threadLocalDocumentRegion.set(structuredRegion);
- }
- else {
- cachedDocumentRegion = structuredRegion;
- }
- }
-
- /**
- * Sets the document's partitioner.
- *
- * @see IDocumentPartitioner
- */
- public void setDocumentPartitioner(IDocumentPartitioner partitioner) {
- Assert.isNotNull(parentDocument, "text store must be set before document partitioner"); //$NON-NLS-1$
- IDocumentPartitioner oldPartioner = null;
- oldPartioner = getDocumentPartitioner(IDocumentExtension3.DEFAULT_PARTITIONING);
- if (oldPartioner != null) {
- oldPartioner.disconnect();
- }
- // some operations, such as convert line delimters, sets the partioner
- // to null
- // then resets it when done.
- if (partitioner != null) {
- partitioner.connect(this);
- }
- setDocumentPartitioner(IDocumentExtension3.DEFAULT_PARTITIONING, partitioner);
- }
-
- /**
- */
- public void setEncodingMemento(EncodingMemento encodingMemento) {
- this.encodingMemento = encodingMemento;
- }
-
- /**
- * @see IStructuredDocument#setLineDelimiter(String)
- */
- public void setLineDelimiter(String delimiter) {
- // make sure our preferred delimiter is
- // one of the legal ones
- if (Utilities.containsString(getLegalLineDelimiters(), delimiter)) {
- preferedDelimiter = delimiter;
- }
- else {
- Logger.trace("IStructuredDocument", "Attempt to set linedelimiter to non-legal delimiter"); //$NON-NLS-1$ //$NON-NLS-2$
- preferedDelimiter = PlatformLineDelimiter;
- }
- }
-
- public void setParser(RegionParser newParser) {
- fParser = newParser;
- }
-
- /**
- *
- */
- public void setReParser(IStructuredTextReParser newReParser) {
- fReParser = newReParser;
- if (fReParser != null) {
- fReParser.setStructuredDocument(this);
- }
- }
-
- /**
- * One of the APIs to manipulate the IStructuredDocument in terms of text.
- */
- public NewModelEvent setText(Object requester, String theString) {
- stopPostNotificationProcessing();
- clearReadOnly();
- // Note: event must be computed before 'fire' method called
- fDocumentEvent = new DocumentEvent(this, 0, getLength(), theString);
- fireModelAboutToBeChanged();
- NewModelEvent result = null;
- parentDocument.set(theString);
- //
- resetParser(0, parentDocument.getLength());
- setCachedDocumentRegion(getParser().getDocumentRegions());
- // when starting afresh, our cachedNode should be our firstNode,
- // so be sure to initialize the firstNode and lastNode
- initializeFirstAndLastDocumentRegion();
- StructuredDocumentRegionIterator.setParentDocument(getCachedDocumentRegion(), this);
- // initialize the structuredDocument variable of each instance in the
- // new chain
- //StructuredDocumentRegionIterator.setStructuredDocument(getCachedNode(),
- // this);
- result = new NewModelEvent(this, requester);
- fireStructuredDocumentEvent(result);
- resumePostNotificationProcessing();
- return result;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#startSequentialRewrite(boolean)
- */
- public void startSequentialRewrite(boolean normalize) {
- // TODO: why isn't this implemented!?
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#stopPostNotificationProcessing()
- */
- public void stopPostNotificationProcessing() {
- ++fStoppedCount;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.IDocumentExtension#stopSequentialRewrite()
- */
- public void stopSequentialRewrite() {
- // TODO: why isn't this implemented!?
- }
-
- public String toString() {
- //return "an instance of IStructuredDocument: " + "@" +
- // Integer.toHexString(hashCode());
- // made shorter, generic for test printouts
- return "an instance of IStructuredDocument"; // + "@" + //$NON-NLS-1$
- // Integer.toHexString(hashCode());
- }
-
- private StructuredDocumentEvent updateModel(Object requester, int start, int lengthToReplace, String changes) {
- StructuredDocumentEvent result = null;
- IStructuredTextReParser reParser = getReParser();
- // initialize the IStructuredTextReParser with the standard data
- // that's
- // always needed
- reParser.initialize(requester, start, lengthToReplace, changes);
- result = reParser.reparse();
- // if result is null at this point, then there must be an error, since
- // even if there
- // was no change (either disallow due to readonly, or a person pasted
- // the same thing
- // they had selected) then a "NoChange" event should have been fired.
- Assert.isNotNull(result, "no structuredDocument event was created in IStructuredDocument::updateStructuredDocument"); //$NON-NLS-1$
- return result;
- }
-
- /**
- * Called by re-parser. Note: this method may be "public" but should only
- * be called by re-parsers in the right circumstances.
- */
- public void updateParentDocument(int start, int lengthToReplace, String changes) {
- stopPostNotificationProcessing();
- // update stored text
- try {
- parentDocument.replace(start, lengthToReplace, changes);
- }
- catch (org.eclipse.jface.text.BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- resumePostNotificationProcessing();
- }
-
- /**
- * purely for debugging/performance measurements In practice, would always
- * be 'true'. (and should never be called by called by clients). Its not
- * 'final' just so it can be varied during debugging/performance
- * measurement runs.
- *
- * @param use_local_thread
- */
- public static void setUSE_LOCAL_THREAD(final boolean use_local_thread) {
- USE_LOCAL_THREAD = use_local_thread;
- }
-
- public Object getAdapter(Class adapter) {
- return Platform.getAdapterManager().getAdapter(this, adapter);
- }
-
- void setFirstDocumentRegion(IStructuredDocumentRegion region) {
- firstDocumentRegion = region;
-
- }
-
- void setLastDocumentRegion(IStructuredDocumentRegion region) {
- lastDocumentRegion = region;
-
- }
-
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getPartitionings()
- * @since 3.0
- */
- public String[] getPartitionings() {
- if (fDocumentPartitioners == null)
- return new String[0];
- String[] partitionings= new String[fDocumentPartitioners.size()];
- fDocumentPartitioners.keySet().toArray(partitionings);
- return partitionings;
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getLegalContentTypes(java.lang.String)
- * @since 3.0
- */
- public String[] getLegalContentTypes(String partitioning) throws BadPartitioningException {
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
- if (partitioner != null)
- return partitioner.getLegalContentTypes();
- if (DEFAULT_PARTITIONING.equals(partitioning))
- return new String[] { DEFAULT_CONTENT_TYPE };
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getZeroLengthContentType(java.lang.String, int)
- * @since 3.0
- */
- public String getContentType(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (offset > getLength()))
- throw new BadLocationException();
-
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
-
- if (partitioner instanceof IDocumentPartitionerExtension2)
- return ((IDocumentPartitionerExtension2) partitioner).getContentType(offset, preferOpenPartitions);
- else if (partitioner != null)
- return partitioner.getContentType(offset);
- else if (DEFAULT_PARTITIONING.equals(partitioning))
- return DEFAULT_CONTENT_TYPE;
- else
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getZeroLengthPartition(java.lang.String, int)
- * @since 3.0
- */
- public ITypedRegion getPartition(String partitioning, int offset, boolean preferOpenPartitions) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (offset > getLength()))
- throw new BadLocationException();
-
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
-
- if (partitioner instanceof IDocumentPartitionerExtension2)
- return ((IDocumentPartitionerExtension2) partitioner).getPartition(offset, preferOpenPartitions);
- else if (partitioner != null)
- return partitioner.getPartition(offset);
- else if (DEFAULT_PARTITIONING.equals(partitioning))
- return new TypedRegion(0, getLength(), DEFAULT_CONTENT_TYPE);
- else
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#computeZeroLengthPartitioning(java.lang.String, int, int)
- * @since 3.0
- */
- public ITypedRegion[] computePartitioning(String partitioning, int offset, int length, boolean includeZeroLengthPartitions) throws BadLocationException, BadPartitioningException {
- if ((0 > offset) || (0 > length) || (offset + length > getLength()))
- throw new BadLocationException();
-
- IDocumentPartitioner partitioner= getDocumentPartitioner(partitioning);
-
- if (partitioner instanceof IDocumentPartitionerExtension2)
- return ((IDocumentPartitionerExtension2) partitioner).computePartitioning(offset, length, includeZeroLengthPartitions);
- else if (partitioner != null)
- return partitioner.computePartitioning(offset, length);
- else if (DEFAULT_PARTITIONING.equals(partitioning))
- return new TypedRegion[] { new TypedRegion(offset, length, DEFAULT_CONTENT_TYPE) };
- else
- throw new BadPartitioningException();
- }
-
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#getDocumentPartitioner(java.lang.String)
- * @since 3.0
- */
- public IDocumentPartitioner getDocumentPartitioner(String partitioning) {
- return fDocumentPartitioners != null ? (IDocumentPartitioner) fDocumentPartitioners.get(partitioning) : null;
- }
- /*
- * @see org.eclipse.jface.text.IDocumentExtension3#setDocumentPartitioner(java.lang.String, org.eclipse.jface.text.IDocumentPartitioner)
- * @since 3.0
- */
- public void setDocumentPartitioner(String partitioning, IDocumentPartitioner partitioner) {
- if (partitioner == null) {
- if (fDocumentPartitioners != null) {
- fDocumentPartitioners.remove(partitioning);
- if (fDocumentPartitioners.size() == 0)
- fDocumentPartitioners= null;
- }
- } else {
- if (fDocumentPartitioners == null)
- fDocumentPartitioners= new HashMap();
- fDocumentPartitioners.put(partitioning, partitioner);
- }
- DocumentPartitioningChangedEvent event= new DocumentPartitioningChangedEvent(this);
- event.setPartitionChange(partitioning, 0, getLength());
- fireDocumentPartitioningChanged(event);
- }
- /**
- * Fires the document partitioning changed notification to all registered
- * document partitioning listeners. Uses a robust iterator.
- *
- * @param event the document partitioning changed event
- *
- * @see IDocumentPartitioningListenerExtension2
- * @since 3.0
- */
- protected void fireDocumentPartitioningChanged(DocumentPartitioningChangedEvent event) {
- if (fDocumentPartitioningListeners == null || fDocumentPartitioningListeners.size() == 0)
- return;
-
- List list= new ArrayList(fDocumentPartitioningListeners);
- Iterator e= list.iterator();
- while (e.hasNext()) {
- IDocumentPartitioningListener l= (IDocumentPartitioningListener) e.next();
- if (l instanceof IDocumentPartitioningListenerExtension2) {
- IDocumentPartitioningListenerExtension2 extension2= (IDocumentPartitioningListenerExtension2) l;
- extension2.documentPartitioningChanged(event);
- } else if (l instanceof IDocumentPartitioningListenerExtension) {
- IDocumentPartitioningListenerExtension extension= (IDocumentPartitioningListenerExtension) l;
- extension.documentPartitioningChanged(this, event.getCoverage());
- } else {
- l.documentPartitioningChanged(this);
- }
- }
-
- }
- /*
- * @see org.eclipse.jface.text.IDocument#addDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
- *
- * Registers the document partitioning listener with the document. After
- * registration the IDocumentPartitioningListener is informed about each
- * partition change cause by a document manipulation. If a document
- * partitioning listener is also a document listener, the following
- * notification sequence is guaranteed if a document manipulation changes
- * the document partitioning: 1)
- * listener.documentAboutToBeChanged(DocumentEvent); 2)
- * listener.documentPartitioningChanged(); 3)
- * listener.documentChanged(DocumentEvent); If the listener is already
- * registered nothing happens.
- *
- * @see IDocumentPartitioningListener
- */
-
- public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- Assert.isNotNull(listener);
- if (! fDocumentPartitioningListeners.contains(listener))
- fDocumentPartitioningListeners.add(listener);
- }
- /*
- * @see org.eclipse.jface.text.IDocument#removeDocumentPartitioningListener(org.eclipse.jface.text.IDocumentPartitioningListener)
- */
- public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- Assert.isNotNull(listener);
- fDocumentPartitioningListeners.remove(listener);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java
deleted file mode 100644
index 77631a334d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/BasicStructuredDocumentRegion.java
+++ /dev/null
@@ -1,613 +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.core.internal.text;
-
-
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.events.RegionChangedEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-import org.eclipse.wst.sse.core.internal.Logger;
-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.core.util.Assert;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-public class BasicStructuredDocumentRegion extends Object implements IStructuredDocumentRegion {
- protected int start;
- protected int length;
-
- private ITextRegionList _regions;
- /**
- * was this node terminated normally
- */
- // 0 == false, 1 == true
- private byte hasEnd = 0;
- private IStructuredDocumentRegion previous = null;
- private IStructuredDocumentRegion next = null;
- //private String fType;
- /**
- * allow a pointer back to this nodes model
- */
- private IStructuredDocument fParentDocument;
- private static final String UNDEFINED = "org.eclipse.wst.sse.structuredDocument.UNDEFINED"; //$NON-NLS-1$
- private static final String TEXT_STORE_NOT_ASSIGNED = "text store not assigned yet"; //$NON-NLS-1$
-
- public BasicStructuredDocumentRegion() {
- super();
- _regions = new TextRegionListImpl();
-
- }
-
- public void addRegion(ITextRegion aRegion) {
- _getRegions().add(aRegion);
- }
-
- public void adjustLengthWith(int i) {
- length += i;
- }
-
- public void adjustStart(int i) {
- start += i;
- }
-
- /**
- * getEnd and getEndOffset are the same only for IStructuredDocumentRegions
- */
- public int getEnd() {
- return start + length;
- }
-
- /**
- * getEnd and getEndOffset are the same only for IStructuredDocumentRegions
- */
- public int getEndOffset() {
- return getEnd();
- }
-
- // public IStructuredDocumentRegion getFirstNode() {
- // IStructuredDocumentRegion aNode = (IStructuredDocumentRegion) fOwningDocument.getFirstStructuredDocumentRegion();
- // return aNode;
- // }
- public ITextRegion getFirstRegion() {
- if (_getRegions() == null)
- return null;
- return _getRegions().get(0);
- }
-
- public String getFullText(ITextRegion aRegion) {
- String result = null;
- try {
- int regionStart = aRegion.getStart();
- int regionLength = aRegion.getLength();
- result = fParentDocument.get(start + regionStart, regionLength);
- }
- catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- return result;
- }
-
- public String getFullText(String context) {
- // DMW: looping is faster than enumeration,
- // so switched around 2/12/03
- //Enumeration e = getRegions().elements();
- ITextRegion region = null;
- String result = ""; //$NON-NLS-1$
- int length = getRegions().size();
- for (int i = 0; i < length; i++) {
- region = getRegions().get(i);
- if (region.getType() == context)
- result += getFullText(region);
- }
- return result;
- }
-
- public ITextRegion getLastRegion() {
- if (_getRegions() == null)
- return null;
- return _getRegions().get(_getRegions().size() - 1);
- }
-
- public int getLength() {
- return length;
- }
-
- public IStructuredDocumentRegion getNext() {
- return next;
- }
-
- public int getNumberOfRegions() {
- return _getRegions().size();
- }
-
- public IStructuredDocumentRegion getPrevious() {
- return previous;
- }
-
- /**
- * The parameter offset refers to the overall offset in the document.
- */
- public ITextRegion getRegionAtCharacterOffset(int offset) {
- ITextRegion result = null;
- if (_getRegions() != null) {
- // transform the requested offset to the "scale" that
- // regions are stored in, which are all relative to the
- // start point.
- //int transformedOffset = offset - getStartOffset();
- //
- int length = getRegions().size();
- for (int i = 0; i < length; i++) {
- ITextRegion region = getRegions().get(i);
- if (Debug.debugStructuredDocument) {
- System.out.println("region(s) in IStructuredDocumentRegion::getRegionAtCharacterOffset: " + region); //$NON-NLS-1$
- System.out.println(" requested offset: " + offset); //$NON-NLS-1$
- //System.out.println(" transformedOffset: " + transformedOffset); //$NON-NLS-1$
- System.out.println(" region start: " + region.getStart()); //$NON-NLS-1$
- System.out.println(" region end: " + region.getEnd()); //$NON-NLS-1$
- System.out.println(" region type: " + region.getType()); //$NON-NLS-1$
- System.out.println(" region class: " + region.getClass()); //$NON-NLS-1$
-
- }
- if ((getStartOffset(region) <= offset) && (offset < getEndOffset(region))) {
- result = region;
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * getStart and getStartOffset are the same
- * only for IStrucutredDocumentRegions
- */
- public int getStart() {
- return start;
- }
-
- /**
- * getStart and getStartOffset are the same
- * only for IStrucutredDocumentRegions
- */
- public int getStartOffset() {
- return getStart();
- }
-
- public String getText() {
- String result = null;
- try {
- if (fParentDocument == null) {
- // likely to happen during inspecting
- result = TEXT_STORE_NOT_ASSIGNED;
- }
- else {
- result = fParentDocument.get(start, length);
- }
- }
- catch (BadLocationException e) {
- throw new SourceEditingRuntimeException(e);
- }
- return result;
- }
-
- public String getText(ITextRegion aRegion) {
- // assert: aRegion can not be null
- // (might be performance hit if literally put in assert call,
- // but aRegion can not be null). Needs to be checked
- // by calling code.
- try {
- return fParentDocument.get(this.getStartOffset(aRegion), aRegion.getTextLength());
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Returns the text of the first region with the matching context type
- */
- public String getText(String context) {
- // DMW: looping is faster than enumeration,
- // so switched around 2/12/03
- //Enumeration e = getRegions().elements();
- ITextRegion region = null;
- String result = ""; //$NON-NLS-1$
- int length = getRegions().size();
- for (int i = 0; i < length; i++) {
- region = getRegions().get(i);
- if (region.getType() == context) {
- result = getText(region);
- break;
- }
- }
- return result;
- }
-
- /**
- * @return int
- */
- public int getTextEndOffset() {
- ITextRegion region = _getRegions().get(_getRegions().size() - 1);
- return getStartOffset() + region.getTextEnd();
- }
-
- /**
- * Provides the type of IStructuredDocumentRegion ... not to be confused with type of XML node!
- */
- // For now return a String.
- public String getType() {
- // for a "named" XML node (e.g. start tag), but type of
- // flatnode is "named xml node" (which is always the second region).
- // Therefore, if there's two or more regions, the type for the flatnode
- // will be the type of the second region. Otherwise it will be the type
- // of the first region.
- // Note: this can be refined as needed.
- String result = UNDEFINED; //"IStructuredDocumentRegion.UNDEFINED"; //$NON-NLS-1$
- // we are assume there is always at least one region in a flatnode!
- result = getRegions().get(0).getType();
- // typcially subclassed, if something other than first region is
- // desired
- return result;
- }
-
- /**
- *
- * @return boolean
- */
- public boolean isEnded() {
- return (hasEnd == 1);
- }
-
- /**
- *
- * @param newHasEnd boolean
- */
- public void setEnded(boolean newHasEnd) {
- if (newHasEnd) {
- hasEnd = 1;
- }
- else {
- hasEnd = 0;
- }
- }
-
- public void setLength(int newLength) {
- //textLength = newLength;
- length = newLength;
- }
-
- public void setNext(IStructuredDocumentRegion newNext) {
- next = newNext;
- }
-
- public void setPrevious(IStructuredDocumentRegion newPrevious) {
- previous = newPrevious;
- }
-
- public void setStart(int newStart) {
- start = newStart;
- }
-
- public String toString() {
- // NOTE: if the document held by any region has been updated and the region offsets have not
- // yet been updated, the output from this method invalid.
- // Also note, this method can not be changed, without "breaking"
- // unit tests, since some of them compare current results to previous
- // results.
- String result = null;
- result = "[" + getStart() + ", " + getEnd() + "] (" + getText() + ")"; //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- return result;
- }
-
- private void updateDownStreamRegions(ITextRegion changedRegion, int lengthDifference) {
- int listLength = _getRegions().size();
- int startIndex = 0;
- // first, loop through to find index of where to start
- for (int i = 0; i < listLength; i++) {
- ITextRegion region = _getRegions().get(i);
- if (region == changedRegion) {
- startIndex = i;
- break;
- }
- }
- // now, beginning one past the one that was changed, loop
- // through to end of list, adjusting the start postions.
- startIndex++;
- for (int j = startIndex; j < listLength; j++) {
- ITextRegion region = _getRegions().get(j);
- region.adjustStart(lengthDifference);
- }
- }
-
- // This is a language specific method (e.g. HTML, Java, Prolog, etc.) so could/should be made configurable.
- /* (non-Javadoc)
- */
- // public StructuredDocumentEvent updateModel(Object requester, String changes, int start, int end, IStructuredDocumentRegion flatnode) {
- public StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion structuredDocumentRegion, String changes, int requestStart, int lengthToReplace) {
- StructuredDocumentEvent result = null;
- int lengthDifference = Utilities.calculateLengthDifference(changes, lengthToReplace);
- // Get the region pointed to by the requestStart postion, and give that region a chance to effect
- // the update.
- ITextRegion region = getRegionAtCharacterOffset(requestStart);
- // if there is no region, then the requested changes must come right after the
- // node (and right after the last region). This happens, for example, when someone
- // types something at the end of the document, or more commonly, when they are right
- // at the beginning of one node, and the dirty start is therefore calculated to be the
- // previous node.
- // So, in this case, we'll give the last region a chance to see if it wants to
- // swallow the requested changes -- but only for inserts -- deletes and "replaces"
- // should be reparsed if they are in these border regions, and only if the
- if ((region == null) && (lengthToReplace == 0)) {
- region = _getRegions().get(_getRegions().size() - 1);
- // make sure the region is contiguous
- if (getEndOffset(region) == requestStart) {
- result = region.updateModel(requester, this, changes, requestStart, lengthToReplace);
- }
- }
- else {
- if (region != null) {
- //
- // If the requested change spans more than one region, then
- // we don't give the region a chance to update.
- if ((containsOffset(region, requestStart)) && (containsOffset(region, requestStart + lengthToReplace))) {
- result = region.updateModel(requester, this, changes, requestStart, lengthToReplace);
- }
- }
- }
- // if result is not null, then we need to update the start and end
- // postions of the regions that follow this one
- // if result is null, then apply the flatnode specific checks on what it can change
- // (i.e. more than one region, but no change to the node itself)
- if (result != null) {
- // That is, a region decided it could handle the change and created
- // a region changed event.
- Assert.isTrue(result instanceof RegionChangedEvent, "Program Error"); //$NON-NLS-1$
- updateDownStreamRegions(((RegionChangedEvent) result).getRegion(), lengthDifference);
- // PLUS, we need to update our own node end point (length)
- setLength(getLength() + lengthDifference);
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- */
- public IStructuredDocument getParentDocument() {
-
- return fParentDocument;
- }
-
- public void setParentDocument(IStructuredDocument document) {
- fParentDocument = document;
-
- }
-
- /* (non-Javadoc)
- */
- public boolean containsOffset(ITextRegion containedRegion, int offset) {
- return getStartOffset(containedRegion) <= offset && offset < getEndOffset(containedRegion);
- }
-
- /* (non-Javadoc)
- */
- public int getStartOffset(ITextRegion containedRegion) {
- // assert: containedRegion can not be null
- // (might be performance hit if literally put in assert call,
- // but containedRegion can not be null). Needs to be checked
- // by calling code.
- return getStartOffset() + containedRegion.getStart();
- }
-
- /* (non-Javadoc)
- */
- public int getEndOffset(ITextRegion containedRegion) {
- return getStartOffset(containedRegion) + containedRegion.getLength();
- }
-
- /* (non-Javadoc)
- */
- public int getTextEndOffset(ITextRegion containedRegion) {
- return getStartOffset(containedRegion) + containedRegion.getTextLength();
- }
-
- /* (non-Javadoc)
- */
- public boolean containsOffset(int i) {
-
- return getStartOffset() <= i && i < getEndOffset();
- }
-
- /* (non-Javadoc)
- */
- public String getFullText() {
- try {
- return getParentDocument().get(start, length);
- }
- catch (BadLocationException e) {
- // program error
- throw new SourceEditingRuntimeException(e);
- }
- }
-
- /* (non-Javadoc)
- */
- public int getTextEnd() {
-
- //return start + textLength;
- return start + length;
- }
-
- /* (non-Javadoc)
- */
- public int getTextLength() {
- //return textLength;
- return length;
- }
-
- /* (non-Javadoc)
- */
- public void adjust(int i) {
- start += i;
- }
-
- /* (non-Javadoc)
- */
- public void equatePositions(ITextRegion region) {
- start = region.getStart();
- length = region.getLength();
- //textLength = region.getTextLength();
-
- }
-
- public ITextRegionList getRegions() {
- return _getRegions();
- }
-
- /**
- * Even inside-this class uses of 'regions' should use this method,
- * as this is where (soft) memory management/reparsing, etc., will be
- * centralized.
- */
- private ITextRegionList _getRegions() {
-
- return _regions;
- }
-
- public void setRegions(ITextRegionList containedRegions) {
- _regions = containedRegions;
- }
-
- public boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion newDocumentRegion, ITextRegion newRegion, int shift) {
- boolean result = false;
- // if any region is null, we return false (even if both are!)
- if ((oldRegion != null) && (newRegion != null)) {
- // if the regions are the same instance, they are equal
- if (oldRegion == newRegion) {
- result = true;
- }
- else {
- // this is the non-trivial part
- // note: we change for type first, then start offset and end offset,
- // since that would decide many cases right away and avoid the text comparison
- if (oldRegion.getType() == newRegion.getType()) {
- if (sameOffsetsAs(oldRegion, newDocumentRegion, newRegion, shift)) {
- if (sameTextAs(oldRegion, newDocumentRegion, newRegion, shift)) {
- result = true;
- }
- }
- }
- }
-
- }
-
- return result;
- }
-
- private boolean sameOffsetsAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- if (getStartOffset(oldRegion) == documentRegion.getStartOffset(newRegion) - shift) {
- if (getEndOffset(oldRegion) == documentRegion.getEndOffset(newRegion) - shift) {
- return true;
- }
- }
- return false;
- }
-
- private boolean sameTextAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift) {
- boolean result = false;
- try {
- if (getText(oldRegion).equals(documentRegion.getText(newRegion))) {
- result = true;
- }
- }
- catch (SourceEditingRuntimeException e) {
- if (e.getOriginalException() instanceof BadLocationException) {
- // this happens normally if document has been deleted from
- // and therefore regions are not equal
- result = false;
- }
- else {
- throw e;
- }
- }
-
- return result;
- }
-
- public boolean sameAs(IStructuredDocumentRegion region, int shift) {
- boolean result = false;
- // if region == null, we return false;
- if (region != null) {
- // if the regions are the same instance, they are equal
- if (this == region) {
- result = true;
- }
- else {
- // this is the non-trivial part
- // note: we change for type first, then start offset and end offset,
- // since that would decide many cases right away and avoid the text comparison
- if (getType() == region.getType()) {
- if (sameOffsetsAs(region, shift) && sameTextAs(region, shift)) {
- result = true;
- }
- }
-
- }
- }
- return result;
- }
-
- private boolean sameOffsetsAs(IStructuredDocumentRegion region, int shift) {
- if (getStartOffset() == region.getStartOffset() - shift) {
- if (getEndOffset() == region.getEndOffset() - shift) {
- return true;
- }
- }
- return false;
- }
-
- private boolean sameTextAs(IStructuredDocumentRegion region, int shift) {
- boolean result = false;
- try {
- if (getText().equals(region.getText())) {
- result = true;
- }
- }
- catch (SourceEditingRuntimeException e) {
- if (e.getOriginalException() instanceof BadLocationException || e.getOriginalException() instanceof StringIndexOutOfBoundsException) {
- // this happens normally if document has been deleted from
- // and therefore regions are not equal
- result = false;
- }
- else {
- throw e;
- }
- }
-
- return result;
- }
-
- /* (non-Javadoc)
- */
- public void adjustTextLength(int i) {
- // not supported
-
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java
deleted file mode 100644
index d2269b9971..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/CoreNodeList.java
+++ /dev/null
@@ -1,130 +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.core.internal.text;
-
-
-
-import java.util.Enumeration;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegionList;
-
-
-public class CoreNodeList implements IStructuredDocumentRegionList {
-
- IStructuredDocumentRegion[] flatNodes;
- int currentIndex = -1;
- int countedLength;
- IStructuredDocumentRegion head;
-
- /**
- * CoreNodeList constructor comment.
- */
- public CoreNodeList() {
- super();
- // create an array, even if zero length
- flatNodes = new IStructuredDocumentRegion[0];
- }
-
- public CoreNodeList(IStructuredDocumentRegion newHead) {
- super();
- // save head
- head = newHead;
- int count = 0;
- IStructuredDocumentRegion countNode = newHead;
- // we have to go through the list once, to get its
- // length in order to create the array
- while (countNode != null) {
- count++;
- countNode = countNode.getNext();
- }
- // create an array, even if zero length
- flatNodes = new IStructuredDocumentRegion[count];
- // start countNode over again, so to speak.
- countNode = newHead;
- count = 0;
- while (countNode != null) {
- flatNodes[count++] = countNode;
- countNode = countNode.getNext();
- }
- if (count > 0) {
- currentIndex = 0;
- // else it stays at -1 initialized at object creation
- //
- // save length
- countedLength = count;
- }
- }
-
- public CoreNodeList(IStructuredDocumentRegion start, IStructuredDocumentRegion end) {
- super();
- // save head
- head = start;
- int count = 0;
- IStructuredDocumentRegion countNode = start;
- if ((start == null) || (end == null)) {
- // error condition
- //throw new IllegalArgumentException("Must provide start and end nodes to construct CoreNodeList");
- }
- else {
- count = 1;
- while ((countNode != null) && (countNode != end)) {
- count++;
- countNode = countNode.getNext();
- }
- }
- // if we ended because the last one was null,
- // backup one.
- if (countNode == null)
- count--;
- if (count < 0) {
- count = 0;
- }
- flatNodes = new IStructuredDocumentRegion[count];
- if (count > 0) {
- flatNodes[0] = countNode = start;
- for (int i = 1; i < count; i++) {
- flatNodes[i] = flatNodes[i - 1].getNext();
- }
-
- }
- currentIndex = 0;
- countedLength = count;
- }
-
- public Enumeration elements() {
- StructuredDocumentRegionEnumeration result = null;
- if ((flatNodes != null) && (flatNodes.length > 0))
- result = new StructuredDocumentRegionEnumeration(flatNodes[0], flatNodes[flatNodes.length - 1]);
- else
- result = new StructuredDocumentRegionEnumeration(null);
- return result;
- }
-
- public int getLength() {
- return flatNodes.length;
- }
-
- public boolean includes(Object o) {
- if (flatNodes == null)
- return false;
- for (int i = 0; i < flatNodes.length; i++)
- if (flatNodes[i] == o)
- return true;
- return false;
- }
-
- public IStructuredDocumentRegion item(int i) {
- return flatNodes[i];
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
deleted file mode 100644
index cc7734d42f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/MinimalDocument.java
+++ /dev/null
@@ -1,348 +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.core.internal.text;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.IDocumentListener;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.IDocumentPartitioningListener;
-import org.eclipse.jface.text.IPositionUpdater;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.jface.text.Position;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.internal.NotImplementedException;
-import org.eclipse.wst.sse.core.internal.document.NullStructuredDocumentPartitioner;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-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.IStructuredTextReParser;
-
-
-/**
- * Purely a dummy "marker" instance for StructuredDocumentRegions which are
- * created temorarily in the course of re-parsing. Primarily a place holder,
- * but can be needed to get text from.
- */
-public class MinimalDocument implements IStructuredDocument {
- private SubSetTextStore data;
-
- /**
- * Marked private to be sure never created without data being initialized.
- *
- */
- private MinimalDocument() {
- super();
- }
-
- public MinimalDocument(SubSetTextStore initialContents) {
- this();
- data = initialContents;
- }
-
- public char getChar(int offset) throws BadLocationException {
- return data.get(offset);
- }
-
- public int getLength() {
- return data.getLength();
- }
-
- public String get() {
- String result = null;
- result = data.get(0, data.getLength());
- return result;
- }
-
- public String get(int offset, int length) throws BadLocationException {
- String result = null;
- try {
- result = data.get(offset, length);
- }
- catch (StringIndexOutOfBoundsException e) {
- throw new BadLocationException();
- }
- return result;
- }
-
- public void set(String text) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- // data.set(text);
- }
-
- public void replace(int offset, int length, String text) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- // data.replace(offset, length, text);
- }
-
- public String getText() {
- return data.get(0, data.getLength());
- }
-
- public void addDocumentListener(IDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeDocumentListener(IDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePrenotifiedDocumentListener(IDocumentListener documentAdapter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPositionCategory(String category) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePositionCategory(String category) throws BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String[] getPositionCategories() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public boolean containsPositionCategory(String category) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPosition(Position position) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePosition(Position position) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPosition(String category, Position position) throws BadLocationException, BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePosition(String category, Position position) throws BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public Position[] getPositions(String category) throws BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public boolean containsPosition(String category, int offset, int length) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int computeIndexInCategory(String category, int offset) throws BadLocationException, BadPositionCategoryException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addPositionUpdater(IPositionUpdater updater) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removePositionUpdater(IPositionUpdater updater) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void insertPositionUpdater(IPositionUpdater updater, int index) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IPositionUpdater[] getPositionUpdaters() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String[] getLegalContentTypes() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String getContentType(int offset) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public ITypedRegion getPartition(int offset) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public ITypedRegion[] computePartitioning(int offset, int length) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeDocumentPartitioningListener(IDocumentPartitioningListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void setDocumentPartitioner(IDocumentPartitioner partitioner) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IDocumentPartitioner getDocumentPartitioner() {
- // temp fix
- return new NullStructuredDocumentPartitioner();
- // throw new NotImplementedException("intentionally not implemented");
- }
-
- public int getLineLength(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getLineOffset(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IRegion getLineInformation(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IRegion getLineInformationOfOffset(int offset) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getNumberOfLines() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getNumberOfLines(int offset, int length) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int computeNumberOfLines(String text) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String[] getLegalLineDelimiters() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String getLineDelimiter(int line) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int search(int startOffset, String findString, boolean forwardSearch, boolean caseSensitive, boolean wholeWord) throws BadLocationException {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addModelAboutToBeChangedListener(IModelAboutToBeChangedListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addModelChangedListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void addModelChangingListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegion getFirstStructuredDocumentRegion() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegion getLastStructuredDocumentRegion() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public String getLineDelimiter() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void setLineDelimiter(String delimiter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public int getLineOfOffset(int offset) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegion getRegionAtCharacterOffset(int offset) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocumentRegionList getRegionList() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeModelAboutToBeChangedListener(IModelAboutToBeChangedListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeModelChangedListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void removeModelChangingListener(IStructuredDocumentListener listener) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public StructuredDocumentEvent replaceText(Object source, int oldStart, int replacementLength, String requestedChange) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public NewModelEvent setText(Object requester, String allText) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public RegionParser getParser() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredDocument newInstance() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public EncodingMemento getEncodingMemento() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void setEncodingMemento(EncodingMemento encodingMemento) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public IStructuredTextReParser getReParser() {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public boolean containsReadOnly(int startOffset, int length) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void makeReadOnly(int startOffset, int length) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public void clearReadOnly(int startOffset, int length) {
- // TODO: this is called from notifier loop inappropriately
- // throw new NotImplementedException("intentionally not implemented");
- }
-
- public void fireNewDocument(Object requester) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-
- public Object getAdapter(Class adapter) {
- throw new NotImplementedException("intentionally not implemented"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java
deleted file mode 100644
index 1f7521e56c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentReParser.java
+++ /dev/null
@@ -1,1714 +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.core.internal.text;
-
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.FindReplaceDocumentAdapter;
-import org.eclipse.jface.text.IRegion;
-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.internal.Logger;
-import org.eclipse.wst.sse.core.parser.BlockTagParser;
-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.IStructuredTextReParser;
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionCollection;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.util.Debug;
-import org.eclipse.wst.sse.core.util.StringUtils;
-import org.eclipse.wst.sse.core.util.Utilities;
-
-
-/**
- * This class provides a centralized place to put "reparsing" logic. This is
- * the logic that reparses the text incrementally, as a user types in new
- * characters, or DOM nodes are inserted or deleted. Note: it is not a thread
- * safe class.
- */
-public class StructuredDocumentReParser implements IStructuredTextReParser {
- // note: this is the impl class of IStructuredDocument, not the interface
- // FUTURE_TO_DO: I believe some of these can be made private now.?
- protected BasicStructuredDocument fStructuredDocument;
- protected int fStart;
- protected int fLengthToReplace;
- protected String fChanges;
- protected Object fRequester;
- protected int fLengthDifference;
- protected String fDeletedText;
- protected final CoreNodeList EMPTY_LIST = new CoreNodeList();
- protected IStructuredDocumentRegion dirtyStart = null;
- protected IStructuredDocumentRegion dirtyEnd = null;
-
- private FindReplaceDocumentAdapter fFindReplaceDocumentAdapter = null;
-
- /**
- * variable used in anticiapation of multithreading
- */
- protected boolean isParsing;
- final private String singleQuote = new String(new char[]{'\''});
- final private String doubleQuote = new String(new char[]{'\"'});
-
- public StructuredDocumentReParser() {
- super();
- }
-
- public StructuredDocumentEvent _checkBlockNodeList(List blockTagList) {
- StructuredDocumentEvent result = null;
- if (blockTagList != null) {
- for (int i = 0; i < blockTagList.size(); i++) {
- org.eclipse.wst.sse.core.parser.BlockMarker blockTag = (org.eclipse.wst.sse.core.parser.BlockMarker) blockTagList.get(i);
- String tagName = blockTag.getTagName();
- result = checkForCriticalName("<" + tagName); //$NON-NLS-1$
- if (result != null)
- break;
- result = checkForCriticalName("</" + tagName); //$NON-NLS-1$
- if (result != null)
- break;
- }
- }
- return result;
- }
-
- /**
- * Common utility for checking for critical word such as " <SCRIPT>"
- */
- private StructuredDocumentEvent _checkForCriticalWord(String criticalTarget, boolean checkEnd) {
- StructuredDocumentEvent result = null;
- int documentLength = fStructuredDocument.getLength();
- int propLen = fLengthToReplace;
- if (propLen > documentLength)
- propLen = documentLength;
- int startNeighborhood = fStart - criticalTarget.length();
- int adjustInsert = 0;
- if (startNeighborhood < 0) {
- adjustInsert = 0 - startNeighborhood;
- startNeighborhood = 0;
- }
- int endNeighborhood = fStart + fLengthToReplace + criticalTarget.length() - 1;
- if (endNeighborhood > documentLength)
- endNeighborhood = documentLength - 1;
- int oldlen = endNeighborhood - startNeighborhood; // + 1;
- if (oldlen + startNeighborhood > documentLength) {
- oldlen = documentLength - startNeighborhood;
- }
- String oldText = fStructuredDocument.get(startNeighborhood, oldlen);
- String peek = StringUtils.paste(oldText, fChanges, criticalTarget.length() - adjustInsert, fLengthToReplace);
- boolean isCriticalString = checkTagNames(oldText, criticalTarget, checkEnd);
- boolean toBeCriticalString = checkTagNames(peek, criticalTarget, checkEnd);
- if ((isCriticalString != toBeCriticalString) || // OR if both are
- // critical and there's
- // a change in the end
- // tag ('>')
- ((isCriticalString && toBeCriticalString) && (changeInIsEndedState(oldText, peek)))) {
- // if it involves a change of a critical string (making one where
- // there wasn't, or removing
- // one where there was one) then reparse everthing.
- result = reparse(0, documentLength - 1);
- }
- return result;
- }
-
- private int _computeStartOfDifferences(CoreNodeList oldNodes, CoreNodeList newNodes) {
- int startOfDifferences = -1;
- int newNodesLength = newNodes.getLength();
- boolean foundDifference = false;
- boolean done = false;
- // we'll control our loop based on the old List length
- int oldNodesLength = oldNodes.getLength();
- // be sure to check 'done' first, so startOfDifferences isn't
- // icremented if done is true
- done : while ((!done) && (++startOfDifferences < oldNodesLength)) {
- IStructuredDocumentRegion oldNode = oldNodes.item(startOfDifferences);
- // this lessThanEffectedRegion is to check to be sure the node is
- // infact a candidate
- // to be considered as "old". This check is important for the case
- // where some
- // text is replaceing text that
- // appears identical, but is a different instance. For example, if
- // the text
- // is <P><B></B></P> and <B></B> is inserted at postion 3,
- // resulting in <P><B></B><B></B></P>
- // we do not want the
- // first <B> to be considered old ... it is the new one, the second
- // <B> is the old one.
- if (_lessThanEffectedRegion(oldNode)) {
- // be sure to check that we have new nodes to compare against.
- if (startOfDifferences > newNodesLength) {
- foundDifference = false;
- done = true;
- continue done;
- }
- else {
- //
- IStructuredDocumentRegion newNode = newNodes.item(startOfDifferences);
- // note: shift is 0 while at beginning of list, before the
- // insertion (or deletion) point. After that, it is
- // fStart+fLengthDifference
- if (!(oldNode.sameAs(newNode, 0))) {
- foundDifference = true;
- done = true;
- continue done;
- }
- else { // if they are equal, then we will be keeping the
- // old one, so
- // we need to be sure its parentDocument is set back to
- // the right instance
- oldNode.setParentDocument(fStructuredDocument);
- }
- }
- }
- else {
- // we didn't literally find a difference, but we count it as
- // such by implication
- foundDifference = true;
- done = true;
- continue done;
- }
- }
- // if we literally found a difference, then all is ok and we can return
- // it.
- // if we did not literally find one, then we have to decide why.
- if (!foundDifference) {
- if (newNodesLength == oldNodesLength) { // then lists are identical
- // (and may be of zero
- // length)
- startOfDifferences = -1;
- }
- else {
- if (newNodesLength > oldNodesLength) { // then lists are
- // identical except for
- // newNodes added
- startOfDifferences = oldNodesLength;
- }
- else {
- if (newNodesLength < oldNodesLength) { // then lists are
- // identical except
- // for old Nodes
- // deleted
- startOfDifferences = newNodesLength;
- }
- }
- }
- }
- return startOfDifferences;
- }
-
- private int _computeStartOfDifferences(IStructuredDocumentRegion oldNodeParam, ITextRegionList oldRegions, IStructuredDocumentRegion newNodeParam, ITextRegionList newRegions) {
- int startOfDifferences = -1;
- int newRegionsLength = newRegions.size();
- boolean foundDifference = false;
- boolean done = false;
- // we'll control our loop based on the old List length
- int oldRegionsLength = oldRegions.size();
- // be sure to check 'done' first, so startOfDifferences isn't
- // icremented if done is true
- done : while ((!done) && (++startOfDifferences < oldRegionsLength)) {
- ITextRegion oldRegion = oldRegions.get(startOfDifferences);
- // this lessThanEffectedRegion is to check to be sure the node is
- // infact a candidate
- // to be considered as "old". This check is important for the case
- // where some
- // text is replaceing text that
- // appears identical, but is a different instance. For example, if
- // the text
- // is <P><B></B></P> and <B></B> is inserted at postion 3,
- // resulting in <P><B></B><B></B></P>
- // we do not want the
- // first <B> to be considered old ... it is the new one, the second
- // <B> is the old one.
- if (_lessThanEffectedRegion(oldNodeParam, oldRegion)) {
- // be sure to check that we have new nodes to compare against.
- if (startOfDifferences > newRegionsLength) {
- foundDifference = false;
- done = true;
- continue done;
- }
- else {
- //
- ITextRegion newRegion = newRegions.get(startOfDifferences);
- // note: shift is 0 while at beginning of list, before the
- // insertion (or deletion) point. After that, it is
- // fStart+fLengthDifference
- if (!(oldNodeParam.sameAs(oldRegion, newNodeParam, newRegion, 0))) {
- foundDifference = true;
- done = true;
- continue done;
- }
- else {
- // if they are equal, then we will be keeping the old
- // one.
- // unlike the flatnode case, there is no reason to
- // update
- // the textstore, since its the same text store in
- // either case
- // (since its the same flatnode)
- //oldRegion.setTextStore(fStructuredDocument.parentDocument);
- }
- }
- }
- else {
- // we didn't literally find a difference, but we count it as
- // such by implication
- foundDifference = true;
- done = true;
- continue done;
- }
- }
- // if we literally found a difference, then all is ok and we can return
- // it.
- // if we did not literally find one, then we have to decide why.
- if (!foundDifference) {
- if (newRegionsLength == oldRegionsLength) { // then lists are
- // identical (and may
- // be of zero length)
- startOfDifferences = -1;
- }
- else {
- if (newRegionsLength > oldRegionsLength) { // then lists are
- // identical except
- // for newRegions
- // added
- startOfDifferences = oldRegionsLength;
- }
- else {
- if (newRegionsLength < oldRegionsLength) { // then lists
- // are identical
- // except for
- // old Nodes
- // deleted
- startOfDifferences = newRegionsLength;
- }
- }
- }
- }
- return startOfDifferences;
- }
-
- private CoreNodeList _formMinimumList(CoreNodeList flatnodes, int startOfDifferences, int endOfDifferences) {
- CoreNodeList minimalNodes = null;
- // if startOfDifferces is still its initial value, then we have an
- // empty document
- if (startOfDifferences == -1) {
- minimalNodes = EMPTY_LIST;
- }
- else {
- // if we do not have any flatnode in our flatnode list, then simply
- // return our standard empty list
- if (flatnodes.getLength() == 0) {
- minimalNodes = EMPTY_LIST;
- }
- else {
- // if startOfDifferences is greater than endOfDifferences, then
- // that means the calculations "crossed" each other, and hence,
- // there really is no differences, so, again, return the empty
- // list
- if (startOfDifferences > endOfDifferences) {
- minimalNodes = EMPTY_LIST;
- }
- else {
- // the last check be sure we have some differnces
- if ((endOfDifferences > -1)) {
- minimalNodes = new CoreNodeList(flatnodes.item(startOfDifferences), flatnodes.item(endOfDifferences));
- }
- else {
- // there were no differences, the list wasn't
- // minimized, so simply return it.
- minimalNodes = flatnodes;
- }
- }
- }
- }
- return minimalNodes;
- }
-
- private boolean _greaterThanEffectedRegion(IStructuredDocumentRegion oldNode) {
- boolean result = false;
- int nodeStart = oldNode.getStartOffset();
- int changedRegionEnd = fStart + fLengthToReplace - 1;
- result = nodeStart > changedRegionEnd;
- return result;
- }
-
- private boolean _greaterThanEffectedRegion(IStructuredDocumentRegion oldNode, ITextRegion oldRegion) {
- boolean result = false;
- int regionStartOffset = oldNode.getStartOffset(oldRegion);
- int effectedRegionEnd = fStart + fLengthToReplace - 1;
- result = regionStartOffset > effectedRegionEnd;
- return result;
- }
-
- private boolean _lessThanEffectedRegion(IStructuredDocumentRegion oldNode) {
- boolean result = false;
- int nodeEnd = oldNode.getEndOffset() - 1;
- result = nodeEnd < fStart;
- return result;
- }
-
- private boolean _lessThanEffectedRegion(IStructuredDocumentRegion oldNode, ITextRegion oldRegion) {
- boolean result = false;
- int nodeEnd = oldNode.getEndOffset(oldRegion) - 1;
- result = nodeEnd < fStart;
- return result;
- }
-
- private boolean _regionsSameKind(ITextRegion newRegion, ITextRegion oldRegion) {
- boolean result = false;
- // if one region is a container region, and the other not, always
- // return false
- // else, just check their type.
- // DW druing refactoring, looks like a "typo" here, using 'old' in
- // both.
- // if (isContainerRegion(oldRegion) != isContainerRegion(oldRegion))
- if (isCollectionRegion(oldRegion) != isCollectionRegion(newRegion))
- result = false;
- else if (oldRegion.getType() == newRegion.getType())
- result = true;
- return result;
- }
-
- /**
- * @param oldRegion
- */
- private boolean isCollectionRegion(ITextRegion aRegion) {
- return (aRegion instanceof ITextRegionCollection);
- }
-
- // private boolean hasCollectionRegions(ITextRegion aRegion) {
- // boolean result = false;
- // if (aRegion instanceof ITextRegionCollection) {
- // ITextRegionCollection regionContainter = (ITextRegionCollection)
- // aRegion;
- // ITextRegionList regions = regionContainter.getRegions();
- // Iterator iterator = regions.iterator();
- // while (iterator.hasNext()) {
- // if (aRegion instanceof ITextRegionCollection) {
- // result = true;
- // break;
- // }
- // }
- // }
- // return result;
- // }
- /**
- * This method is specifically to detect changes in 'isEnded' state,
- * although it still does so with heuristics. If number of '>' changes,
- * assume the isEnded state has changed.
- */
- private boolean changeInIsEndedState(String oldText, String newText) {
- int nOld = StringUtils.occurrencesOf(oldText, '>');
- int nNew = StringUtils.occurrencesOf(newText, '>');
- return !(nOld == nNew);
- }
-
- /**
- * Allow a reparser to check for extra syntactic cases that require parsing
- * beyond the flatNode boundary.
- *
- * This implementation is very XML-centric.
- */
- protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionSyntax() {
- StructuredDocumentEvent result;
- // Case 1: Quote characters are involved
- result = checkForQuotes();
- if (result == null) {
- // Case 2: The input forms or undoes a comment beginning or comment
- // end
- result = checkForComments();
- }
- if (result == null) {
- // Case 3: The input forms or undoes a processing instruction
- result = checkForPI();
- }
- if (result == null) {
- // Case 4: The input forms or undoes a CDATA section
- result = checkForCDATA();
- }
- return result;
- }
-
- /**
- * A change to a CDATA tag can result in all being reparsed.
- */
- private StructuredDocumentEvent checkForCDATA() {
- StructuredDocumentEvent result = null;
- result = checkForCriticalKey("<![CDATA["); //$NON-NLS-1$
- if (result == null)
- result = checkForCriticalKey("]]>"); //$NON-NLS-1$
- return result;
- }
-
- /**
- * If a comment start or end tag is being added or deleted, we'll rescan
- * the whole document. The reason is that content that is revealed or
- * commented out can effect the interpretation of the rest of the document.
- * Note: for now this is very XML specific, can refactor/improve later.
- */
- protected StructuredDocumentEvent checkForComments() {
- StructuredDocumentEvent result = null;
- result = checkForCriticalKey("<!--"); //$NON-NLS-1$
- if (result == null)
- result = checkForCriticalKey("-->"); //$NON-NLS-1$
- // we'll also check for these degenerate cases
- if (result == null)
- result = checkForCriticalKey("<!--->"); //$NON-NLS-1$
- return result;
- }
-
- /**
- * Common utility for checking for critical word such as " <SCRIPT>"
- */
- protected StructuredDocumentEvent checkForCriticalKey(String criticalTarget) {
- return _checkForCriticalWord(criticalTarget, false);
- }
-
- /**
- * Common utility for checking for critical word such as " <SCRIPT>"
- */
- private StructuredDocumentEvent checkForCriticalName(String criticalTarget) {
- return _checkForCriticalWord(criticalTarget, true);
- }
-
- // /**
- // * Currently this method is pretty specific to ?ML
- // * @deprecated - not really deprecated, but plan to make
- // * protected ... I'm not sure why its public or misspelled?
- // */
- protected StructuredDocumentEvent checkForCrossStructuredDocumentRegionBoundryCases() {
- StructuredDocumentEvent result = null;
- // Case 1: See if the language's syntax requires that multiple
- // StructuredDocumentRegions be rescanned
- if (result == null) {
- result = checkForCrossStructuredDocumentRegionSyntax();
- }
- // Case 2: "block tags" whose content is left unparsed
- if (result == null) {
- Object parser = fStructuredDocument.getParser();
- if (parser instanceof BlockTagParser) {
- List blockTags = ((BlockTagParser) parser).getBlockMarkers();
- result = _checkBlockNodeList(blockTags);
- }
- }
- // FUTURE_TO_DO: is there a better place to do this?
- // or! do we already do it some other more central place?
- if (result != null) {
- result.setDeletedText(fDeletedText);
- }
- return result;
- }
-
- /**
- * Checks to see if change request exactly matches the text it would be
- * replacing. (In future, this, or similar method is where to check for
- * "read only" attempted change.)
- */
- private StructuredDocumentEvent checkForNoChange() {
- StructuredDocumentEvent result = null;
- // don't check equals unless lengths match
- // should be a tiny bit faster, since usually not
- // of equal lengths (I'm surprised String's equals method
- // doesn't do this.)
- if ((fChanges != null) && (fDeletedText != null) && (fChanges.length() == fDeletedText.length()) && (fChanges.equals(fDeletedText))) {
- result = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- }
- return result;
- }
-
- /**
- * A change to a PI tag can result in all being reparsed.
- */
- private StructuredDocumentEvent checkForPI() {
- StructuredDocumentEvent result = null;
- result = checkForCriticalKey("<?"); //$NON-NLS-1$
- if (result == null)
- result = checkForCriticalKey("?>"); //$NON-NLS-1$
- return result;
- }
-
- // For simplicity, if either text to be deleted, or text to be inserted
- // contains at least
- // one quote, we'll search for previous quote in document, if any, and use
- // that flatnode as
- // a dirty start, and we'll use end of document as dirty end. We need to
- // assume either \" or
- // \' is an exceptable quote. (NOTE: this is, loosely, an XML assumption --
- // other languages
- // would differ, but we'll "hard code" for XML for now.
- // future_TODO: this is a really bad heuristic ... we should be looking for
- // odd number of quotes
- // within a structuredDocumentRegion (or something!) This causes way too
- // much reparsing on
- // simple cases, like deleting a tag with a quoted attribute!
- private StructuredDocumentEvent checkForQuotes() {
- // routine is supported with null or empty string meaning the same
- // thing: deletion
- if (fChanges == null)
- fChanges = ""; //$NON-NLS-1$
- //
- StructuredDocumentEvent result = null;
- try {
- int dirtyStartPos = -1;
- String proposedDeletion = fStructuredDocument.get(fStart, fLengthToReplace);
- if (fStart < fStructuredDocument.getLength()) {
- if ((fChanges.indexOf(singleQuote) > -1) || (proposedDeletion.indexOf(singleQuote) > -1)) {
- IRegion singleQuoteRegion = getFindReplaceDocumentAdapter().find(fStart, singleQuote, false, false, false, false);
- if (singleQuoteRegion != null) {
- dirtyStartPos = singleQuoteRegion.getOffset();
- }
- }
- else if ((fChanges.indexOf(doubleQuote) > -1) || (proposedDeletion.indexOf(doubleQuote) > -1)) {
- IRegion doubleQuoteRegion = getFindReplaceDocumentAdapter().find(fStart, doubleQuote, false, false, false, false);
- if (doubleQuoteRegion != null) {
- dirtyStartPos = doubleQuoteRegion.getOffset();
- }
- }
- }
- if (dirtyStartPos > -1) {
- // then we found one, do create new structuredDocument event
- // based on the previous quote to end of document
- // except, we need to be positive that the previous quote is
- // in a "safe start" region (e.g. if in JSP content, we need to
- // backup till we include the whole JSP region, in order for it
- // to be correctly re-parsed. The backing up is done in the
- // reparse/find dirty start from hint
- // method.
- result = reparse(dirtyStartPos, fStructuredDocument.getLength() - 1);
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- if (result != null) {
- result.setDeletedText(fDeletedText);
- }
- return result;
- }
-
- private int adjustForSafeStart() {
- return 0;
- }
-
- private StructuredDocumentEvent checkHeuristics() {
- StructuredDocumentEvent result = null;
- result = checkForNoChange();
- if (result == null) {
- result = checkForCrossStructuredDocumentRegionBoundryCases();
- if (result == null) {
- result = quickCheck();
- }
- }
- return result;
- }
-
- /**
- * Takes into account "tag name" rules for comparisons; case-insensitive.
- */
- private boolean checkTagNames(String compareText, String criticalTarget, boolean checkEnd) {
- boolean result = false;
- if ((compareText == null) || (criticalTarget == null))
- return false;
- int posOfCriticalWord = compareText.toLowerCase().indexOf(criticalTarget.toLowerCase());
- result = posOfCriticalWord > -1;
- if (checkEnd && result) {
- // instead of returning true right away, we'll only return true the
- // potentially matched tag is indeed a tag, for example, if <SCRIPT
- // becomes <SCRIPTS we don't want to say the latter is a critical
- // tag
- int lastPos = posOfCriticalWord + criticalTarget.length();
- if (lastPos < compareText.length()) {
- char lastChar = compareText.charAt(lastPos);
- // Future: check formal definition of this java method, vs. XML
- // parsing rules
- result = (!Character.isLetterOrDigit(lastChar));
- }
- }
- return result;
- }
-
- /**
- * Part 1 of 2 steps to do a core_reparse
- *
- * Parses a portion of the current text in the IStructuredDocument and
- * returns the raw result
- */
- private IStructuredDocumentRegion _core_reparse_text(int rescanStart, int rescanEnd) {
- fStructuredDocument.resetParser(rescanStart, rescanEnd);
- return fStructuredDocument.getParser().getDocumentRegions();
- }
-
- /**
- * Part 2 of 2 steps to do a core_reparse
- *
- * Integrates a list of StructuredDocumentRegions based on the current text
- * contents of the IStructuredDocument into the IStructuredDocument data
- * structure
- */
- private StructuredDocumentEvent _core_reparse_update_model(IStructuredDocumentRegion newNodesHead, int rescanStart, int rescanEnd, CoreNodeList oldNodes, boolean firstTime) {
- StructuredDocumentEvent result = null;
- CoreNodeList newNodes = null;
- // rescan
- newNodes = new CoreNodeList(newNodesHead);
- // adjust our newNode chain so the offset positions match
- // our text store (not the simple string of text reparsed)
- StructuredDocumentRegionIterator.adjustStart(newNodesHead, rescanStart);
- // initialize the parentDocument variable of each instance in the new
- // chain
- StructuredDocumentRegionIterator.setParentDocument(newNodesHead, fStructuredDocument);
- // initialize the structuredDocument variable of each instance in the
- // new chain
- //StructuredDocumentRegionIterator.setStructuredDocument(newNodesHead,
- // fStructuredDocument);
- //
- if (firstTime) {
- fStructuredDocument.setCachedDocumentRegion(newNodesHead);
- fStructuredDocument.initializeFirstAndLastDocumentRegion();
- // note: since we are inserting nodes, for the first time, there is
- // no adjustments
- // to downstream stuff necessary.
- result = new StructuredDocumentRegionsReplacedEvent(fStructuredDocument, fRequester, oldNodes, newNodes, fChanges, fStart, fLengthToReplace);
- }
- else {
- // note: integrates changes into model as a side effect
- result = minimumEvent(oldNodes, newNodes);
- }
- result.setDeletedText(fDeletedText);
- return result;
- }
-
- /**
- * The core reparsing method ... after the dirty start and dirty end have
- * been calculated elsewhere, and the text updated.
- */
- protected StructuredDocumentEvent core_reparse(int rescanStart, int rescanEnd, CoreNodeList oldNodes, boolean firstTime) {
- IStructuredDocumentRegion newNodesHead = null;
- StructuredDocumentEvent result = null;
- newNodesHead = _core_reparse_text(rescanStart, rescanEnd);
- result = _core_reparse_update_model(newNodesHead, rescanStart, rescanEnd, oldNodes, firstTime);
- return result;
- }
-
- /**
- * Resets state to "not parsing"
- */
- private synchronized void endReParse() {
- isParsing = false;
- dirtyStart = null;
- dirtyEnd = null;
- }
-
- protected IStructuredDocumentRegion findDirtyEnd(int end) {
- // Caution: here's one place we have to cast
- IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(end);
- // if not well formed, get one past, if there is something there
- if ((result != null) && (!result.isEnded())) {
- if (result.getNext() != null) {
- result = result.getNext();
- }
- }
- // also, get one past if exactly equal to the end (this was needed
- // as a simple fix to when a whole exact region is deleted.
- // there's probably a better way.
- if ((result != null) && (end == result.getEnd())) {
- if (result.getNext() != null) {
- result = result.getNext();
- }
- }
- // moved to subclass for quick transition
- // 12/6/2001 - Since we've changed the parser/scanner to allow a lone
- // '<' without
- // always interpretting it as start of a tag name, we need to be a
- // little fancier, in order
- // to "skip" over any plain 'ol content between the lone '<' and any
- // potential meating
- // regions past plain 'ol content.
- // if (isLoneOpenFollowedByContent(result) && (result.getNext() !=
- // null)) {
- // result = result.getNext();
- // }
- if (result != null)
- fStructuredDocument.setCachedDocumentRegion(result);
- dirtyEnd = result;
- return dirtyEnd;
- }
-
- protected void findDirtyStart(int start) {
- IStructuredDocumentRegion result = fStructuredDocument.getRegionAtCharacterOffset(start);
- // heuristic: if the postion is exactly equal to the start, then
- // go back one more, if it exists. This prevents problems with
- // insertions
- // of text that should be merged with the previous node instead of
- // simply hung
- // off of it as a separate node (ex.: XML content inserted right before
- // an open
- // bracket should become part of the previous content node)
- if (result != null) {
- IStructuredDocumentRegion previous = result.getPrevious();
- if ((previous != null) && ((!(previous.isEnded())) || (start == result.getStart()))) {
- result = previous;
- }
- // If we are now at the end of a "tag dependent" content area (or
- // JSP area)
- // then we need to back up all the way to the beginning of that.
- IStructuredDocumentRegion potential = result;
- // moved to subclass to speed transition
- // while (isPartOfBlockRegion(potential)) {
- // potential = potential.getPrevious();
- // }
- if (potential != null) {
- result = potential;
- fStructuredDocument.setCachedDocumentRegion(result);
- }
- }
- dirtyStart = result;
- }
-
- protected CoreNodeList formOldNodes(IStructuredDocumentRegion dirtyStart, IStructuredDocumentRegion dirtyEnd) {
- CoreNodeList oldNodes = new CoreNodeList(dirtyStart, dirtyEnd);
- // Now save the old text, that "goes with" the old nodes and regions.
- // Notice we are getting it directly from the text store
- String oldText = null;
- int oldStart = -1;
- int oldEnd = -1;
- // make sure there is some text, if not, use empty string
- // (if one node is not null, the other should ALWAYS be not null too,
- // since it
- // would at least be equal to it.)
- if (dirtyStart != null) {
- oldStart = dirtyStart.getStart();
- oldEnd = dirtyEnd.getEnd();
- oldText = fStructuredDocument.get(oldStart, oldEnd - oldStart);
- }
- else {
- oldStart = 0;
- oldEnd = 0;
- oldText = ""; //$NON-NLS-1$
- }
- // create a temporary text store for this text
- SubSetTextStore subTextStore = new SubSetTextStore(oldText, oldStart, oldEnd, fStructuredDocument.getLength());
- // Now update the text store of the oldNodes
- StructuredDocumentRegionIterator.setParentDocument(oldNodes, new MinimalDocument(subTextStore));
- return oldNodes;
- }
-
- // Note: if thead safety is needed, this and all the other public methods
- // of this class
- // should be synchronized.
- public void initialize(Object requester, int start, int lengthToReplace, String changes) {
- isParsing = true;
- fRequester = requester;
- fStart = start;
- fLengthToReplace = lengthToReplace;
- fChanges = changes;
- // notice this one is derived
- fLengthDifference = Utilities.calculateLengthDifference(fChanges, fLengthToReplace);
- fDeletedText = fStructuredDocument.get(fStart, fLengthToReplace);
- }
-
- protected void insertNodes(IStructuredDocumentRegion previousOldNode, IStructuredDocumentRegion nextOldNode, CoreNodeList newNodes) {
- //
- IStructuredDocumentRegion firstNew = null;
- IStructuredDocumentRegion lastNew = null;
- //
- IStructuredDocumentRegion oldPrevious = previousOldNode;
- IStructuredDocumentRegion oldNext = nextOldNode;
- //
- if (newNodes.getLength() > 0) {
- // get pointers
- firstNew = newNodes.item(0);
- lastNew = newNodes.item(newNodes.getLength() - 1);
- // switch surrounding StructuredDocumentRegions' references to
- // lists
- if (oldPrevious != null)
- oldPrevious.setNext(firstNew);
- if (oldNext != null) {
- oldNext.setPrevious(lastNew);
- }
- else {
- // SIDE EFFECT
- // if oldNext is null, that means we are replaceing the
- // lastNode in the chain,
- // so we need to update the structuredDocuments lastNode as the
- // last of the new nodes.
- fStructuredDocument.setLastDocumentRegion(newNodes.item(newNodes.getLength() - 1));
- }
- if (firstNew != null)
- firstNew.setPrevious(oldPrevious);
- if (lastNew != null)
- lastNew.setNext(oldNext);
- }
- // else nothing to insert
- }
-
- /**
- * @return boolean
- */
- public boolean isParsing() {
- return isParsing;
- }
-
- /**
- * The minimization algorithm simply checks the old nodes to see if any of
- * them "survived" the rescan and are unchanged. If so, the instance of the
- * old node is used instead of the new node. Before the requested change,
- * need to check type, offsets, and text to determine if the same. After
- * the requested change, need to check type and text, but adjust the
- * offsets to what ever the change was.
- */
- protected StructuredDocumentEvent minimumEvent(CoreNodeList oldNodes, CoreNodeList newNodes) {
- StructuredDocumentEvent event = null;
- CoreNodeList minimalOldNodes = null;
- CoreNodeList minimalNewNodes = null;
- // To minimize nodes, we'll collect all those
- // that are not equal into old and new lists
- // Note: we assume that old and new nodes
- // are basically contiguous -- and we force it to be so,
- // by starting at the beginning to
- // find first difference, and then starting at the end to find
- // last difference. Everything in between we assume is different.
- //
- //
- //
- // startOfDifferences is the index into the core node list where the
- // first difference
- // occurs. But it may point into the old or the new list.
- int startOfDifferences = _computeStartOfDifferences(oldNodes, newNodes);
- int endOfDifferencesOld = -1;
- int endOfDifferencesNew = -1;
- // if one of the lists are shorter than where the differences start,
- // then
- // then some portion of the lists are identical
- if ((startOfDifferences >= oldNodes.getLength()) || (startOfDifferences >= newNodes.getLength())) {
- if (oldNodes.getLength() < newNodes.getLength()) {
- // Then there are new regions to add
- // these lengths will cause the vector of old ones to not
- // have any elements, and the vector of new regions to have
- // just the new ones not in common with the old ones
- //startOfDifferences should equal oldNodes.getLength(),
- // calculated above on _computeStartOfDifferences
- minimalOldNodes = EMPTY_LIST;
- endOfDifferencesNew = newNodes.getLength() - 1;
- minimalNewNodes = _formMinimumList(newNodes, startOfDifferences, endOfDifferencesNew);
- }
- else {
- if (oldNodes.getLength() > newNodes.getLength()) {
- // delete old
- // then there are old regions to delete
- // these lengths will cause the vector of old regions to
- // contain the ones to delete, and the vector of new
- // regions
- // not have any elements
- //startOfDifferences should equal newNodes.getLength(),
- // calculated above on _computeStartOfDifferences
- endOfDifferencesOld = oldNodes.getLength() - 1;
- minimalOldNodes = _formMinimumList(oldNodes, startOfDifferences, endOfDifferencesOld);
- minimalNewNodes = EMPTY_LIST;
- }
- else
- // unlikely event
- event = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- }
- }
- else {
- // We found a normal startOfDiffernces, but have not yet found the
- // ends.
- // We'll look for the end of differences by going backwards down
- // the two lists.
- // Here we need a seperate index for each array, since they may be
- // (and
- // probably are) of different lengths.
- int indexOld = oldNodes.getLength() - 1;
- int indexNew = newNodes.getLength() - 1;
- // The greaterThanEffectedRegion is important to gaurd against
- // incorrect counting
- // when something identical is inserted to what's already there
- // (see minimization test case 5)
- // Note: the indexOld > startOfDifferences keeps indexOld from
- // getting too small,
- // so that the subsequent oldNodes.item(indexOld) is always valid.
- while ((indexOld >= startOfDifferences) && (_greaterThanEffectedRegion(oldNodes.item(indexOld)))) {
- if (!(oldNodes.item(indexOld).sameAs(newNodes.item(indexNew), fLengthDifference))) {
- break;
- }
- else {
- // if they are equal, then we will be keeping the old one,
- // so
- // we need to be sure its parentDocument is set back to the
- // right instance
- oldNodes.item(indexOld).setParentDocument(fStructuredDocument);
- }
- indexOld--;
- indexNew--;
- }
- endOfDifferencesOld = indexOld;
- endOfDifferencesNew = indexNew;
- minimalOldNodes = _formMinimumList(oldNodes, startOfDifferences, endOfDifferencesOld);
- minimalNewNodes = _formMinimumList(newNodes, startOfDifferences, endOfDifferencesNew);
- } /////////////////////////////////////////
- //
- IStructuredDocumentRegion firstDownStreamNode = null;
- event = regionCheck(minimalOldNodes, minimalNewNodes);
- if (event != null) {
- firstDownStreamNode = minimalOldNodes.item(0).getNext();
- if (firstDownStreamNode != null && fLengthDifference != 0) { // if
- // firstDownStream
- // is
- // null,
- // then
- // we're
- // at
- // the
- // end
- // of
- // the
- // document
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- } //
- }
- else {
- event = nodesReplacedCheck(minimalOldNodes, minimalNewNodes);
- // now splice the new chain of nodes to where the old chain is (or
- // was)
- // the firstDownStreamNode (the first of those after the new nodes)
- // is
- // remembered as a tiny optimization.
- if (minimalOldNodes.getLength() == 0 && minimalNewNodes.getLength() > 0) {
- // if no old nodes are being deleted, then use the
- // the newNodes offset (minus one) to find the point to
- // update downstream nodes, and after updating downstream
- // nodes postions, insert the new ones.
- int insertOffset = minimalNewNodes.item(0).getStartOffset();
- IStructuredDocumentRegion lastOldUnchangedNode = null;
- if (insertOffset > 0) {
- lastOldUnchangedNode = fStructuredDocument.getRegionAtCharacterOffset(insertOffset - 1);
- firstDownStreamNode = lastOldUnchangedNode.getNext();
- }
- else {
- // we're inserting at very beginning
- firstDownStreamNode = fStructuredDocument.getFirstStructuredDocumentRegion();
- // SIDE EFFECT: change the firstNode pointer if we're
- // inserting at beginning
- fStructuredDocument.setFirstDocumentRegion(minimalNewNodes.item(0));
- }
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- insertNodes(lastOldUnchangedNode, firstDownStreamNode, minimalNewNodes);
- // this (nodes replaced) is the only case where we need to
- // update the cached Node
- reSetCachedNode(minimalOldNodes, minimalNewNodes);
- }
- else {
- firstDownStreamNode = switchNodeLists(minimalOldNodes, minimalNewNodes);
- // no need to adjust the length of the new nodes themselves,
- // they
- // are already correct, but we do need to
- // adjust all "down stream" nodes with the length of the
- // insertion or deletion
- // --- adjustment moved to calling method.
- if (firstDownStreamNode != null) {
- // && event != null
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- } //
- // this (nodes replaced) is the only case where we need to
- // update the cached Node
- reSetCachedNode(minimalOldNodes, minimalNewNodes);
- }
- }
- return event;
- }
-
- protected StructuredDocumentEvent nodesReplacedCheck(CoreNodeList oldNodes, CoreNodeList newNodes) {
- // actually, nothing to check here, since (and assuming) we've already
- // minimized the number of nodes, and ruled out mere region changes
- StructuredDocumentEvent result = new StructuredDocumentRegionsReplacedEvent(fStructuredDocument, fRequester, oldNodes, newNodes, fChanges, fStart, fLengthToReplace);
- return result;
- }
-
- /**
- * A method to allow any heuristic "quick checks" that might cover many
- * many cases, before expending the time on a full reparse.
- *
- */
- public StructuredDocumentEvent quickCheck() {
- StructuredDocumentEvent result = null;
- // if the dirty start is null, then we have an empty document.
- // in which case we'll return null so everything can be
- // reparsed "from scratch" . If its not null, we'll give the flatnode a
- // chance
- // to handle, but only if there is one flatnode involved.
- if (dirtyStart != null && dirtyStart == dirtyEnd) {
- IStructuredDocumentRegion targetNode = dirtyStart;
- result = dirtyStart.updateModel(fRequester, targetNode, fChanges, fStart, fLengthToReplace);
- if (result != null) {
- // at this point only, we need to update the text store and
- // and downstream nodes.
- // FUTURE_TO_DO: can this dependency on structuredDocument
- // method be eliminated?
- fStructuredDocument.updateParentDocument(fStart, fLengthToReplace, fChanges);
- IStructuredDocumentRegion firstDownStreamNode = targetNode.getNext();
- // then flatnode must have been the last one, so need to update
- // any downstream ones
- if (firstDownStreamNode != null) {
- StructuredDocumentRegionIterator.adjustStart(firstDownStreamNode, fLengthDifference);
- }
- }
- }
- if (result != null) {
- result.setDeletedText(fDeletedText);
- }
- return result;
- }
-
- /**
- * If only one node is involved, sees how many regions are changed. If only
- * one, then its a 'regionChanged' event ... if more than one, its a
- * 'regionsReplaced' event.
- */
- protected StructuredDocumentEvent regionCheck(IStructuredDocumentRegion oldNode, IStructuredDocumentRegion newNode) {
- //
- StructuredDocumentEvent result = null;
- ITextRegionList oldRegions = oldNode.getRegions();
- ITextRegionList newRegions = newNode.getRegions();
- // Also causes ArrayStoreExceptions when we encounter a container
- // ITextRegion[] oldRegionsArray = new
- // ITextRegion[] newRegionsArray = new
- ITextRegion[] oldRegionsArray = oldRegions.toArray();
- ITextRegion[] newRegionsArray = newRegions.toArray();
- //
- // for the 'regionsReplaced' event, we don't care if
- // the regions changed due to type, or text,
- // we'll just collect all those that are not equal
- // into the old and new region lists.
- // Note: we, of course, assume that old and new regions
- // are basically contiguous -- and we force it to be so,
- // even if not literally so, by starting at beginning to
- // find first difference, and then starting at end to find
- // last difference. Everything in between we assume is different.
- //
- // going up is easy, we start at zero in each, and continue
- // till regions are not the same.
- int startOfDifferences = _computeStartOfDifferences(oldNode, oldRegions, newNode, newRegions);
- int endOfDifferencesOld = -1;
- int endOfDifferencesNew = -1;
- //
- //
- // if one of the lists are shorter than where the differences start,
- // then
- // then some portion of the lists are identical
- if ((startOfDifferences >= oldRegions.size()) || (startOfDifferences >= newRegions.size())) {
- if (oldRegions.size() < newRegions.size()) {
- // INSERT CASE
- // then there are new regions to add
- // these lengths will cause the vector of old ones to not
- // have any elements, and the vector of new regions to have
- // just the new ones.
- startOfDifferences = oldRegionsArray.length;
- endOfDifferencesOld = oldRegionsArray.length - 1;
- endOfDifferencesNew = newRegionsArray.length - 1;
- }
- else {
- if (oldRegions.size() > newRegions.size()) {
- // DELETE CASE
- // then there are old regions to delete
- // these lengths will cause the vector of old regions to
- // contain the ones to delete, and the vector of new
- // regions
- // not have any elements
- startOfDifferences = newRegionsArray.length;
- endOfDifferencesOld = oldRegionsArray.length - 1;
- endOfDifferencesNew = newRegionsArray.length - 1;
- }
- else {
- // else the lists are identical!
- // unlikely event, probably error in current design, since
- // we check for identity at the very beginning of
- // reparsing.
- result = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- }
- }
- }
- else {
- if ((startOfDifferences > -1) && (endOfDifferencesOld < 0) && (endOfDifferencesNew < 0)) {
- // We found a normal startOfDiffernces, but have not yet found
- // the ends.
- // We'll look for the end of differences by going backwards
- // down the two lists.
- // Here we need a seperate index for each array, since they may
- // be (and
- // probably are) of different lengths.
- int indexOld = oldRegionsArray.length - 1;
- int indexNew = newRegionsArray.length - 1;
- while ((indexOld >= startOfDifferences) && (_greaterThanEffectedRegion(oldNode, oldRegionsArray[indexOld]))) {
- if ((!(oldNode.sameAs(oldRegionsArray[indexOld], newNode, newRegionsArray[indexNew], fLengthDifference)))) {
- //endOfDifferencesOld = indexOne;
- //endOfDifferencesNew = indexTwo;
- break;
- }
- indexOld--;
- indexNew--;
- }
- endOfDifferencesOld = indexOld;
- endOfDifferencesNew = indexNew;
- }
- }
- //
- // result != null means the impossible case above occurred
- if (result == null) {
- // Now form the two vectors of different regions
- ITextRegionList holdOldRegions = new TextRegionListImpl();
- ITextRegionList holdNewRegions = new TextRegionListImpl();
- if (startOfDifferences > -1 && endOfDifferencesOld > -1) {
- for (int i = startOfDifferences; i <= endOfDifferencesOld; i++) {
- holdOldRegions.add(oldRegionsArray[i]);
- }
- }
- if (startOfDifferences > -1 && endOfDifferencesNew > -1) {
- for (int i = startOfDifferences; i <= endOfDifferencesNew; i++) {
- holdNewRegions.add(newRegionsArray[i]);
- }
- }
- if (holdOldRegions.size() == 0 && holdNewRegions.size() == 0) {
- // then this means the regions were identical, which means
- // someone
- // pasted exactly the same thing they had selected, or !!!
- // someone deleted the end bracket of the tag. !!!?
- result = new NoChangeEvent(fStructuredDocument, fRequester, fChanges, fStart, fLengthToReplace);
- }
- else {
- //If both holdOldRegions and holdNewRegions are of length 1,
- // then its
- // a "region changed" event, else a "regions replaced" event.
- // so we want the new instance of region to become part of the
- // old instance of old node
- if ((holdOldRegions.size() == 1) && (holdNewRegions.size() == 1) && _regionsSameKind((holdNewRegions.get(0)), (holdOldRegions.get(0)))) {
- ITextRegion newOldRegion = swapNewForOldRegion(oldNode, holdOldRegions.get(0), newNode, holdNewRegions.get(0));
- // -- need to update any down stream regions, within this
- // 'oldNode'
- updateDownStreamRegions(oldNode, newOldRegion);
- result = new RegionChangedEvent(fStructuredDocument, fRequester, oldNode, newOldRegion, fChanges, fStart, fLengthToReplace);
- }
- else {
- replaceRegions(oldNode, holdOldRegions, newNode, holdNewRegions);
- // -- need to update any down stream regions, within this
- // 'oldNode'
- // don't need with the way replaceRegions is implemented.
- // It handles.
- //if(holdNewRegions.size() > 0)
- //updateDownStreamRegions(oldNode, (ITextRegion)
- // holdNewRegions.lastElement());
- result = new RegionsReplacedEvent(fStructuredDocument, fRequester, oldNode, holdOldRegions, holdNewRegions, fChanges, fStart, fLengthToReplace);
- }
- }
- }
- return result;
- }
-
- /**
- * If only one node is involved, sees how many regions are changed. If only
- * one, then its a 'regionChanged' event ... if more than one, its a
- * 'regionsReplaced' event.
- */
- protected StructuredDocumentEvent regionCheck(CoreNodeList oldNodes, CoreNodeList newNodes) {
- if (Debug.debugStructuredDocument)
- System.out.println("IStructuredDocument::regionsReplacedCheck"); //$NON-NLS-1$
- //$NON-NLS-1$
- //$NON-NLS-1$
- // the "regionsReplaced" event could only be true if and only if the
- // nodelists
- // are each only "1" in length.
- StructuredDocumentEvent result = null;
- int oldLength = oldNodes.getLength();
- int newLength = newNodes.getLength();
- if ((oldLength != 1) || (newLength != 1)) {
- result = null;
- }
- else {
- IStructuredDocumentRegion oldNode = oldNodes.item(0);
- IStructuredDocumentRegion newNode = newNodes.item(0);
- result = regionCheck(oldNode, newNode);
- }
- return result;
- }
-
- /**
- * An entry point for reparsing. It calculates the dirty start and dirty
- * end flatnodes based on the start point and length of the changes.
- *
- */
- public StructuredDocumentEvent reparse() {
- StructuredDocumentEvent result = null;
- // if we do not have a cachedNode, then the document
- // must be empty, so simply use 'null' as the dirtyStart and dirtyEnd
- // otherwise, find them.
- if (fStructuredDocument.getCachedDocumentRegion() != null) {
- findDirtyStart(fStart);
- int end = fStart + fLengthToReplace;
- findDirtyEnd(end);
- }
- if (fStructuredDocument.getCachedDocumentRegion() != null) {
- result = checkHeuristics();
- }
- if (result == null) {
- result = reparse(dirtyStart, dirtyEnd);
- }
- endReParse();
- return result;
- }
-
- /**
- * An entry point for reparsing. It calculates the dirty start and dirty
- * end flatnodes based on suggested positions to begin and end. This is
- * needed for cases where parsing must go beyond the immediate node and its
- * direct neighbors.
- *
- */
- protected StructuredDocumentEvent reparse(int reScanStartHint, int reScanEndHint) {
- StructuredDocumentEvent result = null;
- // if we do not have a cachedNode, then the document
- // must be empty, so simply use 'null' as the dirtyStart and dirtyEnd
- if (fStructuredDocument.getCachedDocumentRegion() != null) {
- findDirtyStart(reScanStartHint);
- findDirtyEnd(reScanEndHint);
- }
- result = reparse(dirtyStart, dirtyEnd);
- isParsing = false;
- // debug
- //verifyStructured(result);
- return result;
- }
-
- private void verifyStructured(StructuredDocumentEvent event) {
- if (event instanceof StructuredDocumentRegionsReplacedEvent) {
- StructuredDocumentRegionsReplacedEvent nodesReplacedEvent = (StructuredDocumentRegionsReplacedEvent) event;
- IStructuredDocumentRegionList list = nodesReplacedEvent.getNewStructuredDocumentRegions();
- for (int i = 0; i < list.getLength(); i++) {
- IStructuredDocument parentDocument = list.item(i).getParentDocument();
- if (parentDocument instanceof MinimalDocument) {
- throw new IllegalStateException("invalid result"); //$NON-NLS-1$
- }
- }
- }
- else if (event instanceof RegionChangedEvent) {
- RegionChangedEvent regionChangedEvent = (RegionChangedEvent) event;
- IStructuredDocument parentDocument = regionChangedEvent.getStructuredDocumentRegion().getParentDocument();
- if (parentDocument instanceof MinimalDocument) {
- throw new IllegalStateException("invalid result"); //$NON-NLS-1$
- }
- }
- else if (event instanceof RegionsReplacedEvent) {
- RegionsReplacedEvent regionsReplacedEvent = (RegionsReplacedEvent) event;
- IStructuredDocument parentDocument = regionsReplacedEvent.getStructuredDocumentRegion().getParentDocument();
- if (parentDocument instanceof MinimalDocument) {
- throw new IllegalStateException("invalid result"); //$NON-NLS-1$
- }
- }
- else if (event instanceof NewModelEvent) {
- NewModelEvent newModelEvent = (NewModelEvent) event;
- IStructuredDocument parentDocument = newModelEvent.getStructuredDocument();
- if (parentDocument instanceof MinimalDocument) {
- throw new IllegalStateException("invalid result"); //$NON-NLS-1$
- }
- IStructuredDocumentRegionList list = parentDocument.getRegionList();
- for (int i = 0; i < list.getLength(); i++) {
- IStructuredDocument innerParentDocument = list.item(i).getParentDocument();
- if (innerParentDocument instanceof MinimalDocument) {
- throw new IllegalStateException("invalid result"); //$NON-NLS-1$
- }
- }
-
- }
- }
-
- /**
- * The core reparsing method ... after the dirty start and dirty end have
- * been calculated elsewhere.
- */
- protected StructuredDocumentEvent reparse(IStructuredDocumentRegion dirtyStart, IStructuredDocumentRegion dirtyEnd) {
- StructuredDocumentEvent result = null;
- int rescanStart = -1;
- int rescanEnd = -1;
- boolean firstTime = false;
- //
- // "save" the oldNodes (that may be replaced) in a list
- CoreNodeList oldNodes = formOldNodes(dirtyStart, dirtyEnd);
- if (dirtyStart == null || dirtyEnd == null) {
- // dirtyStart or dirty end are null, then that means we didn't have
- // a
- // cached node, which means we have an empty document, so we
- // just need to rescan the changes
- rescanStart = 0;
- rescanEnd = fChanges.length();
- firstTime = true;
- }
- else {
- // set the start of the text to rescan
- rescanStart = dirtyStart.getStart();
- //
- // set the end of the text to rescan
- // notice we use the same rationale as for the rescanStart,
- // with the added caveat that length has to be added to it,
- // to compensate for the new text which has been added or deleted.
- // If changes has zero length, then "length" will be negative,
- // since
- // we are deleting text. Otherwise, use the difference between
- // what's selected to be replaced and the length of the new text.
- rescanEnd = dirtyEnd.getEnd() + fLengthDifference;
- }
- // now that we have the old stuff "saved" away, update the document
- // with the changes.
- // FUTURE_TO_DO -- don't fire "document changed" event till later
- fStructuredDocument.updateParentDocument(fStart, fLengthToReplace, fChanges);
- // ------------------ now the real work
- result = core_reparse(rescanStart, rescanEnd, oldNodes, firstTime);
- //
- // event is returned to the caller, incase there is
- // some opitmization they can do
- return result;
- }
-
- protected void replaceRegions(IStructuredDocumentRegion oldNode, ITextRegionList oldRegions, IStructuredDocumentRegion newNode, ITextRegionList newRegions) {
- int insertPos = -1;
- ITextRegionList regions = oldNode.getRegions();
- // make a fake flatnode to be new parent of oldRegions, so their text
- // will be right.
- //IStructuredDocumentRegion holdOldStructuredDocumentRegion = new
- // BasicStructuredDocumentRegion(oldNode);
- //
- // need to reset the parent of the new to-be-inserted regions to be the
- // same oldNode that is the one having its regions changed
- // DW, 4/16/2003, removed since ITextRegion no longer has parent.
- // ITextRegionContainer oldParent = oldNode;
- // for (int i = 0; i < newRegions.size(); i++) {
- // AbstractRegion region = (AbstractRegion) newRegions.elementAt(i);
- // region.setParent(oldParent);
- // }
- // if there are no old regions, insert the new regions according to
- // offset
- if (oldRegions.size() == 0) {
- ITextRegion firstNewRegion = newRegions.get(0);
- int firstOffset = newNode.getStartOffset(firstNewRegion);
- // if at beginning, insert there
- if (firstOffset == 0) {
- insertPos = 0;
- }
- else {
- //
- ITextRegion regionAtOffset = oldNode.getRegionAtCharacterOffset(firstOffset);
- if (regionAtOffset == null)
- insertPos = regions.size();
- else
- insertPos = regions.indexOf(regionAtOffset);
- }
- }
- else {
- // else, delete old ones before inserting new ones in their place
- ITextRegion firstOldRegion = oldRegions.get(0);
- insertPos = regions.indexOf(firstOldRegion);
- regions.removeAll(oldRegions);
- }
- regions.addAll(insertPos, newRegions);
- // now regions vector of each node should be of equal length,
- // so go through each, and make sure the old regions
- // offsets matches the new regions offsets
- // (we'll just assign them all, but could be slightly more effiecient)
- ITextRegionList allNewRegions = newNode.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion nextOldishRegion = regions.get(i);
- ITextRegion nextNewRegion = allNewRegions.get(i);
- nextOldishRegion.equatePositions(nextNewRegion);
- checkAndAssignParent(oldNode, nextOldishRegion);
- }
- oldNode.setLength(newNode.getLength());
- oldNode.setEnded(newNode.isEnded());
- oldNode.setParentDocument(newNode.getParentDocument());
- // removed concept of part of these regions, so no longer need to do.
- // for (int i = 0; i < oldRegions.size(); i++) {
- // ITextRegion region = (ITextRegion) oldRegions.elementAt(i);
- // region.setParent(holdOldStructuredDocumentRegion);
- // }
- }
-
- private void checkAndAssignParent(IStructuredDocumentRegion oldNode, ITextRegion region) {
- if (region instanceof ITextRegionContainer) {
- ((ITextRegionContainer) region).setParent(oldNode);
- return;
- }
- if (region instanceof ITextRegionCollection) {
- ITextRegionCollection textRegionCollection = (ITextRegionCollection) region;
- ITextRegionList regionList = textRegionCollection.getRegions();
- for (int i = 0; i < regionList.size(); i++) {
- ITextRegion innerRegion = regionList.get(i);
- checkAndAssignParent(oldNode, innerRegion);
- }
- }
- }
-
- private void reSetCachedNode(CoreNodeList oldNodes, CoreNodeList newNodes) {
- // use the last newNode as the new cachedNode postion, unless its null
- // (e.g. when nodes are deleted) in which case, assign
- // it to a "safe" node so we don't lose reference to the
- // structuredDocument!
- if (newNodes.getLength() > 0) {
- // use last new node as the cache
- fStructuredDocument.setCachedDocumentRegion(newNodes.item(newNodes.getLength() - 1));
- }
- else {
- // if cachedNode is an old node, then we're in trouble:
- // we can't leave it as the cached node! and its already
- // been disconnected from the model, so we can't do getNext
- // or getPrevious, so we'll get one that is right before
- // (or right after) the offset of the old nodes that are being
- // deleted.
- //
- // if newNodesHead and cachedNode are both null, then
- // it means we were asked to insert an empty string into
- // an empty document. So we have nothing to do here
- // (that is, we have no node to cache)
- // similarly if there are no new nodes and no old nodes then
- // nothing to do (but that should never happen ... we shouldn't
- // get there if there is no event to generate).
- if ((fStructuredDocument.getCachedDocumentRegion() != null) && (oldNodes.getLength() > 0)) {
- // note: we can't simple use nodeAtCharacterOffset, since it
- // depends on cachedNode.
- if (oldNodes.includes(fStructuredDocument.getCachedDocumentRegion()))
- fStructuredDocument.setCachedDocumentRegion(fStructuredDocument.getFirstStructuredDocumentRegion());
- }
- if ((fStructuredDocument.getCachedDocumentRegion() == null) && (Debug.displayWarnings)) {
- // this will happen now legitamately when all text is deleted
- // from a document
- System.out.println("Warning: StructuredDocumentReParser::reSetCachedNode: could not find a node to cache! (its ok if all text deleted)"); //$NON-NLS-1$
- }
- }
- }
-
- /**
- * @param newstructuredDocument
- */
- public void setStructuredDocument(IStructuredDocument newStructuredDocument) {
- // NOTE: this method (and class) depend on being able to
- // do the following cast (i.e. references some fields directly)
- fStructuredDocument = (BasicStructuredDocument) newStructuredDocument;
- fFindReplaceDocumentAdapter = null;
- }
-
- private IStructuredDocumentRegion splice(CoreNodeList oldNodes, CoreNodeList newNodes) {
- //
- IStructuredDocumentRegion firstOld = null;
- IStructuredDocumentRegion firstNew = null;
- IStructuredDocumentRegion lastOld = null;
- IStructuredDocumentRegion lastNew = null;
- //
- IStructuredDocumentRegion oldPrevious = null;
- IStructuredDocumentRegion oldNext = null;
- IStructuredDocumentRegion newPrevious = null;
- IStructuredDocumentRegion newNext = null;
- //
- // if called with both arguments empty lists, we can disregard.
- // this happens, for example, when some text is replaced with the
- // identical text.
- if ((oldNodes.getLength() == 0) && (newNodes.getLength() == 0)) {
- return null;
- }
- // get pointers
- if (newNodes.getLength() > 0) {
- firstNew = newNodes.item(0);
- lastNew = newNodes.item(newNodes.getLength() - 1);
- }
- //
- if (oldNodes.getLength() > 0) {
- firstOld = oldNodes.item(0);
- lastOld = oldNodes.item(oldNodes.getLength() - 1);
- if (firstOld != null)
- oldPrevious = firstOld.getPrevious();
- if (lastOld != null)
- oldNext = lastOld.getNext();
- }
- // handle switch
- if (newNodes.getLength() > 0) {
- // switch surrounding StructuredDocumentRegions' references to
- // lists
- if (oldPrevious != null)
- oldPrevious.setNext(firstNew);
- if (newPrevious != null)
- newPrevious.setNext(firstOld);
- if (oldNext != null)
- oldNext.setPrevious(lastNew);
- if (newNext != null)
- newNext.setPrevious(lastOld);
- // switch list pointers to surrounding StructuredDocumentRegions
- if (firstOld != null)
- firstOld.setPrevious(newPrevious);
- if (lastOld != null)
- lastOld.setNext(newNext);
- if (firstNew != null)
- firstNew.setPrevious(oldPrevious);
- if (lastNew != null)
- lastNew.setNext(oldNext);
- }
- else {
- // short circuit when there are no new nodes
- if (oldPrevious != null)
- oldPrevious.setNext(oldNext);
- if (oldNext != null)
- oldNext.setPrevious(oldPrevious);
- }
- //
- // SIDE EFFECTs
- // if we have oldNodes, and if oldNext or oldPrevious is null,
- // that means we are replacing
- // the lastNode or firstNode the structuredDocuments's chain of nodes,
- // so we need to update the structuredDocuments last or first Node
- // as the last or first of the new nodes.
- // (and sometimes even these will be null! such as when deleting all
- // text in a document).
- if ((oldNext == null) && (oldNodes.getLength() > 0)) {
- if (newNodes.getLength() > 0) {
- fStructuredDocument.setLastDocumentRegion(lastNew);
- }
- else {
- // in this case, the last node is being deleted, but not
- // replaced
- // with anything. In this case, we can just back up one
- // from the first old node
- fStructuredDocument.setLastDocumentRegion(firstOld.getPrevious());
- }
- }
- if ((oldPrevious == null) && (oldNodes.getLength() > 0)) {
- if (newNodes.getLength() > 0) {
- fStructuredDocument.setFirstDocumentRegion(firstNew);
- }
- else {
- // in this case the first node is being deleted, but not
- // replaced
- // with anything. So, we just go one forward past the last old
- // node.
- fStructuredDocument.setFirstDocumentRegion(lastOld.getNext());
- }
- }
- // as a tiny optimization, we return the first of the downstream nodes,
- // if any
- return oldNext;
- }
-
- /**
- * The purpose of this method is to "reuse" the old container region, when
- * found to be same (so same instance doesn't change). The goal is to
- * "transform" the old region, so its equivelent to the newly parsed one.
- *
- */
- private ITextRegion swapNewForOldRegion(IStructuredDocumentRegion oldNode, ITextRegion oldRegion, IStructuredDocumentRegion newNode, ITextRegion newRegion) {
- // makes the old region instance the correct size.
- oldRegion.equatePositions(newRegion);
- // adjusts old node instance appropriately
- oldNode.setLength(newNode.getLength());
- oldNode.setEnded(newNode.isEnded());
- // we do have to set the parent document, since the oldNode's
- // were set to a temporary one, then newNode's have the
- // right one.
- oldNode.setParentDocument(newNode.getParentDocument());
- // if we're transforming a container region, we need to be sure to
- // transfer the new embedded regions, to the old parent
- // Note: if oldRegion hasEmbeddedRegions, then we know the
- // newRegion does too, since we got here because they were the
- // same type.
- if (isCollectionRegion(oldRegion)) { // ||
- // hasContainerRegions(oldRegion))
- // {
- transferEmbeddedRegions(oldNode, (ITextRegionContainer) oldRegion, (ITextRegionContainer) newRegion);
- }
- return oldRegion;
- }
-
- private IStructuredDocumentRegion switchNodeLists(CoreNodeList oldNodes, CoreNodeList newNodes) {
- IStructuredDocumentRegion result = splice(oldNodes, newNodes);
- // ensure that the old nodes hold no references to the existing model
- if (oldNodes.getLength() > 0) {
- IStructuredDocumentRegion firstItem = oldNodes.item(0);
- firstItem.setPrevious(null);
- IStructuredDocumentRegion lastItem = oldNodes.item(oldNodes.getLength() - 1);
- lastItem.setNext(null);
- }
- return result;
- }
-
- /**
- * The purpose of this method is to "reuse" the old container region, when
- * found to be same (so same instance doesn't change). The goal is to
- * "transform" the old region, so its equivelent to the newly parsed one.
- *
- */
- private void transferEmbeddedRegions(IStructuredDocumentRegion oldNode, ITextRegionContainer oldRegion, ITextRegionContainer newRegion) {
- // the oldRegion should already have the right parent, since
- // we got here because all's equivelent except the region
- // postions have changed.
- //oldRegion.setParent(newRegion.getParent());
- // but we should check if there's "nested" embedded regions, and if
- // so, we can just move them over. setting their parent as this old
- // region.
- ITextRegionList newRegionsToTransfer = newRegion.getRegions();
- oldRegion.setRegions(newRegionsToTransfer);
- Iterator newRegionsInOldOne = newRegionsToTransfer.iterator();
- while (newRegionsInOldOne.hasNext()) {
- ITextRegion newOne = (ITextRegion) newRegionsInOldOne.next();
- if (isCollectionRegion(newOne)) { // ||
- // hasContainerRegions(newOne)) {
- //((ITextRegionContainer) newOne).setParent(oldRegion);
- oldRegion.setRegions(newRegion.getRegions());
- }
- }
- }
-
- private void updateDownStreamRegions(IStructuredDocumentRegion flatNode, ITextRegion lastKnownRegion) {
- // so all regions after the last known region (last known to be ok)
- // have to have their start and end values adjusted.
- ITextRegionList regions = flatNode.getRegions();
- int listLength = regions.size();
- int startIndex = 0;
- // first, loop through to find where to start
- for (int i = 0; i < listLength; i++) {
- ITextRegion region = regions.get(i);
- if (region == lastKnownRegion) {
- startIndex = i;
- break;
- }
- }
- // now, beginning one past the last known one, loop
- // through to end of list, adjusting the start and end postions.
- startIndex++;
- for (int j = startIndex; j < listLength; j++) {
- ITextRegion region = regions.get(j);
- region.adjustStart(fLengthDifference);
- }
- }
-
- public IStructuredTextReParser newInstance() {
- return new StructuredDocumentReParser();
- }
-
- /**
- * @return Returns the findReplaceDocumentAdapter.
- */
- public FindReplaceDocumentAdapter getFindReplaceDocumentAdapter() {
- if (fFindReplaceDocumentAdapter == null) {
- fFindReplaceDocumentAdapter = new FindReplaceDocumentAdapter(fStructuredDocument);
- }
- return fFindReplaceDocumentAdapter;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.java
deleted file mode 100644
index e8b6281c46..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionEnumeration.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.core.internal.text;
-
-
-
-import java.util.Enumeration;
-import java.util.NoSuchElementException;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.util.Debug;
-
-
-public class StructuredDocumentRegionEnumeration implements Enumeration {
-
- private int count;
- private IStructuredDocumentRegion head;
- private IStructuredDocumentRegion oldHead;
-
- /**
- * StructuredDocumentRegionEnumeration constructor comment.
- */
- public StructuredDocumentRegionEnumeration(IStructuredDocumentRegion newHead) {
- super();
- IStructuredDocumentRegion countNode = head = newHead;
- while (countNode != null) {
- count++;
- countNode = countNode.getNext();
- }
- if (Debug.DEBUG > 5) {
- System.out.println("N Nodes in StructuredDocumentRegionEnumeration Contructor: " + count); //$NON-NLS-1$
- }
- }
-
- /**
- * StructuredDocumentRegionEnumeration constructor comment.
- */
- public StructuredDocumentRegionEnumeration(IStructuredDocumentRegion start, IStructuredDocumentRegion end) {
- super();
- IStructuredDocumentRegion countNode = head = start;
- if ((start == null) || (end == null)) {
- // error condition
- count = 0;
- return;
- }
- //If both nodes are non-null, we assume there is always at least one item
- count = 1;
- while (countNode != end) {
- count++;
- countNode = countNode.getNext();
- }
- if (org.eclipse.wst.sse.core.util.Debug.DEBUG > 5) {
- System.out.println("N Nodes in StructuredDocumentRegionEnumeration Contructor: " + count); //$NON-NLS-1$
- }
- }
-
- /**
- * hasMoreElements method comment.
- */
- public synchronized boolean hasMoreElements() {
- return count > 0;
- }
-
- /**
- * nextElement method comment.
- */
- public synchronized Object nextElement() {
- if (count > 0) {
- count--;
- oldHead = head;
- head = head.getNext();
- return oldHead;
- }
- throw new NoSuchElementException("StructuredDocumentRegionEnumeration"); //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.java
deleted file mode 100644
index fd3ab9eed9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/StructuredDocumentRegionIterator.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.core.internal.text;
-
-
-
-import java.util.Vector;
-
-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.util.Assert;
-
-
-public class StructuredDocumentRegionIterator {
-
- /**
- *
- */
- private StructuredDocumentRegionIterator() {
- }
-
- public final static IStructuredDocumentRegion adjustStart(IStructuredDocumentRegion headNode, int adjustment) {
- IStructuredDocumentRegion aNode = headNode;
- while (aNode != null) {
- aNode.adjustStart(adjustment);
- aNode = aNode.getNext();
- }
- return headNode;
- }
-
- public final static int countRegions(IStructuredDocumentRegionList flatNodes) {
- int result = 0;
- if (flatNodes != null) {
- int length = flatNodes.getLength();
- for (int i = 0; i < length; i++) {
- IStructuredDocumentRegion node = flatNodes.item(i);
- // don't know why, but we're getting null pointer exceptions in this method
- if (node != null) {
- result = result + node.getNumberOfRegions();
- }
- }
- }
- return result;
- }
-
- public final static String getText(CoreNodeList flatNodes) {
- String result = null;
- if (flatNodes == null) {
- result = ""; //$NON-NLS-1$
- }
- else {
- StringBuffer buff = new StringBuffer();
- //IStructuredDocumentRegion aNode = null;
- int length = flatNodes.getLength();
- for (int i = 0; i < length; i++) {
- buff.append(flatNodes.item(i).getText());
- }
- result = buff.toString();
- }
- return result;
- }
-
- // public final static IStructuredDocumentRegion setStructuredDocument(IStructuredDocumentRegion headNode, BasicStructuredDocument structuredDocument) {
- // IStructuredDocumentRegion aNode = headNode;
- // while (aNode != null) {
- // aNode.setParentDocument(structuredDocument);
- // aNode = (IStructuredDocumentRegion) aNode.getNext();
- // }
- // return headNode;
- // }
- public final static IStructuredDocumentRegion setParentDocument(IStructuredDocumentRegion headNode, IStructuredDocument document) {
- IStructuredDocumentRegion aNode = headNode;
- while (aNode != null) {
- aNode.setParentDocument(document);
- aNode = aNode.getNext();
- }
- return headNode;
- }
-
- public final static CoreNodeList setParentDocument(CoreNodeList nodelist, IStructuredDocument textStore) {
- Assert.isNotNull(nodelist, "nodelist was null in CoreNodeList::setTextStore(CoreNodeList, StructuredTextStore)"); //$NON-NLS-1$
- int len = nodelist.getLength();
- for (int i = 0; i < len; i++) {
- IStructuredDocumentRegion node = nodelist.item(i);
- //Assert.isNotNull(node, "who's putting null in the node list? in CoreNodeList::setTextStore(CoreNodeList, StructuredTextStore)"); //$NON-NLS-1$
- node.setParentDocument(textStore);
- }
- return nodelist;
- }
-
- public final static Vector toVector(IStructuredDocumentRegion headNode) {
- IStructuredDocumentRegion aNode = headNode;
- Vector v = new Vector();
- while (aNode != null) {
- v.addElement(aNode);
- aNode = aNode.getNext();
- }
- return v;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java
deleted file mode 100644
index 37c167ee85..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/SubSetTextStore.java
+++ /dev/null
@@ -1,126 +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.core.internal.text;
-
-/**
- * This is a convience or utility class that allows you to make a copy of a
- * part of a larger text store, but have the copy behave as if it was the
- * larger text store.
- *
- * In other words, it provides a subset of a larger document, that "looks like"
- * the orginal document. That is, "looks like" in terms of offsets and lengths.
- * Valid access can only be made to data between the orignal offsets, even
- * though those offsets are in the same units at the original, and even though
- * the length appears to be long.
- *
- * For example, if a subsettext store is created for the def part of abcdefgh,
- * then get(3,5) is valid, getLength is 8. Any other access, such as
- * getChar(2), would be invalid.
- */
-import org.eclipse.jface.text.ITextStore;
-
-/**
- * Similar to basics of IDocument, but the offsets are mapped from coordinates
- * of underlying storage to a "virtual" document.
- */
-public class SubSetTextStore implements ITextStore {
- private int pseudoBeginOffset; // maps to "zero" postion of new text
- private int pseudoEndOffset;
- private int pseudoLength; // length of old/original document
- private StringBuffer stringBuffer = new StringBuffer();
-
- /**
- * SubSetTextStore constructor comment.
- *
- * @param initialContent
- * java.lang.String
- */
- public SubSetTextStore(String initialContent, int beginOffset, int endOffset, int originalDocumentLength) {
- super();
- pseudoBeginOffset = beginOffset;
- pseudoEndOffset = endOffset;
- // used to be originalDocument.getLength ... not sure if used, or which
- // is right
- pseudoLength = originalDocumentLength;
- stringBuffer = new StringBuffer(initialContent);
- //set(initialContent);
- }
-
- /**
- * @return java.lang.String
- * @param begin
- * int
- * @param end
- * int
- */
- public String get(int begin, int length) {
- // remap the begin and end to "appear" to be in the
- // same coordinates of the original parentDocument
- return _get(begin - pseudoBeginOffset, length);
- }
-
- // this is our "private" get, which methods in this class should
- // use to get using "real" coordinates of underlying representation.
- private String _get(int begin, int length) {
- char[] chars = new char[length];
- int srcEnd = begin + length;
- stringBuffer.getChars(begin, srcEnd, chars, 0);
- return new String(chars);
- }
-
- /**
- * @return java.lang.String
- * @param begin
- * int
- * @param end
- * int
- */
- public char getChar(int pos) {
- // remap the begin and end to "appear" to be in the
- // same coordinates of the original parentDocument
- return get(pos - pseudoBeginOffset);
- }
-
- /**
- * We redefine getLength so its not the true length of this sub-set
- * document, but the length of the original. This is needed, as a simple
- * example, if you want to see if the pseudo end is equal the last position
- * of the original document.
- */
- public int getLength() {
- return pseudoLength;
- }
-
- /**
- * Returns the length as if considered a true, standalone document
- */
- public int getTrueLength() {
- return stringBuffer.length();
- }
-
- public void replace(int begin, int length, String changes) {
- // remap the begin and end to "appear" to be in the
- // same coordinates of the original parentDocument
- int end = begin + length;
- stringBuffer.replace(begin - pseudoBeginOffset, end, changes);
- }
-
- public char get(int offset) {
- return stringBuffer.charAt(offset - pseudoBeginOffset);
- }
-
- public void set(String text) {
- stringBuffer.setLength(0);
- stringBuffer.append(text);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java
deleted file mode 100644
index 129fd07b44..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/internal/text/TextRegionListImpl.java
+++ /dev/null
@@ -1,224 +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.core.internal.text;
-
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-
-
-public class TextRegionListImpl implements ITextRegionList {
-
- private ITextRegion[] fRegions;
- private int fRegionsCount = 0;
- private final static int growthConstant = 2;
-
- private class RegionIterator implements Iterator {
- private int index = -1;
- private int maxindex = -1;
- private ITextRegion[] fIteratorRegions;
-
- public RegionIterator() {
- fIteratorRegions = toArray();
- maxindex = fIteratorRegions.length - 1;
- }
-
- public boolean hasNext() {
- return index < maxindex;
- }
-
- public Object next() {
- if (!(index < maxindex))
- throw new NoSuchElementException();
- return fIteratorRegions[++index];
- }
-
- public void remove() {
- throw new UnsupportedOperationException("can not remove regions via iterator"); //$NON-NLS-1$
-
- }
-
- }
-
- private class NullIterator implements Iterator {
- public NullIterator() {
- }
-
- public boolean hasNext() {
- return false;
- }
-
- public Object next() {
- throw new NoSuchElementException();
- }
-
- public void remove() {
- throw new UnsupportedOperationException("can not remove regions via iterator"); //$NON-NLS-1$
-
- }
-
- }
-
- public TextRegionListImpl() {
- super();
- }
-
- public TextRegionListImpl(ITextRegionList regionList) {
- this();
- fRegions = (ITextRegion[]) regionList.toArray().clone();
- fRegionsCount = fRegions.length;
- }
-
- public boolean add(ITextRegion region) {
-
- if (region == null)
- return false;
- ensureCapacity(fRegionsCount + 1);
- fRegions[fRegionsCount++] = region;
- return true;
- }
-
- public ITextRegion get(int index) {
- if (index < 0 || index > fRegionsCount) {
- throw new ArrayIndexOutOfBoundsException(index);
- }
- ITextRegion result = fRegions[index];
- return result;
- }
-
- public void remove(ITextRegion a) {
- if (fRegions == null || a == null)
- return;
- int newIndex = 0;
- ITextRegion[] newRegions = new ITextRegion[fRegionsCount];
- int oldRegionCount = fRegionsCount;
- boolean found = false;
- for (int oldIndex = 0; oldIndex < oldRegionCount; oldIndex++) {
- ITextRegion candidate = fRegions[oldIndex];
- if (a == candidate) {
- fRegionsCount--;
- found = true;
- }
- else
- newRegions[newIndex++] = fRegions[oldIndex];
- }
- if (found)
- fRegions = newRegions;
- }
-
- private void ensureCapacity(int needed) {
- if (fRegions == null) {
- // first time
- fRegions = new ITextRegion[needed];
- return;
- }
- int oldLength = fRegions.length;
- if (oldLength < needed) {
- ITextRegion[] oldAdapters = fRegions;
- ITextRegion[] newAdapters = new ITextRegion[needed + growthConstant];
- System.arraycopy(oldAdapters, 0, newAdapters, 0, fRegionsCount);
- fRegions = newAdapters;
- }
- }
-
- public int size() {
- return fRegionsCount;
- }
-
- public void clear() {
- // note: size of array is not reduced!
- fRegionsCount = 0;
- }
-
- public boolean addAll(int insertPos, ITextRegionList newRegions) {
- // beginning of list is 0 to insertPos-1
- // remainder of list is insertPos to fRegionsCount
- // resulting total will be be fRegionsCount + newRegions.size()
- if (insertPos < 0 || insertPos > fRegionsCount) {
- throw new ArrayIndexOutOfBoundsException(insertPos);
- }
-
- int newRegionsSize = newRegions.size();
-
- ensureCapacity(fRegionsCount + newRegionsSize);
-
- int numMoved = fRegionsCount - insertPos;
- if (numMoved > 0)
- System.arraycopy(fRegions, insertPos, fRegions, insertPos + newRegionsSize, numMoved);
-
- for (int i = 0; i < newRegionsSize; i++)
- fRegions[insertPos++] = newRegions.get(i);
-
- fRegionsCount += newRegionsSize;
- return newRegionsSize != 0;
-
- }
-
- public boolean isEmpty() {
- return fRegionsCount == 0;
- }
-
- public Iterator iterator() {
- if (size() == 0) {
- return new NullIterator();
- }
- else {
- return new RegionIterator();
- }
- }
-
- public ITextRegion remove(int index) {
- // much more efficient ways to implement this, but
- // I doubt if called often
- ITextRegion oneToRemove = get(index);
- remove(oneToRemove);
- return oneToRemove;
- }
-
- public void removeAll(ITextRegionList regionList) {
- // much more efficient ways to implement this, but
- // I doubt if called often
- if (regionList != null) {
- for (int i = 0; i < regionList.size(); i++) {
- this.remove(regionList.get(i));
- }
- }
-
- }
-
- public ITextRegion[] toArray() {
- // return "clone" of internal array
- ITextRegion[] newArray = new ITextRegion[fRegionsCount];
- System.arraycopy(fRegions, 0, newArray, 0, fRegionsCount);
- return newArray;
- }
-
- public int indexOf(ITextRegion region) {
-
- int result = -1;
- if (region != null) {
- if (fRegions != null) {
- for (int i = 0; i < fRegions.length; i++) {
- if (region.equals(fRegions[i])) {
- result = i;
- break;
- }
- }
- }
- }
- return result;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java
deleted file mode 100644
index b8bb21c0af..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/AbstractModelHandler.java
+++ /dev/null
@@ -1,72 +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.core.modelhandler;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.internal.modelhandler.PluginContributedFactoryReader;
-
-
-public abstract class AbstractModelHandler implements IModelHandler {
- private String associatedContentTypeId;
- private String modelHandlerID;
- private boolean defaultSetting;
-
- public AbstractModelHandler() {
- super();
- }
-
- public boolean isDefault() {
- return defaultSetting;
- }
-
- public abstract IDocumentCharsetDetector getEncodingDetector();
-
- public String getAssociatedContentTypeId() {
- return associatedContentTypeId;
- }
-
- protected void setAssociatedContentTypeId(String contentTypeId) {
- associatedContentTypeId = contentTypeId;
- }
-
- public String getId() {
- return modelHandlerID;
- }
-
- protected void setId(String id) {
- modelHandlerID = id;
- }
-
- public void setDefault(boolean defaultParam) {
- defaultSetting = defaultParam;
- }
-
- /**
- * These factories are added automatically by model manager
- */
- public List getAdapterFactories() {
- List result = new ArrayList();
- Collection holdFactories = PluginContributedFactoryReader.getInstance().getFactories(this);
- if (holdFactories != null) {
- result.addAll(holdFactories);
- }
- return result;
- }
-
- // XXX: can be removed once we transition completely
- protected boolean USE_FILE_BUFFERS = false;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.java
deleted file mode 100644
index fd8cadc57a..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/EmbeddedTypeHandler.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.core.modelhandler;
-
-import java.util.List;
-
-import org.eclipse.wst.sse.core.IFactoryRegistry;
-import org.eclipse.wst.sse.core.parser.JSPCapableParser;
-
-
-/**
- */
-public interface EmbeddedTypeHandler {
-
- /**
- * Returns a list of mime tyeps (as Strings) this handler is appropriate for
- */
- List getSupportedMimeTypes();
-
- /**
- * Returns the unique identifier for the content type family this ContentTypeDescription
- * belongs to.
- */
- public String getFamilyId();
-
- /**
- * These AdapterFactories are NOT added to IStructuredModel's
- * AdapterFactory Registry ...
- * they are for use by "JSP Aware AdapterFactories"
- * The are added to the "registry" in the PageDirectiveAdapter.
- */
- List getAdapterFactories();
-
- /**
- * initializeParser
- * Its purpose is to setBlockTags
- */
- void initializeParser(JSPCapableParser parser);
-
- void uninitializeParser(JSPCapableParser parser);
-
- /**
- * This method is to give the EmbeddedContentType
- * an opportunity to add factories directly to the
- * IStructuredModel's AdapterFactory registry.
- */
- void initializeFactoryRegistry(IFactoryRegistry registry);
-
- void uninitializeFactoryRegistry(IFactoryRegistry registry);
-
- public EmbeddedTypeHandler newInstance();
-
- boolean isDefault();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.java
deleted file mode 100644
index 73639ff5aa..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IDocumentTypeHandler.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.core.modelhandler;
-
-import org.eclipse.wst.sse.core.document.IDocumentCharsetDetector;
-import org.eclipse.wst.sse.core.document.IDocumentLoader;
-
-/**
- * Interface to allow custom content types to be defined as
- * extension points in plugins.
- */
-public interface IDocumentTypeHandler {
-
- /**
- * The Loader is reponsible for decoding the Resource,
- */
- IDocumentLoader getDocumentLoader();
-
- /**
- * @deprecated - likely to go away, so I marked
- * as deprecated to discoursage use
- */
- IDocumentCharsetDetector getEncodingDetector();
-
- /**
- * Must return unique ID that is the
- * same as identified in plugin registry
- */
- String getId();
-
-
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.java
deleted file mode 100644
index 6f6da8f0e5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandler.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.core.modelhandler;
-
-import java.util.List;
-
-import org.eclipse.wst.sse.core.ModelLoader;
-
-
-public interface IModelHandler extends IDocumentTypeHandler {
- /**
- * This method should return Factories
- * which are added automatically
- * by IModelManager. This can and will often be an empty List
- * (or null),
- * since some AdapterFactories must be added
- * by Loader directly, and most should be added
- * by Editors. FormatAdapterFactory is an example of
- * one that can be returned here, since the timing of
- * adding it is not critical, but it may be needed
- * even when an editor is not being used.
- */
- List getAdapterFactories();
-
- boolean isDefault();
-
- /**
- * Returns the ID for the associated ContentTypeHandler
- * But is needed for now.
- */
- String getAssociatedContentTypeId();
-
- /**
- * The Loader is reponsible for decoding the Resource,
- */
- ModelLoader getModelLoader();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandlerForJSP.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandlerForJSP.java
deleted file mode 100644
index 9de730279b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelhandler/IModelHandlerForJSP.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.core.modelhandler;
-
-import org.eclipse.core.resources.IFile;
-
-public interface IModelHandlerForJSP extends IModelHandler {
-
- /**
- * This method leaves it completely up to the JSP Model Handler Handler
- * which EmbeddedTypeHandler to return.
- *
- * NOTE: may not stay, since leaves lots up to the implementer
- * of this content type
- *
- * @deprecated - see head comment
- */
- EmbeddedTypeHandler getEmbeddedContentHandlerFor(IFile iFile);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.java
deleted file mode 100644
index 8d16745ff0..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapter.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.core.modelquery;
-
-import org.eclipse.wst.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.xml.uriresolver.util.IdResolver;
-
-
-public interface ModelQueryAdapter extends INodeAdapter {
-
- public CMDocumentCache getCMDocumentCache();
-
- public IdResolver getIdResolver();
-
- public ModelQuery getModelQuery();
-
- void release();
-
- void setIdResolver(IdResolver newIdResolver);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.java
deleted file mode 100644
index 7f075e4c40..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/ModelQueryAdapterImpl.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.core.modelquery;
-
-
-
-import org.eclipse.wst.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.sse.core.INodeNotifier;
-import org.eclipse.wst.xml.uriresolver.util.IdResolver;
-
-
-public class ModelQueryAdapterImpl implements ModelQueryAdapter {
-
- protected ModelQuery modelQuery;
- protected IdResolver idResolver;
- protected CMDocumentCache cmDocumentCache;
-
- public ModelQueryAdapterImpl(CMDocumentCache cmDocumentCache, ModelQuery modelQuery, IdResolver idResolver) {
- this.cmDocumentCache = cmDocumentCache;
- this.modelQuery = modelQuery;
- this.idResolver = idResolver;
- }
-
- public CMDocumentCache getCMDocumentCache() {
- return cmDocumentCache;
- }
-
- public IdResolver getIdResolver() {
- return idResolver;
- }
-
- public ModelQuery getModelQuery() {
- return modelQuery;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type
- * allows it to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- return type.equals(ModelQueryAdapter.class);
- }
-
- /**
- */
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- /**
- * @see ModelQueryAdapter#setIdResolver(IdResolver)
- */
-
- public void setIdResolver(IdResolver newIdResolver) {
- idResolver = newIdResolver;
- if (modelQuery instanceof MovableModelQuery)
- ((MovableModelQuery) modelQuery).setIdResolver(newIdResolver);
- }
-
- /**
- * @see ModelQueryAdapter#release()
- */
- public void release() {
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.java
deleted file mode 100644
index df54b9790d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/modelquery/MovableModelQuery.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.core.modelquery;
-
-
-
-import org.eclipse.wst.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.uriresolver.util.IdResolver;
-
-public interface MovableModelQuery extends ModelQuery {
-
- void setIdResolver(IdResolver newIdResolver);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.java
deleted file mode 100644
index 9532439809..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockMarker.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.core.parser;
-
-
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-public class BlockMarker extends TagMarker {
-
- // allow for JSP expressions within the block
- protected boolean fAllowJSP = true;
-
- protected boolean fCaseSensitive = false;
-
- // the context for the contents of this tag (BLOCK_TEXT, JSP_CONTENT, etc.)
- protected String fContext;
-
- /**
- * It's not appropriate to make "empty" BlockMarker, so we'll
- * mark as private.
- */
- private BlockMarker() {
- super();
- }
-
- public BlockMarker(String tagName, ITextRegion marker, String context) {
- this(tagName, marker, context, true);
- }
-
- public BlockMarker(String tagName, ITextRegion marker, String context, boolean caseSensitive) {
- this(tagName, marker, context, caseSensitive, true);
- }
-
- /**
- * @deprecated - TODO: Nitin, this is used frequently, what's the substitue?
- * @param tagName
- * @param offset
- * @param context
- * @param caseSensitive
- */
- public BlockMarker(String tagName, int offset, String context, boolean caseSensitive) {
- this(tagName, null, context, caseSensitive, true);
- }
-
- public BlockMarker(String tagName, ITextRegion marker, String context, boolean caseSensitive, boolean allowJSP) {
- super(tagName, marker);
- setContext(context);
- setCaseSensitive(caseSensitive);
- setAllowJSP(allowJSP);
- }
-
- public BlockMarker(String tagName, String regionContext, boolean caseSensitive) {
- this(tagName, null, regionContext, caseSensitive, false);
- }
-
- /**
- * Gets the allowJSP.
- * @return Returns a boolean
- */
- public boolean allowsJSP() {
- return fAllowJSP;
- }
-
- /**
- * Gets the context.
- * @return Returns a String
- */
- public String getContext() {
- return fContext;
- }
-
- /**
- *
- * @return boolean
- */
- public final boolean isCaseSensitive() {
- return fCaseSensitive;
- }
-
- /**
- * Sets the allowJSP.
- * @param allowJSP The allowJSP to set
- */
- public void setAllowJSP(boolean allowJSP) {
- fAllowJSP = allowJSP;
- }
-
- public final void setCaseSensitive(boolean sensitive) {
- fCaseSensitive = sensitive;
- }
-
- /**
- * Sets the context.
- * @param context The context to set
- */
- public void setContext(String context) {
- fContext = context;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.java
deleted file mode 100644
index 4cff65d3c4..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTagParser.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.core.parser;
-
-
-
-import java.util.List;
-
-public interface BlockTagParser {
-
- void beginBlockScan(String tagName);
-
- void addBlockMarker(BlockMarker marker);
-
- BlockMarker getBlockMarker(String tagName);
-
- List getBlockMarkers();
-
- void removeBlockMarker(BlockMarker marker);
-
- void removeBlockMarker(String tagName);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.java
deleted file mode 100644
index 30851c6754..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/BlockTokenizer.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.core.parser;
-
-
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.Reader;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-
-public interface BlockTokenizer {
-
- void addBlockMarker(BlockMarker marker);
-
- void beginBlockMarkerScan(String newTagName, String context);
-
- void beginBlockTagScan(String newTagName);
-
- List getBlockMarkers();
-
- ITextRegion getNextToken() throws IOException;
-
- int getOffset();
-
- boolean isEOF();
-
- void removeBlockMarker(BlockMarker marker);
-
- void removeBlockMarker(String tagname);
-
- void reset(char[] charArray, int newOffset);
-
- void reset(char[] charArray);
-
- void reset(InputStream in, int newOffset);
-
- void reset(InputStream in);
-
- void reset(Reader in, int newOffset);
-
- void reset(Reader in);
-
- BlockTokenizer newInstance();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.java
deleted file mode 100644
index 38a2d6db15..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/IBlockedStructuredDocumentRegion.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.core.parser;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-/**
- *
- */
-public interface IBlockedStructuredDocumentRegion extends IStructuredDocumentRegion {
- String getPartitionType();
-
- void setPartitionType(String partitionType);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.java
deleted file mode 100644
index 3750bafbe3..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/JSPCapableParser.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.core.parser;
-
-import java.util.List;
-
-public interface JSPCapableParser extends RegionParser, BlockTagParser {
- void addNestablePrefix(TagMarker marker);
-
- /**
- * returns the TagMarkers for prefixes that are allowed to be nestable
- * @return
- */
- List getNestablePrefixes();
-
- void removeNestablePrefix(String tagName);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.java
deleted file mode 100644
index b213728d2b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/RegionParser.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.core.parser;
-
-
-
-import java.io.Reader;
-import java.util.List;
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-
-public interface RegionParser {
-
- IStructuredDocumentRegion getDocumentRegions();
-
- List getRegions();
-
- void reset(Reader reader);
-
- /**
- * An additional offset for use with any position-dependant parsing rules
- */
- void reset(Reader reader, int offset);
-
- void reset(String input);
-
- /**
- * An additional offset for use with any position-dependant parsing rules
- */
- void reset(String input, int offset);
-
- /**
- * The 'newInstance' method is similar to 'clone', but does
- * not include the copying of any content. For a pure RegionParser itself,
- * there would be little state to "clone", but for some subtypes,
- * such as StructuredDocumentRegionParser and JSPCapableParser, there could the more
- * internal data to "clone", such as the internal tokenizer
- * should be cloned (including block tags, etc).
- */
- RegionParser newInstance();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.java
deleted file mode 100644
index 44ae4f7c88..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionHandler.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.core.parser;
-
-
-
-import org.eclipse.wst.sse.core.text.IStructuredDocumentRegion;
-
-public interface StructuredDocumentRegionHandler {
-
- // Sent when a IStructuredDocumentRegion is first parsed
- public void nodeParsed(IStructuredDocumentRegion aCoreStructuredDocumentRegion);
-
- // Sent when the calling parser's model undergoes a full reset
- // and any information based upon the old model should be
- // cleared
- public void resetNodes();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.java
deleted file mode 100644
index 5c759a3b6d..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/StructuredDocumentRegionParser.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.core.parser;
-
-
-
-public interface StructuredDocumentRegionParser extends RegionParser {
-
- void addStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler);
-
- void removeStructuredDocumentRegionHandler(StructuredDocumentRegionHandler handler);
-
- void resetHandlers();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.java
deleted file mode 100644
index 81e4ba8cd9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/parser/TagMarker.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.core.parser;
-
-import org.eclipse.wst.sse.core.text.ITextRegion;
-
-public class TagMarker {
-
- // a ITextRegion (meant to be updated with the model) marking the position
- // where this tagname becomes effective
- protected ITextRegion fMarker = null;
-
- // the tagname
- protected String fTagName = null;
-
- /**
- *
- */
- public TagMarker() {
- super();
- }
-
- public TagMarker(String tagname) {
- super();
- setTagName(tagname);
- }
-
- public TagMarker(String tagname, ITextRegion marker) {
- super();
- setTagName(tagname);
- setMarker(marker);
- }
-
- /**
- */
- public final ITextRegion getMarker() {
- return fMarker;
- }
-
- /**
- * @return java.lang.String
- */
- public final String getTagName() {
- return fTagName;
- }
-
- /**
- * @return boolean
- */
- public boolean isGlobal() {
- return fMarker == null;
- }
-
- /**
- * @param newMarker
- */
- public final void setMarker(ITextRegion newMarker) {
- fMarker = newMarker;
- }
-
- /**
- * @param newTagname
- * java.lang.String
- */
- public final void setTagName(String newTagName) {
- fTagName = newTagName;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java
deleted file mode 100644
index cb3accc603..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/CommonModelPreferenceNames.java
+++ /dev/null
@@ -1,137 +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.core.preferences;
-
-import org.eclipse.wst.sse.core.internal.nls.ResourceHandler;
-
-/**
- * Here is a description of how each common model file preference is used.
- *
- * inputCodeset
- * The character code to use when reading a file.
- *
- * outputCodeset
- * The character code to use when writing a file.
- *
- * endOfLineCode
- * The End-of-line character(s) to use.
- *
- * tabWidth
- * The number of spaces representing a tab.
- * This number is also used as number of spaces to indent during formatting when indentUsingTabs is false.
- *
- * splitLines
- * Indicates if long lines should be splitted.
- *
- * splitLinesUsingEditorsWidth
- * Indicates if long lines should be splitted using the editor's current width.
- * The editor's current width will be used when splitting long lines if splitLinesUsingEditorWidth is true.
- * lineWidth will be used when splitting long lines if splitLinesUsingEditorWidth is false.
- *
- * lineWidth
- * The maximum width of a line before a line split is needed.
- * This number is only used when lineSplitting is true, otherwise it's ignored.
- *
- * splitMultiAttrs
- * Indicates if tags with multiple attributes should be formatted (splitting each attr on a new line).
- *
- * indentUsingTabs
- * Indicates if tabs should be used for indentation during formatting.
- * The same number of spaces specified by tabWidth will be used for indentation if indentUsingTabs is false.
- *
- * clearAllBlankLines
- * Indicates if all blanks lines should be cleared during formatting.
- * Blanks lines will be kept when clearAllBlankLines is false.
- *
- * formattingSupported
- * Indicates if the current content type supports formatting.
- * The splitLines, splitLinesUsingEditorsWidth, lineWidth, splitMultiAttrs, and indentUsingTabs preferences
- * will be meaningless if formattingSupported is false.
- *
- * contentAssistSupported
- * Indicates if the current content type supports content assist.
- * The autoPropose, and autoProposeCode preferences
- * will be meaningless if contentAssistSupported is false.
- *
- * preferredMarkupCaseSupported
- * Indicates if the current content type supports "preferred markup case for content assist, and code generation".
- * The tagNameCase, and attrNameCase preferences
- * will be meaningless if preferredMarkupCaseSupported is false.
- *
- */
-public interface CommonModelPreferenceNames {
-
- String INPUT_CODESET = "inputCodeset";//$NON-NLS-1$
- String OUTPUT_CODESET = "outputCodeset";//$NON-NLS-1$
- String END_OF_LINE_CODE = "endOfLineCode";//$NON-NLS-1$
-
- String TAB_WIDTH = "tabWidth";//$NON-NLS-1$
- String LINE_WIDTH = "lineWidth";//$NON-NLS-1$
- String SPLIT_MULTI_ATTRS = "splitMultiAttrs";//$NON-NLS-1$
- String INDENT_USING_TABS = "indentUsingTabs";//$NON-NLS-1$
- String CLEAR_ALL_BLANK_LINES = "clearAllBlankLines";//$NON-NLS-1$
-
- String TAG_NAME_CASE = "tagNameCase";//$NON-NLS-1$
- String ATTR_NAME_CASE = "attrNameCase";//$NON-NLS-1$
-
- String FORMATTING_SUPPORTED = "formattingSupported";//$NON-NLS-1$
-
- String PREFERRED_MARKUP_CASE_SUPPORTED = "preferredMarkupCaseSupported";//$NON-NLS-1$
-
- String TASK_TAG_TAGS = "task-tag-tags"; //$NON-NLS-1$
- String TASK_TAG_PRIORITIES = "task-tag-priorities"; //$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[] = {TAB_WIDTH, LINE_WIDTH, SPLIT_MULTI_ATTRS, INDENT_USING_TABS, CLEAR_ALL_BLANK_LINES, TAG_NAME_CASE, ATTR_NAME_CASE,};
-
- String FORMATTING_PREFERENCES[] = {TAB_WIDTH, LINE_WIDTH, SPLIT_MULTI_ATTRS, INDENT_USING_TABS, CLEAR_ALL_BLANK_LINES,};
-
- String AUTO = "Auto";//$NON-NLS-1$
- String UTF_8 = "UTF-8";//$NON-NLS-1$
- String ISO_8859_1 = "ISO-8859-1";//$NON-NLS-1$
-
- // pa_TODO need to use core ResourceHandler
- String LF = ResourceHandler.getString("EOL_Unix_UI"); //$NON-NLS-1$
- String CR = ResourceHandler.getString("EOL_Mac_UI"); //$NON-NLS-1$
- String CRLF = ResourceHandler.getString("EOL_Windows_UI"); //$NON-NLS-1$
- String NO_TRANSLATION = ResourceHandler.getString("NoTranslation"); //$NON-NLS-1$
-
- String STRING_LF = "\n";//$NON-NLS-1$
- String STRING_CR = "\r";//$NON-NLS-1$
- String STRING_CRLF = "\r\n";//$NON-NLS-1$
-
- int ASIS = 0;
- int LOWER = 1;
- int UPPER = 2;
-
- // cleanup preference names
- String CLEANUP_TAG_NAME_CASE = "cleanupTagNameCase";//$NON-NLS-1$
- String CLEANUP_ATTR_NAME_CASE = "cleanupAttrNameCase";//$NON-NLS-1$
- String COMPRESS_EMPTY_ELEMENT_TAGS = "compressEmptyElementTags";//$NON-NLS-1$
- String INSERT_REQUIRED_ATTRS = "insertRequiredAttrs";//$NON-NLS-1$
- String INSERT_MISSING_TAGS = "insertMissingTags";//$NON-NLS-1$
- String QUOTE_ATTR_VALUES = "quoteAttrValues";//$NON-NLS-1$
- String FORMAT_SOURCE = "formatSource";//$NON-NLS-1$
- String CONVERT_EOL_CODES = "convertEOLCodes";//$NON-NLS-1$
- String CLEANUP_EOL_CODE = "cleanupEOLCode";//$NON-NLS-1$
-
- String LAST_ACTIVE_PAGE = "lastActivePage";//$NON-NLS-1$
-
- // need to put default tab width preference here so it is accessible by both model and editor
- // this way, editor does not need to query model's default tab width preference
- int DEFAULT_TAB_WIDTH = 4;
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.java
deleted file mode 100644
index f36217128e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/preferences/PreferenceChangeListener.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.core.preferences;
-
-
-
-public interface PreferenceChangeListener {
-
- void preferencesChanged();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java
deleted file mode 100644
index f64f281476..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/DeleteEqualPositionUpdater.java
+++ /dev/null
@@ -1,62 +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.core.text;
-
-import org.eclipse.jface.text.BadPositionCategoryException;
-import org.eclipse.jface.text.DefaultPositionUpdater;
-
-/**
- * Follows the behavior of DefaultPositionUpdater except in addition to
- * deleting/overwriting text which completely contains the position deletes
- * the position, deleting text that equals the text in position also deletes the position.
- *
- * @see org.eclipse.jface.text.DefaultPositionUpdater
- */
-public class DeleteEqualPositionUpdater extends DefaultPositionUpdater {
-
- /**
- * @param category
- */
- public DeleteEqualPositionUpdater(String category) {
- super(category);
- }
-
- /**
- * Determines whether the currently investigated position has been deleted by
- * the replace operation specified in the current event. If so, it deletes
- * the position and removes it from the document's position category.
- *
- * NOTE: position is deleted if current event completely overwrites position OR if
- * current event deletes the area surrounding/including the position
- * @return <code>true</code> if position has been deleted
- */
- protected boolean notDeleted() {
- // position is deleted if current event completely overwrites position OR if
- // current event deletes the area surrounding/including the position
- if ((fOffset < fPosition.offset && (fPosition.offset + fPosition.length < fOffset + fLength)) || (fOffset <= fPosition.offset && (fPosition.offset + fPosition.length <= fOffset + fLength) && fReplaceLength == 0)) {
-
- fPosition.delete();
-
- try {
- fDocument.removePosition(getCategory(), fPosition);
- }
- catch (BadPositionCategoryException x) {
- }
-
- return false;
- }
-
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java
deleted file mode 100644
index 20cee79b88..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocument.java
+++ /dev/null
@@ -1,186 +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.core.text;
-
-
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.wst.encoding.EncodingMemento;
-import org.eclipse.wst.sse.core.document.IEncodedDocument;
-import org.eclipse.wst.sse.core.events.IModelAboutToBeChangedListener;
-import org.eclipse.wst.sse.core.events.IStructuredDocumentListener;
-import org.eclipse.wst.sse.core.events.NewModelEvent;
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-import org.eclipse.wst.sse.core.parser.RegionParser;
-
-
-
-/**
- * A IStructuredDocument is a collection of StructuredDocumentRegions. Its called "flat" because its contents
- * by design do not contain much structural information beyond containment.
- *
- */
-public interface IStructuredDocument extends IEncodedDocument, IAdaptable {
-
- void addModelAboutToBeChangedListener(IModelAboutToBeChangedListener listener);
-
- /**
- * The StructuredDocumentListners and ModelChagnedListeners are very similar.
- * They both receive identical events. The difference is the timing.
- * The "pure" StructuredDocumentListners are notified after the structuredDocument has
- * been changed, but before other, related models may have been changed
- * such as the Structural Model. The Structural model is in fact itself a
- * "pure" StructuredDocumentListner. The ModelChangedListeners can rest assured
- * that all models and data have been updated from the change by the tiem
- * they are notified. This is especially important for the text widget, for example,
- * which may rely on both structuredDocument and structural model information.
- */
- void addModelChangedListener(IStructuredDocumentListener listener);
-
- /**
- * The StructuredDocumentListners and ModelChagnedListeners are very similar.
- * They both receive identical events. The difference is the timing.
- * The "pure" StructuredDocumentListners are notified after the structuredDocument has
- * been changed, but before other, related models may have been changed
- * such as the Structural Model. The Structural model is in fact itself a
- * "pure" StructuredDocumentListner. The ModelChangedListeners can rest assured
- * that all models and data have been updated from the change by the tiem
- * they are notified. This is especially important for the text widget, for example,
- * which may rely on both structuredDocument and structural model information.
- */
- void addModelChangingListener(IStructuredDocumentListener listener);
-
- org.eclipse.wst.sse.core.text.IStructuredDocumentRegion getFirstStructuredDocumentRegion();
-
- org.eclipse.wst.sse.core.text.IStructuredDocumentRegion getLastStructuredDocumentRegion();
-
- /**
- * This can be considered the preferred delimiter.
- */
- public String getLineDelimiter();
-
- public void setLineDelimiter(String delimiter);
-
- int getLineOfOffset(int offset); // throws SourceEditingException;
-
- IStructuredDocumentRegion getRegionAtCharacterOffset(int offset);
-
- IStructuredDocumentRegionList getRegionList();
-
- String getText();
-
- void removeModelAboutToBeChangedListener(IModelAboutToBeChangedListener listener);
-
- void removeModelChangedListener(IStructuredDocumentListener listener);
-
- void removeModelChangingListener(IStructuredDocumentListener listener);
-
- /**
- * One of the APIs to manipulate the IStructuredDocument.
- *
- * replaceText replaces the text from oldStart to oldEnd with the new text
- * found in the requestedChange string. If oldStart and oldEnd are equal,
- * it is an insertion request. If requestedChange is null (or empty) it
- * is a delete request. Otherwise it is a replace request.
- */
- StructuredDocumentEvent replaceText(Object source, int oldStart, int replacementLength, String requestedChange);
-
- /**
- * One of the APIs to manipulate the IStructuredDocument in terms of Text.
- *
- * The setText method replaces all text in the model.
- */
- NewModelEvent setText(Object requester, String allText);
-
- /**
- * The parser is now required on constructor, so there are occasions
- * it needs to be retrieved, such as to be initialized by EmbeddedContentType
- */
- RegionParser getParser();
-
- /**
- * newInstance is similar to clone, except it contains
- * no data. One important thing to duplicate is the parser,
- * with the parser correctly "cloned", including its tokeninzer,
- * block tags, etc.
- *
- * NOTE: even after obtaining a 'newInstance' the client may have to
- * do some initialization, for example, it may need to add its own
- * model listeners. Or, as another example, if the IStructuredDocument has a parser
- * of type StructuredDocumentRegionParser, then the client may need to add its own
- * StructuredDocumentRegionHandler to that parser, if it is in fact needed.
- */
- IStructuredDocument newInstance();
-
- /**
- * This method is to remember info about the encoding
- * When the resource was last loaded or saved. Note:
- * it is not kept "current", that is, can not be
- * depended on blindly to reflect what encoding to use.
- * For that, must go through the normal rules expressed in
- * Loaders and Dumpers.
- */
-
- EncodingMemento getEncodingMemento();
-
- /**
- * This method is to remember info about the encoding
- * When the resource was last loaded or saved. Note:
- * it is not kept "current", that is, can not be
- * depended on blindly to reflect what encoding to use.
- * For that, must go through the normal rules expressed in
- * Loaders and Dumpers.
- */
- void setEncodingMemento(EncodingMemento encodingMemento);
-
-
- /**
- * Note: this method was made public, and part of the
- * interface, for easier testing. Clients normally never
- * manipulate the reparser directly (nor should they need
- * to).
- */
- IStructuredTextReParser getReParser();
-
- /**
- * returns true if any portion of startOffset to length is readonly
- * @param startOffset
- * @param length
- * @return
- */
- boolean containsReadOnly(int startOffset, int length);
-
- /**
- * causes that portion of the document from startOffset to length to
- * be marked as readonly. Note that if this range overlaps with some
- * other region with is readonly, the regions are effectivly combined.
- * @param startOffset
- * @param length
- */
- void makeReadOnly(int startOffset, int length);
-
- /**
- * this API ensures that any portion of the document within startOff
- * to length is not readonly (that is, that its editable). Note that if
- * the range overlaps with other readonly regions, those other readonly
- * regions will be adjusted.
- * @param startOffset
- * @param length
- */
- void clearReadOnly(int startOffset, int length);
-
- /**
- *
- */
- void fireNewDocument(Object requester);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java
deleted file mode 100644
index 5d3ec6f34f..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegion.java
+++ /dev/null
@@ -1,89 +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.core.text;
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-
-
-
-/**
- * A ITextRegionCollection is a collection of ITextRegions. It is a
- * structural unit, but a minimal one. For example, in might
- * consist of a "start tag" but not a whole XML node.
- */
-public interface IStructuredDocumentRegion extends ITextRegionCollection {
-
-
-
- IStructuredDocumentRegion getNext();
-
- IStructuredDocumentRegion getPrevious();
-
- boolean isEnded();
-
- IStructuredDocument getParentDocument();
-
- /**
- * For use by parsers and reparsers only.
- */
- void addRegion(ITextRegion aRegion);
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustLengthWith(int i);
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustStart(int i);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setEnded(boolean hasEnd);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setLength(int newLength);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setNext(IStructuredDocumentRegion newNext);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setPrevious(IStructuredDocumentRegion newPrevious);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setStart(int newStart);
-
- /**
- * For use by parsers and reparsers only.
- */
- StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion flatnode, String changes, int start, int end);
-
- /**
- * For use by parsers and reparsers only.
- */
- void setParentDocument(IStructuredDocument document);
-
- boolean sameAs(IStructuredDocumentRegion region, int shift);
-
- boolean sameAs(ITextRegion oldRegion, IStructuredDocumentRegion documentRegion, ITextRegion newRegion, int shift);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.java
deleted file mode 100644
index 238110ce98..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredDocumentRegionList.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.core.text;
-
-
-
-import java.util.Enumeration;
-
-/**
- * This is a class used to provide a list of StructuredDocumentRegions, so the implementation of
- * how the list is formed can be hidden (encapsulated by this class).
- */
-public interface IStructuredDocumentRegionList {
-
- Enumeration elements();
-
- int getLength();
-
- IStructuredDocumentRegion item(int i);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.java
deleted file mode 100644
index c4c735ca64..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextPartitioner.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.core.text;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-
-
-/**
- * A partitioner interface required by the StructuredTextPartitionerForJSP
- * for handling the embedded content type properly. This has not yet been
- * finalized.
- */
-
-public interface IStructuredTextPartitioner extends IDocumentPartitioner {
- void connect(IDocument document);
-
- /**
- * @deprecated - not sure why we needed to make
- * this part of interface ... but probably shouldn't be.
- */
- StructuredTypedRegion createPartition(int offset, int length, String type);
-
- void disconnect();
-
- String getDefault();
-
- String getPartitionType(ITextRegion region, int offset);
-
- String getPartitionTypeBetween(IStructuredDocumentRegion previousNode, ITextRegion previousStartTagNameRegion, IStructuredDocumentRegion nextNode, ITextRegion nextEndTagNameRegion);
-
- String[] getLegalContentTypes();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.java
deleted file mode 100644
index 1755279cd2..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/IStructuredTextReParser.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.core.text;
-
-
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-
-public interface IStructuredTextReParser {
-
- void initialize(Object requester, int start, int lengthToReplace, String changes);
-
- /**
- * This method is provided in anticipation of eventual multithreading. This is needed
- * since the intialize method sets state variables that must be "in sync" with the
- * structuredDocument.
- */
- public boolean isParsing();
-
- /**
- * An entry point for reparsing. It calculates the dirty start and dirty end
- * flatnodes based on the start point and length of the changes, which are
- * provided by the initialize method.
- *
- */
- public StructuredDocumentEvent reparse();
-
- public void setStructuredDocument(IStructuredDocument newStructuredDocument);
-
- public IStructuredTextReParser newInstance();
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.java
deleted file mode 100644
index ff199a9fce..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegion.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.core.text;
-
-import org.eclipse.wst.sse.core.events.StructuredDocumentEvent;
-
-
-
-/**
- * A simple description of a bit of text (technically, a bit of a text buffer) than has
- * a "type" associated with it. For example, for the XML text "&LT;IMG&GT;", the '<'
- * might form a region of type "open bracket" where as the text "IMG" might form a region
- * of type "tag name".
- *
- * Note that there are three positions associated with a region, the start, the end, and
- * the end of the text. The end of the region should always be greater than or equal to
- * the end of the text, because the end of the text simply includes any white space that
- * might follow the non-whitespace portion of the region. This whitespace is assumed to
- * be ignorable except for reasons of maintaining it in the original document for formatting,
- * appearance, etc.
- *
- */
-public interface ITextRegion {
-
- int getEnd();
-
- int getLength();
-
- int getStart();
-
- /**
- * In some implementations, the "end" of the region (accessible
- * via getEnd()) also contains any and all white space that may
- * or may not be present after the "token" (read: relevant) part
- * of the region. This method, getTextEnd(), is specific for the
- * "token" part of the region, without the whitespace.
- */
- int getTextEnd();
-
- /**
- * The text length is equal to length if there is no white space at the end of a region.
- * Otherwise it is smaller than length.
- */
- int getTextLength();
-
- String getType();
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustLengthWith(int i);
-
- /**
- * For use by parsers and reparsers only.
- */
- void adjustStart(int i);
-
- /**
- *
- * For use by parsers and reparsers only.
- */
- void adjustTextLength(int i);
-
- void equatePositions(ITextRegion region);
-
- /**
- * For use by parsers and reparsers only.
- */
- //StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion parent, String changes, int startOffset, int lengthToReplace);
- /**
- * @deprecated - may be removed after C3.
- * it seems no one implements this in a meaningful way.
- */
- StructuredDocumentEvent updateModel(Object requester, IStructuredDocumentRegion parent, String changes, int requestStart, int lengthToReplace);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.java
deleted file mode 100644
index 1b28af6e37..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionCollection.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.core.text;
-
-public interface ITextRegionCollection extends ITextRegion {
- /**
- * For use by parsers and reparsers only.
- */
- void setRegions(ITextRegionList embeddedRegions);
-
- ITextRegionList getRegions();
-
- int getNumberOfRegions();
-
- ITextRegion getFirstRegion();
-
- ITextRegion getLastRegion();
-
- boolean containsOffset(ITextRegion region, int i);
-
- boolean containsOffset(int i);
-
- int getStartOffset();
-
- int getStartOffset(ITextRegion containedRegion);
-
- int getLength();
-
- int getEndOffset();
-
- int getEndOffset(ITextRegion containedRegion);
-
- int getTextEndOffset();
-
- int getTextEndOffset(ITextRegion containedRegion);
-
- String getText();
-
- String getText(ITextRegion containedRegion);
-
- String getFullText();
-
- String getFullText(ITextRegion containedRegion);
-
- ITextRegion getRegionAtCharacterOffset(int offset);
-
- void equatePositions(ITextRegion region);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.java
deleted file mode 100644
index 4c3301e78e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionContainer.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.core.text;
-
-/**
- *
- */
-public interface ITextRegionContainer extends ITextRegionCollection {
-
- ITextRegionCollection getParent();
-
- /**
- * For use by parsers and reparsers only.
- */
-
- void setParent(ITextRegionCollection parent);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.java
deleted file mode 100644
index a6917e6aa6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/ITextRegionList.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.core.text;
-
-import java.util.Iterator;
-
-
-public interface ITextRegionList {
- public boolean add(ITextRegion region);
-
- public boolean addAll(int insertPos, ITextRegionList newRegions);
-
- public int size();
-
- public ITextRegion get(int index);
-
- public int indexOf(ITextRegion region);
-
- public boolean isEmpty();
-
- public Iterator iterator();
-
- public ITextRegion remove(int index);
-
- public void remove(ITextRegion region);
-
- public ITextRegion[] toArray();
-
- public void clear();
-
- public void removeAll(ITextRegionList regionList);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java
deleted file mode 100644
index e8e7abd8a9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredRegion.java
+++ /dev/null
@@ -1,87 +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.core.text;
-
-import org.eclipse.jface.text.IRegion;
-
-
-
-/**
- * Similar to jface region except we wanted a setting on length
- */
-public class SimpleStructuredRegion implements StructuredRegion {
-
- /** The region offset */
- private int fOffset;
- /** The region length */
- private int fLength;
-
- /**
- * Create a new region.
- *
- * @param offset the offset of the region
- * @param length the length of the region
- */
- public SimpleStructuredRegion(int offset, int length) {
- fOffset = offset;
- fLength = length;
- }
-
- /*
- * @see IRegion#getLength
- */
- public int getLength() {
- return fLength;
- }
-
- /*
- * @see IRegion#getOffset
- */
- public int getOffset() {
- return fOffset;
- }
-
- /**
- * Two regions are equal if they have the same offset and length.
- *
- * @see Object#equals
- */
- public boolean equals(Object o) {
- if (o instanceof IRegion) {
- IRegion r = (IRegion) o;
- return r.getOffset() == fOffset && r.getLength() == fLength;
- }
- return false;
- }
-
- /**
- * @see Object#hashCode
- * hascode is overridden since we provide our own equals.
- */
- public int hashCode() {
- return (fOffset << 24) | (fLength << 16);
- }
-
- /**
- * Sets the length.
- * @param length The length to set
- */
- public void setLength(int length) {
- fLength = length;
- }
-
- public void setOffset(int offset) {
- fOffset = offset;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.java
deleted file mode 100644
index 858bd41f9e..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/SimpleStructuredTypedRegion.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.core.text;
-
-
-
-/**
- * Similar jace TypedRegion, but had to subclass our version
- * which allowed length to be set.
- */
-public class SimpleStructuredTypedRegion extends SimpleStructuredRegion implements StructuredTypedRegion {
-
- /** The region's type */
- private String fType;
-
- /**
- * Creates a typed region based on the given specification.
- *
- * @param offset the region's offset
- * @param length the region's length
- * @param type the region's type
- */
- public SimpleStructuredTypedRegion(int offset, int length, String type) {
- super(offset, length);
- fType = type;
- }
-
- /*
- * @see ITypedRegion#getType()
- */
- public String getType() {
- return fType;
- }
-
- public void setType(String type) {
- fType = type;
- }
-
- /**
- * Two typed positions are equal if they have the same offset, length, and type.
- *
- * @see Object#equals
- */
- public boolean equals(Object o) {
- if (o instanceof SimpleStructuredTypedRegion) {
- SimpleStructuredTypedRegion r = (SimpleStructuredTypedRegion) o;
- return super.equals(r) && ((fType == null && r.getType() == null) || fType.equals(r.getType()));
- }
- return false;
- }
-
- /*
- * @see Object#hashCode
- */
- public int hashCode() {
- int type = fType == null ? 0 : fType.hashCode();
- return super.hashCode() | type;
- }
-
- /**
- * @see java.lang.Object#toString()
- */
- public String toString() {
- StringBuffer s = new StringBuffer();
- s.append(getOffset());
- s.append(":"); //$NON-NLS-1$
- s.append(getLength());
- s.append(" - "); //$NON-NLS-1$
- s.append(getType());
- return s.toString();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.java
deleted file mode 100644
index a66e047b78..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredRegion.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.core.text;
-
-import org.eclipse.jface.text.IRegion;
-
-/**
- * Like super class except allows length and offset to be modified.
- * This is convenient for some algorithms, and allows region objects
- * to be reused. Note: There MIGHT be some code that assumes regions are
- * immutable. This class would not be appropriate for those uses.
- */
-public interface StructuredRegion extends IRegion {
- void setLength(int length);
-
- void setOffset(int offset);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java
deleted file mode 100644
index add0fb9f64..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/StructuredTypedRegion.java
+++ /dev/null
@@ -1,26 +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.core.text;
-
-import org.eclipse.jface.text.ITypedRegion;
-
-/**
- * Similar to extended interface, except it allows
- * the length, offset, and type to be set.
- * This is useful when iterating through a number
- * of "small" regions, that all map to the
- * the same partion regions.
- */
-public interface StructuredTypedRegion extends StructuredRegion, ITypedRegion {
- void setType(String type);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java
deleted file mode 100644
index 8a31f0f944..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/text/rules/StructuredTextPartitioner.java
+++ /dev/null
@@ -1,571 +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.core.text.rules;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Locale;
-
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IDocumentPartitioner;
-import org.eclipse.jface.text.ITypedRegion;
-import org.eclipse.wst.sse.core.events.StructuredDocumentRegionsReplacedEvent;
-import org.eclipse.wst.sse.core.internal.parser.ForeignRegion;
-import org.eclipse.wst.sse.core.parser.IBlockedStructuredDocumentRegion;
-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.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-import org.eclipse.wst.sse.core.text.SimpleStructuredTypedRegion;
-import org.eclipse.wst.sse.core.text.StructuredRegion;
-import org.eclipse.wst.sse.core.text.StructuredTypedRegion;
-
-
-/**
- * Base Document partitioner for StructuredDocuments. BLOCK_TEXT ITextRegions
- * have a partition type of BLOCK or BLOCK:TAGNAME if a surrounding tagname was
- * recorded.
- */
-public class StructuredTextPartitioner implements IDocumentPartitioner {
-
- public final static String ST_DEFAULT_PARTITION = "org.eclipse.wst.sse.ui.ST_DEFAULT"; //$NON-NLS-1$
- public final static String ST_UNKNOWN_PARTITION = "org.eclipse.wst.sse.UNKNOWN_PARTITION_TYPE"; //$NON-NLS-1$
- protected String[] fSupportedTypes = null;
- protected IStructuredDocument structuredDocument;
- protected StructuredTypedRegion internalReusedTempInstance = new SimpleStructuredTypedRegion(0, 0, ST_DEFAULT_PARTITION);
- private CachedComputedPartitions cachedPartitions = new CachedComputedPartitions(-1, -1, null);
-
- class CachedComputedPartitions {
- int fOffset;
- int fLength;
- ITypedRegion[] fPartitions;
- boolean isInValid;
-
- CachedComputedPartitions(int offset, int length, ITypedRegion[] partitions) {
- fOffset = offset;
- fLength = length;
- fPartitions = partitions;
- isInValid = true;
- }
- }
-
- /**
- * StructuredTextPartitioner constructor comment.
- */
- public StructuredTextPartitioner() {
- super();
- }
-
- /**
- * Returns the partitioning of the given range of the connected
- * document. There must be a document connected to this partitioner.
- *
- * @param offset the offset of the range of interest
- * @param length the length of the range of interest
- * @return the partitioning of the range
- */
- synchronized public ITypedRegion[] computePartitioning(int offset, int length) {
- if (structuredDocument == null) {
- throw new IllegalStateException("document partitioner is not connected"); //$NON-NLS-1$
- }
- ITypedRegion[] results = null;
- if ((!cachedPartitions.isInValid) && (offset == cachedPartitions.fOffset) && (length == cachedPartitions.fLength)) {
- results = cachedPartitions.fPartitions;
- }
- else {
-
- List list = new ArrayList();
- if (length == 0) {
- list.add(getPartition(offset));
- }
- else {
- int currentPos = offset;
- int endPos = offset + length;
- if (endPos > structuredDocument.getLength()) {
- // this can occur if the model instance is being changed and everyone's
- // not yet up to date
- return new ITypedRegion[]{createPartition(offset, length, getUnknown())};
- }
- StructuredTypedRegion previousPartition = null;
- while (currentPos < endPos) {
- internalGetPartition(currentPos, false);
- currentPos += internalReusedTempInstance.getLength();
- // check if this partition just continues last one (type is the same),
- // if so, just extend length of last one, not need to create new
- // instance.
- if (previousPartition != null && internalReusedTempInstance.getType().equals(previousPartition.getType())) {
- // same partition type
- previousPartition.setLength(previousPartition.getLength() + internalReusedTempInstance.getLength());
- }
- else {
- // not the same, so add to list
- StructuredTypedRegion partition = createNewPartitionInstance();
- list.add(partition);
- // and make current, previous
- previousPartition = partition;
- }
- }
- }
- results = new ITypedRegion[list.size()];
- list.toArray(results);
- if (results.length > 0) {
- // truncate returned results to requested range
- if (results[0].getOffset() < offset && results[0] instanceof StructuredRegion) {
- ((StructuredRegion) results[0]).setOffset(offset);
- }
- int lastEnd = results[results.length - 1].getOffset() + results[results.length - 1].getLength();
- if (lastEnd > offset + length && results[results.length - 1] instanceof StructuredRegion) {
- ((StructuredRegion) results[results.length - 1]).setLength(offset + length - results[results.length - 1].getOffset());
- }
- }
- cachedPartitions.fLength = length;
- cachedPartitions.fOffset = offset;
- cachedPartitions.fPartitions = results;
- cachedPartitions.isInValid = false;
- }
- return results;
- }
-
- /**
- * Connects the document to the partitioner, i.e. indicates the
- * begin of the usage of the receiver as partitioner of the
- * given document.
- */
- public void connect(IDocument document) {
- if (document instanceof IStructuredDocument) {
- this.structuredDocument = (IStructuredDocument) document;
- }
- else {
- throw new IllegalArgumentException("This class and API are for StructuredDocuments only"); //$NON-NLS-1$
- }
- }
-
- /**
- * Creates the concrete partition from the given values. Returns a new
- * instance for each call.
- *
- * Subclasses may override.
- *
- * @param offset
- * @param length
- * @param type
- * @return ITypedRegion
- */
- public StructuredTypedRegion createPartition(int offset, int length, String type) {
- return new SimpleStructuredTypedRegion(offset, length, type);
- }
-
- protected void setInternalPartition(int offset, int length, String type) {
- internalReusedTempInstance.setOffset(offset);
- internalReusedTempInstance.setLength(length);
- internalReusedTempInstance.setType(type);
- }
-
- /**
- * Disconnects the document from the partitioner, i.e. indicates the end of
- * the usage of the receiver as partitioner of the given document.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#disconnect()
- */
- public void disconnect() {
- this.structuredDocument = null;
- }
-
- /**
- * Informs about a forthcoming document change.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentAboutToBeChanged(DocumentEvent)
- */
- public void documentAboutToBeChanged(DocumentEvent event) {
- cachedPartitions.isInValid = true;
- }
-
- /**
- * The document has been changed. The partitioner updates
- * the set of regions and returns whether the structure of the
- * document partitioning has been changed, i.e. whether partitions
- * have been added or removed.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#documentChanged(DocumentEvent)
- */
- public boolean documentChanged(DocumentEvent event) {
- boolean result = false;
- if (event instanceof StructuredDocumentRegionsReplacedEvent) {
- // partitions don't always change with document regions do,
- // but that's the only "quick check" we have.
- // I'm not sure if something more sophisticated will be needed
- // in the future. (dmw, 02/18/04).
- result = true;
- }
- return result;
- }
-
- /**
- * Returns the content type of the partition containing the
- * given character position of the given document. The document
- * has previously been connected to the partitioner.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#getContentType(int)
- */
- public String getContentType(int offset) {
- return getPartition(offset).getType();
- }
-
- /**
- * Returns the set of all possible content types the partitoner supports.
- * I.e. Any result delivered by this partitioner may not contain a content type
- * which would not be included in this method's result.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#getLegalContentTypes()
- */
- public java.lang.String[] getLegalContentTypes() {
- if (fSupportedTypes == null) {
- initLegalContentTypes();
- }
- return fSupportedTypes;
- }
-
- /**
- * to be abstract eventually
- */
- protected void initLegalContentTypes() {
- fSupportedTypes = new String[]{ST_DEFAULT_PARTITION, ST_UNKNOWN_PARTITION};
- }
-
- /**
- * Returns the partition containing the given character position of
- * the given document. The document has previously been connected to the
- * partitioner.
- *
- * @see org.eclipse.jface.text.IDocumentPartitioner#getPartition(int)
- */
- public ITypedRegion getPartition(int offset) {
- internalGetPartition(offset, true);
- return createNewPartitionInstance();
- }
-
- private StructuredTypedRegion createNewPartitionInstance() {
- return new SimpleStructuredTypedRegion(internalReusedTempInstance.getOffset(), internalReusedTempInstance.getLength(), internalReusedTempInstance.getType());
- }
-
- /**
- * Returns the partition containing the given character position of
- * the given document. The document has previously been connected to the
- * partitioner. If the checkBetween parameter is true, an offset between a
- * start and end tag will return a zero-length region.
- */
- synchronized private void internalGetPartition(int offset, boolean checkBetween) {
- if (structuredDocument == null) {
- throw new IllegalStateException("document partitioner is not connected"); //$NON-NLS-1$
- }
-
- boolean partitionFound = false;
- // get flatnode type and map to partition type :
- // Note: a partion can be smaller than a flatnode, if that flatnode
- // contains a region container.
- // That's why we need to get "relevent region".
- IStructuredDocumentRegion structuredDocumentRegion = structuredDocument.getRegionAtCharacterOffset(offset);
- // flatNode is null if empty document
- // this is king of a "normal case" for empty document
- if (structuredDocumentRegion == null && structuredDocument.getLength() == 0) {
- // in order to prevent infinite error loops, this partition must never have a zero length
- setInternalPartition(offset, 0, getDefault());
- partitionFound = true;
- }
- else if (structuredDocumentRegion == null && structuredDocument.getLength() != 0) {
- // this case is "unusual". When would region be null, and document longer
- // than 0. I think this means somethings "out of sync". And we may want
- // to "flag" that fact and just return one big region of 'unknown', instead
- // of one character at a time.
- setInternalPartition(offset, 1, getUnknown());
- partitionFound = true;
- }
- else if (checkBetween) {
- if (structuredDocumentRegion == null && structuredDocument.getLength() == 0) {
- // known special case for an empty document
- setInternalPartition(offset, 0, getDefault());
- partitionFound = true;
- }
- else if (structuredDocumentRegion.getStartOffset() == offset) {
- IStructuredDocumentRegion previousStructuredDocumentRegion = structuredDocumentRegion.getPrevious();
- if (previousStructuredDocumentRegion != null) {
- ITextRegion next = structuredDocumentRegion.getRegionAtCharacterOffset(offset);
- ITextRegion previousStart = previousStructuredDocumentRegion.getRegionAtCharacterOffset(previousStructuredDocumentRegion.getStartOffset());
- partitionFound = doParserSpecificCheck(offset, partitionFound, structuredDocumentRegion, previousStructuredDocumentRegion, next, previousStart);
- }
- }
- }
- else if (structuredDocumentRegion == null) {
- setInternalPartition(offset, 0, getDefault());
- partitionFound = true;
- }
- if (!partitionFound) {
- ITextRegion resultRegion = structuredDocumentRegion.getRegionAtCharacterOffset(offset);
- partitionFound = isDocumentRegionBasedPartition(structuredDocumentRegion, resultRegion, offset);
- if (!partitionFound) {
- // Note: this new logic doesn't handle container regions inside of
- // container regions ... may need to make this first clause
- // a recursive method
- if (resultRegion != null && resultRegion instanceof ITextRegionContainer) {
- ITextRegionContainer containerRegion = (ITextRegionContainer) resultRegion;
- // then need to "drill down" for relevent region and relevent offset
- ITextRegion deepRegion = containerRegion.getRegionAtCharacterOffset(offset);
- int endOffset = containerRegion.getEndOffset(deepRegion);
- String type = getPartitionType(deepRegion, endOffset);
- setInternalPartition(offset, endOffset - offset, type);
- }
- else {
- if (resultRegion != null) {
- String type = getPartitionType(resultRegion, offset);
- setInternalPartition(offset, structuredDocumentRegion.getEndOffset(resultRegion) - offset, type);
- }
- else {
- // can happen at EOF
- setInternalPartition(offset, 1, getUnknown());
- }
- }
- }
- }
- }
-
- /**
- * Provides for a per-StructuredDocumentRegion override selecting the partition type using more than
- * just a single ITextRegion.
- *
- * @param structuredDocumentRegion the StructuredDocumentRegion
- * @param containedChildRegion an ITextRegion within the given StructuredDocumentRegion that would
- * normally determine the partition type by itself
- * @param offset the document offset
- * @return true if the partition type will be overridden, false to continue normal processing
- */
- protected boolean isDocumentRegionBasedPartition(IStructuredDocumentRegion structuredDocumentRegion, ITextRegion containedChildRegion, int offset) {
- return false;
- }
-
- protected boolean doParserSpecificCheck(int offset, boolean partitionFound, IStructuredDocumentRegion sdRegion, IStructuredDocumentRegion previousStructuredDocumentRegion, ITextRegion next, ITextRegion previousStart) {
- // this (conceptually) abstract method is not concerned with
- // specific region types
- return false;
- }
-
- /**
- * Return the ITextRegion at the given offset. For most cases, this will
- * be the flatNode itself. Should it contain an embedded ITextRegionContainer,
- * will return the internal region at the offset
- *
- *
- * @param flatNode
- * @param offset
- * @return ITextRegion
- */
- private String getReleventRegionType(IStructuredDocumentRegion flatNode, int offset) {
- // * Note: the original form of this method -- which returned "deep" region, isn't that
- // * useful, after doing parent elimination refactoring,
- // * since once the deep region is returned, its hard to get its text or offset without
- // * proper parent.
- ITextRegion resultRegion = null;
- if (containsEmbeddedRegion(flatNode)) {
- resultRegion = flatNode.getRegionAtCharacterOffset(offset);
- if (resultRegion instanceof ITextRegionContainer) {
- resultRegion = flatNode.getRegionAtCharacterOffset(offset);
- ITextRegionList regions = ((ITextRegionContainer) resultRegion).getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (flatNode.getStartOffset(region) <= offset && offset < flatNode.getEndOffset(region)) {
- resultRegion = region;
- break;
- }
- }
- }
- }
- else {
- resultRegion = flatNode;
- }
- return resultRegion.getType();
- }
-
- /**
- * Determines if the given ITextRegionContainer itself contains another ITextRegionContainer
- * @param ITextRegionContainer
- * @return boolean
- */
- protected boolean containsEmbeddedRegion(IStructuredDocumentRegion container) {
- boolean containsEmbeddedRegion = false;
-
- ITextRegionList regions = container.getRegions();
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (region instanceof ITextRegionContainer) {
- containsEmbeddedRegion = true;
- break;
- }
- }
- return containsEmbeddedRegion;
- }
-
- /**
- * Returns the partition based on region type. This basically maps from one
- * region-type space to another, higher level, region-type space.
- *
- * @param region
- * @param offset
- * @return String
- */
- protected String getPartitionType(ITextRegion region, int offset) {
- String result = getDefault();
- // if (region instanceof ContextRegionContainer) {
- // result = getPartitionType((ITextRegionContainer) region, offset);
- // } else {
- if (region instanceof ITextRegionContainer) {
- result = getPartitionType((ITextRegionContainer) region, offset);
- }
-
- result = getPartitionFromBlockedText(region, offset, result);
-
- return result;
-
- }
-
- protected String getPartitionFromBlockedText(ITextRegion region, int offset, String result) {
- // parser sensitive code was moved to subclass for quick transition
- // this (conceptually) abstract version isn't concerned with blocked text
-
- return result;
- }
-
- /**
- * To be used, instead of default, when there is some thing
- * surprising about are attempt to partition
- */
- protected String getUnknown() {
- return ST_UNKNOWN_PARTITION;
- }
-
- /**
- * Similar to method with 'ITextRegion' as argument, except for
- * RegionContainers, if it has embedded regions, then we need
- * to drill down and return DocumentPartition based on "lowest level"
- * region type. For example, in
- * <body id="<%= object.getID() %>" >
- * The text between <%= and %> would be a "java region" not
- * an "HTML region".
- */
- protected String getPartitionType(ITextRegionContainer region, int offset) {
- // TODO this method needs to be 'cleaned up' after refactoring
- // its instanceof logic seems messed up now.
- String result = null;
- if (region != null) {
- ITextRegion coreRegion = region;
- if (coreRegion instanceof ITextRegionContainer) {
- result = getPartitionType((ITextRegionContainer) coreRegion, ((ITextRegionContainer) coreRegion).getRegions(), offset);
- }
- else {
- result = getPartitionType(region);
- }
- }
- else {
- result = getPartitionType((ITextRegion) region, offset);
- }
-
- return result;
- }
-
- /**
- * Computes the partition type for the zero-length partition between a start
- * tag and end tag with the given name regions.
- *
- * @param previousStartTagNameRegion
- * @param nextEndTagNameRegion
- * @return String
- */
- protected String getPartitionTypeBetween(IStructuredDocumentRegion previousNode, ITextRegion previousStartTagNameRegion, IStructuredDocumentRegion nextNode, ITextRegion nextEndTagNameRegion) {
- return getDefault();
- }
-
- /**
- * Method getPartitionType.
- * @param region
- * @return String
- */
- private String getPartitionType(ITextRegion region) {
- // if it get's to this "raw" level, then
- // must be default.
- return getDefault();
- }
-
- /**
- * To be used by default!
- */
- public String getDefault() {
-
- return ST_DEFAULT_PARTITION;
- }
-
- protected String getPartitionType(ForeignRegion region, int offset) {
- String tagname = region.getSurroundingTag();
- String result = null;
- if(result != null) {
- result = "BLOCK:" + tagname.toUpperCase(Locale.ENGLISH); //$NON-NLS-1$
- }
- else {
- result = "BLOCK"; //$NON-NLS-1$
- }
- return result;
- }
-
- /**
- */
- protected String getPartitionType(IBlockedStructuredDocumentRegion blockedStructuredDocumentRegion, int offset) {
- String result = null;
- ITextRegionList regions = blockedStructuredDocumentRegion.getRegions();
-
- // regions should never be null, or hold zero regions, but just in case...
- if (regions != null && regions.size() > 0) {
- if (regions.size() == 1) {
- // if only one, then its a "pure" blocked note.
- // if more than one, then must contain some embedded region container
- ITextRegion blockedRegion = regions.get(0);
- // double check for code safefy, though should always be true
- if (blockedRegion instanceof ForeignRegion) {
- result = getPartitionType((ForeignRegion) blockedRegion, offset);
- }
- }
- else {
- // must have some embedded region container, so we'll make sure we'll get the appropriate one
- result = getReleventRegionType(blockedStructuredDocumentRegion, offset);
- }
- }
- return result;
- }
-
- private String getPartitionType(ITextRegionContainer coreRegion, ITextRegionList regions, int offset) {
- String result = null;
- for (int i = 0; i < regions.size(); i++) {
- ITextRegion region = regions.get(i);
- if (coreRegion.containsOffset(region, offset)) {
- result = getPartitionType(region, offset);
- break;
- }
- }
- return result;
- }
-
- public IDocumentPartitioner newInstance() {
- return new StructuredTextPartitioner();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java
deleted file mode 100644
index 89b6a30403..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/CommandCursorPosition.java
+++ /dev/null
@@ -1,62 +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.core.undo;
-
-
-
-public interface CommandCursorPosition {
-
- /**
- * Returns the cursor position to be set to after this command is redone.
- * @return int
- */
- int getRedoCursorPosition();
-
- /**
- * Returns the length of text to be selected after this command is redone.
- * @return int
- */
- int getRedoSelectionLength();
-
- /**
- * Returns the cursor position to be set to after this command is undone.
- * @return int
- */
- int getUndoCursorPosition();
-
- /**
- * Returns the length of text to be selected after this command is undone.
- * @return int
- */
- int getUndoSelectionLength();
-
- /**
- * Sets the cursor position to be used after this command is redone.
- */
- void setRedoCursorPosition(int cursorPosition);
-
- /**
- * Sets the length of text to be selected after this command is redone.
- */
- void setRedoSelectionLength(int selectionLength);
-
- /**
- * Sets the cursor position to be used after this command is undone.
- */
- void setUndoCursorPosition(int cursorPosition);
-
- /**
- * Sets the length of text to be selected after this command is undone.
- */
- void setUndoSelectionLength(int selectionLength);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java
deleted file mode 100644
index bf1d736944..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextCommand.java
+++ /dev/null
@@ -1,34 +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.core.undo;
-
-
-
-public interface StructuredTextCommand {
-
- String getTextDeleted();
-
- int getTextEnd();
-
- String getTextInserted();
-
- int getTextStart();
-
- void setTextDeleted(String textDeleted);
-
- void setTextEnd(int textEnd);
-
- void setTextInserted(String textInserted);
-
- void setTextStart(int textStart);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextUndoManager.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextUndoManager.java
deleted file mode 100644
index f912ec3643..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/undo/StructuredTextUndoManager.java
+++ /dev/null
@@ -1,95 +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.core.undo;
-
-import org.eclipse.emf.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.IUndoManager;
-
-
-
-public interface StructuredTextUndoManager extends IUndoManager {
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, int cursorPosition, int selectionLength);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description);
-
- /**
- * Begin recording undo transactions.
- */
- void beginRecording(Object requester, String label, String description, int cursorPosition, int selectionLength);
-
- /**
- * Disable undo management.
- */
- void disableUndoManagement();
-
- /**
- * Enable undo management.
- */
- void enableUndoManagement();
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester);
-
- /**
- * End recording undo transactions.
- */
- void endRecording(Object requester, int cursorPosition, int selectionLength);
-
- /**
- * Get the redo command even if it's not committed yet.
- */
- Command getRedoCommand();
-
- /**
- * Get the text viewer the undo manager is connected to.
- */
- ITextViewer getTextViewer();
-
- /**
- * Get the undo command even if it's not committed yet.
- */
- Command getUndoCommand();
-
- /**
- * Set the command stack.
- */
- void setCommandStack(CommandStack commandStack);
-
- void disconnect(ITextViewer textViewer);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Assert.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Assert.java
deleted file mode 100644
index 22a1305152..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/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.core.util;
-
-import org.eclipse.wst.sse.core.internal.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.core/src/org/eclipse/wst/sse/core/util/Debug.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Debug.java
deleted file mode 100644
index 9e5efbe226..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Debug.java
+++ /dev/null
@@ -1,193 +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.core.util;
-
-
-
-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.ITextRegionCollection;
-import org.eclipse.wst.sse.core.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.text.ITextRegionList;
-
-public class Debug {
-
- public static boolean debugNotifyDeferred = false;
-
- public static int DEBUG = 0;
-
- public static boolean collectStats = false;
- public static boolean jsDebugContextAssist = false;
- //
- public static boolean useStandardEolInWidget = false;
- //
- public static boolean syntaxHighlighting = false;
- public static boolean headParsing = false;
-
- public static boolean debugBreakpoints = false;
-
- /** effects output of Logger */
- public static boolean displayToConsole = true;
- public static boolean displayWarnings = false;
- public static boolean displayInfo = false;
- //
- public static boolean debugMediator = false;
- public static boolean debugCaretMediator = false;
- //
- public static boolean debugStructuredDocument = false;
- //
- public static boolean debugTreeModel = false;
- public static boolean debugDisplayTreePositions = false;
- public static boolean debugUpdateTreePositions = false;
- //
- public static boolean jsDebugSyntaxColoring = false;
- //
- public static boolean debugTokenizer = false;
- public static boolean debugTaglibs = false;
- //
- public static boolean debugRtfFormatProvider = false;
- public static boolean debugReconciling = false;
- //
- public static boolean perfTest = false;
- public static boolean perfTestStructuredDocumentOnly = false;
- public static boolean perfTestRawStructuredDocumentOnly = false;
- public static boolean perfTestStructuredDocumentEventOnly = false;
- public static boolean perfTestAdapterClassLoading = false;
- public static boolean perfTestFormat = false;
- public static boolean checkForMemoryLeaks = false;
- //
- public static boolean failedTests = false;
-
- /**
- * Debug constructor comment.
- */
- public Debug() {
- super();
- }
-
- /**
- * For tests and debug only
- */
-
- public static void dump(IStructuredDocument structuredDocument) {
- dump(structuredDocument, false);
- }
-
- public static void dump(IStructuredDocument structuredDocument, boolean verbose) {
- ITextRegionCollection flatNode = null;
- System.out.println("Dump of structuredDocument:"); //$NON-NLS-1$
- IStructuredDocumentRegionList flatNodes = structuredDocument.getRegionList();
- java.util.Enumeration enum = flatNodes.elements();
- while (enum.hasMoreElements()) {
- flatNode = (ITextRegionCollection) enum.nextElement();
- if (!verbose) {
- String outString = flatNode.toString();
- outString = org.eclipse.wst.sse.core.util.StringUtils.escape(outString);
- System.out.println(outString);
- }
- else {
- dump(flatNode, verbose);
- }
- }
- System.out.println();
- System.out.println("= = = = = ="); //$NON-NLS-1$
- System.out.println();
- }
-
- public static String toStringUtil(IStructuredDocument object) {
- String className = object.getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- // ==> // String resultText = null;
- String result = shortClassName;
- // NOTE: if the document held by any region has been updated and the region offsets have not
- // yet been updated, the output from this method invalid.
- return result;
-
- }
-
- public static String toStringUtil(ITextRegionCollection object) {
- String className = object.getClass().getName();
- String shortClassName = className.substring(className.lastIndexOf(".") + 1); //$NON-NLS-1$
- // ==> // String resultText = null;
- String result = shortClassName;
- // NOTE: if the document held by any region has been updated and the region offsets have not
- // yet been updated, the output from this method invalid.
- return result;
-
- }
-
- /**
- * @param flatNode
- * @param verbose
- */
- public static void dump(ITextRegionCollection region, boolean verbose) {
- if (region == null)
- return;
- if (verbose) {
- printParent(region);
- }
- printChildRegions(region, 0);
- }
-
- private static void printChildRegions(ITextRegionCollection region, int depth) {
- if (region != null) {
- // ==> // ITextRegionCollection regionCollection = region;
- System.out.println(region);
- ITextRegionList regionList = region.getRegions();
- for (int i = 0; i < regionList.size(); i++) {
- ITextRegion r = regionList.get(i);
- if (r instanceof ITextRegionCollection) {
- ITextRegionCollection rc = (ITextRegionCollection) r;
- printChildRegions(rc, depth++);
- }
- else {
- System.out.println(space(depth) + r);
- depth--;
- }
- }
- }
- }
-
- /**
- * @param depth
- * @return
- */
- private static String space(int depth) {
- String result = " "; //$NON-NLS-1$
- for (int i = 0; i < depth; i++) {
- result += " "; //$NON-NLS-1$
- }
- return result;
- }
-
- private static void printParent(ITextRegionContainer region) {
- System.out.println(" [parent document: " + toStringUtil(region.getParent()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static void printParent(IStructuredDocumentRegion region) {
- System.out.println(" [parent document: " + toStringUtil(region.getParentDocument()) + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- private static void printParent(ITextRegionCollection region) {
- if (region instanceof IStructuredDocumentRegion) {
- printParent((IStructuredDocumentRegion) region);
- }
- else if (region instanceof ITextRegionContainer) {
- printParent((ITextRegionContainer) region);
- }
- else
- System.out.println(" [parent document: " + "(na)" + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.java
deleted file mode 100644
index e1274b5ea8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/DocumentInputStream.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.core.util;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-
-public class DocumentInputStream extends InputStream {
- private IDocument fDocument;
- private int fMark = -1;
- private int fPosition = 0;
-
- public DocumentInputStream(IDocument source) {
- super();
- fDocument = source;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#available()
- */
- public int available() throws IOException {
- return fDocument.getLength() - fPosition;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#close()
- */
- public void close() throws IOException {
- this.fDocument = null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#mark(int)
- */
- public synchronized void mark(int readlimit) {
- fMark = fPosition;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#markSupported()
- */
- public boolean markSupported() {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#read()
- */
- public int read() throws IOException {
- try {
- if (fPosition < fDocument.getLength())
- return fDocument.getChar(fPosition++);
- else
- return -1;
- }
- catch (BadLocationException e) {
- throw new IOException(e.getMessage());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#reset()
- */
- public synchronized void reset() throws IOException {
- fPosition = fMark;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see java.io.InputStream#skip(long)
- */
- public long skip(long n) throws IOException {
- long skipped = n;
- if (n < fDocument.getLength() - fPosition) {
- skipped = n;
- fPosition += skipped;
- }
- else {
- skipped = fDocument.getLength() - fPosition;
- fPosition = fDocument.getLength();
- }
- return skipped;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.java
deleted file mode 100644
index 192c8f62d3..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/JarUtilities.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.core.util;
-
-import java.io.ByteArrayInputStream;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.jar.JarFile;
-import java.util.zip.ZipEntry;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.wst.sse.core.internal.Logger;
-
-
-public class JarUtilities {
-
- /**
- * @see http://java.sun.com/products/jsp/errata_1_1_a_042800.html, Issues 8 & 9
- *
- * "There are two cases. In both cases the TLD_URI is to be interpreted relative to the root of the Web Application. In the first case the TLD_URI refers to a TLD file directly. In the second case, the TLD_URI refers to a JAR file. If so, that JAR file should have a TLD at location META-INF/taglib.tld."
- */
- public static final String JSP11_TAGLIB = "META-INF/taglib.tld"; //$NON-NLS-1$
-
- public static String[] getEntryNames(String jarFilename, boolean excludeDirectories) {
- JarFile jarfile = null;
- List entryNames = new ArrayList();
- String[] names = null;
- try {
- jarfile = new JarFile(jarFilename);
- Enumeration entries = jarfile.entries();
- while (entries.hasMoreElements()) {
- ZipEntry z = (ZipEntry) entries.nextElement();
- if (!(z.isDirectory() && excludeDirectories))
- entryNames.add(z.getName());
- }
- }
- catch (IOException ioExc) {
- Logger.logException(ioExc);
- return null;
- }
- finally {
- try {
- jarfile.close();
- }
- catch (IOException e) {
- // nothing can be done
- }
- }
- names = new String[entryNames.size()];
- entryNames.toArray(names);
- return names;
- }
-
- public static String[] getEntryNames(String jarFilename) {
- return getEntryNames(jarFilename, true);
- }
-
- public static String[] getEntryNames(IResource jarResource) {
- if (jarResource == null)
- return null;
- return getEntryNames(jarResource.getLocation().toString());
- }
-
- public static InputStream getInputStream(String jarFilename, String entryName) {
- // check sanity
- if (jarFilename == null || jarFilename.length() < 1 || entryName == null || entryName.length() < 1)
- return null;
-
- // JAR files are not allowed to have leading '/' in member names
- String internalName = null;
- if (entryName.startsWith("/")) //$NON-NLS-1$
- internalName = entryName.substring(1);
- else
- internalName = entryName;
-
- return getCachedInputStream(jarFilename, internalName);
- }
-
- /**
- * Provides a stream to a local copy of the input
- */
- protected static InputStream getCachedInputStream(String jarFilename, String entryName) {
- File testFile = new File(jarFilename);
- if (!testFile.exists())
- return null;
-
- JarFile jarfile = null;
- try {
- jarfile = new JarFile(jarFilename);
- }
- catch (IOException ioExc) {
- Logger.logException(ioExc);
- closeJarFile(jarfile);
- return null;
- }
-
- ZipEntry zentry = jarfile.getEntry(entryName);
- if (zentry == null) {
- closeJarFile(jarfile);
- return null;
- }
-
- InputStream entryInputStream = null;
- try {
- entryInputStream = jarfile.getInputStream(zentry);
- }
- catch (IOException ioExc) {
- Logger.logException(ioExc);
- return null;
- }
-
- byte bytes[] = null;
- if (entryInputStream != null) {
- StringBuffer buffer = new StringBuffer();
- try {
- // read, bytes->chars
- int c;
- while ((c = entryInputStream.read()) >= 0)
- buffer.append((char) c);
- entryInputStream.close();
- }
- catch (IOException ioe) {
- // no cleanup can be done
- }
- // convert back, chars->bytes
- bytes = new byte[buffer.length()];
- for (int i = 0; i < bytes.length; i++)
- bytes[i] = (byte) buffer.charAt(i);
- }
- // }
-
- closeJarFile(jarfile);
-
- return new ByteArrayInputStream(bytes);
- }
-
- public static void closeJarFile(JarFile file) {
- if (file == null)
- return;
- try {
- file.close();
- }
- catch (IOException ioe) {
- // no cleanup can be done
- Logger.log(Logger.ERROR, "Could not close file " + file.getName()); //$NON-NLS-1$
- }
- finally {
- file = null;
- }
- }
-
- public static InputStream getInputStream(IResource jarResource, String entryName) {
- if (jarResource == null)
- return null;
- return getInputStream(jarResource.getLocation().toString(), entryName);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java
deleted file mode 100644
index 1c0e0964e5..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/PathHelper.java
+++ /dev/null
@@ -1,148 +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.core.util;
-
-
-
-import java.io.File;
-import java.util.StringTokenizer;
-
-/**
- * Collection of helper methods to manage and convert links
- * Originally part of the LinksManager
- */
-public class PathHelper {
-
- public static final String FORWARD_SLASH = "/";//$NON-NLS-1$
- public static final String BACKWARD_SLASH = "\\";//$NON-NLS-1$
- public static String RELATIVE_PATH_SIG = "../";//$NON-NLS-1$
-
- /**
- * adjust relative path isside the absolute path
- */
- public static String adjustPath(String path) {
- int i = 0;
- while ((i = path.indexOf(RELATIVE_PATH_SIG)) > 0) {
- // split the string into two
- String part1 = path.substring(0, i - 1);
- String part2 = path.substring(i + RELATIVE_PATH_SIG.length() - 1);
- // strip one path seg from part1
- int j = part1.lastIndexOf(FORWARD_SLASH);
- if (j == -1) {
- // can't resolve. passed path is like E:/eclipseproject/../../sample.css.
- return "";//$NON-NLS-1$
- }
- part1 = part1.substring(0, j);
- path = part1 + part2;
- }
- return path;
- }
-
- /**
- * Append trailing url slash if needed
- */
- public static String appendTrailingURLSlash(String input) {
- // check to see already a slash
- if (!input.endsWith(FORWARD_SLASH)) {
- input += FORWARD_SLASH;
- }
- return input;
- }
-
- /**
- * Convert to relative url based on base
- */
- public static String convertToRelative(String input, String base) {
- // tokenize the strings
- StringTokenizer inputTokenizer = new StringTokenizer(input, FORWARD_SLASH);
- StringTokenizer baseTokenizer = new StringTokenizer(base, FORWARD_SLASH);
- String token1 = "", token2 = "";//$NON-NLS-2$//$NON-NLS-1$
- //
- // Go through until equls
- while (true) {
- if (!inputTokenizer.hasMoreTokens() || !baseTokenizer.hasMoreTokens())
- break;
- token1 = baseTokenizer.nextToken();
- token2 = inputTokenizer.nextToken();
- if (!token1.equals(token2))
- break;
- }
- // now generate the backs
- String output = "";//$NON-NLS-1$
- while (baseTokenizer.hasMoreTokens()) {
- baseTokenizer.nextToken();
- output += "../"; //$NON-NLS-1$
- }
- output += token2;
- // generate the rest
- while (inputTokenizer.hasMoreTokens()) {
- output = output + FORWARD_SLASH + inputTokenizer.nextToken();
- }
- return output;
- }
-
- /**
- * Return the containing folder path.
- * Will handle both url and file path
- */
- public static String getContainingFolderPath(String path) {
- String retValue = path;
-
- int urlSlashIndex = path.lastIndexOf(FORWARD_SLASH);
- int filePathSlashIndex = path.lastIndexOf(File.separator);
- int index = filePathSlashIndex;
- if (urlSlashIndex > filePathSlashIndex)
- index = urlSlashIndex;
- if (index >= 0)
- retValue = path.substring(0, index);
- return retValue;
- }
-
- /**
- * Remove leading path separator
- */
- public static String removeLeadingPathSeparator(String path) {
- if (path.startsWith(File.separator))
- path = path.substring(File.separator.length());
- return path;
- }
-
- /**
- * Remove leading path separator
- */
- public static String removeLeadingSeparator(String path) {
- if (path.startsWith(File.separator))
- path = path.substring(File.separator.length());
- else if (path.startsWith(FORWARD_SLASH) || path.startsWith(BACKWARD_SLASH))
- path = path.substring(FORWARD_SLASH.length());
- return path;
- }
-
- /**
- * Switch to file path slashes
- */
- public static String switchToFilePathSlashes(String path) {
- path = path.replace(FORWARD_SLASH.charAt(0), File.separatorChar);
- path = path.replace(BACKWARD_SLASH.charAt(0), File.separatorChar);
- return path;
- }
-
- /**
- * Switch to file path slashes
- */
- public static String switchToForwardSlashes(String path) {
- path = path.replace(File.separatorChar, FORWARD_SLASH.charAt(0));
- path = path.replace(BACKWARD_SLASH.charAt(0), FORWARD_SLASH.charAt(0));
- return path;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java
deleted file mode 100644
index ca0ad681d3..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ProjectResolver.java
+++ /dev/null
@@ -1,217 +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.core.util;
-
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.StringTokenizer;
-
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.xml.uriresolver.util.URIHelper;
-
-public class ProjectResolver implements URIResolver {
- private IProject fProject = null;
- private String fFileBaseLocation = null;
-
- /**
- * It is strongly recommended that clients use project.getAdapter(URIResolver.class)
- * to obtain a URIResolver aware of the Project's special requirements. Note that
- * a URIResolver may not be returned at all so manually creating this object may
- * still be required.
- */
- public ProjectResolver(IProject project) {
- super();
- fProject = project;
- }
-
- public java.lang.String getFileBaseLocation() {
- return fFileBaseLocation;
- }
-
- public java.lang.String getLocationByURI(String uri) {
- return getLocationByURI(uri, getFileBaseLocation());
- }
-
- public java.lang.String getLocationByURI(String uri, String baseReference) {
- if (uri == null)
- return null;
- /* defect 244817
- try {
- URL aURL = new URL(uri);
- */
- /**
- * An actual URL was given, but only the "file:///" protocol is
- * supported. Resolve the URI by finding the file to which it
- * points.
- */
- /* defect 244817
- if (!aURL.getProtocol().equals("platform")) { //$NON-NLS-1$
- if (aURL.getProtocol().equals("file") && (aURL.getHost().equals("localhost") || aURL.getHost().length() == 0)) { //$NON-NLS-2$//$NON-NLS-1$
- return aURL.getFile();
- }
- return uri;
- }
- }
- catch (MalformedURLException mfuExc) {
- }
- */
- // defect 244817 start
- if (isFileURL(uri)) {
- try {
- URL url = new URL(uri);
- return getPath(url);
- }
- catch (MalformedURLException e) {
- }
- }
- // defect 244817 end
- return URIHelper.normalize(uri, baseReference, getRootLocationString());
- }
-
- // defect 244817 start
- /**
- *
- * @param passedSpec
- * @return boolean
- */
- private boolean isFileURL(String passedSpec) {
- if (passedSpec == null) {
- return false;
- }
- final String spec = passedSpec.trim();
- if (spec.length() == 0) {
- return false;
- }
- final int limit = spec.length();
- String newProtocol = null;
- for (int index = 0; index < limit; index++) {
- final char p = spec.charAt(index);
- if (p == '/') { //$NON-NLS-1$
- break;
- }
- if (p == ':') { //$NON-NLS-1$
- newProtocol = spec.substring(0, index);
- break;
- }
- }
- return (newProtocol != null && newProtocol.compareToIgnoreCase("file") == 0); //$NON-NLS-1$
- }
-
- /**
- *
- * @param url
- * @return String
- */
- private String getPath(URL url) {
- String ref = url.getRef() == null ? "" : "#" + url.getRef(); //$NON-NLS-1$ //$NON-NLS-2$
- String strPath = url.getFile() + ref;
- IPath path;
- if (strPath.length() == 0) {
- path = Path.ROOT;
- }
- else {
- path = new Path(strPath);
- String query = null;
- StringTokenizer parser = new StringTokenizer(strPath, "?"); //$NON-NLS-1$
- int tokenCount = parser.countTokens();
- if (tokenCount == 2) {
- path = new Path((String) parser.nextElement());
- query = (String) parser.nextElement();
- }
- if (query == null) {
- parser = new StringTokenizer(path.toString(), "#"); //$NON-NLS-1$
- tokenCount = parser.countTokens();
- if (tokenCount == 2) {
- path = new Path((String) parser.nextElement());
- }
- }
- }
- return getPath(path, url.getHost());
- }
-
- /**
- *
- * @param path
- * @param host
- * @return String
- */
- private String getPath(IPath path, String host) {
- IPath newPath = path;
- // They are potentially for only Windows operating system.
- // a.) if path has a device, and if it begins with IPath.SEPARATOR, remove it
- final String device = path.getDevice();
- if ((device != null) && (device.length() > 0)) {
- if (device.charAt(0) == IPath.SEPARATOR) {
- final String newDevice = device.substring(1);
- newPath = path.setDevice(newDevice);
- }
- }
- // b.) if it has a hostname, it is UNC name... Any java or eclipse api helps it ??
- if (path != null && host != null && host.length() != 0) {
- IPath uncPath = new Path(host);
- uncPath = uncPath.append(path);
- newPath = uncPath.makeUNC(true);
- }
- return newPath.toString();
- }
-
- // defect 244817 end
- /**
- * Resolve the (possibly relative) URI acording to RFC1808
- * using the default file base location. Resolves resource references
- * into absolute resource locations without ensuring that the resource
- * actually exists.
- *
- * Note: currently resolveCrossProjectLinks is ignored in this implementation.
- */
- public java.lang.String getLocationByURI(String uri, boolean resolveCrossProjectLinks) {
- return getLocationByURI(uri, getFileBaseLocation(), resolveCrossProjectLinks);
- }
-
- /**
- * Perform the getLocationByURI action using the baseReference as the
- * point of reference instead of the default for this resolver
- *
- * Note: currently resolveCrossProjectLinks is ignored in this implementation.
- */
- public java.lang.String getLocationByURI(String uri, String baseReference, boolean resolveCrossProjectLinks) {
- return getLocationByURI(uri, baseReference);
- }
-
- public org.eclipse.core.resources.IProject getProject() {
- return fProject;
- }
-
- public org.eclipse.core.resources.IContainer getRootLocation() {
- return fProject;
- }
-
- protected String getRootLocationString() {
- return null;
- }
-
- public void setFileBaseLocation(java.lang.String newFileBaseLocation) {
- fFileBaseLocation = newFileBaseLocation;
- }
-
- public void setProject(org.eclipse.core.resources.IProject newProject) {
- fProject = newProject;
- }
-
- public InputStream getURIStream(String uri) {
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java
deleted file mode 100644
index 4974bedab9..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ResourceUtil.java
+++ /dev/null
@@ -1,68 +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.core.util;
-
-
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IWorkspaceRoot;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.wst.sse.core.IStructuredModel;
-
-
-/**
- * Note: this class should probably go in util package.
- * Seems general purpose enough.
- */
-public class ResourceUtil {
-
- /**
- * Obtain IFile from IStructuredModel
- */
- public static IFile getFileFor(IStructuredModel model) {
- if (model == null)
- return null;
- String path = model.getBaseLocation();
- if (path == null || path.length() == 0) {
- Object id = model.getId();
- if (id == null)
- return null;
- path = id.toString();
- }
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- IFile file = root.getFileForLocation(new Path(path));
- return file;
- }
-
- /**
- * Obtain IFiles from IStructuredModel (includes linkedResources)
- * @return the corresponding files in the workspace, or an empty array if none
- */
- public static IFile[] getFilesFor(IStructuredModel model) {
- IFile[] files = new IFile[0];
-
- if (model != null) {
- String path = model.getBaseLocation();
- if (path == null || path.length() == 0) {
- Object id = model.getId();
- if (id == null)
- return files;
- path = id.toString();
- }
- IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
- files = root.findFilesForLocation(new Path(path));
- }
- return files;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java
deleted file mode 100644
index cce8eb22c6..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/ScriptLanguageKeys.java
+++ /dev/null
@@ -1,39 +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.core.util;
-
-/**
- * Contains list of script languages and mime types
- */
-public interface ScriptLanguageKeys {
- public static final String[] JAVASCRIPT_LANGUAGE_KEYS = {"javascript", //$NON-NLS-1$
- "javascript1.0", //$NON-NLS-1$
- "javascript1.1", //$NON-NLS-1$
- "javascript1.2", //$NON-NLS-1$
- "javascript1.3", //$NON-NLS-1$
- "javascript1.4", //$NON-NLS-1$
- "javascript1.5", //$NON-NLS-1$
- "javascript1.6", //$NON-NLS-1$
- "jscript", //$NON-NLS-1$
- "sashscript"}; //$NON-NLS-1$
-
- public static final String[] JAVASCRIPT_MIME_TYPE_KEYS = {"text/javascript", //$NON-NLS-1$
- "text/jscript", //$NON-NLS-1$
- "text/sashscript"}; //$NON-NLS-1$
-
- public static final String JAVASCRIPT = "javascript"; //$NON-NLS-1$
-
- public static final String[] JAVA_LANGUAGE_KEYS = new String[]{"java"}; //$NON-NLS-1$
-
- public static final String JAVA = "java"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java
deleted file mode 100644
index 1d2d32d2bb..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/StringUtils.java
+++ /dev/null
@@ -1,711 +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.core.util;
-
-
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.StringTokenizer;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.Document;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.wst.sse.core.exceptions.SourceEditingRuntimeException;
-
-
-public class StringUtils {
-
- protected static final String EQUAL_SIGN = "="; //$NON-NLS-1$
- protected static final String EQUAL_SIGN_ENTITY = "&#61;"; //$NON-NLS-1$
- protected static final String LINE_FEED = "\n"; //$NON-NLS-1$
- protected static final String LINE_FEED_ENTITY = "\\n"; //$NON-NLS-1$
- protected static final String LINE_FEED_TAG = "<dl>"; //$NON-NLS-1$
- protected static final String CARRIAGE_RETURN = "\r"; //$NON-NLS-1$
- protected static final String CARRIAGE_RETURN_ENTITY = "\\r"; //$NON-NLS-1$
- protected static final String LINE_TAB = "\t"; //$NON-NLS-1$
- protected static final String LINE_TAB_ENTITY = "\\t"; //$NON-NLS-1$
- protected static final String LINE_TAB_TAG = "<dd>"; //$NON-NLS-1$
- protected static final String LESS_THAN = "<"; //$NON-NLS-1$
- protected static final String LESS_THAN_ENTITY = "&lt;"; //$NON-NLS-1$
- protected static final String GREATER_THAN = ">"; //$NON-NLS-1$
- protected static final String GREATER_THAN_ENTITY = "&gt;"; //$NON-NLS-1$
- protected static final String AMPERSTAND = "&"; //$NON-NLS-1$
- protected static final String AMPERSTAND_ENTITY = "&&;"; //$NON-NLS-1$
- protected static final String SINGLE_QUOTE = "'"; //$NON-NLS-1$
- protected static final String SINGLE_QUOTE_ENTITY = "&#039;"; //$NON-NLS-1$
- protected static final String DOUBLE_QUOTE = "\""; //$NON-NLS-1$
- protected static final String DOUBLE_QUOTE_ENTITY = "&quot;"; //$NON-NLS-1$
- protected static final String SPACE = " "; //$NON-NLS-1$
- protected static final String SPACE_ENTITY = "&nbsp;"; //$NON-NLS-1$
- protected static final char SINGLE_QUOTE_CHAR = '\''; //$NON-NLS-1$
- protected static final char DOUBLE_QUOTE_CHAR = '\"'; //$NON-NLS-1$
- protected static final String CR = "\r"; // carriage return //$NON-NLS-1$
- protected static final String LF = "\n"; // line feed //$NON-NLS-1$
- protected static final String CRLF = "\r\n"; // carriage return and line feed //$NON-NLS-1$
- protected static final String DELIMITERS = " \t\n\r\f"; // delimiters //$NON-NLS-1$
- private static final String TRUE = "true"; //$NON-NLS-1$
- private static final String FALSE = "false"; //$NON-NLS-1$
-
- /**
- * StringUtils constructor comment.
- */
- private StringUtils() {
- super();
- }
-
- /**
- * Breaks out space-separated words into an array of words.
- * For example: <code>"no comment"</code> into an array
- * <code>a[0]="no"</code> and <code>a[1]= "comment"</code>.
- *
- * @param value the string to be converted
- * @return the list of words
- */
- public static String[] asArray(String value) {
- ArrayList list = new ArrayList();
- StringTokenizer stok = new StringTokenizer(value);
- while (stok.hasMoreTokens()) {
- list.add(stok.nextToken());
- }
- String result[] = new String[list.size()];
- list.toArray(result);
- return result;
- }
-
- /**
- * Breaks out delim-separated words into an array of words.
- * For example: <code>"no comment"</code> into an array
- * <code>a[0]="no"</code> and <code>a[1]= "comment"</code>.
- *
- * @param value the string to be converted
- * @return the list of words
- */
- public static String[] asArray(String value, String delim) {
- return asArray(value, delim, false);
- }
-
- /**
- * Breaks out delim-separated words into an array of words.
- * For example: <code>"abc,,def"</code> into an array
- * <code>a[0]="abc"</code>, <code>a[1]=null</code>
- * , and <code>a[2]= "def"</code>where "," is the delim.
- *
- * @param value the string to be converted
- * @return the list of words
- */
- public static String[] asFixedArray(String value, String delim) {
- String array[] = asArray(value, delim, true);
- int arrayLength = array.length;
- boolean stringFound = false;
- ArrayList list = new ArrayList();
-
- for (int i = 0; i < arrayLength; i++) {
- String token = array[i];
- if (token.compareTo(delim) == 0) {
- if (!stringFound)
- list.add(null);
- stringFound = false;
- }
- else {
- list.add(token);
- stringFound = true;
- }
- }
- // add one more null if last token is the delim
- if (!stringFound)
- list.add(null);
-
- String result[] = new String[list.size()];
- list.toArray(result);
- return result;
- }
-
- /**
- * Breaks out delim-separated words into an array of words.
- * For example: <code>"no comment"</code> into an array
- * <code>a[0]="no"</code> and <code>a[1]= "comment"</code>.
- *
- * @param value the string to be converted
- * @return the list of words
- */
- public static String[] asArray(String value, String delim, boolean returnTokens) {
- ArrayList list = new ArrayList();
- StringTokenizer stok = new StringTokenizer(value, delim, returnTokens);
- while (stok.hasMoreTokens()) {
- list.add(stok.nextToken());
- }
- String result[] = new String[list.size()];
- list.toArray(result);
- return result;
- }
-
- public static String chop(String source) {
- return chop(source, "/"); //$NON-NLS-1$
- }
-
- public static String chop(String source, String delimiter) {
- return source.substring(0, source.lastIndexOf(delimiter));
- }
-
- /**
- * Converts a string into a form that will not conflict with saving
- * it into an INI file
- */
- public static String escape(String normalString) {
- if (normalString == null)
- return null;
- StringBuffer escapedBuffer = new StringBuffer();
- StringTokenizer toker = new StringTokenizer(normalString, EQUAL_SIGN + LINE_FEED + CARRIAGE_RETURN + LINE_TAB, true);
- String chunk = null;
- while (toker.hasMoreTokens()) {
- chunk = toker.nextToken();
- if (chunk.equals(EQUAL_SIGN)) {
- escapedBuffer.append(EQUAL_SIGN_ENTITY);
- }
- else if (chunk.equals(LINE_FEED)) {
- escapedBuffer.append(LINE_FEED_ENTITY);
- }
- else if (chunk.equals(CARRIAGE_RETURN)) {
- escapedBuffer.append(CARRIAGE_RETURN_ENTITY);
- }
- else if (chunk.equals(LINE_TAB)) {
- escapedBuffer.append(LINE_TAB_ENTITY);
- }
- else {
- escapedBuffer.append(chunk);
- }
- }
- return escapedBuffer.toString();
- }
-
- public static String firstLineOf(String text) {
- if (text == null || text.length() < 1) {
- return text;
- }
- IDocument doc = new Document(text);
- try {
- int lineNumber = doc.getLineOfOffset(0);
- IRegion line = doc.getLineInformation(lineNumber);
- return doc.get(line.getOffset(), line.getLength());
- }
- catch (BadLocationException e) {
- // do nothing
- }
- return text;
- }
-
- /**
- * @deprecated
- * renamed to appendIfNotEndWith
- */
- public static String insertIfNotEndWith(String aString, String insertString) {
- return appendIfNotEndWith(aString, insertString);
- }
-
- /**
- * Append appendString to the end of aString only if aString does not end with the insertString.
- */
- public static String appendIfNotEndWith(String aString, String appendString) {
- if ((aString != null) && (appendString != null))
- if (aString.endsWith(appendString))
- return aString;
- else
- return aString + appendString;
- else
- return aString;
- }
-
- /**
- * Insert insertString to the beginning of aString only if aString does not start with the insertString.
- */
- public static String insertIfNotStartWith(String aString, String insertString) {
- if ((aString != null) && (insertString != null))
- if (aString.startsWith(insertString))
- return aString;
- else
- return insertString + aString;
- else
- return aString;
- }
-
- public static boolean isQuoted(String string) {
- if ((string == null) || (string.length() < 2))
- return false;
-
- int lastIndex = string.length() - 1;
- char firstChar = string.charAt(0);
- char lastChar = string.charAt(lastIndex);
-
- return (((firstChar == SINGLE_QUOTE_CHAR) && (lastChar == SINGLE_QUOTE_CHAR)) || ((firstChar == DOUBLE_QUOTE_CHAR) && (lastChar == DOUBLE_QUOTE_CHAR)));
- }
-
- /**
- * Unit tests.
- * @param args java.lang.String[]
- */
- public static void main(String[] args) {
- //testPaste();
- testStripNonLetterDigits();
- }
-
- public static void testPaste() {
- String testString = "The quick brown fox ..."; //$NON-NLS-1$
- System.out.println(paste(testString, null, 4, 5));
- System.out.println(paste(testString, null, 4, 6));
- System.out.println(paste(testString, "", 4, 6)); //$NON-NLS-1$
- System.out.println(paste(testString, "fast", 4, 6)); //$NON-NLS-1$
- System.out.println(paste(testString, "fast ", 4, 6)); //$NON-NLS-1$
- System.out.println(paste(testString, "But ", 0, 0)); //$NON-NLS-1$
- System.out.println(paste("", "burp", 4, 6)); //$NON-NLS-2$//$NON-NLS-1$
- }
-
- public static void testStripNonLetterDigits() {
- String testString = "abc"; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = ""; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "\"abc\""; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "\"ab-c1?"; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "+++"; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "abc="; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
- testString = "abc "; //$NON-NLS-1$
- System.out.println(testString + " -->" + stripNonLetterDigits(testString) + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
-
- }
-
- /*
- * Returns the merged form of both strings
- */
- public static String merge(String newStart, String newEnd) {
- String[] regions = overlapRegions(newStart, newEnd);
- return regions[0] + regions[1] + regions[2];
- }
-
- public static int occurrencesOf(String searchString, char targetChar) {
- int result = 0;
- int len = searchString.length();
- for (int i = 0; i < len; i++) {
- if (targetChar == searchString.charAt(i))
- result++;
- }
- return result;
- }
-
- /**
- *
- * @return java.lang.String[]
- * @param start java.lang.String
- * @param end java.lang.String
- *
- * Returns a 3 String array containing unique text from the start, duplicated text
- * that overlaps the start and end, and the unique text from the end.
- */
- private static String[] overlapRegions(String start, String end) {
- String[] results = new String[3];
- if (start != null && end == null)
- return new String[]{start, "", ""}; //$NON-NLS-2$//$NON-NLS-1$
- if (start == null && end != null)
- return new String[]{"", "", end}; //$NON-NLS-2$//$NON-NLS-1$
- if (start == null && end == null)
- return new String[]{"", "", ""}; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
-
- int startLength = start.length();
- int endLength = end.length();
-
- if (startLength == 0 || endLength == 0)
- return new String[]{"", "", ""}; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
-
- String testStart = ""; //$NON-NLS-1$
- String testEnd = ""; //$NON-NLS-1$
- int mergeLength = Math.min(startLength, endLength);
- boolean finished = false;
- while (mergeLength > 0 && !finished) {
- testStart = start.substring(startLength - mergeLength);
- testEnd = end.substring(0, mergeLength);
- //case sensitive
- if (testStart.equals(testEnd)) {
- finished = true;
- results[0] = start.substring(0, startLength - mergeLength);
- results[1] = start.substring(startLength - mergeLength);
- results[2] = end.substring(mergeLength);
- }
- mergeLength--;
- }
- if (!finished) {
- results[0] = start;
- results[1] = ""; //$NON-NLS-1$
- results[2] = end;
- }
-
- return results;
- }
-
- /**
- * Packs an array of Strings into a single comma delimited String.
- * @param strings
- * @return
- * @todo Generated comment
- */
- public static String pack(String[] strings) {
- StringBuffer buf = new StringBuffer();
- for (int i = 0; i < strings.length; i++) {
- buf.append(StringUtils.replace(strings[i], ",", "&comma;")); //$NON-NLS-1$ //$NON-NLS-2$
- if (i < strings.length - 1)
- buf.append(","); //$NON-NLS-1$
- }
- return buf.toString();
- }
-
- /**
- * Unpacks a comma delimited String into an array of Strings
- * @param s
- * @return
- * @todo Generated comment
- */
- public static String[] unpack(String s) {
- StringTokenizer toker = new StringTokenizer(s, ","); //$NON-NLS-1$
- List list = new ArrayList();
- while (toker.hasMoreTokens()) {
- // since we're separating the values with ',', escape ',' in the
- // values
- list.add(StringUtils.replace(toker.nextToken(), "&comma;", ",").trim()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return (String[]) list.toArray(new String[0]);
- }
-
- /*
- * Pastes the new text into the old at the start position, replacing text implied by length.
- */
- public static String paste(String oldText, String newText, int start, int length) {
- String result = null;
- StringBuffer sb = new StringBuffer();
- int startIndex = start;
- int endIndex = start + length;
- if (startIndex > oldText.length()) {
- startIndex = oldText.length();
- }
- sb.append(oldText.substring(0, startIndex));
- // null or empty new text accompliches a delete
- if (newText != null) {
- sb.append(newText);
- }
- if (endIndex < oldText.length()) {
-
- sb.append(oldText.substring(endIndex));
- }
- result = sb.toString();
- return result;
- }
-
- /**
- * Replace matching literal portions of a string with another string
- */
- public static String replace(String aString, String source, String target) {
- if (aString == null)
- return null;
- String normalString = ""; //$NON-NLS-1$
- int length = aString.length();
- int position = 0;
- int previous = 0;
- int spacer = source.length();
- while (position + spacer - 1 < length && aString.indexOf(source, position) > -1) {
- position = aString.indexOf(source, previous);
- normalString = normalString + aString.substring(previous, position) + target;
- position += spacer;
- previous = position;
- }
- normalString = normalString + aString.substring(position, aString.length());
-
- return normalString;
- }
-
- /**
- * Restore the entity references for markup delimiters in text where
- * they have been replaced by the proper Unicode values through a DOM
- * text parser.
- */
- public static String restoreMarkers(String text) {
- String content = text;
- content = replace(content, AMPERSTAND, AMPERSTAND_ENTITY);
- content = replace(content, LESS_THAN, LESS_THAN_ENTITY);
- content = replace(content, GREATER_THAN, GREATER_THAN_ENTITY);
- return content;
- }
-
- /**
- * Removes extra whitespace characters and quotes
- */
- public static String strip(String quotedString) {
- if (quotedString == null || quotedString.length() == 0)
- return quotedString;
- String trimmed = quotedString.trim();
- if (trimmed.length() < 2)
- return quotedString;
-
- char first = trimmed.charAt(0);
- char nextToLast = trimmed.charAt(trimmed.length() - 2);
- char last = trimmed.charAt(trimmed.length() - 1);
-
- if ((first == '\"' && last == '\"' && nextToLast != '\\') || (first == '\'' && last == '\'' && nextToLast != '\\')) {
- return trimmed.substring(1, trimmed.length() - 1);
- }
- return trimmed;
- }
-
- /** Similar to strip, except quotes don't need to match
- * such as "UTF' is still stripped of both quotes.
- * (Plus, this one does not detect escaped quotes)
- */
- public static String stripQuotes(String quotedValue) {
- if (quotedValue == null)
- return null;
- // normally will never have leading or trailing blanks,
- // but if it does, we'll do lenient interpretation
- return stripQuotesLeaveInsideSpace(quotedValue).trim();
- }
-
- /**
- * Like strip quotes, except leaves the start and end space inside the quotes
- * @param quotedValue
- * @return
- */
- public static String stripQuotesLeaveInsideSpace(String quotedValue) {
- if (quotedValue == null)
- return null;
- // nomally will never have leading or trailing blanks ... but just in case.
- String result = quotedValue.trim();
- int len = result.length();
- if (len > 0) {
- char firstChar = result.charAt(0);
- if ((firstChar == SINGLE_QUOTE_CHAR) || (firstChar == DOUBLE_QUOTE_CHAR)) {
- result = result.substring(1, len);
- }
- len = result.length();
- if (len > 0) {
- char lastChar = result.charAt(len - 1);
- if ((lastChar == SINGLE_QUOTE_CHAR) || (lastChar == DOUBLE_QUOTE_CHAR)) {
- result = result.substring(0, len - 1);
- }
- }
- }
- return result;
- }
-
- /**
- * Remove "escaped" chars from a string.
- */
- public static String unescape(String aString) {
- if (aString == null)
- return null;
- String normalString = replace(aString, EQUAL_SIGN_ENTITY, EQUAL_SIGN);
- normalString = replace(normalString, LINE_FEED_ENTITY, LINE_FEED);
- normalString = replace(normalString, CARRIAGE_RETURN_ENTITY, CARRIAGE_RETURN);
- normalString = replace(normalString, LINE_TAB_ENTITY, LINE_TAB);
- return normalString;
- }
-
- public static String uniqueEndOf(String newStart, String newEnd) {
- String[] regions = overlapRegions(newStart, newEnd);
- return regions[2];
- }
-
- public static String toString(boolean booleanValue) {
- if (booleanValue)
- return TRUE;
- else
- return FALSE;
- }
-
- public static boolean contains(String[] arrayOfStrings, String needle, boolean caseSensitive) {
- boolean result = false;
- if (needle == null)
- return false;
- if (arrayOfStrings == null)
- return false;
-
- if (caseSensitive) {
- for (int i = 0; i < arrayOfStrings.length; i++) {
- if (needle.equals(arrayOfStrings[i])) {
- result = true;
- break;
- }
- }
- }
- else {
- for (int i = 0; i < arrayOfStrings.length; i++) {
- if (needle.equalsIgnoreCase(arrayOfStrings[i])) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- public static String convertLineDelimiters(String allText, String lineDelimiterToUse) {
- IDocument tempDoc = new Document(allText);
-
- if (lineDelimiterToUse == null)
- lineDelimiterToUse = System.getProperty("line.separator"); //$NON-NLS-1$
-
- String newText = new String();
- int lineCount = tempDoc.getNumberOfLines();
- for (int i = 0; i < lineCount; i++) {
- try {
- org.eclipse.jface.text.IRegion lineInfo = tempDoc.getLineInformation(i);
- int lineStartOffset = lineInfo.getOffset();
- int lineLength = lineInfo.getLength();
- int lineEndOffset = lineStartOffset + lineLength;
- newText += allText.substring(lineStartOffset, lineEndOffset);
-
- if ((i < lineCount - 1) && (tempDoc.getLineDelimiter(i) != null))
- newText += lineDelimiterToUse;
- }
- catch (BadLocationException exception) {
- throw new SourceEditingRuntimeException(exception);
- }
- }
-
- return newText;
- }
-
- /**
- * Replaces all instances of special HTML characters
- * with the appropriate HTML entity equivalent.
- * WARNING only use this method for strings that dont already have HTML-specific items such as
- * tags and entities.
- * @param String content String to convert
- *
- * @return String the converted string
- * @see HTMLPrinter#convertToHTMLContent(String content)
- */
- public static String convertToHTMLContent(String content) {
- content = replace(content, AMPERSTAND, AMPERSTAND_ENTITY);
- content = replace(content, LESS_THAN, LESS_THAN_ENTITY);
- content = replace(content, GREATER_THAN, GREATER_THAN_ENTITY);
- content = replace(content, LINE_FEED, LINE_FEED_TAG);
- content = replace(content, LINE_TAB, LINE_TAB_TAG);
- content = replace(content, SINGLE_QUOTE, SINGLE_QUOTE_ENTITY);
- content = replace(content, DOUBLE_QUOTE, DOUBLE_QUOTE_ENTITY);
- content = replace(content, SPACE + SPACE, SPACE_ENTITY + SPACE_ENTITY); // replacing every space would be too much
- return content;
- }
-
- /**
- * This method strips anything from the beginning and end of a
- * string that is not a letter or digit. It is used by some
- * encoding detectors to come up with the encoding name from
- * illformed input (e.g in <?xml encoding="abc?> -- where final
- * quote is left off, the '>' is returned with the
- * rest of the attribute value 'abc').
- */
- public static String stripNonLetterDigits(String fullValue) {
- if (fullValue == null || fullValue.length() == 0)
- return fullValue;
- int fullValueLength = fullValue.length();
- int firstPos = 0;
- while (firstPos < fullValueLength && !Character.isLetterOrDigit(fullValue.charAt(firstPos))) {
- firstPos++;
- }
- int lastPos = fullValueLength - 1;
- while (lastPos > firstPos && !Character.isLetterOrDigit(fullValue.charAt(lastPos))) {
- lastPos--;
- }
- String result = fullValue;
- if (firstPos != 0 || lastPos != fullValueLength) {
- result = fullValue.substring(firstPos, lastPos + 1);
- }
- return result;
- }
-
- public static int indexOfLineDelimiter(String aString) {
- return indexOfLineDelimiter(aString, 0);
- }
-
- public static int indexOfLineDelimiter(String aString, int offset) {
- int index = -1;
-
- if (aString != null && aString.length() > 0) {
- index = aString.indexOf(CRLF, offset);
- if (index == -1) {
- index = aString.indexOf(CR, offset);
- if (index == -1)
- index = aString.indexOf(LF, offset);
- }
- }
-
- return index;
- }
-
- public static boolean containsLineDelimiter(String aString) {
- return indexOfLineDelimiter(aString) != -1;
- }
-
- public static int indexOfLastLineDelimiter(String aString) {
- return indexOfLastLineDelimiter(aString, aString.length());
- }
-
- public static int indexOfLastLineDelimiter(String aString, int offset) {
- int index = -1;
-
- if (aString != null && aString.length() > 0) {
- index = aString.lastIndexOf(CRLF, offset);
- if (index == -1) {
- index = aString.lastIndexOf(CR, offset);
- if (index == -1)
- index = aString.lastIndexOf(LF, offset);
- }
- }
-
- return index;
- }
-
- public static int indexOfNonblank(String aString) {
- return indexOfNonblank(aString, 0);
- }
-
- public static int indexOfNonblank(String aString, int offset) {
- int index = -1;
-
- if (aString != null && aString.length() > 0) {
- for (int i = offset; i < aString.length(); i++) {
- if (DELIMITERS.indexOf(aString.substring(i, i + 1)) == -1) {
- index = i;
- break;
- }
- }
- }
-
- return index;
- }
-
- public static boolean containsLetters(String fullValue) {
-
- if (fullValue == null || fullValue.length() == 0)
- return false;
-
- char[] chars = fullValue.toCharArray();
- for(int i=0; i<fullValue.length(); i++)
- if(Character.isLetter(chars[i]))
- return true;
-
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java
deleted file mode 100644
index c7534f3262..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/TextUtilities.java
+++ /dev/null
@@ -1,81 +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.core.util;
-
-
-
-/**
- * Collection of text functions.
- */
-// This class was originally copied from org.eclipse.jface.text, and made public
-public class TextUtilities {
-
- /**
- * Determines which one of fgDelimiters appears first in the text. If none of them the
- * hint is returned.
- * @deprecated - no longer needed, at least not here
- */
- public static String determineLineDelimiter(StringBuffer textBuffer, String[] possibles, String hint) {
- try {
- // TODO: avoid use of String instance
- String text = textBuffer.toString();
- int[] info = indexOf(possibles, text, 0);
- return possibles[info[1]];
- }
- catch (ArrayIndexOutOfBoundsException x) {
- }
- return hint;
- }
-
- /**
- * Returns whether the text ends with one of the given search strings.
- */
- public static boolean endsWith(String[] searchStrings, String text) {
- for (int i = 0; i < searchStrings.length; i++) {
- if (text.endsWith(searchStrings[i]))
- return true;
- }
- return false;
- }
-
- /**
- * Returns the position in the string greater than offset
- * of the longest matching search string.
- */
- public static int[] indexOf(String[] searchStrings, String text, int offset) {
-
- int[] result = {-1, -1};
-
- for (int i = 0; i < searchStrings.length; i++) {
- int index = text.indexOf(searchStrings[i], offset);
- if (index >= 0) {
-
- if (result[0] == -1) {
- result[0] = index;
- result[1] = i;
- }
- else if (index < result[0]) {
- result[0] = index;
- result[1] = i;
- }
- else if (index == result[0] && searchStrings[i].length() > searchStrings[result[1]].length()) {
- result[0] = index;
- result[1] = i;
- }
- }
- }
-
- return result;
-
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.java
deleted file mode 100644
index 7d3bc01299..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/URIResolver.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.core.util;
-
-import java.io.InputStream;
-
-import org.eclipse.core.resources.IContainer;
-import org.eclipse.core.resources.IProject;
-
-
-
-public interface URIResolver {
-
- String getFileBaseLocation();
-
- /**
- * Resolve the (possibly relative) URI acording to RFC1808
- * using the default file base location. Resolves resource references
- * into absolute resource locations without ensuring that the resource
- * actually exists.
- */
- String getLocationByURI(String uri);
-
- /**
- * Perform the getLocationByURI action using the baseReference as the
- * point of reference instead of the default for this resolver
- */
- String getLocationByURI(String uri, String baseReference);
-
- /**
- * Resolve the (possibly relative) URI acording to RFC1808
- * using the default file base location. Resolves resource references
- * into absolute resource locations without ensuring that the resource
- * actually exists.
- *
- * If resolveCrossProjectLinks is set to true, then this method will
- * properly resolve the URI if it is a valid URI to another (appropriate)
- * project.
- */
- String getLocationByURI(String uri, boolean resolveCrossProjectLinks);
-
- /**
- * Perform the getLocationByURI action using the baseReference as the
- * point of reference instead of the default for this resolver
- *
- * If resolveCrossProjectLinks is set to true, then this method will
- * properly resolve the URI if it is a valid URI to another (appropriate)
- * project.
- */
- String getLocationByURI(String uri, String baseReference, boolean resolveCrossProjectLinks);
-
- /**
- * Attempts to return a direct inputstream to the given URI which must be
- * relative to the default point of reference.
- */
- InputStream getURIStream(String uri);
-
- IProject getProject();
-
- IContainer getRootLocation();
-
- void setFileBaseLocation(String newLocation);
-
- void setProject(IProject newProject);
-
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.java
deleted file mode 100644
index 5103cb372c..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/util/Utilities.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.core.util;
-
-
-
-import java.io.BufferedInputStream;
-import java.io.InputStream;
-
-import org.eclipse.wst.encoding.CodedIO;
-import org.eclipse.wst.encoding.internal.BufferedLimitedStream;
-
-
-public class Utilities {
-
-
- /**
- * Utilities constructor comment.
- */
- public Utilities() {
- super();
- }
-
- /**
- * a common calculation in some of the parsing methods (e.g. in ContextRegion and IStructuredDocumentRegion)
- */
- public static int calculateLengthDifference(String changes, int lengthToReplace) {
- // determine the length by the text itself, or, if there is no text to
- // insert (i.e. we are doing a delete) then calculate the length as
- // a negative number to denote the amount to delete.
- // For a straight insert, the selection Length will be zero.
- int lengthDifference = 0;
- if (changes == null) {
- // the delete case
- lengthDifference = 0 - lengthToReplace;
- }
- else {
- lengthDifference = changes.length() - lengthToReplace;
- }
- if (Debug.debugStructuredDocument) {
- System.out.println("lengthDifference: " + lengthDifference);//$NON-NLS-1$
- }
- return lengthDifference;
- }
-
- /**
- * Careful, this uses identity. Not good for basic strings.
- */
- public static boolean contains(Object[] objectArray, Object object) {
- boolean result = false;
- // if object or objectArray is null, return false
- if ((objectArray != null) && (object != null)) {
- for (int i = 0; i < objectArray.length; i++) {
- if (objectArray[i] == object) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- public static boolean containsString(String[] objectArray, String object) {
- boolean result = false;
- // if object or objectArray is null, return false
- if ((objectArray != null) && (object != null)) {
- for (int i = 0; i < objectArray.length; i++) {
- if (objectArray[i].equals(object)) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
-
- /**
- * Used for log/trace messages. Id is assumed to be some form of a filename. See IModelManager.
- */
- public static String makeShortId(Object id) {
- if (id == null)
- id = "NOID";
- String whole = id.toString();
- String part = whole.substring(whole.lastIndexOf("/") + 1); //$NON-NLS-1$
- return "..." + part; //$NON-NLS-1$
- }
-
- /**
- * Ensures that an InputStream has mark/reset support.
- */
- public static InputStream getMarkSupportedStream(InputStream original) {
- if (original == null)
- return null;
- if (original.markSupported())
- return original;
- InputStream buffered = new BufferedInputStream(original, CodedIO.MAX_BUF_SIZE);
- buffered.mark(CodedIO.MAX_MARK_SIZE);
- return buffered;
- }
- /**
- * Ensures that an InputStream has mark/reset support,
- * is readlimit is set, and that the stream is "limitable"
- * (that is, reports "end of input" rather than allow going past
- * mark). This is very specialized stream introduced to overcome
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=67211.
- * See also https://bugs.eclipse.org/bugs/show_bug.cgi?id=68565
- */
- public static InputStream getLimitedStream(InputStream original) {
- if (original == null)
- return null;
- if (original instanceof BufferedLimitedStream)
- return original;
- return new BufferedLimitedStream(original, CodedIO.MAX_BUF_SIZE);
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.java
deleted file mode 100644
index d515c8f430..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationAdapter.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.core.validate;
-
-
-
-import org.eclipse.wst.sse.core.INodeAdapter;
-import org.eclipse.wst.sse.core.IndexedRegion;
-
-/**
- */
-public interface ValidationAdapter extends INodeAdapter {
-
- /**
- */
- void setReporter(ValidationReporter reporter);
-
- /**
- */
- void validate(IndexedRegion node);
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.java
deleted file mode 100644
index d6b7cf70c8..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationMessage.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.core.validate;
-
-
-
-/**
- */
-public class ValidationMessage {
-
- private String message;
- private int offset;
- private int length;
- private int severity;
- public static final int ERROR = 1;
- public static final int WARNING = 2;
- public static final int INFORMATION = 3;
-
- /**
- */
- public ValidationMessage(String message, int offset, int severity) {
- this(message, offset, 0, severity);
- }
-
- /**
- */
- public ValidationMessage(String message, int offset, int length, int severity) {
- super();
-
- this.message = message;
- this.offset = offset;
- this.length = length;
- this.severity = severity;
- }
-
- /**
- */
- public int getLength() {
- return this.length;
- }
-
- /**
- */
- public String getMessage() {
- return this.message;
- }
-
- /**
- */
- public int getOffset() {
- return this.offset;
- }
-
- /**
- */
- public int getSeverity() {
- return this.severity;
- }
-}
diff --git a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.java b/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.java
deleted file mode 100644
index 17a619cc6b..0000000000
--- a/bundles/org.eclipse.wst.sse.core/src/org/eclipse/wst/sse/core/validate/ValidationReporter.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.core.validate;
-
-
-
-/**
- */
-public interface ValidationReporter {
-
- /**
- */
- void report(ValidationMessage message);
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/build.properties b/bundles/org.eclipse.wst.sse.ui/build.properties
deleted file mode 100644
index ceada8808a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/build.properties
+++ /dev/null
@@ -1,13 +0,0 @@
-bin.includes = html/,\
- icons/,\
- plugin.properties,\
- plugin.xml,\
- .options,\
- toc.xml,\
- schema/,\
- jspdebug.properties,\
- editor.jar,\
- Editing.properties
-jars.compile.order = editor.jar
-source.editor.jar = src/
-output.editor.jar = bin/
diff --git a/bundles/org.eclipse.wst.sse.ui/html/maintopic.html b/bundles/org.eclipse.wst.sse.ui/html/maintopic.html
deleted file mode 100644
index a476078ace..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/html/maintopic.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Main Topic</title>
-</head>
-
-<body>
-<h1>Main Topic</h1>
-Please enter your text here.
-</body>
-</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.sse.ui/html/subtopic.html b/bundles/org.eclipse.wst.sse.ui/html/subtopic.html
deleted file mode 100644
index 8a61c501d6..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/html/subtopic.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Sub Topic</title>
-</head>
-
-<body>
-<h1>Sub Topic</h1>
-Please enter your text here.
-</body>
-</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.sse.ui/html/toc.html b/bundles/org.eclipse.wst.sse.ui/html/toc.html
deleted file mode 100644
index 326f0a9ff3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/html/toc.html
+++ /dev/null
@@ -1,13 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
-
-<html>
-<head>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
- <title>Table of Contents</title>
-</head>
-
-<body>
-<h1>Table of Contents</h1>
-Please enter your text here.
-</body>
-</html> \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/ctool16/spellcheck.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/ctool16/spellcheck.gif
deleted file mode 100644
index c71de32fce..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/ctool16/spellcheck.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/collapseall.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/collapseall.gif
deleted file mode 100644
index 7dc0de5130..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/collapseall.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/delete.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/delete.gif
deleted file mode 100644
index 2e197c25e8..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/delete.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/synced.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/synced.gif
deleted file mode 100644
index 4b9e567edd..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/dlcl16/synced.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/dtool16/spellcheck.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/dtool16/spellcheck.gif
deleted file mode 100644
index a4cf55ffe9..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/dtool16/spellcheck.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/collapseall.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/collapseall.gif
deleted file mode 100644
index a2d80a9044..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/collapseall.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/delete.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/delete.gif
deleted file mode 100644
index 0ae6decd03..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/delete.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/synced.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/synced.gif
deleted file mode 100644
index 05cefef687..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/elcl16/synced.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/etool16/spellcheck.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/etool16/spellcheck.gif
deleted file mode 100644
index c71de32fce..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/etool16/spellcheck.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/occ_match.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/occ_match.gif
deleted file mode 100644
index 9e033dea5f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/occ_match.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/preferences.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/preferences.gif
deleted file mode 100644
index 4c07fea144..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/preferences.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/prop_ps.gif b/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/prop_ps.gif
deleted file mode 100644
index 3aec64dbdd..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/full/obj16/prop_ps.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/icons/sourceEditor.gif b/bundles/org.eclipse.wst.sse.ui/icons/sourceEditor.gif
deleted file mode 100644
index 75ebdb8586..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/icons/sourceEditor.gif
+++ /dev/null
Binary files differ
diff --git a/bundles/org.eclipse.wst.sse.ui/javadoc.xml b/bundles/org.eclipse.wst.sse.ui/javadoc.xml
deleted file mode 100644
index a2d69abc8a..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/javadoc.xml
+++ /dev/null
@@ -1,22 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<project
- default="javadoc"
- name="project_name">
- <target name="javadoc">
- <javadoc
- access="package"
- author="true"
- classpath="bin;..\com.ibm.etools.contentmodel\runtime\contentmodel.jar;..\org.apache.xerces\xmlParserAPIs.jar;..\org.apache.xerces\xercesImpl.jar;..\org.eclipse.core.boot\boot.jar;..\org.eclipse.core.boot.nl1\nl1.jar;..\org.eclipse.core.runtime\runtime.jar;..\org.eclipse.core.runtime.nl1\nl1.jar;..\com.ibm.etools.common.command\runtime\common.jar;..\com.ibm.etools.xmlutility\runtime\xmlutility.jar;..\org.eclipse.core.resources\resources.jar;..\org.eclipse.ant.core\antsupport.jar;..\org.eclipse.ant.core.nl1\nl1.jar;..\org.eclipse.core.resources.nl1\nl1.jar;..\com.ibm.etools.logging.util\runtime\logutil.jar;..\com.ibm.etools.logging.util\runtime\ibmjsse.jar;..\com.ibm.etools.logging.util\runtime\ibmjcefw.jar;..\com.ibm.etools.logging.util.nl1\nl1.jar;..\org.eclipse.ui\workbench.jar;..\org.eclipse.update.core\updatecore.jar;..\org.eclipse.update.core.nl1\nl1.jar;..\org.eclipse.help\help.jar;..\org.apache.lucene\lucene-1.2-rc4.jar;..\org.apache.lucene\lucene-demos-1.2-rc4.jar;..\org.eclipse.help.nl1\nl1.jar;..\org.eclipse.swt.win32\ws\win32\swt.jar;..\org.eclipse.swt.nl1\nl1.jar;..\org.eclipse.ui.nl1\nl1.jar;..\org.eclipse.ui.win32\workbenchwin32.jar;..\com.ibm.sed.preferences\bin;..\com.ibm.sed.preferences\runtime\sedpreferences.jar;..\com.ibm.etools.xml.encoding\runtime\xml.encoding.jar;..\com.ibm.etools.xml.encoding.nl1\nl1.jar;..\com.ibm.sed.preferences.nl1\nl1.jar;..\com.ibm.sed.model\bin;..\org.eclipse.jdt.ui\jdt.jar;..\org.eclipse.jdt.core\jdtcore.jar;..\org.eclipse.jdt.core.nl1\nl1.jar;..\org.eclipse.search\search.jar;..\org.eclipse.search.nl1\nl1.jar;..\org.eclipse.debug.core\dtcore.jar;..\org.eclipse.debug.core.nl1\nl1.jar;..\org.eclipse.debug.ui\dtui.jar;..\org.eclipse.debug.ui.nl1\nl1.jar;..\org.eclipse.jdt.debug\jdi.jar;..\org.eclipse.jdt.debug\jdimodel.jar;..\org.eclipse.jdt.debug.nl1\nl1.jar;..\org.eclipse.jdt.launching\launching.jar;..\org.eclipse.jdt.launching.nl1\nl1.jar;..\org.eclipse.compare\compare.jar;..\org.eclipse.compare.nl1\nl1.jar;..\org.eclipse.jdt.ui.nl1\nl1.jar;..\com.ibm.sed.editor.extensions\bin;..\com.ibm.debug.javascript\jsdebug.jar;..\com.ibm.debug.javascript\bsf.jar;..\com.ibm.debug.common\commondebug.jar;..\com.ibm.debug.common.nl1\nl1.jar;..\com.ibm.debug.javascript.nl1\nl1.jar;..\com.ibm.etools.xml.common.ui\runtime\xmlcommonui.jar;..\com.ibm.etools.b2bgui\runtime\b2bgui.jar;..\com.ibm.etools.b2butil\runtime\b2butil.jar;..\com.ibm.sed.preferences\bin;..\com.ibm.etools.b2butil.nl1\nl1.jar;..\com.ibm.etools.b2bgui.nl1\nl1.jar;..\com.ibm.sed.model\bin;..\com.ibm.etools.validate.xml\runtime\validatexml.jar;..\com.ibm.etools.xml.tools.validation\runtime\xml.validation.jar;..\com.ibm.etools.validation\runtime\validate.jar;..\com.ibm.etools.validation.core\runtime\common.jar;..\com.ibm.etools.validation.nl1\nl1.jar;..\com.ibm.etools.validation.nl1\validate_nl1.jar;..\com.ibm.etools.emf\runtime\mofrt.jar;..\com.ibm.etools.emf\runtime\mofwb.jar;..\com.ibm.etools.java\runtime\javaplugin.jar;..\com.ibm.etools.java\runtime\wftworkbenchutils.jar;..\com.ibm.etools.emf.workbench\runtime\emfworkbench.jar;..\com.ibm.etools.java.core\runtime\mofjava.jar;..\com.ibm.etools.java.core\runtime\wftutils.jar;..\com.ibm.etools.java.nl1\wftworkbenchutils_nl1.jar;..\com.ibm.etools.validate.xml.nl1\nl1.jar;..\com.ibm.etools.xml.common.ui.nl1\nl1.jar;..\com.ibm.etools.spellcheck\bin;..\com.ibm.etools.spellcheck.dictionaries\bin;..\com.ibm.etools.deviceprofile\runtime\deviceprofile.jar;..\com.ibm.etools.deviceprofile.nl1\nl1.jar;..\com.ibm.sed.editor.nl1\nl1.jar"
- destdir="doc"
- nodeprecated="false"
- nodeprecatedlist="false"
- noindex="false"
- nonavbar="false"
- notree="false"
- packagenames="com.ibm.sed.style.java,com.ibm.sed.preferences.ui.html,com.ibm.sed.edit.xml,com.ibm.sed.contentproperties.ui,com.ibm.sed.contentassist.html,com.ibm.sed.autoindent,com.ibm.sed.view.tree,com.ibm.sed.css.contentassist,com.ibm.sed.contentassist,com.ibm.sed.internal.editor,com.ibm.sed.preferences.javascript,com.ibm.sed.edit.simple,com.ibm.sed.edit.adapters,com.ibm.sed.nls,com.ibm.sed.view.events,com.ibm.sed.edit.js,com.ibm.sed.view.util,com.ibm.sed.edit.nls,com.ibm.sed.contentassist.html.javascript,com.ibm.sed.contentassist.jsp.java,com.ibm.sed.style.html.javascript,com.ibm.sed.contentassist.html.javascript.tmpcopied,com.ibm.sed.css.image,com.ibm.sed.styleupdate.html,com.ibm.sed.edit.registry,com.ibm.sed.preferences.ui.jsp,com.ibm.sed.doubleclick,com.ibm.sed.edit.extension,com.ibm.sed.editor,com.ibm.sed.preferences.ui.xml,com.ibm.sed.edit.internal.extension,com.ibm.sed.css.edit.cleanup,com.ibm.sed.view.propertySheet,com.ibm.sed.taginfo,com.ibm.sed.contentassist.jsp,com.ibm.sed.edit.registry.embedded,com.ibm.sed.contentassist.xml,com.ibm.sed.preferences.ui,com.ibm.sed.style,com.ibm.sed.edit.ui"
- sourcepath="sedxml"
- splitindex="true"
- use="true"
- version="true" />
- </target>
-</project>
diff --git a/bundles/org.eclipse.wst.sse.ui/jspdebug.properties b/bundles/org.eclipse.wst.sse.ui/jspdebug.properties
deleted file mode 100644
index 0001f8caa3..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/jspdebug.properties
+++ /dev/null
@@ -1 +0,0 @@
-useWAS403=true \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.sse.ui/plugin.properties b/bundles/org.eclipse.wst.sse.ui/plugin.properties
deleted file mode 100644
index 70acdf822f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/plugin.properties
+++ /dev/null
@@ -1,68 +0,0 @@
-Structured_Source_Editor.name=Structured Source Editor
-Structured_Source_Editor_NL_Support.name=Structured Source Editor NL Support
-Standalone_Structured_Source_Editor.name=Standalone Structured Source Editor
-# Name on preferences page
-WEB_AND_XML_Files.name=Web and XML
-Structured_Text_Editor.name=Structured Text Editor
-
-##### Added from contentproperties
-Content_Properties.name=Content Properties
-Content_Properties_NL_Support.name=Content Properties NL Support
-##### Added from contentproperties
-
-#
-sourceEditorFontDefiniton.label=Structured Text Editor Text Font
-sourceEditorFontDefintion.description=The Structured text editor text font is used by Structured text editors.
-
-Adapter_Factory_Description_Extension.name=Adapter Factory Description Extension
-Embedded_Content_Type_Adapter_Factory_Provider_Extension.name=Embedded Content Type Adapter Factory Provider Extension
-Extended_Editor_Actions_Extension.name=Extended Editor Actions Extension
-Drop_Target_Transfers_Extension.name=Drop Target Transfers Extension
-Bean_Info_Provider_Extension.name=Bean Info Provider Extension
-Extended_Editor_Configuration_Extension.name=Extended Editor Configuration Extension
-##########################################################################
-# These strings are used in Workbench Keys Preferences
-##########################################################################
-scope.structuredTextEditor.name=Source Editor
-scope.structuredTextEditor.description=Source Editor scope
-command.comment.name=Comment
-command.comment.description=Comment
-command.uncomment.name=Uncomment
-command.uncomment.description=Uncomment
-command.toggle.comment.name=Toggle Comment
-command.toggle.comment.description=Toggle Comment
-command.add.block.comment.name=Add Block Comment
-command.add.block.comment.description=Add Block Comment
-command.remove.block.comment.name=Remove Block Comment
-command.remove.block.comment.description=Remove Block Comment
-command.cleanup.document.name=Cleanup Document
-command.cleanup.document.description=Cleanup document
-command.format.document.name=Format Document
-command.format.document.description=Format document
-command.format.active.elements.name=Format Active Elements
-command.format.active.elements.description=Format active elements
-command.open.file.from.source.name=Open Selection
-command.open.file.from.source.description=Open an editor on the selected link
-command.search.find.occurrences.name=Occurrences in File
-command.search.find.occurrences.description=Find occurrences of the selection in the file
-ActionDefinition.selectEnclosing.name=Select Enclosing Element
-ActionDefinition.selectEnclosing.description=Expand selection to include enclosing element
-ActionDefinition.selectNext.name=Select Next Element
-ActionDefinition.selectNext.description=Expand selection to include next sibling
-ActionDefinition.selectPrevious.name=Select Previous Element
-ActionDefinition.selectPrevious.description=Expand selection to include previous sibling
-ActionDefinition.selectLast.name=Restore Last Selection
-ActionDefinition.selectLast.description=Restore last selection
-ActionDefinition.showJavadoc.name=Show Tooltip Description
-ActionDefinition.showJavadoc.description=Displays the hover help for the selected element
-ActionDefinition.quickFix.name=Quick Fix
-ActionDefinition.quickFix.description=Quick Fix
-
-##########################################################################
-# These strings are used in file and container resource popup menu
-##########################################################################
-Source=&Source
-FormatDocument=&Format document
-ConvertLineDelimitersToCRLF=Convert Line Delimiters To CRLF (&Windows)
-ConvertLineDelimitersToLF=Convert Line Delimiters To LF (&UNIX, MacOS X)
-ConvertLineDelimitersToCR=Convert Line Delimiters To CR (Classic &MacOS)
diff --git a/bundles/org.eclipse.wst.sse.ui/plugin.xml b/bundles/org.eclipse.wst.sse.ui/plugin.xml
deleted file mode 100644
index c6ea34e3ad..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/plugin.xml
+++ /dev/null
@@ -1,540 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?eclipse version="3.0"?>
-<plugin
- id="org.eclipse.wst.sse.ui"
- name="%Structured_Source_Editor.name"
- version="1.0.0"
- provider-name="Eclipse.org"
- class="org.eclipse.wst.sse.ui.EditorPlugin">
-
- <runtime>
- <library name="editor.jar">
- <export name="*"/>
- </library>
- </runtime>
- <requires>
- <import plugin="org.eclipse.core.runtime.compatibility"/>
- <import plugin="org.eclipse.ui.ide"/>
- <import plugin="org.eclipse.jface.text"/>
-<!-- added for break point support -->
-<!-- -->
- <import plugin="org.eclipse.debug.core"/>
- <import plugin="org.eclipse.debug.ui"/>
- <import plugin="org.eclipse.ui.editors"/>
-<!-- added for marker and annotation support -->
- <import plugin="org.eclipse.search"/>
- <import plugin="org.eclipse.swt"/>
- <import plugin="org.eclipse.jface"/>
- <import plugin="org.eclipse.ui"/>
- <import plugin="org.eclipse.ui.workbench.texteditor"/>
- <import plugin="org.eclipse.ui.workbench"/>
- <import plugin="org.eclipse.ui.views"/>
- <import plugin="org.eclipse.wst.sse.core"/>
- <import plugin="org.eclipse.core.filebuffers"/>
- <import plugin="org.eclipse.core.resources"/>
- <import plugin="org.eclipse.core.runtime"/>
- <import plugin="org.eclipse.wst.encoding"/>
- <import plugin="org.eclipse.wst.validation.core"/>
- </requires>
-
-
-<!-- Added from extensions -->
-<!-- extension point for breakpoint extension -->
- <extension-point id="breakpoint" name="%Breakpoint_Extension.name"/>
-<!-- extension point for spellcheck extension -->
- <extension-point id="spellcheck" name="%SpellCheck_Extension.name"/>
-<!-- extension point for reconcile validation -->
-<!-- interfaces for this extension point can be found in org.eclipse.wst.validation.core -->
- <extension-point id="reconcileValidator" name="%Reconcile_Validator_Extension.name" schema="schema/org.eclipse.wst.sse.ui.reconcileValidator.exsd"/>
- <extension-point id="openon" name="%Open_On_Extension_Point_Extension.name" schema="schema/org.eclipse.wst.sse.ui.openon.exsd"/>
-<!-- Added from extensions -->
-
-<!-- Added from contentproperties -->
- <extension
- point="org.eclipse.ui.startup">
- <startup>
- </startup>
- </extension>
-<!-- Added from contentproperties -->
-
-
- <extension-point id="adapterFactoryDescription" name="%Adapter_Factory_Description_Extension.name"/>
- <extension-point id="embeddedAdapterFactoryProvider" name="%Embedded_Content_Type_Adapter_Factory_Provider_Extension.name"/>
- <extension-point id="extendedEditorActions" name="%Extended_Editor_Actions_Extension.name"/>
- <extension-point id="dropTargetTransfers" name="%Drop_Target_Transfers_Extension.name"/>
- <extension-point id="extendedconfiguration" name="%Extended_Editor_Configuration_Extension.name" schema="schema/extendedconfiguration.exsd"/>
-
-<!--
- note: this perspective stuff should probably go in the
- XMLPerspective
- or in the plugin.xml for xml.tools
- -->
-<!-- PERSPECTIVE EXTENSIONS -->
- <extension
- point="org.eclipse.wst.sse.ui.extendedconfiguration">
- <contentoutlineconfiguration
- class="org.eclipse.wst.sse.ui.views.contentoutline.StructuredContentOutlineConfiguration"
- target="org.eclipse.wst.sse.ui.StructuredTextEditor">
- </contentoutlineconfiguration>
- <propertysheetconfiguration
- class="org.eclipse.wst.sse.ui.views.properties.StructuredPropertySheetConfiguration"
- target="org.eclipse.wst.sse.ui.StructuredTextEditor">
- </propertysheetconfiguration>
- <textviewerconfiguration
- class="org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration"
- target="org.eclipse.wst.sse.ui.StructuredTextEditor">
- </textviewerconfiguration>
- <preferencepages
- preferenceids="org.eclipse.ui.preferencePages.Workbench/org.eclipse.ui.preferencePages.Editors/org.eclipse.wst.sse.ui.preferences.editor"
- target="org.eclipse.wst.sse.ui.StructuredTextEditor">
- </preferencepages>
- </extension>
-<!-- associate the NavigateActionSet with various parts of the XML perspective-->
- <extension
- point="org.eclipse.ui.actionSetPartAssociations">
- <actionSetPartAssociation
- targetID="org.eclipse.ui.edit.text.actionSet.annotationNavigation">
- <part
- id="org.eclipse.wst.sse.ui.StructuredTextEditor">
- </part>
- </actionSetPartAssociation>
- <actionSetPartAssociation
- targetID="org.eclipse.ui.NavigateActionSet">
-<!--
- <part id="org.eclipse.ui.views.ResourceNavigator"/>
- <part id="org.eclipse.ui.views.ContentOutline"/>
- -->
-<!--
- should probably only "force" association of action sets for workbench parts that we own
- or only if the view is focusse in the XMLPerspective
- -->
- <part
- id="org.eclipse.wst.sse.ui.StructuredTextEditor">
- </part>
- </actionSetPartAssociation>
- </extension>
- <extension
- point="org.eclipse.ui.preferencePages">
-<!-- ROOT PREFERENCE PAGE FOR WEB AND XML FILES -->
- <page
- name="%WEB_AND_XML_Files.name"
- class="org.eclipse.wst.sse.ui.preferences.ui.FilePreferencePage"
- id="org.eclipse.wst.sse.ui.preferences">
- </page>
-<!-- Source Editor Preference page under Workbench->Editors -->
- <page
- name="%Structured_Text_Editor.name"
- category="org.eclipse.ui.preferencePages.Editors"
- class="org.eclipse.wst.sse.ui.preferences.ui.StructuredTextEditorPreferencePage"
- id="org.eclipse.wst.sse.ui.preferences.editor">
- </page>
- </extension>
- <extension
- point="org.eclipse.ui.commands">
- <scope
- name="%scope.structuredTextEditor.name"
- parent="org.eclipse.ui.textEditorScope"
- description="%scope.structuredTextEditor.description"
- id="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope">
- </scope>
- <!-- dmw 6/6 removed from 'scope' parentId="org.eclipse.ui.textEditorScope" -->
-
-<!-- Edit commands -->
- <command
- name="%ActionDefinition.selectEnclosing.name"
- description="%ActionDefinition.selectEnclosing.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.structure.select.enclosing">
- </command>
- <command
- name="%ActionDefinition.selectNext.name"
- description="%ActionDefinition.selectNext.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.structure.select.next">
- </command>
- <command
- name="%ActionDefinition.selectPrevious.name"
- description="%ActionDefinition.selectPrevious.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.structure.select.previous">
- </command>
- <command
- name="%ActionDefinition.selectLast.name"
- description="%ActionDefinition.selectLast.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.structure.select.last">
- </command>
- <command
- name="%ActionDefinition.showJavadoc.name"
- description="%ActionDefinition.showJavadoc.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.show.javadoc">
- </command>
- <command
- name="%ActionDefinition.quickFix.name"
- description="%ActionDefinition.quickFix.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.edit.text.java.correction.assist.proposals">
- </command>
-<!-- Source commands -->
- <command
- name="%command.toggle.comment.name"
- description="%command.toggle.comment.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.toggle.comment">
- </command>
- <command
- name="%command.add.block.comment.name"
- description="%command.add.block.comment.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.add.block.comment">
- </command>
- <command
- name="%command.remove.block.comment.name"
- description="%command.remove.block.comment.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.remove.block.comment">
- </command>
- <command
- name="%command.cleanup.document.name"
- description="%command.cleanup.document.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.cleanup.document">
- </command>
- <command
- name="%command.format.document.name"
- description="%command.format.document.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.format.document">
- </command>
- <command
- name="%command.format.active.elements.name"
- description="%command.format.active.elements.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.format.active.elements">
- </command>
-<!-- Navigate commands -->
- <command
- name="%command.open.file.from.source.name"
- description="%command.open.file.from.source.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.open.file.from.source">
- </command>
-<!-- Find Occurrences -->
- <command
- name="%command.search.find.occurrences.name"
- description="%command.search.find.occurrences.description"
- category="org.eclipse.ui.category.edit"
- id="org.eclipse.wst.sse.ui.edit.search.find.occurrences">
- </command>
-<!-- Edit commands -->
- <keyBinding
- string="Alt+Shift+ARROW_UP"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.structure.select.enclosing"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Alt+Shift+ARROW_RIGHT"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.structure.select.next"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Alt+Shift+ARROW_LEFT"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.structure.select.previous"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Alt+Shift+ARROW_DOWN"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.structure.select.last"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="F2"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.show.javadoc"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+1"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.edit.text.java.correction.assist.proposals"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
-<!-- Source commands -->
- <keyBinding
- string="Ctrl+Shift+C"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.toggle.comment"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+/"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.add.block.comment"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+\"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.remove.block.comment"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+L"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.cleanup.document"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+Shift+F"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.format.document"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- <keyBinding
- string="Ctrl+I"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.format.active.elements"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
-<!-- Navigate commands -->
- <keyBinding
- string="F3"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.open.file.from.source"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
-<!-- Find Occurrences -->
- <keyBinding
- string="Ctrl+Shift+A"
- scope="org.eclipse.wst.sse.ui.edit.structuredTextEditorScope"
- command="org.eclipse.wst.sse.ui.edit.search.find.occurrences"
- configuration="org.eclipse.ui.defaultAcceleratorConfiguration">
- </keyBinding>
- </extension>
-<!-- Font and colors contributions -->
- <extension
- point="org.eclipse.ui.themes">
- <themeElementCategory
- label="%Structured_Text_Editor.name"
- id="org.eclipse.wst.sse.ui">
- </themeElementCategory>
- <fontDefinition
- label="%sourceEditorFontDefiniton.label"
- categoryId="org.eclipse.wst.sse.ui"
- defaultsTo="org.eclipse.jface.textfont"
- id="org.eclipse.wst.sse.ui.textfont">
- <description>
- %sourceEditorFontDefintion.description
- </description>
- </fontDefinition>
- </extension>
- <extension
- point="org.eclipse.wst.sse.ui.dropTargetTransfers">
- <dropTargetContribution
- targetID="org.eclipse.wst.sse.ui.StructuredTextEditor"
- id="org.eclipse.wst.sse.ui.edit.extention.ExtendedTransfers">
- <transfer
- priority="mid"
- singleton="true"
- class="org.eclipse.swt.dnd.FileTransfer"
- method="getInstance"
- id="org.eclipse.swt.dnd.FileTransfer">
- </transfer>
- <dropAction
- class="org.eclipse.wst.sse.ui.extension.FileDropAction"
- transferID="org.eclipse.swt.dnd.FileTransfer"
- id="org.eclipse.wst.sse.ui.extension.FileDropAction">
- </dropAction>
- <transfer
- priority="low"
- singleton="true"
- class="org.eclipse.swt.dnd.TextTransfer"
- method="getInstance"
- id="org.eclipse.swt.dnd.TextTransfer">
- </transfer>
- <dropAction
- class="org.eclipse.wst.sse.ui.extension.TextDropAction"
- transferID="org.eclipse.swt.dnd.TextTransfer"
- id="org.eclipse.wst.sse.ui.extension.TextDropAction">
- </dropAction>
- </dropTargetContribution>
- </extension>
-<!-- new for annotation support -->
- <extension
- point="org.eclipse.ui.editors.annotationTypes">
- <type
- super="org.eclipse.ui.workbench.texteditor.error"
- markerType="org.eclipse.wst.sse.problem"
- name="org.eclipse.wst.sse.ui.temp.error"
- markerSeverity="2">
- </type>
- <type
- super="org.eclipse.ui.workbench.texteditor.warning"
- markerType="org.eclipse.wst.sse.problem"
- name="org.eclipse.wst.sse.ui.temp.warning"
- markerSeverity="1">
- </type>
- <type
- super="org.eclipse.ui.workbench.texteditor.info"
- markerType="org.eclipse.wst.sse.problem"
- name="org.eclipse.wst.sse.ui.temp.info"
- markerSeverity="0">
- </type>
- </extension>
- <extension
- point="org.eclipse.ui.editors.markerAnnotationSpecification">
- <specification
- annotationImageProvider="org.eclipse.wst.sse.ui.internal.ui.StructuredTextAnnotationImageProvider"
- verticalRulerPreferenceValue="false"
- annotationType="org.eclipse.wst.sse.ui.temp.error">
- </specification>
- <specification
- annotationImageProvider="org.eclipse.wst.sse.ui.internal.ui.StructuredTextAnnotationImageProvider"
- verticalRulerPreferenceValue="false"
- annotationType="org.eclipse.wst.sse.ui.temp.warning">
- </specification>
- <specification
- annotationImageProvider="org.eclipse.wst.sse.ui.internal.ui.StructuredTextAnnotationImageProvider"
- annotationType="org.eclipse.wst.sse.ui.temp.info">
- </specification>
- </extension>
-<!-- dynamic content type supporting editor, no supported file extensions by default -->
- <extension
- point="org.eclipse.ui.editors">
- <editor
- name="%Standalone_Structured_Source_Editor.name"
- icon="icons/sourceEditor.gif"
- contributorClass="org.eclipse.wst.sse.ui.ui.ActionContributor"
- class="org.eclipse.wst.sse.ui.StructuredTextEditor"
- symbolicFontName="org.eclipse.wst.sse.ui.textfont"
- id="org.eclipse.wst.sse.ui.StructuredTextEditor">
- </editor>
- </extension>
- <extension
- point="org.eclipse.ui.popupMenus">
- <objectContribution
- objectClass="org.eclipse.core.resources.IContainer"
- id="org.eclipse.wst.sse.ui.actions.ContainerSourceActions">
- <menu
- label="%Source"
- path="additions"
- id="source">
- <groupMarker
- name="sourceGroup">
- </groupMarker>
- <separator
- name="separator">
- </separator>
- <groupMarker
- name="convertGroup">
- </groupMarker>
- </menu>
- <action
- label="%FormatDocument"
- class="org.eclipse.wst.sse.ui.ui.FormatActionDelegate"
- menubarPath="source/sourceGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.ContainerSourceActions.Format">
- </action>
- <action
- label="%ConvertLineDelimitersToCR"
- class="org.eclipse.wst.sse.ui.ui.ConvertLineDelimitersToCRActionDelegate"
- menubarPath="source/convertGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.ContainerSourceActions.EOLCR">
- </action>
- <action
- label="%ConvertLineDelimitersToLF"
- class="org.eclipse.wst.sse.ui.ui.ConvertLineDelimitersToLFActionDelegate"
- menubarPath="source/convertGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.ContainerSourceActions.EOLLF">
- </action>
- <action
- label="%ConvertLineDelimitersToCRLF"
- class="org.eclipse.wst.sse.ui.ui.ConvertLineDelimitersToCRLFActionDelegate"
- menubarPath="source/convertGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.ContainerSourceActions.EOLCRLF">
- </action>
- </objectContribution>
- <objectContribution
- objectClass="org.eclipse.core.resources.IFile"
- id="org.eclipse.wst.sse.ui.actions.FileSourceActions">
- <menu
- label="%Source"
- path="additions"
- id="source">
- <groupMarker
- name="sourceGroup">
- </groupMarker>
- <separator
- name="separator">
- </separator>
- <groupMarker
- name="convertGroup">
- </groupMarker>
- </menu>
- <action
- label="%FormatDocument"
- class="org.eclipse.wst.sse.ui.ui.FormatActionDelegate"
- menubarPath="source/sourceGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.FileSourceActions.Format">
- </action>
- <action
- label="%ConvertLineDelimitersToCR"
- class="org.eclipse.wst.sse.ui.ui.ConvertLineDelimitersToCRActionDelegate"
- menubarPath="source/convertGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.FileSourceActions.EOLCR">
- </action>
- <action
- label="%ConvertLineDelimitersToLF"
- class="org.eclipse.wst.sse.ui.ui.ConvertLineDelimitersToLFActionDelegate"
- menubarPath="source/convertGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.FileSourceActions.EOLLF">
- </action>
- <action
- label="%ConvertLineDelimitersToCRLF"
- class="org.eclipse.wst.sse.ui.ui.ConvertLineDelimitersToCRLFActionDelegate"
- menubarPath="source/convertGroup"
- enablesFor="+"
- id="org.eclipse.wst.sse.ui.actions.FileSourceActions.EOLCRLF">
- </action>
- </objectContribution>
- </extension>
-<!-- contribute the Edit Preferences action -->
- <extension
- point="org.eclipse.wst.sse.ui.extendedEditorActions">
- <editorContribution
- targetID="org.eclipse.wst.sse.ui.StructuredTextEditor"
- id="org.eclipse.wst.sse.ui.extendedActions">
- <action
- popupmenuPath="group.add"
- class="org.eclipse.wst.sse.ui.preferences.ui.EditStructuredTextEditorPreferencesAction"
- id="org.eclipse.wst.sse.ui.preferences.ui.EditStructuredTextEditorPreferencesAction">
- </action>
- </editorContribution>
- </extension>
-
-<!--================================================================================================-->
-<!-- contribute a SearchResultViewPage for Occurrences in file -->
-<!--================================================================================================-->
- <extension
- id="Occurrences search page"
- point="org.eclipse.search.searchResultViewPages">
- <viewPage
- id="org.eclipse.wst.sse.ui.search.OccurrencesSearchResultPage"
- searchResultClass="org.eclipse.wst.sse.ui.internal.search.OccurrencesSearchResult"
- class="org.eclipse.wst.sse.ui.internal.search.OccurrencesSearchViewPage">
- </viewPage>
- </extension>
-
-</plugin>
diff --git a/bundles/org.eclipse.wst.sse.ui/schema/extendedconfiguration.exsd b/bundles/org.eclipse.wst.sse.ui/schema/extendedconfiguration.exsd
deleted file mode 100644
index 2546638b2e..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/schema/extendedconfiguration.exsd
+++ /dev/null
@@ -1,292 +0,0 @@
-<?xml version='1.0' encoding='UTF-8'?>
-<!-- Schema file written by PDE -->
-<schema targetNamespace="org.eclipse.wst.sse.ui">
-<annotation>
- <appInfo>
- <meta.schema plugin="org.eclipse.wst.sse.ui" id="extendedconfiguration" name="Extended Editor Configuration"/>
- </appInfo>
- <documentation>
- The SSE StructuredTextEditor is intended to be as flexible as possible. Much of its design centers around the notion of defining and redefining its behavior and appearance based on the Content Type of its input.
- </documentation>
- </annotation>
-
- <element name="extension">
- <complexType>
- <any>
- <element name="textviewerconfiguration" />
- <element name="contentoutlineconfiguration" />
- <element name="propertysheetconfiguration" />
- <element name="sourceeditingtexttools" />
- <element name="spellchecktarget" />
- <element name="preferencepages" />
- </any>
- <attribute name="point" type="string" use="required">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="id" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- <attribute name="name" type="string">
- <annotation>
- <documentation>
-
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="textviewerconfiguration">
- <annotation>
- <documentation>
- The subclass of org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration to use.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- A class with a null constructor fulfilling the requirements of the functionname.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="target" type="string" use="required">
- <annotation>
- <documentation>
- A string defining when to use this extension, usually an Editor ID or SSE Content Type. Multiple targets may be given as a comma delimited value.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="contentoutlineconfiguration">
- <annotation>
- <documentation>
- The subclass of org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration to use.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- A class with a null constructor fulfilling the requirements of the functionname.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="target" type="string" use="required">
- <annotation>
- <documentation>
- A string defining when to use this extension, usually an Editor ID or SSE Content Type. Multiple targets may be given as a comma delimited value.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="propertysheetconfiguration">
- <annotation>
- <documentation>
- The subclass of org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration to use.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- A class with a null constructor fulfilling the requirements of the functionname.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="target" type="string" use="required">
- <annotation>
- <documentation>
- A string defining when to use this extension, usually an Editor ID or SSE Content Type. Multiple targets may be given as a comma delimited value.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="sourceeditingtexttools">
- <annotation>
- <documentation>
- The implementor of org.eclipse.wst.sse.ui.extensions.breakpoint.SourceEditingTextTools to provide.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- A class with a null constructor fulfilling the requirements of the functionname.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="target" type="string" use="required">
- <annotation>
- <documentation>
- A string defining when to use this extension, usually an Editor ID or SSE Content Type. Multiple targets may be given as a comma delimited value.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="spellchecktarget">
- <annotation>
- <documentation>
- The implementor of org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckTarget to use.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- A class with a null constructor fulfilling the requirements of the functionname.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="target" type="string" use="required">
- <annotation>
- <documentation>
- A string defining when to use this extension, usually an Editor ID or SSE Content Type. Multiple targets may be given as a comma delimited value.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="characterpairmatcher">
- <annotation>
- <documentation>
- The implementor of org.eclipse.jface.text.source.ICharacterPairMatcher to use in the source viewer decoration support.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="class" type="string" use="required">
- <annotation>
- <documentation>
- A class with a null constructor that implements org.eclipse.jface.text.source.ICharacterPairMatcher.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="target" type="string" use="required">
- <annotation>
- <documentation>
- A string defining when to use this extension, usually an Editor ID or SSE Content Type. Multiple targets may be given as a comma delimited value.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
- <element name="preferencepages">
- <annotation>
- <documentation>
- The list of Preference page IDs to show for the editor's Preferences.
- </documentation>
- </annotation>
- <complexType>
- <attribute name="preferenceids" type="string" use="required">
- <annotation>
- <documentation>
- A fully qualified preference page ID path.
- </documentation>
- </annotation>
- </attribute>
- <attribute name="target" type="string" use="required">
- <annotation>
- <documentation>
- A string defining when to use this extension, usually an Editor ID or SSE Content Type. Multiple targets may be given as a comma delimited value.
- </documentation>
- </annotation>
- </attribute>
- </complexType>
- </element>
-
-
- <annotation>
- <appInfo>
- <meta.section type="since"/>
- </appInfo>
- <documentation>
- 3.0
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="examples"/>
- </appInfo>
- <documentation>
- &lt;pre&gt;
-&lt;extension point=&quot;org.eclipse.wst.sse.ui.extendedconfiguration&quot;&gt;
-
-&lt;!-- associating to an input&apos;s Content Type--&gt;
- &lt;textviewerconfiguration
- class=&quot;org.eclipse.wst.sse.ui.html.StructuredTextViewerConfigurationHTML&quot;
- target=&quot;org.eclipse.wst.sse.contenttype.html&quot;/&gt;
-
-&lt;!-- associating to multiple editor IDs --&gt;
- &lt;contentoutlineconfiguration
- class=&quot;org.eclipse.wst.sse.ui.xml.views.contentoutline.XMLContentOutlineConfiguration&quot;
- target=&quot;org.eclipse.wst.sse.ui.xml.StructuredTextEditorXML, org.eclipse.wst.xmleditor.internal.XMLMultiPageEditorPart&quot;/&gt;
-
-&lt;!-- associating to multiple Content Types --&gt;
- &lt;propertysheetconfiguration
- class=&quot;org.eclipse.wst.sse.ui.xml.views.properties.XMLPropertySheetConfiguration&quot;
- target=&quot;org.eclipse.wst.sse.contenttype.xml, org.eclipse.wst.sse.contenttype.html, org.eclipse.wst.sse.contenttype.jsp&quot;/&gt;
-
-&lt;/extension&gt;
-&lt;/pre&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="apiInfo"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="implementation"/>
- </appInfo>
- <documentation>
- &lt;br&gt;
-&lt;code&gt;org.eclipse.wst.sse.ui.extension.ExtendedConfigurationBuilder&lt;/code&gt; is responsible for creating the extension objects as requested. New instances are returned for each request that succeeds. Invalid function names and targets will return null. The &lt;code&gt;StructuredTextEditor&lt;/code&gt; will automatically try targets generated by &lt;code&gt;org.eclipse.wst.sse.ui.extensions.ConfigurationPointCalculator&lt;/code&gt; according to where the &lt;code&gt;StructuredTextEditor&lt;/code&gt; finds itself at runtime. &lt;code&gt;ConfigurationPointCalculator&lt;/code&gt; ensures that the targets are always searched in a specific and predictable order. The following table lists the functionalities currenty in use:
-&lt;p&gt;
-&lt;table border=&quot;1&quot;&gt;
-&lt;tbody valign=&quot;top&quot;&gt;
-&lt;tr&gt;&lt;td&gt;&lt;b&gt;Functionality names&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Implementation requirement&lt;/b&gt;&lt;/td&gt;&lt;td&gt;&lt;b&gt;Responsibilities&lt;/b&gt;&lt;/td&gt;&lt;/tr&gt;
-&lt;tr&gt;&lt;td&gt;textviewerconfiguration&lt;/td&gt;&lt;td&gt;Must subclass &lt;code&gt;org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Defines the source viewer configuration to use, affecting Highlighting, Formatting, Content Assist, Hover help, and more.&lt;/td&gt;&lt;/tr&gt;
-&lt;tr&gt;&lt;td&gt;contentoutlineconfiguration&lt;/td&gt;&lt;td&gt;Must subclass &lt;code&gt;org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Defines how the IStructuredModel for the editor&apos;s input maps to elements with a Tree control, as well as selection filtering, toolbar and menu contributions, etc.&lt;/td&gt;&lt;/tr&gt;
-&lt;tr&gt;&lt;td&gt;propertysheetconfiguration&lt;/td&gt;&lt;td&gt;Must subclass &lt;code&gt;org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Defines the Property Source Provider, toolbar contributions, etc.&lt;/td&gt;&lt;/tr&gt;
-&lt;tr&gt;&lt;td&gt;sourceeditingtexttools&lt;/td&gt;&lt;td&gt;Must implement &lt;code&gt;org.eclipse.wst.sse.ui.extensions.breakpoint.SourceEditingTextTools&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Provides DOM to text and positional mapping information for use when setting and clearing breakpoints.&lt;/td&gt;&lt;/tr&gt;
-&lt;tr&gt;&lt;td&gt;spellchecktarget&lt;/td&gt;&lt;td&gt;Must implement &lt;code&gt;org.eclipse.wst.sse.ui.extensions.spellcheck.SpellCheckTarget&lt;/code&gt;&lt;/td&gt;&lt;td&gt;Provides targetting information for the IBM eTools Spell Checker&lt;/td&gt;&lt;/tr&gt;
-&lt;/tbody&gt;
-&lt;/table&gt;&lt;/p&gt;
- </documentation>
- </annotation>
-
- <annotation>
- <appInfo>
- <meta.section type="copyright"/>
- </appInfo>
- <documentation>
-
- </documentation>
- </annotation>
-
-</schema>
diff --git a/bundles/org.eclipse.wst.sse.ui/src/Editing.properties b/bundles/org.eclipse.wst.sse.ui/src/Editing.properties
deleted file mode 100644
index 76e3d7c31f..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/src/Editing.properties
+++ /dev/null
@@ -1,573 +0,0 @@
-Macro_must_have_a_name_INFO_=IWAK0003I Macro must have a name
-Macro_name_can_not_start_w_INFO_=IWAK0004I Macro name can not start with whitespace
-Rename_Macro_UI_=Rename Macro
-Copy_Macro_UI_=Copy Macro
-New_Macro_UI_=New Macro
-Source__UI_=Source:
-The_maximum_width_must_be__UI_=The maximum width must be an integer
-Only_whitespace_characters_UI_=Only whitespace characters are allowed in the indentation
-The_number_of_spaces_must__UI_=The number of spaces must be an integer
-Alphabetically_sort_the_li_UI_=Alphabetically sort the list of proposals
-Prompt_when_these_characte_UI_=Prompt when these characters are inserted:
-This_encoding({0})_is_not__WARN_=IWAK0005W This encoding({0}) is not supported. Continue ?
-The_encoding_of_Preference_WARN_=IWAK0006W The encoding of Preference({0}) and the encoding in the document({1}) are different. {1} will be used. Continue ?
-Begin/End_Comment_UI_=Begin/End Comment
-Commented_Text_UI_=Commented Text
-Begin/End_CDATA_UI_=Begin/End CDATA
-CDATA_UI_=CDATA
-Begin/End_Processing_Instr_UI_=Begin/End Processing Instruction
-Processing_Instruction_Con_UI_=Processing Instruction Content
-Start/End_Markup_UI_=Start/End Markup
-Names_UI_=Names
-## on the following line solely translate: Begin
-Begin_DOCTYPE_UI_=Begin DOCTYPE
-## on the following line solely translate: keyword
-DOCTYPE_SYSTEM/PUBLIC_keyw_UI_=DOCTYPE SYSTEM/PUBLIC keyword
-## on the following line solely translate: End
-End_DOCTYPE_UI_=End DOCTYPE
-Click_on_the_sample_text_w_UI_=Click on the sample text whose style you want to customize:
-1This_encoding({0})_is_not__WARN_=IWAK0007W This encoding({0}) is not supported. The default encoding will be used instead.
-Encoding_warning_UI_=Encoding warning
-A_temporary_backup_version_WARN_=IWAK0008W A temporary backup version of the file {0} was found in {1}.\n\nThis indicates a previous editing session with this file did not end normally and the file you are trying to edit might have been damaged. Would you like to use the backup version?
-Improper_shutdown_warning_UI_=Improper shutdown warning
-Editing_canceled_at_users__INFO_=IWAK0009I Editing canceled at users request
-Unable_to_save_the_documen_ERROR_=IWAK0010E Unable to save the document. Output file not found.
-Unable_to_save_the_documen1_ERROR_=IWAK0011E Unable to save the document. Unsupported encoding.
-Unable_to_save_the_documen2_ERROR_=IWAK0012E Unable to save the document. An I/O error occurred while saving the document.
-Unable_to_save_the_documen3_ERROR_=IWAK0013E Unable to save the document. An severe I/O error occurred while saving the document.
-An_I/O_error_while_creatin_ERROR_=IWAK0014E An I/O error while creating temporary backup copy
-An_severe_I/O_error_while__ERROR_=IWAK0015E An severe I/O error while creating temporary backup copy
-Text_Change_UI_=Text Change
-&Undo_Text_Change_@Ctrl+Z_UI_=&Undo Text Change @Ctrl+Z
-Undo_Text_Change._UI_=Undo Text Change.
-&Undo_{0}_@Ctrl+Z_UI_=&Undo {0} @Ctrl+Z
-Undo__{0}._UI_=Undo: {0}.
-&Redo_Text_Change_@Ctrl+Y_UI_=&Redo Text Change @Ctrl+Y
-Redo_Text_Change._UI_=Redo Text Change.
-&Redo_{0}_@Ctrl+Y_UI_=&Redo {0} @Ctrl+Y
-Redo__{0}._UI_=Redo: {0}.
-Cleanup_Document_UI_=Cleanup Document
-Format_Document_UI_=Format Document
-Format_Active_Elements_UI_=Format Active Elements
-Text_Cut_UI_=Text Cut
-Text_Paste_UI_=Text Paste
-Source_UI_=Source
-Invalid_Input__Must_be_IFi_ERROR_=IWAK0016E Invalid Input: Must be IFileEditorInput
-An_error_has_occurred_when1_ERROR_=IWAK0017E An error has occurred when initializing the input for the the editor's source page.
-No_known_attribute__UI_=No known attribute
-Content_Assist_not_availab_UI_=Content Assist not available at the current location
-SEVERE_internal_error_occu_UI_=SEVERE internal error occurred
-Double_Quotes_UI_=Double Quotes
-Single_Quotes_UI_=Single Quotes
-ContentAssistProposals.label=Con&tent Assist
-ContentAssistProposals.tooltip=Content Assist
-ContentAssistProposals.image=
-ContentAssistProposals.description=Content Assist
-QuickFix.label=&Quick Fix
-QuickFix.tooltip=Quick Fix
-QuickFix.image=
-QuickFix.description=Quick Fix
-Comment.label=Co&mment
-Comment.tooltip=Comment
-Comment.image=
-Comment.description=Comment
-Uncomment.label=&Uncomment
-Uncomment.tooltip=Uncomment
-Uncomment.image=
-Uncomment.description=Uncomment
-ToggleComment.label=Togg&le Comment
-ToggleComment.tooltip=Toggle Comment
-ToggleComment.image=
-ToggleComment.description=Toggle Comment
-AddBlockComment.label=Add &Block Comment
-AddBlockComment.tooltip=Add Block Comment
-AddBlockComment.image=
-AddBlockComment.description=Add Block Comment
-RemoveBlockComment.label=Remove Bloc&k Comment
-RemoveBlockComment.tooltip=Remove Block Comment
-RemoveBlockComment.image=
-RemoveBlockComment.description=Remove Block Comment
-CleanupDocument.label=C&leanup Document...
-CleanupDocument.tooltip=Cleanup Document
-CleanupDocument.image=
-CleanupDocument.description=Cleanup Document
-FormatDocument.label=&Document
-FormatDocument.tooltip=Format Document
-FormatDocument.image=
-FormatDocument.description=Format Document
-FormatActiveElements.label=Act&ive Elements
-FormatActiveElements.tooltip=Format Active Elements
-FormatActiveElements.image=
-FormatActiveElements.description=Format Active Elements
-OpenFileFromSource.label=Op&en Selection
-OpenFileFromSource.tooltip=Open an editor on the selected link
-OpenFileFromSource.image=
-OpenFileFromSource.description=Open an editor on the selected link
-ShowTooltipDesc.label=Show &Tooltip Description
-ShowTooltipDesc.tooltip=Displays the hover help for the selected element
-ShowTooltipDesc.image=
-ShowTooltipDesc.description=Displays the hover help for the selected element
-StructureSelectEnclosing.label=&Enclosing Element
-StructureSelectEnclosing.tooltip=Expand selection to include enclosing element
-StructureSelectEnclosing.description=Expand selection to include enclosing element
-StructureSelectNext.label=&Next Element
-StructureSelectNext.tooltip=Expand selection to include next sibling
-StructureSelectNext.description=Expand selection to include next sibling
-StructureSelectPrevious.label=&Previous Element
-StructureSelectPrevious.tooltip=Expand selection to include previous sibling
-StructureSelectPrevious.description=Expand selection to include previous sibling
-StructureSelectHistory.label=&Restore Last Selection
-StructureSelectHistory.tooltip=Restore last selection
-StructureSelectHistory.description=Restore last selection
-Save.label=&Save
-An_error_has_occurred_when_ERROR_=IWAK0018E An error has occurred when retrieving resources for the source editor. The Eclipse Workbench installation may have been corrupted.
-No_content_model_found_UI_=No content model found
-## save as problems (next two) should match what is in workbench
-Problems_During_Save_As_UI_=Problems During Save As...
-Save_could_not_be_complete_UI_=Save could not be completed.
-2concat=Macro name \"{0}\" is already in use
-3concat=Close with \"{0}\"
-5concat=Close with \"></{0}>\"
-8concat=<{0}> has no known child tags
-27concat=No known child tag names of <{0}> begin with \"{1}\"
-28concat=<{0}> has no known child tags
-15concat=End with {0}>
-17concat=End with \"</{0}>\"
-18concat=The document element <{0}> is already present.
-29concat=No definition was found for element <{0}> in {1}
-20concat=No definition was found for element <{0}>
-24concat=No content model found for {0}.
-25concat=Element <{0}> is unknown.
-30concat=<{0}> has no known child tags.
-31concat=Element <{0}> is unknown.
-11concat=No known child tag names of <{0}> begin with \"{1}\".
-14concat=<{0}> has no known child tags.
-9concat=Close with {0}
-6concat=comment {0}
-Capitalization_style_of_pr_UI_=Capitalization style of proposals:
-CSS_Cleanup_UI_=CSS Cleanup
-Cleanup_UI_=Cleanup
-Identifier_case__UI_=Identifier case:
-Property_name_case__UI_=Property name case:
-model_did_not_existing_dur_UI_=model did not existing during reload request in FileModelProvider
-new_File_was_null_after_mo_UI_=new File was null after move ... should be impossible
-Property_value_case__UI_=Property value case:
-Selector_tag_name_case__UI_=Selector tag name case:
-Quote_values_UI_=Quote values
-The_line_width_must_be_an__EXC_=IWAK0019E The line width must be an integer
-Incorrect_call_UI_=Incorrect call
-1concat_ERROR_=IWAK0020E {0} has no available child tags.
-Edit_Document_Type_UI_=Edit Document Type
-DocumentType_name__UI_=DocumentType name:
-Public_identifier__UI_=Public identifier:
-System_reference__UI_=System reference:
-All_UI_=All
-Tag_UI_=Tag
-Attribute_UI_=Attribute
-Attribute_Value_UI_=Attribute Value
-1concat={0} has no available child tags.
-Text_Shift_Right_UI_=Text Shift Right
-Text_Shift_Left_UI_=Text Shift Left
-4concat_EXC_=IWAK0021E {0} is in use.
-7concat_ERROR_=IWAK0022E One or more characters could not be decoded according to the encoding parameter {1}. Position of first invalid character is {0}.
-8concat_ERROR_=IWAK0023E One or more characters could not be decoded according to the encoding parameter {1}. Position of first invalid character is greater than {0}.
-12concat_ERROR_=IWAK0024E {0} was in use or open in an editor.
-23concat_EXC_=IWAK0025E Resource {0} does not exist.
-32concat_EXC_=IWAK0026E Editor could not be open on {0}
-Add..._UI_=Add...
-Error_opening_file_UI_=Error opening file
-Error_during_save_UI_=Error during save
-Operation_could_not_be_com_ERROR_=IWAK0027E Operation could not be completed. Be sure to save your work in any open editors.
-Java_Content_Assist_is_not_UI_=Java Content Assist is not available for the current cursor location
-End_with=End with
-Close_with=Close with
-4concat=''{0}'' is not a valid input
-## The following strings are for "XML->XML Source" Preferences and "Web Tools->Source" Preferences
-Formatting_UI_=Formatting
-Line_width__UI_=Line &width:
-Clear_all_blank_lines_UI_=Clear all &blank lines
-Source_page_UI_=Source page
-Show_line_numbers_UI_=Show line &numbers
-Show_overview_ruler_UI_=Show o&verview ruler
-Tab_width__UI_=&Tab width:
-Content_assist_UI_=Content assist
-Automatically_make_suggest_UI_=Automatically ma&ke suggestions
-Prompt_when_these_characte_UI_=P&rompt when these characters are inserted:
-Preferred_markup_case_UI_=Preferred markup case for content assist, and code generation
-Tag_names__UI_=Tag names:
-Tag_names_Upper_case_UI_=&Uppercase
-Tag_names_Lower_case_UI_=&Lowercase
-Attribute_names__UI_=Attribute names:
-Attribute_names_Upper_case_UI_=U&ppercase
-Attribute_names_Lower_case_UI_=L&owercase
-## The following strings are for "XML->XML Source->Macros" Preferences and "Web Tools->Source->Macros" Preferences
-New..._UI_=Ne&w...
-Copy..._UI_=&Copy...
-Rename..._UI_=&Rename...
-Remove_UI_=Re&move
-Enabled_at_Location__UI_=&Enabled at Location:
-Content__UI_=Co&ntent:
-Set_Cursor_Position_UI_=&Set Cursor Position
-Macro_name__UI_=&Macro name:
-New_macro_name__UI_=New &macro name:
-## The following strings are for "XML->XML Source->XML Style" Preferences, "Web Tools->Source->HTML Style" Preferences, and "Web Tools->Source->JavaScript Style" Preferences
-Content_type__UI_=Co&ntent type:
-Foreground_UI_=&Foreground:
-Background_UI_=&Background:
-Bold_UI_=B&old
-Restore_Default_UI_=&Restore Default
-Sample_text__UI_=&Sample text:
-## The following strings are for the XML/HTML Cleanup dialog
-As-is_UI_=As-is
-Lower_UI_=Lower
-Upper_UI_=Upper
-Tag_name_case_for_HTML_UI_=Tag name case for HTML:
-Tag_name_case_As-is_UI_=&As-is
-Tag_name_case_Lower_UI_=&Lower
-Tag_name_case_Upper_UI_=&Upper
-Attribute_name_case_for_HTML_UI_=Attribute name case for HTML:
-Attribute_name_case_As-is_UI_=A&s-is
-Attribute_name_case_Lower_UI_=L&ower
-Attribute_name_case_Upper_UI_=U&pper
-Compress_empty_element_tags_UI_=Compress empty element tags
-Insert_required_attributes_UI_=Insert required attributes
-Insert_missing_tags_UI_=&Insert missing tags
-Quote_attribute_values_UI_=&Quote attribute values
-Format_source_UI_=&Format source
-Convert_EOL_codes_UI_=Convert line &delimiters to
-EOL_Windows_UI=&Windows
-EOL_Unix_UI=U&NIX
-EOL_Mac_UI=&Mac
-CSS_Cleanup_..._UI_=&CSS Cleanup ...
-##
-AddBreakpoint.label=Add &Breakpoint
-AddBreakpoint.tooltip=Add Breakpoint
-AddBreakpoint.description=Add Breakpoint
-AddBreakpoint.error.dialog.title=Add Breakpoint
-AddBreakpoint.error.dialog.message=Cannot add breakpoint
-##
-ToggleBreakpoint.label=Toggle Breakpoint
-ToggleBreakpoint.tooltip=Toggle Breakpoint
-ToggleBreakpoint.description=Toggle Breakpoint
-##
-EnableBreakpoint.label=Enable Breakpoint
-EnableBreakpoint.tooltip=Enable Breakpoint
-EnableBreakpoint.description=Enable Breakpoint
-##
-DisableBreakpoint.label=Disable Breakpoint
-DisableBreakpoint.tooltip=Disable Breakpoint
-DisableBreakpoint.description=Disable Breakpoint
-##
-ManageBreakpoints.add.label=Add &Breakpoint
-ManageBreakpoints.remove.label=Remove Breakpoint
-ManageBreakpoints.tooltip=Add/Remove Breakpoint
-ManageBreakpoints.error.adding.title1=Add Breakpoint
-ManageBreakpoints.error.adding.message1=Cannot add breakpoint
-ManageBreakpoints.error.removing.title1=Remove Breakpoint
-ManageBreakpoints.error.removing.message1=Cannot remove breakpoint
-ManageBreakpoints.error.retrieving.message=Retrieving markers failed:
-Hide_Hover_Help_1=Hide Hover Help
-Show_Hover_Help_2=Show Hover Help
-&Hover_Help_3=&Hover Help
-AbstractColorPageDescription=Customize the syntax highlighting by selecting the type of text whose style you want to customize from either the combo box or the sample text area
-JSPSourcePreferencePageDescription=Embedded content type\'s source preferences will be used. Select the file type for customization
-Creating_or_saving_files=Creating or saving files
-End-of-line_code_desc=The following line delimiter will apply:
-End-of-line_code=&Line delimiter:
-Creating_files=Creating files
-Encoding_desc=The following encoding will apply:
-Encoding=En&coding:
-XMLMacroPageDescription=Create, remove or edit Macros
-&Split_lines_1=&Split lines
-Split_&multiple_attributes_2=Split &multiple attributes each on a new line
-&Indent_using_tabs_3=&Indent using tabs
-Bad_attribute_name_1=Bad attribute name
-## tag info
-Element____1=Element :
-Content_Model____2=Content Model :
-Attribute____3=Attribute :
-Data_Type____4=Data Type :
-Enumerated_Values____5=Enumerated Values :
-##
-Source_Menu_UI=&Source
-Highlight_Current_Line=Hi&ghlight current line
-Show_Attributes=Show Attributes
-Grammar_Constraints=Grammar Constraints
-Use_inferred_grammar_in_absence_of_DTD/Schema=Use inferred grammar in absence of DTD/Schema
-Text_font=Text font:
-C&hange...=C&hange...
-NodeName_may_not_have_nested_content={0} may not have nested content
-##
-Editor.Cut.label=Cu&t@Ctrl+X
-Editor.Cut.tooltip=Cut
-Editor.Cut.image=
-Editor.Cut.description=Cut
-
-Editor.Copy.label=&Copy@Ctrl+C
-Editor.Copy.tooltip=Copy
-Editor.Copy.image=
-Editor.Copy.description=Copy
-
-Editor.Paste.label=&Paste@Ctrl+V
-Editor.Paste.tooltip=Paste
-Editor.Paste.image=
-Editor.Paste.description=Paste
-
-Editor.Delete.label=&Delete@Delete
-Editor.Delete.tooltip=Delete
-Editor.Delete.image=
-Editor.Delete.description=Delete
-## These are copied from org.eclipse.ui.texteditor.EditorMessages.properties
-## They are needed temporarily until CMVC defect 203158 / Bugzilla defect 20054 is fixed
-Editor.ManageBookmarks.tooltip=Adds and Removes Bookmarks
-Editor.ManageBookmarks.image=
-Editor.ManageBookmarks.description=Adds and removes Bookmarks
-Editor.ManageBookmarks.add.label=Add Boo&kmark...
-Editor.ManageBookmarks.remove.label=Remove Boo&kmark
-Editor.ManageBookmarks.add.dialog.title=Add Bookmark
-Editor.ManageBookmarks.add.dialog.message=Enter Bookmark name
-Editor.ManageBookmarks.error.dialog.title=Managing Bookmarks
-Editor.ManageBookmarks.error.dialog.message=Problems managing bookmarks
-
-Editor.ManageTasks.tooltip=Adds and Removes Tasks
-Editor.ManageTasks.image=
-Editor.ManageTasks.description=Adds and removes Tasks
-Editor.ManageTasks.add.label=Add &Task...
-Editor.ManageTasks.remove.label=Remove &Task
-Editor.ManageTasks.add.dialog.title=Add Task
-Editor.ManageTasks.add.dialog.message=Enter Task description
-Editor.ManageTasks.error.dialog.title=Managing Tasks
-Editor.ManageTasks.error.dialog.message=Problems managing tasks
-
-# web content settings
-UI_Description_of_role_of_following_DOCTYPE=Use the following default document type when no DOCTYPE is declared in a file:
-UI_Default_HTML_DOCTYPE_ID___1=&Document type:
-UI_CSS_profile___2=&CSS profile:
-UI_Target_Device___3=&Target device:
-UI_none=none
-UI_Public_ID=Public ID:
-UI_System_ID=System ID:
-ERROR_CORE_CSSContentSettingsPropertyPage_is_instantiated_by_choosing_resource_except_any_file_1=CSSContentSettingsPropertyPage is instantiated by choosing resource except any file
-ERROR_CORE_index_is_out_of_range_in_applySelectedPropertyValue()_in_class_CSSContentSettingsPropertyPage_2=index is out of range in applySelectedPropertyValue() in class CSSContentSettingsPropertyPage
-ERROR_CORE_index_is_out_of_range_in_deleteNoneProperty()_in_class_CSSContentSettingsPropertyPage_3=index is out of range in deleteNoneProperty() in class CSSContentSettingsPropertyPage
-ERROR_CORE_the_number_of_items_is_different_in_list_and_Combo__1=the number of items is different in list and Combo
-#
-ERROR_COREDEV_HTMLContentSettingsPropertyPage_is_instantiated_by_choosing_resource_except_any_file_1=HTMLContentSettingsPropertyPage is instantiated by choosing resource except any file
-ERROR_COREDEV_index_is_out_of_range_in_applySelectedPropertyValue()_in_class_HTMLContentSettingsPropertyPage_2=index is out of range in applySelectedPropertyValue() in class HTMLContentSettingsPropertyPage
-ERROR_COREDEV_index_is_out_of_range_in_deleteNoneProperty()_in_class_HTMLContentSettingsPropertyPage_3=index is out of range in deleteNoneProperty() in class HTMLContentSettingsPropertyPage
-ERROR_COREDEV_ProjectContentSettingsPropertyPage_is_instantiated_by_choosing_resource_except_project_1=ProjectContentSettingsPropertyPage is instantiated by choosing resource except project
-ERROR_COREDEV_index_is_out_of_range_in_applySelectedPropertyValue()_in_class_ProjectContentSettingsPropertyPage_2=index is out of range in applySelectedPropertyValue() in class ProjectContentSettingsPropertyPage
-ERROR_COREDEV_index_is_out_of_range_in_deleteNoneProperty()_in_class_ProjectContentSettingsPropertyPage_3=index is out of range in deleteNoneProperty() in class ProjectContentSettingsPropertyPage
-# jspf,jsf content settings
-_UI_Content_Type_Label_=&Content type:
-_UI_Language_Label_=&Language:
-_UI_Character_Code_Label_=&Encoding:
-_UI_IANA_=IANA:
-_UI_Error_Msg_Content_Type_=Invalid Content Type
-_UI_Error_Msg_Language_=Invalid Language
-_UI_Description_J2EE_Project_=The properties for J2EE Web projects act as "project" default to be lookup when no properties are specified for a particular JSP fragment file.
-_UI_Description_JSPF_File_=The properties are used instead of the page directive that cannot be specified in JSP fragment files. The project setting is used if you specify "none".
-
-#
-_UI_File_is_read_only=File {0} is read-only.
-This_encoding_({0})_is_not_supported._The_default_encoding_({1})_will_be_used_instead._1=This encoding ({0}) is not supported. The default encoding ({1}) will be used instead.
-This_encoding_({0})_is_not_supported._Continue_the_save_using_the_default_({1})__2=This encoding ({0}) is not supported. Continue the save using the default ({1})?
-#
-cannot_convert_some_characters=The encoding ({0}) cannot convert some characters (such as the one in position {1}). Press ''OK'' to save anyway (and some characters will be converted to ''?'' in the saved file), or press ''Cancel'' to return to the editor.
-cannot_convert_some_characters2=The encoding ({0}) cannot convert some characters. Press ''OK'' to save anyway (and some characters will be converted to ''?'' in the saved file), or press ''Cancel'' to return to the editor.
-# The following lines copied from org\eclipse\ui\editors\text\TextEditorMessages.properties in org.eclipse.ui plugin
-Editor.error.save.message=Save could not be completed. {0}
-Editor.error.save.title=Problems During Save As...
-Editor.warning.save.delete=The original file ''{0}'' has been deleted.
-FileDocumentProvider.task.saving=Saving
-Set_color_and_visibilty_of_editor_annotations=Set color and visibilty of editor annotations:
-Analyze_annotations_while_typing=Analyze syntax &while typing
-Analyze_validity_while_typing=Analyze &validity while typing
-Annotation_Presentation=Annotation Presentation:
-Show_in_text=Show in &text
-Show_in_overview_ruler=Show in overview &ruler
-Color=C&olor
-Show_hover_help=Show hov&er help
-#
-Multiple_errors=Multiple annotations found at this line:
-Ill-formed_syntax=Ill-formed syntax:
-Style_Rule_declares_nothing=Style Rule declares nothing
-Style_Declaration_declares_nothing=Style Declaration declares nothing
-Attribute_{0}_is_missing_a_value=Attribute \"{0}\" is missing a value
-Attribute_{0}_has_no_value=Attribute \"{0}\" has no value
-End_tag_has_attributes=End tag has attributes
-Invalid_value_{0}=Invalid value \"{0}\"
-Unknown_attribute_{0}=Unknown attribute \"{0}\"
-Missing_required_attribute_{0}=Missing required attribute \"{0}\"
-Unknown_element_{0}=Unknown element \"{0}\"
-Missing_end_tag_{0}=Missing end tag \"{0}\"
-Missing_start_tag_{0}=Missing start tag \"{0}\"
-
-# actions
-Previous_error=Go to Previous Problem
-Next_error=Go to Next Problem
-# Annotation Types
-AnnotationTypes.Errors=Errors
-AnnotationTypes.Warnings=Warnings
-AnnotationTypes.Tasks=Tasks
-AnnotationTypes.SearchResults=Search Results
-AnnotationTypes.Bookmarks=Bookmarks
-AnnotationTypes.Others=Others
-
-Editor.ConvertToWindows.label=&Windows
-Editor.ConvertToWindows.tooltip=Converts line delimiters to Windows
-Editor.ConvertToWindows.image=
-Editor.ConvertToWindows.description=Converts line delimiters to Windows
-
-Editor.ConvertToUNIX.label=&UNIX
-Editor.ConvertToUNIX.tooltip=Converts line delimiters to UNIX
-Editor.ConvertToUNIX.image=
-Editor.ConvertToUNIX.description=Converts line delimiters to UNIX
-
-Editor.ConvertToMac.label=&Mac
-Editor.ConvertToMac.tooltip=Converts line delimiters to Mac
-Editor.ConvertToMac.image=
-Editor.ConvertToMac.description=Converts line delimiters to Mac
-
-Editor.ToggleInsertMode.label=Sma&rt Insert Mode
-
-EditPreferences.label=Preferences...
-EditPreferences.tooltip=Display preferences for this editor
-EditPreferences.description=Display preferences for this editor
-##########################################################################
-# These strings are used in Workbench menu bar
-##########################################################################
-ExpandSelectionToMenu.label=E&xpand Selection To
-SourceMenu.label=&Source
-FormatMenu.label=F&ormat
-ConvertLineDelimitersMenu.label=Co&nvert Line Delimiters to
-FindOccurrences.label=O&ccurrences in File
-#
-FindOccurrencesActionProvider.0=Current selection does not resolve to a searchable element
-RemoveAction.0=Remove Property
-ShowPropertiesAction.0=Properties
-StructuredContentOutlineConfiguration.0=Collapse All
-StructuredContentOutlineConfiguration.1=Link with Editor
-AbstractOpenOn.0=Current text selection does not resolve to a file
-ActionDelegate.0=\t...Exception when processing resource
-FormatActionDelegate.0=Format Document Progress Dialog
-FormatActionDelegate.1=Format document completed
-FormatActionDelegate.2=Format document cancelled
-FormatActionDelegate.3=Formatting
-FormatActionDelegate.4=\t...MalformedInputException for resource
-ConvertLineDelimitersToCRLFActionDelegate.0=Convert Line Delimiters Progress Dialog
-ConvertLineDelimitersToCRLFActionDelegate.1=Convert line delimiters completed
-ConvertLineDelimitersToCRLFActionDelegate.2=Convert line delimiters cancelled
-ConvertLineDelimitersToCRLFActionDelegate.3=Converting line delimiters for
-ResourceActionProgressDialog.0=Progress Dialog
-ResourceActionProgressDialog.1=Action completed
-ResourceActionProgressDialog.2=Action cancelled
-TranslucencyPreferenceTab.0=Read-Only text style
-StructuredTextEditorPreferencePage.1=Line number foreground
-StructuredTextEditorPreferencePage.2=Matching brackets highlight
-StructuredTextEditorPreferencePage.3=Current line highlight
-StructuredTextEditorPreferencePage.4=Print margin
-StructuredTextEditorPreferencePage.5=Link
-StructuredTextEditorPreferencePage.6=Structured Text Editor Preferences:
-StructuredTextEditorPreferencePage.7=S&upport hyperlink style navigation for "Open Declaration"
-StructuredTextEditorPreferencePage.8=Hyperlink style navigation key &modifier:
-StructuredTextEditorPreferencePage.15=The modifier 'Shift' is not allowed because 'Shift' + click sets a new selection.
-StructuredTextEditorPreferencePage.16=Displayed &tab width:
-StructuredTextEditorPreferencePage.17=Print margin col&umn:
-StructuredTextEditorPreferencePage.18=Show overview &ruler
-StructuredTextEditorPreferencePage.19=Show lin&e numbers
-StructuredTextEditorPreferencePage.20=Highlight &matching brackets
-StructuredTextEditorPreferencePage.21=Hi&ghlight current line
-StructuredTextEditorPreferencePage.22=Sho&w print margin
-StructuredTextEditorPreferencePage.23=Appearance co&lor options:
-StructuredTextEditorPreferencePage.24=C&olor:
-StructuredTextEditorPreferencePage.25=Always &show Quick Diff coloring
-StructuredTextEditorPreferencePage.26=Show changes using &characters instead of colors (on line number bar only)
-StructuredTextEditorPreferencePage.27=Quickdiff &reference providers:
-StructuredTextEditorPreferencePage.28=Make &Default
-StructuredTextEditorPreferencePage.29=(default)
-StructuredTextEditorPreferencePage.30=Analyze annotations while typing
-StructuredTextEditorPreferencePage.31=Show quick fixables
-StructuredTextEditorPreferencePage.32=Annotation presentation options
-StructuredTextEditorPreferencePage.33=Annotations
-StructuredTextEditorPreferencePage.34=Nav&igation
-StructuredTextEditorPreferencePage.35=&Quick Diff
-StructuredTextEditorPreferencePage.36=(default)
-StructuredTextEditorPreferencePage.37=Empty input
-StructuredTextEditorPreferencePage.38=is not a valid input.
-StructuredTextEditorPreferencePage.39=is not a valid input.
-TaskTagPreferenceTab.0=High
-TaskTagPreferenceTab.1=Low
-TaskTagPreferenceTab.2=Normal
-TaskTagPreferenceTab.3=N/A
-TaskTagPreferenceTab.5=Task Tag
-TaskTagPreferenceTab.6=Tag
-TaskTagPreferenceTab.7=Priority
-TaskTagPreferenceTab.8=High
-TaskTagPreferenceTab.9=Normal
-TaskTagPreferenceTab.10=Low
-TaskTagPreferenceTab.12=Tag
-TaskTagPreferenceTab.13=Priority
-TaskTagPreferenceTab.14=New...
-TaskTagPreferenceTab.15=Edit...
-TaskTagPreferenceTab.16=Remove
-TaskTagPreferenceTab.17=Move Up
-TaskTagPreferenceTab.18=Move Down
-TaskTagPreferenceTab.19=Note: changes may not be visible until the workspace is rebuilt
-TaskTagPreferenceTab.20=Task Tags
-TaskTagPreferenceTab.22=Task Tags Settings Changed
-TaskTagPreferenceTab.23=The task tags settings have changed. A full rebuild is required to make changes effective. Do the full build now?
-TaskTagPreferenceTab.24=Yes
-TaskTagPreferenceTab.25=No
-TaskTagPreferenceTab.26=Cancel
-TaskTagPreferenceTab.27=Detecting tasks for task tags
-TaskTagPreferenceTab.28=build aborted
-TaskTagPreferenceTab.29=build completed
-TaskTagPreferenceTab.30=build had errors
-FilePreferencePage.0=Expand the tree to edit preferences for a specific content type.
-NoModificationCompletionProposal.0=No corrections available
-ToggleBreakpointAction.0=Toggle &Breakpoints
-ManageBreakpointAction.0=&Enable Breakpoints
-ManageBreakpointAction.1=&Disable Breakpoints
-EditBreakpointAction.0=Breakpoint &Properties...
-ReconcileStepForMarkup.0=Missing closing quote
-ReconcileStepForMarkup.1=Missing quotes for attribute value
-ReconcileStepForMarkup.2=A tagname cannot start with a space
-ReconcileStepForMarkup.3=Empty tags are not allowed
-ReconcileStepForMarkup.4=Namespaces are not allowed in a Processing Instruction target
-ReconcileStepForMarkup.5=Spaces are not allowed before a Processing Instruction
-ReconcileStepForMarkup.6=Tag missing closing bracket '>'
-## Used in Structured Text Editor Preference Page / Hovers Tab
-TextHoverPreferenceTab.title=Hovers
-TextHoverPreferenceTab.annotationRollover=&Enable annotation roll-over (on new editors)
-TextHoverPreferenceTab.showAffordance=&Show affordance in hover on how to make it sticky
-TextHoverPreferenceTab.hoverPreferences=Text &Hover key modifier preferences:
-TextHoverPreferenceTab.enabled=&Enabled
-TextHoverPreferenceTab.keyModifier=Pressed key &modifier while hovering:
-TextHoverPreferenceTab.description=Description:
-TextHoverPreferenceTab.modifierIsNotValid=Modifier ''{0}'' is not valid.
-TextHoverPreferenceTab.modifierIsNotValidForHover=Modifier ''{0}'' for ''{1}'' hover is not valid.
-TextHoverPreferenceTab.duplicateModifier=''{0}'' hover uses the same modifier as ''{1}'' hover.
-TextHoverPreferenceTab.nameColumnTitle=Text Hover Name
-TextHoverPreferenceTab.modifierColumnTitle=Pressed Key Modifier While Hovering
-TextHoverPreferenceTab.delimiter=+
-TextHoverPreferenceTab.insertDelimiterAndModifierAndDelimiter=\ + {0} +
-TextHoverPreferenceTab.insertModifierAndDelimiter=\ {0} +
-TextHoverPreferenceTab.insertDelimiterAndModifier=\ + {0}
-combinationHover.label=Combined Hover
-combinationHover.desc=Tries the hovers in the sequence listed in the table below this one and uses the one which fits best for the selected element and the current context.
-problemHover.label=Problem Description
-problemHover.desc=Shows the description of the selected problem.
-documentationHover.label=Documentation Description
-documentationHover.desc=Shows the documentation of the selected element.
-annotationHover.label=Annotation Description
-annotationHover.desc=Shows the description of the selected annotation.
-EditStructuredTextEditorPreferencesAction.0=Editor Preferences
-StructuredTextEditorPreferencePage.0=Appearance
-BasicFindOccurrencesAction.0=region match:
-BasicSearchLabelProvider.0=line
-PreferenceManager.0=Original Error:
-NavigationPreferenceTab.0=Modifier ''{0}'' is not valid.
-OccurrencesSearchQuery.0={0} - {1} Occurrences in {2}
-OccurrencesSearchQuery.1={0} - 1 Occurrence in {1}
-OccurrencesSearchQuery.2=file
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);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.sse.ui/toc.xml b/bundles/org.eclipse.wst.sse.ui/toc.xml
deleted file mode 100644
index a5c0bb6c2b..0000000000
--- a/bundles/org.eclipse.wst.sse.ui/toc.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<?NLS TYPE="org.eclipse.help.toc"?>
-
-<toc label="Sample Table of Contents">
- <topic
- label="Main Topic"
- href="html/maintopic.html">
- <topic
- label="Sub Topic"
- href="html/subtopic.html" />
- </topic>
- <topic label="Main Topic 2" />
-</toc>

Back to the top