Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'bundles/org.eclipse.wst.xml.ui/src')
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java226
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java237
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserverAdapter.java74
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java163
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLFormattingStrategy.java105
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java342
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java117
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties349
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java117
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java690
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java224
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java85
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java519
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java139
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java211
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java81
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java192
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java119
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java98
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java168
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/GoToMatchingTagAction.java301
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java146
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java48
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java87
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java84
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/SiblingNavigationAction.java110
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java174
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java200
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java285
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java2509
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java90
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLCompletionProposalComputer.java1134
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLModelQueryCompletionProposalComputer.java1834
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java115
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java122
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java231
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java260
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java66
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java40
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/DefaultXMLCompletionProposalComputer.java200
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java275
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java159
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java49
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java170
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java48
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java170
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java516
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java154
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java53
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLStructuredContentAssistProcessor.java79
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTagsCompletionProposalComputer.java49
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java168
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplatesCompletionProposalComputer.java105
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java257
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java183
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java120
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java81
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java368
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java53
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionAssistantProviderXML.java51
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java47
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java180
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java32
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java192
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java151
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java162
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java188
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java111
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java212
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java172
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java235
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java141
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java73
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java274
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java116
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java80
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java398
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java87
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java184
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java111
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java147
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/UpdateListener.java20
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java201
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java312
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java54
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java327
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java113
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/DOMSelectionConvertorFactory.java86
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java50
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java159
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java60
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AbstractSiblingNavigationHandler.java92
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java77
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java119
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java52
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CommentHandler.java103
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandAllHandler.java54
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java58
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/NextSiblingNavigationHandler.java19
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/PreviousSiblingNavigationHandler.java19
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java80
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java84
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectEnclosingXMLHandler.java59
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectNextXMLHandler.java97
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectPreviousXMLHandler.java75
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleCommentHandler.java193
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java138
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java152
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/CatalogEntryHyperlink.java116
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java171
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java76
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/URLStorageHyperlink.java180
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java93
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java569
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java281
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java205
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java327
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java104
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java346
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/perspective/XMLPerspectiveFactory.java68
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EmptyFilePreferencePage.java100
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java360
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java141
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java288
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLCompletionProposalCategoriesConfiguration.java81
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLContentAssistPreferencePage.java256
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java178
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java306
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSyntaxColoringPage.java873
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java169
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTypingPreferencePage.java130
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java132
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java200
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java172
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLCommentFoldingPosition.java52
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLElementFoldingPosition.java77
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLFoldingStrategy.java69
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java71
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java119
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java833
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/IDOMSourceEditingTextTools.java68
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java182
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java90
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java34
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java31
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java72
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java109
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java88
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/spelling/SpellcheckDelegateAdapterFactory.java83
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java43
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java212
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java184
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java67
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java362
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java38
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java50
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java35
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/CharacterPairInserter.java106
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java27
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/SharedXMLEditorPluginImageHelper.java72
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java95
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonUIContextIds.java51
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java619
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java56
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupQuickAssistProcessor.java147
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java1036
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java342
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java411
-rw-r--r--bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java282
171 files changed, 0 insertions, 33889 deletions
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java
deleted file mode 100644
index 2c11ee3f12..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/StructuredTextViewerConfigurationXML.java
+++ /dev/null
@@ -1,226 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
-import org.eclipse.jface.text.formatter.IContentFormatter;
-import org.eclipse.jface.text.formatter.MultiPassContentFormatter;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.wst.sse.core.text.IStructuredPartitions;
-import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
-import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.text.rules.StructuredTextPartitionerForXML;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-import org.eclipse.wst.xml.ui.internal.XMLFormattingStrategy;
-import org.eclipse.wst.xml.ui.internal.autoedit.AutoEditStrategyForTabs;
-import org.eclipse.wst.xml.ui.internal.contentassist.XMLStructuredContentAssistProcessor;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
-import org.eclipse.wst.xml.ui.internal.style.LineStyleProviderForXML;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- * Configuration for a source viewer which shows XML content.
- * <p>
- * Clients can subclass and override just those methods which must be specific
- * to their needs.
- * </p>
- *
- * @see org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration
- * @since 1.0
- */
-public class StructuredTextViewerConfigurationXML extends StructuredTextViewerConfiguration {
- /*
- * One instance per configuration because not sourceviewer-specific and
- * it's a String array
- */
- private String[] fConfiguredContentTypes;
- /*
- * One instance per configuration
- */
- private LineStyleProvider fLineStyleProviderForXML;
- private ILabelProvider fStatusLineLabelProvider;
-
- /**
- * Create new instance of StructuredTextViewerConfigurationXML
- */
- public StructuredTextViewerConfigurationXML() {
- // Must have empty constructor to createExecutableExtension
- super();
- }
-
- public IAutoEditStrategy[] getAutoEditStrategies(ISourceViewer sourceViewer, String contentType) {
- List allStrategies = new ArrayList(0);
-
- IAutoEditStrategy[] superStrategies = super.getAutoEditStrategies(sourceViewer, contentType);
- for (int i = 0; i < superStrategies.length; i++) {
- allStrategies.add(superStrategies[i]);
- }
-
- // be sure this is last, so it can modify any results form previous
- // commands that might on on same partiion type.
- // add auto edit strategy that handles when tab key is pressed
- allStrategies.add(new AutoEditStrategyForTabs());
-
- return (IAutoEditStrategy[]) allStrategies.toArray(new IAutoEditStrategy[allStrategies.size()]);
- }
-
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
-
- if (fConfiguredContentTypes == null) {
- String[] xmlTypes = StructuredTextPartitionerForXML.getConfiguredContentTypes();
- fConfiguredContentTypes = new String[xmlTypes.length + 2];
- fConfiguredContentTypes[0] = IStructuredPartitions.DEFAULT_PARTITION;
- fConfiguredContentTypes[1] = IStructuredPartitions.UNKNOWN_PARTITION;
- int index = 0;
- System.arraycopy(xmlTypes, 0, fConfiguredContentTypes, index += 2, xmlTypes.length);
- }
- return fConfiguredContentTypes;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration#getContentAssistProcessors(
- * org.eclipse.jface.text.source.ISourceViewer, java.lang.String)
- */
- protected IContentAssistProcessor[] getContentAssistProcessors(ISourceViewer sourceViewer, String partitionType) {
- IContentAssistProcessor processor = new XMLStructuredContentAssistProcessor(
- this.getContentAssistant(), partitionType, sourceViewer);
- return new IContentAssistProcessor[]{processor};
- }
-
- public IContentFormatter getContentFormatter(ISourceViewer sourceViewer) {
- IContentFormatter formatter = super.getContentFormatter(sourceViewer);
- // super was unable to create a formatter, probably because
- // sourceViewer does not have document set yet, so just create a
- // generic one
- if (!(formatter instanceof MultiPassContentFormatter))
- formatter = new MultiPassContentFormatter(getConfiguredDocumentPartitioning(sourceViewer), IXMLPartitions.XML_DEFAULT);
- ((MultiPassContentFormatter) formatter).setMasterStrategy(new XMLFormattingStrategy());
-// ((MultiPassContentFormatter) formatter).setMasterStrategy(new StructuredFormattingStrategy(new FormatProcessorXML()));
-
- return formatter;
- }
-
- public String[] getIndentPrefixes(ISourceViewer sourceViewer, String contentType) {
- Vector vector = new Vector();
-
- // prefix[0] is either '\t' or ' ' x tabWidth, depending on preference
- Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences();
- int indentationWidth = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
- String indentCharPref = preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR);
- boolean useSpaces = XMLCorePreferenceNames.SPACE.equals(indentCharPref);
-
- for (int i = 0; i <= indentationWidth; i++) {
- StringBuffer prefix = new StringBuffer();
- boolean appendTab = false;
-
- if (useSpaces) {
- for (int j = 0; j + i < indentationWidth; j++) {
- prefix.append(' ');
- }
-
- if (i != 0) {
- appendTab = true;
- }
- }
- else {
- for (int j = 0; j < i; j++) {
- prefix.append(' ');
- }
-
- if (i != indentationWidth) {
- appendTab = true;
- }
- }
-
- if (appendTab) {
- prefix.append('\t');
- vector.add(prefix.toString());
- // remove the tab so that indentation - tab is also an indent
- // prefix
- prefix.deleteCharAt(prefix.length() - 1);
- }
- vector.add(prefix.toString());
- }
-
- vector.add(""); //$NON-NLS-1$
-
- return (String[]) vector.toArray(new String[vector.size()]);
- }
-
- public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
- LineStyleProvider[] providers = null;
-
- if ((partitionType == IXMLPartitions.XML_DEFAULT) || (partitionType == IXMLPartitions.XML_CDATA) || (partitionType == IXMLPartitions.XML_COMMENT) || (partitionType == IXMLPartitions.XML_DECLARATION) || (partitionType == IXMLPartitions.XML_PI)) {
- providers = new LineStyleProvider[]{getLineStyleProviderForXML()};
- }
-
- return providers;
- }
-
- private LineStyleProvider getLineStyleProviderForXML() {
- if (fLineStyleProviderForXML == null) {
- fLineStyleProviderForXML = new LineStyleProviderForXML();
- }
- return fLineStyleProviderForXML;
- }
-
- public ILabelProvider getStatusLineLabelProvider(ISourceViewer sourceViewer) {
- if (fStatusLineLabelProvider == null) {
- fStatusLineLabelProvider = new JFaceNodeLabelProvider() {
- public String getText(Object element) {
- if (element == null)
- return null;
-
- StringBuffer s = new StringBuffer();
- Node node = (Node) element;
- while (node != null) {
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- s.insert(0, super.getText(node));
- }
-
- if (node.getNodeType() == Node.ATTRIBUTE_NODE)
- node = ((Attr) node).getOwnerElement();
- else
- node = node.getParentNode();
-
- if (node != null && node.getNodeType() != Node.DOCUMENT_NODE) {
- s.insert(0, IPath.SEPARATOR);
- }
- }
- return s.toString();
- }
-
- };
- }
- return fStatusLineLabelProvider;
- }
-
- protected Map getHyperlinkDetectorTargets(ISourceViewer sourceViewer) {
- Map targets = super.getHyperlinkDetectorTargets(sourceViewer);
- targets.put(ContentTypeIdForXML.ContentTypeID_XML, null);
- return targets;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
deleted file mode 100644
index 4b90cfb3ff..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserver.java
+++ /dev/null
@@ -1,237 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal;
-
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.SSEUIMessages;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * This class is used to observe changes in the DOM and perform
- * occasional'scans' to deduce information. We use a delay timer mechanism to
- * ensure scans are made every couple of seconds to avoid performance
- * problems. Currently this class is used to keep track of referenced grammar
- * uri's within the document ensure that they are loaded by the
- * CMDocumentManager. We might want to generalize this class to perform other
- * suplimental information gathering that is suitable for 'time delayed'
- * computation (error hints etc.).
- */
-// TODO: Where should this class go?
-public class DOMObserver {
-
-
- // An abstract adapter that ensures that the children of a new Node are
- // also adapted
- //
- abstract class DocumentAdapter implements INodeAdapter {
- public DocumentAdapter() {
- }
-
- public void connect(Document document) {
- ((INodeNotifier) document).addAdapter(this);
- adapt(document.getDocumentElement());
- }
-
- public void dicconnect(Document document) {
- ((INodeNotifier) document).removeAdapter(this);
- }
-
- public void adapt(Element element) {
- if (element != null) {
- if (((INodeNotifier) element).getExistingAdapter(this) == null) {
- ((INodeNotifier) element).addAdapter(this);
-
- for (Node child = element.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() == Node.ELEMENT_NODE) {
- adapt((Element) child);
- }
- }
- }
- }
- }
-
- public boolean isAdapterForType(Object type) {
- return type == this;
- }
-
- abstract public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index);
- }
-
- /**
- * This class listens to the changes in the CMDocument and triggers a
- * CMDocument load
- */
- class MyDocumentAdapter extends DocumentAdapter {
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object feature, Object oldValue, Object newValue, int index) {
- switch (eventType) {
- case INodeNotifier.ADD : {
- if (newValue instanceof Element) {
- // System.out.println("ADD (to " +
- // ((Node)notifier).getNodeName() + ") " +
- // ((Element)newValue).getNodeName() + " old " +
- // oldValue);
- adapt((Element) newValue);
- }
- break;
- }
- // case INodeNotifier.REMOVE:
- case INodeNotifier.CHANGE :
- case INodeNotifier.STRUCTURE_CHANGED :
- case INodeNotifier.CONTENT_CHANGED : {
- Node node = (Node) notifier;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- switch (eventType) {
- case INodeNotifier.CHANGE :
- case INodeNotifier.STRUCTURE_CHANGED : {
- // structure change
- invokeDelayedCMDocumentLoad();
- break;
- }
- case INodeNotifier.CONTENT_CHANGED : {
- // some content changed
- break;
- }
- }
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- invokeDelayedCMDocumentLoad();
- }
- break;
- }
- }
- }
- }
-
- /**
- * Intentionally left visible to the user
- */
- class TimerJob extends Job {
- public TimerJob() {
- super(SSEUIMessages.LoadingReferencedGrammars);
- }
-
- public IStatus run(IProgressMonitor monitor) {
- monitor.beginTask("", IProgressMonitor.UNKNOWN); //$NON-NLS-1$
- Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
- invokeCMDocumentLoad();
- monitor.done();
- return Status.OK_STATUS;
- }
- }
-
- private Job timer = new TimerJob();
- protected Document fDocument;
- protected boolean isGrammarInferenceEnabled;
- /**
- * If true, DOMObserver is currently disabled and not loading the content
- * model
- */
- private boolean fIsDisabled = false;
- /**
- * If true, DOMObserver is currently trying to load the content model
- */
- private boolean fIsLoading = false;
-
- public DOMObserver(IStructuredModel model) {
- fDocument = (model instanceof IDOMModel) ? ((IDOMModel) model).getDocument() : null;
-
- if (fDocument != null) {
- // here we create and init an adapter that will listen to
- // changes to the document and contained elements
- MyDocumentAdapter adapter = new MyDocumentAdapter();
- adapter.connect(fDocument);
-
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fDocument);
- if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
- CMDocumentManager cmDocumentManager = modelQuery.getCMDocumentManager();
- cmDocumentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, false);
- }
-
- // attach a dom observer adapter to the document so others have access to
- // domobserver if needed
- INodeAdapter domObserverAdapter = ((INodeNotifier)fDocument).getExistingAdapter(DOMObserverAdapter.class);
- if (domObserverAdapter == null) {
- domObserverAdapter = new DOMObserverAdapter();
- ((INodeNotifier)fDocument).addAdapter(domObserverAdapter);
- }
- ((DOMObserverAdapter)domObserverAdapter).setDOMObserver(this);
- }
- }
-
- public void init() {
- // CS: we seem to expose an XSD initialization problem when we do this
- // immediately
- // very nasty... I need to revist this problem with Ed Merks
- //
- timer.schedule();
- }
-
- public void invokeCMDocumentLoad() {
- if (fIsDisabled) return;
- try {
- fIsLoading = true;
-
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fDocument);
- if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
- CMDocumentLoader loader = isGrammarInferenceEnabled ? new InferredGrammarBuildingCMDocumentLoader(fDocument, modelQuery) : new CMDocumentLoader(fDocument, modelQuery);
- loader.loadCMDocuments();
- }
- } finally {
- fIsLoading = false;
- }
- }
-
- public void invokeDelayedCMDocumentLoad() {
- if (fIsDisabled) return;
- timer.schedule(2000);
- }
-
- public void setGrammarInferenceEnabled(boolean isEnabled) {
- isGrammarInferenceEnabled = isEnabled;
- }
-
- boolean setDisabled(boolean isDisabled, boolean forced) {
- boolean success = true;
-
- if (fIsDisabled != isDisabled) {
- fIsDisabled = isDisabled;
- if (forced) {
- if (isDisabled)
- success = timer.cancel();
- else
- invokeCMDocumentLoad();
- }
- }
- return success;
- }
-
- boolean isLoading() {
- return fIsLoading;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserverAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserverAdapter.java
deleted file mode 100644
index fcd60c405a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/DOMObserverAdapter.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal;
-
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-
-/**
- * This is just an adapter that sits on a document node to allow clients
- * limited access to the DOMObserver. Clients who handle their own content
- * model document loading (as opposed to letting the DOMObserver do it) may
- * use this class to stop the DOMObserver from loading and possibly
- * interfering with the client's document loading.
- */
-public class DOMObserverAdapter implements INodeAdapter {
- private DOMObserver fObserver = null;
-
- public boolean isAdapterForType(Object type) {
- return type == DOMObserverAdapter.class;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- // do nothing
- }
-
- /**
- * The DOMObserver is the one that adds the adapter to the document node,
- * so it'll set itself up here as well.
- *
- * @param observer
- */
- void setDOMObserver(DOMObserver observer) {
- fObserver = observer;
- }
-
- /**
- * Disable the DOMObserver to prevent it from future content model loading
- * for this document.
- *
- * @param disable
- * true if caller wants DOMObserver disabled. false if caller
- * wants DOMObserver enabled.
- * @param force
- * if true, DOMObserver will forcibly be disabled (if the
- * DOMObserver model loading job is scheduled, it will be
- * cancelled)
- * @return true if DOMObserver was successfully disabled. false if
- * DOMObserver was already in the process of loading and was
- * unable to stop
- */
- public boolean disableObserver(boolean disable, boolean force) {
- return fObserver.setDisabled(disable, force);
- }
-
- /**
- * Returns whether or not DOMObserver is currently attempting to load the
- * content model.
- *
- * @return true if DOMObserver is currently in the process of loading the
- * content models. false otherwise.
- */
- public boolean isObserverLoading() {
- return fObserver.isLoading();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java
deleted file mode 100644
index b98e7ab1d2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/Logger.java
+++ /dev/null
@@ -1,163 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal;
-
-
-
-import com.ibm.icu.util.StringTokenizer;
-
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.osgi.framework.Bundle;
-
-/**
- * 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 final String PLUGIN_ID = "org.eclipse.wst.xml.ui"; //$NON-NLS-1$
-
- public static final int ERROR = IStatus.ERROR; // 4
- public static final int ERROR_DEBUG = 200 + ERROR;
- public static final int INFO = IStatus.INFO; // 1
- public static final int INFO_DEBUG = 200 + INFO;
-
- public static final int OK = IStatus.OK; // 0
-
- public static final int OK_DEBUG = 200 + OK;
-
- private static final String TRACEFILTER_LOCATION = "/debug/tracefilter"; //$NON-NLS-1$
- public static final int WARNING = IStatus.WARNING; // 2
- public static final int WARNING_DEBUG = 200 + WARNING;
-
- /**
- * 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, PLUGIN_ID, severity, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null) {
- Platform.getLog(bundle).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, PLUGIN_ID, IStatus.OK, message, exception);
- Bundle bundle = Platform.getBundle(PLUGIN_ID);
- if (bundle != null) {
- Platform.getLog(bundle).log(statusObj);
- }
- }
- }
-
- /**
- * @return true if the platform is debugging
- */
- public static boolean isDebugging() {
- return Platform.inDebugMode();
- }
-
- /**
- * 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(PLUGIN_ID + 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 trace(String category, String message) {
- _trace(category, message, null);
- }
-
- 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);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLFormattingStrategy.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLFormattingStrategy.java
deleted file mode 100644
index 39432efc78..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLFormattingStrategy.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal;
-
-import java.util.LinkedList;
-
-import org.eclipse.jface.text.BadLocationException;
-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.jface.text.formatter.IFormattingStrategyExtension;
-import org.eclipse.text.edits.TextEdit;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.ui.internal.Logger;
-import org.eclipse.wst.xml.core.internal.formatter.DefaultXMLPartitionFormatter;
-
-public class XMLFormattingStrategy extends ContextBasedFormattingStrategy implements IFormattingStrategyExtension {
-
- /** 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 IRegion fRegion;
- private DefaultXMLPartitionFormatter formatter = new DefaultXMLPartitionFormatter();
-
- /**
- * @param formatProcessor
- */
- public XMLFormattingStrategy() {
- super();
- }
-
- /*
- * @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) {
- try {
- if (document instanceof IStructuredDocument) {
- IStructuredModel model = StructuredModelManager.getModelManager().getModelForEdit((IStructuredDocument) document);
- if (model != null) {
- try {
- TextEdit edit = formatter.format(model, fRegion.getOffset(), fRegion.getLength());
- if (edit != null) {
- try {
- model.aboutToChangeModel();
- edit.apply(document);
- }
- finally {
- model.changedModel();
- }
- }
- }
- finally {
- model.releaseFromEdit();
- }
- }
- }
- }
- catch (BadLocationException e) {
- // log for now, unless we find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
- }
-
- /*
- * @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();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
deleted file mode 100644
index 16f6cb39b8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIMessages.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/**********************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others. All rights reserved. This
- * program and the accompanying materials are made available under the terms of
- * the Eclipse Public License v1.0 which accompanies this distribution, and is
- * available at http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- * Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference
- * David Carver - STAR - [205989] - [validation] validate XML after XInclude resolution
- **********************************************************************/
-package org.eclipse.wst.xml.ui.internal;
-
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.osgi.util.NLS;
-
-/**
- * Strings used by XML UI
- *
- * @plannedfor 1.0
- */
-public class XMLUIMessages extends NLS {
- private static final String BUNDLE_NAME = "org.eclipse.wst.xml.ui.internal.XMLUIPluginResources";//$NON-NLS-1$
- private static ResourceBundle fResourceBundle;
-
- public static String Sample_XML_doc;
- public static String Comment_Delimiters_UI_;
- public static String Comment_Content_UI_;
- public static String Tag_Delimiters_UI_;
- public static String Tag_Names_UI_;
- public static String Attribute_Names_UI_;
- public static String Attribute_Equals_UI_;
- public static String Attribute_Values_UI_;
- public static String Declaration_Delimiters_UI_;
- public static String Content_UI_;
- public static String CDATA_Delimiters_UI_;
- public static String CDATA_Content_UI_;
- public static String Processing_Instruction_Del_UI_;
- public static String Processing_Instruction_Con_UI__UI_;
- public static String DOCTYPE_Name_UI_;
- public static String DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_;
- public static String DOCTYPE_Public_Reference_UI_;
- public static String DOCTYPE_System_Reference_UI_;
- public static String Entity_Reference_UI_;
- public static String DELETE;
- public static String ADD_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_ADD_AFTER;
- public static String _UI_MENU_ADD_ATTRIBUTE;
- public static String _UI_MENU_ADD_BEFORE;
- public static String _UI_MENU_ADD_CHILD;
- public static String _UI_MENU_REMOVE;
- public static String _UI_MENU_REPLACE_WITH;
- public static String _UI_MENU_EDIT_DOCTYPE;
- public static String _UI_LABEL_UNDO_REPLACE_DESCRIPTION;
- public static String _UI_LABEL_EDIT_DOCTYPE;
- public static String _UI_INFO_EXPAND_ALL;
- public static String _UI_INFO_COLLAPSE_ALL;
- public static String _UI_MENU_ADD_DTD_INFORMATION;
- public static String _UI_MENU_ADD_SCHEMA_INFORMATION;
- public static String _UI_MENU_EDIT_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_EDIT_NAMESPACES;
- public static String _UI_MENU_ADD_DTD_INFORMATION_TITLE;
- public static String _UI_MENU_EDIT_PROCESSING_INSTRUCTION_TITLE;
- public static String _UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE;
- public static String _UI_MENU_NEW_ATTRIBUTE;
- public static String _UI_MENU_NEW_ATTRIBUTE_TITLE;
- public static String _UI_MENU_EDIT_ATTRIBUTE;
- public static String _UI_MENU_EDIT_ATTRIBUTE_TITLE;
- public static String _UI_MENU_NEW_ELEMENT;
- public static String _UI_MENU_NEW_ELEMENT_TITLE;
- public static String _UI_MENU_RENAME;
- public static String _UI_MENU_RENAME_TITLE;
- public static String _UI_LABEL_ELEMENT_NAME;
- public static String _UI_MENU_ADD_COMMENT;
- public static String _UI_MENU_ADD_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_ADD_CDATA_SECTION;
- public static String _UI_MENU_ADD_PCDATA;
- public static String _UI_MENU_COMMENT;
- public static String _UI_MENU_PROCESSING_INSTRUCTION;
- public static String _UI_MENU_CDATA_SECTION;
- public static String _UI_MENU_PCDATA;
- public static String _UI_MENU_ADD;
- public static String _UI_COMMENT_VALUE;
- public static String _UI_PI_TARGET_VALUE;
- public static String _UI_PI_DATA_VALUE;
- public static String _UI_LABEL_ROOT_ELEMENT_VALUE;
- public static String _UI_LABEL_TARGET_COLON;
- public static String _UI_LABEL_DATA_COLON;
- public static String _UI_LABEL_ROOT_ELEMENT_NAME_COLON;
- public static String _UI_LABEL_PUBLIC_ID_COLON;
- public static String _UI_LABEL_SYSTEM_ID_COLON;
- public static String _UI_LABEL_BROWSE;
- public static String _UI_LABEL_SELECT_XML_CATALOG_ENTRY;
- public static String _UI_LABEL_SPECIFY_SYSTEM_ID;
- public static String _UI_LABEL_SELECT_FILE;
- public static String _UI_LABEL_KEY;
- public static String _UI_LABEL_URI;
- public static String _UI_LABEL_XML_CATALOG_COLON;
- public static String _UI_LABEL_NAMESPACE_NAME;
- public static String _UI_LABEL_LOCATION_HINT;
- public static String _UI_LABEL_PREFIX;
- public static String _UI_LABEL_NAMESPACE_NAME_COLON;
- public static String _UI_LABEL_LOCATION_HINT_COLON;
- public static String _UI_LABEL_PREFIX_COLON;
- public static String _UI_NO_NAMESPACE_NAME;
- public static String _UI_NO_PREFIX;
- public static String _UI_LABEL_XML_SCHEMA_INFORMATION;
- public static String _UI_LABEL_NAME_COLON;
- public static String _UI_LABEL_VALUE_COLON;
- public static String _UI_BUTTON_DELETE;
- public static String _UI_BUTTON_NEW;
- public static String _UI_BUTTON_EDIT;
- public static String _UI_LABEL_NEW_NAMESPACE_INFORMATION;
- public static String _UI_RADIO_BUTTON_SELECT_FROM_WORKSPACE;
- public static String _UI_RADIO_BUTTON_SELECT_FROM_CATALOG;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX;
- public static String _UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX;
- public static String _UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED;
- public static String _UI_WARNING_LOCATION_HINT_NOT_SPECIFIED;
- public static String _UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED;
- public static String _UI_WARNING_PREFIX_NOT_SPECIFIED;
- public static String _UI_WARNING_ROOT_ELEMENT_MUST_BE_SPECIFIED;
- public static String _UI_WARNING_SYSTEM_ID_MUST_BE_SPECIFIED;
- public static String _UI_INVALID_NAME;
- public static String _UI_ENTER_REQ_PREFIX_AND_NAMESPACE;
- public static String _UI_SELECT_REGISTERED_NAMESPACES;
- public static String _UI_SPECIFY_NEW_NAMESPACE;
- public static String _UI_SELECT_NAMESPACE_TO_ADD;
- public static String _UI_ADD_NAMESPACE_DECLARATIONS;
- public static String _UI_NAMESPACE_DECLARATIONS;
- public static String _UI_TARGET_NAMESPACE;
- public static String _ERROR_XML_ATTRIBUTE_ALREADY_EXISTS;
- public static String error_message_goes_here;
- public static String SurroundWithNewElementQuickAssistProposal_0;
- public static String SurroundWithNewElementQuickAssistProposal_1;
- public static String RenameInFileQuickAssistProposal_0;
- public static String RenameInFileQuickAssistProposal_1;
- public static String InsertRequiredAttrsQuickAssistProposal_0;
- public static String InsertRequiredAttrsQuickAssistProposal_1;
- public static String EncodingSettings_0;
- public static String EncodingSettings_1;
- public static String DragNodeCommand_0;
- public static String DragNodeCommand_1;
- public static String CommonEditNamespacesDialog_0;
- public static String JFaceNodeAdapter_1;
- public static String QuickFixProcessorXML_0;
- public static String QuickFixProcessorXML_1;
- public static String QuickFixProcessorXML_2;
- public static String QuickFixProcessorXML_3;
- public static String QuickFixProcessorXML_4;
- public static String QuickFixProcessorXML_5;
- public static String QuickFixProcessorXML_6;
- public static String QuickFixProcessorXML_7;
- public static String QuickFixProcessorXML_8;
- public static String QuickFixProcessorXML_9;
- public static String QuickFixProcessorXML_10;
- public static String QuickFixProcessorXML_11;
- public static String QuickFixProcessorXML_12;
- public static String QuickFixProcessorXML_13;
- public static String QuickFixProcessorXML_14;
- public static String QuickFixProcessorXML_15;
- public static String XMLPropertySourceAdapter_0;
- public static String WorkbenchDefaultEncodingSettings_0;
- public static String refreshoutline_0;
- public static String Creating_files_encoding;
- public static String End_tag_has_attributes;
- public static String Attribute__is_missing_a_value;
- public static String Attribute__has_no_value;
- public static String Missing_end_tag_;
- public static String Missing_start_tag_;
- public static String ReconcileStepForMarkup_0;
- public static String ReconcileStepForMarkup_1;
- public static String ReconcileStepForMarkup_2;
- public static String ReconcileStepForMarkup_3;
- public static String ReconcileStepForMarkup_4;
- public static String ReconcileStepForMarkup_5;
- public static String ReconcileStepForMarkup_6;
- public static String End_with_;
- public static String SEVERE_internal_error_occu_UI_;
- public static String No_known_attribute__UI_;
- public static String Content_Assist_not_availab_UI_;
- public static String Element__is_unknown;
- public static String Comment__;
- public static String Close_with__;
- public static String End_with__;
- public static String Close_with___;
- public static String Close_with____;
- public static String _Has_no_available_child;
- public static String No_known_child_tag;
- public static String __Has_no_known_child;
- public static String No_known_child_tag_names;
- public static String The_document_element__;
- public static String No_definition_for_in;
- public static String No_definition_for;
- public static String No_content_model_for;
- public static String No_content_model_found_UI_;
- public static String Cleanup_UI_;
- public static String Compress_empty_element_tags_UI_;
- public static String Insert_required_attributes_UI_;
- public static String Insert_missing_tags_UI_;
- public static String Quote_attribute_values_UI_;
- public static String Format_source_UI_;
- public static String Convert_EOL_codes_UI_;
- public static String Insert_XML_decl;
- public static String EOL_Windows_UI;
- public static String EOL_Unix_UI;
- public static String EOL_Mac_UI;
- public static String Creating_files;
- public static String Encoding_desc;
- public static String Encoding;
- public static String Creating_or_saving_files;
- public static String End_of_line_code_desc;
- public static String End_of_line_code;
- public static String EOL_Windows;
- public static String EOL_Unix;
- public static String EOL_Mac;
- public static String EOL_NoTranslation;
- public static String XMLFilesPreferencePage_ExtensionLabel;
- public static String XMLFilesPreferencePage_ExtensionError;
- public static String XMLContentAssistPreferencePage_Auto_Activation_UI_;
- public static String XMLContentAssistPreferencePage_Cycling_UI_;
- public static String Automatically_make_suggest_UI_;
- public static String Prompt_when_these_characte_UI_;
- public static String Formatting_UI_;
- public static String Line_width__UI_;
- public static String Split_multiple_attributes;
- public static String Align_final_bracket;
- public static String Preserve_PCDATA_Content;
- public static String Space_before_empty_close_tag;
- public static String Indent_using_tabs;
- public static String Indent_using_spaces;
- public static String Indentation_size;
- public static String Indentation_size_tip;
- public static String Clear_all_blank_lines_UI_;
- public static String Format_comments;
- public static String Format_comments_join_lines;
- public static String Grammar_Constraints;
- public static String Use_inferred_grammar_in_absence_of;
- public static String Suggestion_Strategy;
- public static String Suggestion_Strategy_Lax;
- public static String Suggestion_Strategy_Strict;
- public static String Element____1;
- public static String Content_Model____2;
- public static String Attribute____3;
- public static String Data_Type____4;
- public static String Enumerated_Values____5;
- public static String Default_Value____6;
- public static String SourceMenu_label;
- public static String Comment_label; // Resource bundle
- public static String Comment_tooltip; // Resource bundle
- public static String Comment_description; // Resource bundle
- public static String Uncomment_label; // Resource bundle
- public static String Uncomment_tooltip; // Resource bundle
- public static String Uncomment_description; // Resource bundle
- public static String ToggleComment_label; // Resource bundle
- public static String ToggleComment_tooltip; // Resource bundle
- public static String ToggleComment_description; // Resource bundle
- public static String AddBlockComment_label; // Resource bundle
- public static String AddBlockComment_tooltip; // Resource bundle
- public static String AddBlockComment_description; // Resource bundle
- public static String RemoveBlockComment_label; // Resource bundle
- public static String RemoveBlockComment_tooltip; // Resource bundle
- public static String RemoveBlockComment_description; // Resource bundle
- public static String CleanupDocument_label; // Resource bundle
- public static String CleanupDocument_tooltip; // Resource bundle
- public static String CleanupDocument_description; // Resource bundle
- public static String FindOccurrences_label; // Resource bundle
- public static String OpenFileFromSource_label; // Resource bundle
- public static String OpenFileFromSource_tooltip; // Resource bundle
- public static String OpenFileFromSource_description; // Resource bundle
- public static String XMLContentOutlineConfiguration_0;
- public static String XMLTyping_Auto_Complete;
- public static String XMLTyping_Auto_Remove;
- public static String XMLTyping_Complete_Comments;
- public static String XMLTyping_Close_Strings;
- public static String XMLTyping_Close_Brackets;
- public static String XMLTyping_Complete_End_Tags;
- public static String XMLTyping_Complete_Elements;
- public static String XMLTyping_Remove_End_Tags;
- public static String XMLTyping_Start_Tag;
- public static String XMLTyping_End_Tag;
- public static String StructureSelectEnclosing_label;
- public static String StructureSelectEnclosing_tooltip;
- public static String StructureSelectEnclosing_description;
- public static String StructureSelectNext_label;
- public static String StructureSelectNext_tooltip;
- public static String StructureSelectNext_description;
- public static String StructureSelectPrevious_label;
- public static String StructureSelectPrevious_tooltip;
- public static String StructureSelectPrevious_description;
- public static String MESSAGE_XML_VALIDATION_MESSAGE_UI_;
- public static String Indicate_no_grammar_specified;
- public static String Indicate_no_grammar_specified_severities_error;
- public static String Indicate_no_grammar_specified_severities_warning;
- public static String Indicate_no_grammar_specified_severities_ignore;
- public static String Validating_files;
- public static String SyntaxColoringPage_0;
- public static String SyntaxColoringPage_2;
- public static String SyntaxColoringPage_3;
- public static String SyntaxColoringPage_4;
- public static String SyntaxColoringPage_5;
- public static String SyntaxColoringPage_6;
- public static String EmptyFilePreferencePage_0;
- public static String _UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK;
- public static String gotoMatchingTag_label;
- public static String gotoMatchingTag_description;
- public static String gotoMatchingTag_start;
- public static String gotoMatchingTag_end;
- public static String nextSibling_label;
- public static String nextSibling_description;
- public static String previousSibling_label;
- public static String previousSibling_description;
- public static String Use_XInclude;
- public static String Honour_all_schema_locations;
- public static String Open;
- public static String _UI_BUTTON_SORT;
-
- static {
- // load message values from bundle file
- NLS.initializeMessages(BUNDLE_NAME, XMLUIMessages.class);
- }
-
- private XMLUIMessages() {
- // cannot create new instance
- }
-
- public static ResourceBundle getResourceBundle() {
- try {
- if (fResourceBundle == null) {
- fResourceBundle = ResourceBundle.getBundle(BUNDLE_NAME);
- }
- }
- catch (MissingResourceException x) {
- fResourceBundle = null;
- }
- return fResourceBundle;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java
deleted file mode 100644
index fe8f1715b6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPlugin.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal;
-
-import java.io.IOException;
-
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry;
-import org.eclipse.ui.editors.text.templates.ContributionTemplateStore;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistry;
-import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryRegistryImpl;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.eclipse.wst.xml.ui.internal.templates.TemplateContextTypeIdsXML;
-
-/**
- * The main plugin class to be used in the desktop.
- */
-public class XMLUIPlugin extends AbstractUIPlugin {
- public final static String ID = "org.eclipse.wst.xml.ui"; //$NON-NLS-1$
-
- protected static XMLUIPlugin instance = null;
-
- public static XMLUIPlugin getDefault() {
- return instance;
- }
-
- public synchronized static XMLUIPlugin getInstance() {
- return instance;
- }
-
- /**
- * The template context type registry for the xml editor.
- */
- private ContextTypeRegistry fContextTypeRegistry;
-
- /**
- * The template store for the xml editor.
- *
- */
- private TemplateStore fTemplateStore;
-
- public XMLUIPlugin() {
- super();
- instance = this;
- }
-
- public AdapterFactoryRegistry getAdapterFactoryRegistry() {
- return AdapterFactoryRegistryImpl.getInstance();
-
- }
-
- /**
- * Returns the template store for the xml editor templates.
- *
- * @return the template store for the xml editor templates
- */
- public TemplateStore getTemplateStore() {
- if (fTemplateStore == null) {
- fTemplateStore = new ContributionTemplateStore(getTemplateContextRegistry(), getPreferenceStore(), XMLUIPreferenceNames.TEMPLATES_KEY);
-
- try {
- fTemplateStore.load();
- }
- catch (IOException e) {
- Logger.logException(e);
- }
- }
- return fTemplateStore;
- }
-
- /**
- * Returns the template context type registry for the xml plugin.
- *
- * @return the template context type registry for the xml plugin
- */
- public ContextTypeRegistry getTemplateContextRegistry() {
- if (fContextTypeRegistry == null) {
- ContributionContextTypeRegistry registry = new ContributionContextTypeRegistry();
- registry.addContextType(TemplateContextTypeIdsXML.ALL);
- registry.addContextType(TemplateContextTypeIdsXML.NEW);
- registry.addContextType(TemplateContextTypeIdsXML.TAG);
- registry.addContextType(TemplateContextTypeIdsXML.ATTRIBUTE);
- registry.addContextType(TemplateContextTypeIdsXML.ATTRIBUTE_VALUE);
-
- fContextTypeRegistry = registry;
- }
-
- return fContextTypeRegistry;
- }
-
- /**
- * Get an image from the registry.
- *
- * *This method is used by the referencingfile dialog and should be
- * removed when the dialog is moved to anothercomponent.
- *
- * @param imageName
- * The name of the image.
- * @return The image registered for the given name.
- */
- public Image getImage(String imageName) {
- return getWorkbench().getSharedImages().getImage(imageName);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties
deleted file mode 100644
index 235d0aa7b6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/XMLUIPluginResources.properties
+++ /dev/null
@@ -1,349 +0,0 @@
-###############################################################################
-# Copyright (c) 2001, 2009 IBM Corporation and others.
-# All rights reserved. This program and the accompanying materials
-# are made available under the terms of the Eclipse Public License v1.0
-# which accompanies this distribution, and is available at
-# http://www.eclipse.org/legal/epl-v10.html
-#
-# Contributors:
-# IBM Corporation - initial API and implementation
-# Jens Lukowski/Innoopract - initial renaming/restructuring
-# Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference
-# David Carver - STAR - [205989] - [validation] validate XML after XInclude resolution
-###############################################################################
-## The following line is a sample XML document. Please translate only the following parts:
-## begin color definitions
-## Normal text content.
-Sample_XML_doc=<?xml version=\"1.0\"?>\n<?customProcessingInstruction\n\tXML processor specific\n\tcontent ?>\n<!DOCTYPE colors\n\tPUBLIC \"//IBM/XML/COLORS/\" \"colors.dtd\">\n<colors>\n\t<!-- begin color definitions -->\n\t<color name=\"plaintext\" foreground=\"#000000\"\n\t\tbackground=\"#D4D0C8\" />\n\t<color name=\"bold\" foreground=\"#000000\"\n\t\tbackground=\"#B3ACA0\" />\n\t<![CDATA[<123456789>]]>\n\tNormal text content.\n\t===&gt;look at me!&lt;===\n\t<color name=\"inverse\" foreground=\"#F0F0F0\"\n\t\tbackground=\"#D4D0C8\" />\n\n</colors>\n
-Comment_Delimiters_UI_=Comment Delimiters
-Comment_Content_UI_=Comment Content
-Tag_Delimiters_UI_=Tag Delimiters
-Tag_Names_UI_=Tag Names
-Attribute_Names_UI_=Attribute Names
-Attribute_Equals_UI_=Attribute Equal Signs
-Attribute_Values_UI_=Attribute Values
-Declaration_Delimiters_UI_=Declaration Delimiters
-Content_UI_=Content
-Entity_Reference_UI_=Entity References
-## on the following 2 lines, do not translate CDATA
-CDATA_Delimiters_UI_=CDATA Delimiters
-CDATA_Content_UI_=CDATA Content
-Processing_Instruction_Del_UI_=Processing Instruction Delimiters
-Processing_Instruction_Con_UI__UI_=Processing Instruction Content
-## on the following line solely translate: Name
-DOCTYPE_Name_UI_=DOCTYPE Name
-## on the following line solely translate: Keyword
-DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_=DOCTYPE SYSTEM/PUBLIC Keyword
-## on the following line solely translate: Public Reference
-DOCTYPE_Public_Reference_UI_=DOCTYPE Public Reference
-## on the following line solely translate: System Reference
-DOCTYPE_System_Reference_UI_=DOCTYPE System Reference
-# XML Common UI
-# Constants for strings
-
-DELETE=Remove
-ADD_PROCESSING_INSTRUCTION=Add Processing Instruction
-
-_UI_MENU_ADD_AFTER=Add &After
-_UI_MENU_ADD_ATTRIBUTE=Add A&ttribute
-_UI_MENU_ADD_BEFORE=Add &Before
-_UI_MENU_ADD_CHILD=Add &Child
-_UI_MENU_REMOVE=Re&move
-_UI_MENU_REPLACE_WITH=Re&place With
-_UI_MENU_EDIT_DOCTYPE=Edit DOCTYPE...
-_UI_LABEL_UNDO_REPLACE_DESCRIPTION=Replace
-_UI_LABEL_EDIT_DOCTYPE=Edit DOCTYPE
-_UI_INFO_EXPAND_ALL=Expand All
-_UI_INFO_COLLAPSE_ALL=Collapse All
-
-_UI_MENU_ADD_DTD_INFORMATION=Add DTD Information...
-_UI_MENU_ADD_SCHEMA_INFORMATION=Add Schema Information...
-_UI_MENU_EDIT_PROCESSING_INSTRUCTION=Edit Process&ing Instruction...
-_UI_MENU_EDIT_NAMESPACES=Edit &Namespaces...
-
-_UI_MENU_ADD_DTD_INFORMATION_TITLE=Add DTD Information
-_UI_MENU_EDIT_PROCESSING_INSTRUCTION_TITLE=Edit Processing Instruction
-_UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE=Edit Schema Information
-
-_UI_MENU_NEW_ATTRIBUTE=&New Attribute...
-_UI_MENU_NEW_ATTRIBUTE_TITLE=New Attribute
-_UI_MENU_EDIT_ATTRIBUTE=Edit Attribute...
-_UI_MENU_EDIT_ATTRIBUTE_TITLE=Edit Attribute
-_UI_MENU_NEW_ELEMENT=New &Element...
-_UI_MENU_NEW_ELEMENT_TITLE=New Element
-_UI_MENU_RENAME=R&ename
-_UI_MENU_RENAME_TITLE=Rename
-_UI_LABEL_ELEMENT_NAME=Element name:
-
-_UI_MENU_ADD_COMMENT=Add Comment
-_UI_MENU_ADD_PROCESSING_INSTRUCTION=Add Processing Instruction
-_UI_MENU_ADD_CDATA_SECTION=Add CDATA Section
-_UI_MENU_ADD_PCDATA=Add #PCDATA;
-
-_UI_MENU_COMMENT=C&omment
-_UI_MENU_PROCESSING_INSTRUCTION=P&rocessing Instruction
-_UI_MENU_CDATA_SECTION=CDATA Section
-_UI_MENU_PCDATA=#PC&DATA;
-
-_UI_MENU_ADD=Add
-
-_UI_COMMENT_VALUE=comment
-_UI_PI_TARGET_VALUE=target
-_UI_PI_DATA_VALUE=data
-_UI_LABEL_ROOT_ELEMENT_VALUE=RootElement
-
-_UI_LABEL_TARGET_COLON=Target:
-_UI_LABEL_DATA_COLON=Data:
-_UI_LABEL_ROOT_ELEMENT_NAME_COLON=Root element name:
-_UI_LABEL_PUBLIC_ID_COLON=Public ID:
-_UI_LABEL_SYSTEM_ID_COLON=System ID:
-_UI_LABEL_BROWSE=Browse...
-_UI_LABEL_SELECT_XML_CATALOG_ENTRY=Select XML Catalog Entry
-_UI_LABEL_SPECIFY_SYSTEM_ID=Specify System ID
-_UI_LABEL_SELECT_FILE=Select File
-
-_UI_LABEL_KEY=Key
-_UI_LABEL_URI=URI:
-_UI_LABEL_XML_CATALOG_COLON=XML Catalog
-_UI_LABEL_NAMESPACE_NAME=Namespace Name
-_UI_LABEL_LOCATION_HINT=Location Hint
-_UI_LABEL_PREFIX=Prefix
-_UI_LABEL_NAMESPACE_NAME_COLON=Namespace Name:
-_UI_LABEL_LOCATION_HINT_COLON=Location Hint:
-_UI_LABEL_PREFIX_COLON=Prefix:
-_UI_NO_NAMESPACE_NAME=<no namespace name>
-_UI_NO_PREFIX=<no prefix>
-
-_UI_LABEL_XML_SCHEMA_INFORMATION=XML Schema Information
-
-_UI_LABEL_NAME_COLON=Name:
-_UI_LABEL_VALUE_COLON=Value:
-
-_UI_BUTTON_DELETE=Delete
-_UI_BUTTON_NEW=New...
-_UI_BUTTON_EDIT=Edit...
-
-_UI_LABEL_NEW_NAMESPACE_INFORMATION=New Namespace Information
-
-# SelectFileOrXMLCatalogIdPanel.java
-
-_UI_RADIO_BUTTON_SELECT_FROM_WORKSPACE=Select file from Workspace
-_UI_RADIO_BUTTON_SELECT_FROM_CATALOG=Select XML Catalog entry
-
-_UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME=More than one namespace has been specified with the namespace name :
-_UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME=More than one schema has been specified without a namespace name
-_UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX=More than one namespace has been specificed without a prefix
-_UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX=More than one namespace has been specified with the prefix :
-_UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED=The specified schema can not be located :
-_UI_WARNING_LOCATION_HINT_NOT_SPECIFIED=A location hint has not been specified for the namespace with name
-_UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED=A name must be specified for the namespace with prefix :
-_UI_WARNING_PREFIX_NOT_SPECIFIED=A prefix must be specified for the namespace named :
-_UI_WARNING_ROOT_ELEMENT_MUST_BE_SPECIFIED=A root element name must be specified.
-_UI_WARNING_SYSTEM_ID_MUST_BE_SPECIFIED=A system ID must be specified.
-
-_UI_INVALID_NAME=Invalid name
-
-# String used for editing namespaces (org.eclipse.wst.xml.ui.nsedit)
-_UI_ENTER_REQ_PREFIX_AND_NAMESPACE=Enter the required prefix and namespace URI for the namespace declaration.
-_UI_SELECT_REGISTERED_NAMESPACES=Select From Registered Namespaces
-_UI_SPECIFY_NEW_NAMESPACE=Specify New Namespace
-_UI_SELECT_NAMESPACE_TO_ADD=Select the namespace declarations to add.
-_UI_ADD_NAMESPACE_DECLARATIONS=Add Namespace Declarations
-_UI_NAMESPACE_DECLARATIONS=Namespace Declarations
-_UI_TARGET_NAMESPACE=Target Namespace
-
-_ERROR_XML_ATTRIBUTE_ALREADY_EXISTS=The element already has an attribute with this name.
-
-#
-error_message_goes_here=error message goes here
-SurroundWithNewElementQuickAssistProposal_0=Surround with new element
-SurroundWithNewElementQuickAssistProposal_1=Surround with new element
-RenameInFileQuickAssistProposal_0=Link all references for a rename in file (does not change references in other files)
-RenameInFileQuickAssistProposal_1=Rename in file
-InsertRequiredAttrsQuickAssistProposal_0=Insert required attributes
-InsertRequiredAttrsQuickAssistProposal_1=Insert required attributes
-EncodingSettings_0=IANA:
-EncodingSettings_1=Encoding:
-DragNodeCommand_0=Move
-DragNodeCommand_1=Copy
-CommonEditNamespacesDialog_0=Add...
-JFaceNodeAdapter_1=Refresh Property Sheet
-QuickFixProcessorXML_0=Remove empty tag
-QuickFixProcessorXML_1=Change to empty-element tag
-QuickFixProcessorXML_2=Remove this tag
-QuickFixProcessorXML_3=Insert end tag before first child element
-QuickFixProcessorXML_4=Insert end tag at end of element
-QuickFixProcessorXML_5=Remove attributes in end tag
-QuickFixProcessorXML_6=Insert default attribute value
-QuickFixProcessorXML_7=Remove this attribute
-QuickFixProcessorXML_8=Remove spaces before tag name
-QuickFixProcessorXML_9=Remove spaces before processing instruction
-QuickFixProcessorXML_10=Remove namespace in processing instruction
-QuickFixProcessorXML_11=Remove this element
-QuickFixProcessorXML_12=Remove this attribute value
-QuickFixProcessorXML_13=Insert required attribute
-QuickFixProcessorXML_14=Quote attribute value
-QuickFixProcessorXML_15=Insert closing bracket
-XMLPropertySourceAdapter_0=Attributes
-
-WorkbenchDefaultEncodingSettings_0=Use workspace encoding
-refreshoutline_0=Refreshing Outline
-Creating_files_encoding=Creating files encoding preference
-# ReconcileStepForMarkup
-End_tag_has_attributes=End tag has attributes
-Attribute__is_missing_a_value=Attribute \"{0}\" is missing a value
-Attribute__has_no_value=Attribute \"{0}\" has no value
-Missing_start_tag_=Missing start tag \"{0}\"
-Missing_end_tag_=Missing end tag \"{0}\"
-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 '>'
-# Content Assist
-End_with_=End with {0}>
-SEVERE_internal_error_occu_UI_=SEVERE internal error occurred
-No_known_attribute__UI_=No known attribute
-Content_Assist_not_availab_UI_=Content Assist not available at the current location
-Element__is_unknown=Element <{0}> is unknown.
-Comment__=comment {0}
-Close_with__=Close with {0}
-End_with__=End with \"</{0}>\"
-Close_with___=Close with \"{0}\"
-Close_with____=Close with \"></{0}>\"
-_Has_no_available_child={0} has no available child tags.
-No_known_child_tag=No known child tag names of <{0}> begin with \"{1}\".
-__Has_no_known_child=<{0}> has no known child tags.
-No_known_child_tag_names=No known child tag names of <{0}> begin with \"{1}\"
-The_document_element__=The document element <{0}> is already present.
-No_definition_for_in=No definition was found for element <{0}> in {1}
-No_definition_for=No definition was found for element <{0}>
-No_content_model_for=No content model found for {0}.
-No_content_model_found_UI_=No content model found
-## The following strings are for the XML Cleanup dialog
-Cleanup_UI_=Cleanup
-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
-Insert_XML_decl=Fix XML declaration
-EOL_Windows_UI=&Windows
-EOL_Unix_UI=U&NIX
-EOL_Mac_UI=&Mac
-## XML Files preference page
-Creating_files=Creating files
-Encoding_desc=The following encoding will apply:
-Encoding=En&coding:
-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:
-EOL_Windows=Windows
-EOL_Unix=UNIX
-EOL_Mac=Mac
-EOL_NoTranslation=No translation
-Validating_files=Validating files
-Indicate_no_grammar_specified=Indicate when no &grammar is specified:
-Indicate_no_grammar_specified_severities_error=Error
-Indicate_no_grammar_specified_severities_warning=Warning
-Indicate_no_grammar_specified_severities_ignore=Ignore
-XMLFilesPreferencePage_ExtensionLabel=Add this suffix (if not specified):
-XMLFilesPreferencePage_ExtensionError=Suffix must be one of the following {0}.
-## XML Source preference page
-XMLContentAssistPreferencePage_Auto_Activation_UI_=Auto Activation
-XMLContentAssistPreferencePage_Cycling_UI_=Cycling
-Automatically_make_suggest_UI_=Automatically ma&ke suggestions
-Prompt_when_these_characte_UI_=P&rompt when these characters are inserted:
-Formatting_UI_=Formatting
-Line_width__UI_=Line &width:
-Split_multiple_attributes=Split &multiple attributes each on a new line
-Align_final_bracket=&Align final bracket in multi-line element tags
-Preserve_PCDATA_Content=&Preserve whitespace in tags with PCDATA content
-Space_before_empty_close_tag=Ins&ert whitespace before closing empty end-tags
-Indent_using_tabs=&Indent using tabs
-Indent_using_spaces=I&ndent using spaces
-Indentation_size=In&dentation size:
-Indentation_size_tip=Indentation size
-Clear_all_blank_lines_UI_=Clear all &blank lines
-Format_comments=&Format comments
-Format_comments_join_lines=&Join lines
-Grammar_Constraints=Grammar Constraints
-Use_inferred_grammar_in_absence_of=&Use inferred grammar in absence of DTD/Schema
-Suggestion_Strategy=&Suggestion strategy:
-Suggestion_Strategy_Lax=Lax
-Suggestion_Strategy_Strict=Strict
-## tag info
-Element____1=Element :
-Content_Model____2=Content Model :
-Attribute____3=Attribute :
-Data_Type____4=Data Type :
-Enumerated_Values____5=Enumerated Values :
-Default_Value____6=Default Value :
-## copied from sse.ui
-SourceMenu_label=&Source
-Comment_label=Co&mment
-Comment_tooltip=Comment
-Comment_description=Comment
-Uncomment_label=&Uncomment
-Uncomment_tooltip=Uncomment
-Uncomment_description=Uncomment
-ToggleComment_label=Toggle Comment
-ToggleComment_tooltip=Toggle Comment
-ToggleComment_description=Toggle Comment
-AddBlockComment_label=Add Block Comment
-AddBlockComment_tooltip=Add Block Comment
-AddBlockComment_description=Add Block Comment
-RemoveBlockComment_label=Remove Block Comment
-RemoveBlockComment_tooltip=Remove Block Comment
-RemoveBlockComment_description=Remove Block Comment
-CleanupDocument_label=Cleanup Document...
-CleanupDocument_tooltip=Cleanup Document
-CleanupDocument_description=Cleanup Document
-FindOccurrences_label=Occurrences in File
-OpenFileFromSource_label=Op&en Selection
-OpenFileFromSource_tooltip=Open an editor on the selected link
-OpenFileFromSource_description=Open an editor on the selected link
-XMLContentOutlineConfiguration_0=Show Attributes
-XMLTyping_Auto_Complete=Automatically close
-XMLTyping_Auto_Remove=Automatically remove
-XMLTyping_Complete_Comments=&Comments
-XMLTyping_Close_Strings=A&ttribute values
-XMLTyping_Close_Brackets=(Parentheses) and [square] brac&kets
-XMLTyping_Complete_End_Tags=&Automatically close the tag
-XMLTyping_Complete_Elements=&Insert a matching end tag
-XMLTyping_Remove_End_Tags=E&nd tags when creating empty self-closing tags
-XMLTyping_Start_Tag=When typing a start tag
-XMLTyping_End_Tag=When typing an end tag
-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
-MESSAGE_XML_VALIDATION_MESSAGE_UI_=XML Validator validating {0}
-SyntaxColoringPage_0=Syntax Element:
-SyntaxColoringPage_2=Enable
-SyntaxColoringPage_3=&Bold
-SyntaxColoringPage_4=&Italic
-SyntaxColoringPage_5=&Strike-through
-SyntaxColoringPage_6=&Underline
-EmptyFilePreferencePage_0=Expand the tree to edit preferences for a specific feature.
-_UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK=XML editing preferences. Note that some preferences may be set on the <a>{0}</a> preference page.
-Use_XInclude=Process XML &Inclusions
-Honour_all_schema_locations=&Honour all XML schema locations
-nextSibling_label=Next Sibling
-nextSibling_description=Go to Next Sibling
-previousSibling_label=Previous Sibling
-previousSibling_description=Go to Previous Sibling
-gotoMatchingTag_label=Matching Tag
-gotoMatchingTag_description=Go To Matching Tag
-gotoMatchingTag_start=Start tag of element <{0}>
-gotoMatchingTag_end=End tag of element <{0}>
-Open=Open ''{0}''
-_UI_BUTTON_SORT=Sort
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java
deleted file mode 100644
index e00b29d7eb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractCommentActionXMLDelegate.java
+++ /dev/null
@@ -1,117 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IEditorActionDelegate;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.xml.ui.internal.Logger;
-
-/**
- * Abstract comment action delegate for XML editors
- */
-abstract public class AbstractCommentActionXMLDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
- static final String CLOSE_COMMENT = "-->"; //$NON-NLS-1$
- static final String OPEN_COMMENT = "<!--"; //$NON-NLS-1$
-
- IEditorPart fEditor;
-
- public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- fEditor = targetEditor;
- }
-
- public void dispose() {
- // nulling out just in case
- fEditor = null;
- }
-
- public void runWithEvent(IAction action, Event event) {
- run(action);
- }
-
- public void run(IAction action) {
- if (fEditor instanceof ITextEditor) {
- ITextEditor textEditor = (ITextEditor) fEditor;
- IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- if (document != null) {
- // get current text selection
- ITextSelection textSelection = getCurrentSelection();
- if (textSelection.isEmpty()) {
- return;
- }
-
- processAction(document, textSelection);
- }
- }
- }
-
- public void init(IViewPart view) {
- // do nothing
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing
- }
-
- private ITextSelection getCurrentSelection() {
- if (fEditor instanceof ITextEditor) {
- ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider();
- if (provider != null) {
- ISelection selection = provider.getSelection();
- if (selection instanceof ITextSelection) {
- return (ITextSelection) selection;
- }
- }
- }
- return TextSelection.emptySelection();
- }
-
- abstract void processAction(IDocument document, ITextSelection textSelection);
-
- void removeOpenCloseComments(IDocument document, int offset, int length) {
- try {
- int adjusted_length = length;
-
- // remove open comments
- String string = document.get(offset, length);
- int index = string.lastIndexOf(OPEN_COMMENT);
- while (index != -1) {
- document.replace(offset + index, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- index = string.lastIndexOf(OPEN_COMMENT, index - 1);
- adjusted_length -= OPEN_COMMENT.length();
- }
-
- // remove close comments
- string = document.get(offset, adjusted_length);
- index = string.lastIndexOf(CLOSE_COMMENT);
- while (index != -1) {
- document.replace(offset + index, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- index = string.lastIndexOf(CLOSE_COMMENT, index - 1);
- }
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java
deleted file mode 100644
index be7e202da3..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AbstractNodeActionManager.java
+++ /dev/null
@@ -1,690 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMContentBuilder;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMContentBuilderImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-
-public abstract class AbstractNodeActionManager extends BaseNodeActionManager {
-
-
- /**
- * AddNodeAction
- */
- public class AddNodeAction extends NodeAction {
- protected CMNode cmnode;
- protected String description;
- protected int index;
- protected int nodeType;
- protected Node parent;
- protected String undoDescription;
-
-
- public AddNodeAction(CMNode cmnode, Node parent, int index) {
- this.cmnode = cmnode;
- this.parent = parent;
- this.index = index;
-
- String text = getLabel(parent, cmnode);
- setText(text);
- description = text;
- undoDescription = XMLUIMessages._UI_MENU_ADD + " " + text; //$NON-NLS-1$
- ImageDescriptor descriptor = CMImageUtil.getImageDescriptor(cmnode);
- if (descriptor == null) {
- descriptor = imageDescriptorCache.getImageDescriptor(cmnode);
- }
- setImageDescriptor(descriptor);
- }
-
-
- public AddNodeAction(int nodeType, Node parent, int index) {
- this.nodeType = nodeType;
- this.index = index;
- this.parent = parent;
-
- switch (nodeType) {
- case Node.COMMENT_NODE : {
- description = XMLUIMessages._UI_MENU_COMMENT;
- undoDescription = XMLUIMessages._UI_MENU_ADD_COMMENT;
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- description = XMLUIMessages._UI_MENU_PROCESSING_INSTRUCTION;
- undoDescription = XMLUIMessages._UI_MENU_ADD_PROCESSING_INSTRUCTION;
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- description = XMLUIMessages._UI_MENU_CDATA_SECTION;
- undoDescription = XMLUIMessages._UI_MENU_ADD_CDATA_SECTION;
- break;
- }
- case Node.TEXT_NODE : {
- description = XMLUIMessages._UI_MENU_PCDATA;
- undoDescription = XMLUIMessages._UI_MENU_ADD_PCDATA;
- break;
- }
- }
- setText(description);
- setImageDescriptor(imageDescriptorCache.getImageDescriptor(new Integer(nodeType)));
- }
-
-
- protected void addNodeForCMNode() {
- if (parent != null) {
- insert(parent, cmnode, index);
- }
- }
-
-
- protected void addNodeForNodeType() {
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- Node newChildNode = null;
- boolean format = true;
- switch (nodeType) {
- case Node.COMMENT_NODE : {
- newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE);
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- newChildNode = document.createCDATASection(""); //$NON-NLS-1$
- break;
- }
- case Node.TEXT_NODE : {
- format = false;
- newChildNode = document.createTextNode(parent.getNodeName());
- break;
- }
- }
-
- if (newChildNode != null) {
- List list = new Vector(1);
- list.add(newChildNode);
- insertNodesAtIndex(parent, list, index, format);
- }
- }
-
-
- public String getUndoDescription() {
- return undoDescription;
- }
-
-
- public void run() {
- if (validateEdit(getModel(), getWorkbenchWindowShell())) {
- beginNodeAction(this);
- if (cmnode != null) {
- addNodeForCMNode();
- }
- else {
- addNodeForNodeType();
- }
- endNodeAction(this);
- }
- }
- }
-
-
- /**
- * DeleteAction
- */
- public class DeleteAction extends NodeAction {
- protected List list;
-
- public DeleteAction(List list) {
- setText(XMLUIMessages._UI_MENU_REMOVE);
- this.list = list;
- }
-
- public DeleteAction(Node node) {
- setText(XMLUIMessages._UI_MENU_REMOVE);
- list = new Vector();
- list.add(node);
- }
-
- public String getUndoDescription() {
- return XMLUIMessages.DELETE;
- }
-
- public void run() {
- if (validateEdit(getModel(), getWorkbenchWindowShell())) {
- beginNodeAction(this);
-
- for (Iterator i = list.iterator(); i.hasNext();) {
- Node node = (Node) i.next();
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr attr = (Attr) node;
- attr.getOwnerElement().removeAttributeNode(attr);
- }
- else {
- Node parent = node.getParentNode();
- if (parent != null) {
- Node previousSibling = node.getPreviousSibling();
- if ((previousSibling != null) && isWhitespaceTextNode(previousSibling)) {
- parent.removeChild(previousSibling);
- }
- parent.removeChild(node);
- }
- }
- }
-
- endNodeAction(this);
- }
- }
- }
-
-
- class ImageDescriptorCache {
- protected ImageDescriptor attributeImage = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- protected ImageDescriptor attributeReqImage = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ATT_REQ_OBJ);
- protected ImageDescriptor cdataSectionImage = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_CDATASECTION);
- protected ImageDescriptor commentImage = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_COMMENT);
- protected ImageDescriptor elementImage = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- protected ImageDescriptor piImage = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION);
- protected ImageDescriptor textImage = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_TXTEXT);
-
- public ImageDescriptor getImageDescriptor(Object object) {
- ImageDescriptor result = null;
- if (object instanceof CMNode) {
- CMNode cmnode = (CMNode) object;
- switch (cmnode.getNodeType()) {
- case CMNode.ATTRIBUTE_DECLARATION : {
- result = CMImageUtil.getImageDescriptor(cmnode);
- if (result == null) {
- if (((CMAttributeDeclaration) cmnode).getUsage() == CMAttributeDeclaration.REQUIRED) {
- result = attributeReqImage;
- }
- else {
- result = attributeImage;
- }
- }
- break;
- }
- case CMNode.DATA_TYPE : {
- result = textImage;
- break;
- }
- case CMNode.ELEMENT_DECLARATION : {
- result = CMImageUtil.getImageDescriptor(cmnode);
- if (result == null) {
- result = elementImage;
- }
- break;
- }
- case CMNode.GROUP : {
- result = elementImage;
- break;
- }
- }
- }
- else if (object instanceof Integer) {
- Integer integer = (Integer) object;
- switch (integer.intValue()) {
- case Node.COMMENT_NODE : {
- result = commentImage;
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- result = piImage;
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- result = cdataSectionImage;
- break;
- }
- case Node.TEXT_NODE : {
- result = textImage;
- break;
- }
- }
- }
- return result;
- }
- }
-
- // TODO... remove this class. I'm pretty sure it is no longer used by
- // anyone.
- /**
- * @depracated
- */
- public class InsertAction extends NodeAction {
- protected String description;
- protected int index;
- protected int nodeType;
- protected Node parent;
-
- public InsertAction(int nodeType, Node parent, int index) {
- this.nodeType = nodeType;
- this.index = index;
- this.parent = parent;
- switch (nodeType) {
- case Node.COMMENT_NODE : {
- description = XMLUIMessages._UI_MENU_COMMENT;
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- description = XMLUIMessages._UI_MENU_PROCESSING_INSTRUCTION;
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- description = XMLUIMessages._UI_MENU_CDATA_SECTION;
- break;
- }
- case Node.TEXT_NODE : {
- description = XMLUIMessages._UI_MENU_PCDATA;
- break;
- }
- }
- setText(description);
- setImageDescriptor(imageDescriptorCache.getImageDescriptor(new Integer(nodeType)));
- }
-
- public InsertAction(int nodeType, Node parent, int index, String title) {
- this.nodeType = nodeType;
- this.index = index;
- this.parent = parent;
- description = title;
- setText(description);
- setImageDescriptor(imageDescriptorCache.getImageDescriptor(new Integer(nodeType)));
- }
-
- public String getUndoDescription() {
- return XMLUIMessages._UI_MENU_ADD + " " + description; //$NON-NLS-1$
- }
-
- public void run() {
- if (validateEdit(getModel(), getWorkbenchWindowShell())) {
- beginNodeAction(this);
-
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- Node newChildNode = null;
- boolean format = true;
- switch (nodeType) {
- case Node.COMMENT_NODE : {
- newChildNode = document.createComment(XMLUIMessages._UI_COMMENT_VALUE);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- newChildNode = document.createProcessingInstruction(XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE);
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- newChildNode = document.createCDATASection(""); //$NON-NLS-1$
- break;
- }
- case Node.TEXT_NODE : {
- format = false;
- newChildNode = document.createTextNode(parent.getNodeName());
- break;
- }
- }
-
- if (newChildNode != null) {
- List list = new Vector(1);
- list.add(newChildNode);
- insertNodesAtIndex(parent, list, index, format);
- }
-
- endNodeAction(this);
- }
- }
- }
-
-
- /**
- * ReplaceNodeAction
- */
- public class ReplaceNodeAction extends NodeAction {
- protected CMNode cmnode;
- protected String description;
- protected int endIndex;
- protected Node parent;
- protected int startIndex;
-
-
- public ReplaceNodeAction(Node parent, CMNode cmnode, int startIndex, int endIndex) {
- this.parent = parent;
- this.cmnode = cmnode;
- this.startIndex = startIndex;
- this.endIndex = endIndex;
-
- setText(getLabel(parent, cmnode));
- setImageDescriptor(imageDescriptorCache.getImageDescriptor(cmnode));
- }
-
- public String getUndoDescription() {
- String result = XMLUIMessages._UI_LABEL_UNDO_REPLACE_DESCRIPTION;
- result += " " + getLabel(parent, cmnode); //$NON-NLS-1$
- return result;
- }
-
- public void run() {
- if (validateEdit(getModel(), getWorkbenchWindowShell())) {
- beginNodeAction(this);
-
- if ((parent != null) && (cmnode != null)) {
- remove(parent, startIndex, endIndex);
- insert(parent, cmnode, startIndex);
- }
- endNodeAction(this);
- }
- }
- }
-
- protected ImageDescriptorCache imageDescriptorCache = new ImageDescriptorCache();
- protected Viewer fViewer;
-
- public AbstractNodeActionManager(IStructuredModel model, ModelQuery modelQuery, Viewer viewer) {
- super(model, modelQuery);
- this.fViewer = viewer;
- }
-
-
- public void beginNodeAction(NodeAction action) {
- fModel.beginRecording(action, action.getUndoDescription());
- }
-
-
- protected Action createAddAttributeAction(Element parent, CMAttributeDeclaration ad) {
- Action action = null;
- if (ad == null) {
- action = new EditAttributeAction(this, parent, null, XMLUIMessages._UI_MENU_NEW_ATTRIBUTE, XMLUIMessages._UI_MENU_NEW_ATTRIBUTE_TITLE);
- }
- else {
- action = new AddNodeAction(ad, parent, -1);
- }
- return action;
- }
-
-
- protected Action createAddCDataSectionAction(Node parent, int index) {
- return new AddNodeAction(Node.CDATA_SECTION_NODE, parent, index);
- }
-
-
- protected Action createAddCommentAction(Node parent, int index) {
- return new AddNodeAction(Node.COMMENT_NODE, parent, index);
- }
-
-
- protected Action createAddDoctypeAction(Document document, int index) {
- return new EditDoctypeAction(fModel, document, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION);
- }
-
-
- protected Action createAddElementAction(Node parent, CMElementDeclaration ed, int index) {
- Action action = null;
- if (ed == null) {
- action = new EditElementAction(this, parent, index, XMLUIMessages._UI_MENU_NEW_ELEMENT, XMLUIMessages._UI_MENU_NEW_ELEMENT_TITLE);
- }
- else {
- action = new AddNodeAction(ed, parent, index);
- }
- return action;
- }
-
-
- protected Action createAddPCDataAction(Node parent, CMDataType dataType, int index) {
- Action action = null;
- if (dataType == null) {
- action = new AddNodeAction(Node.TEXT_NODE, parent, index);
- }
- else {
- action = new AddNodeAction(dataType, parent, index);
- }
- return action;
- }
-
-
- protected Action createAddProcessingInstructionAction(Node parent, int index) {
- Node refChild = getRefChildNodeAtIndex(parent, index);
- Action action = new EditProcessingInstructionAction(this, parent, refChild, XMLUIMessages._UI_MENU_ADD_PROCESSING_INSTRUCTION, XMLUIMessages.ADD_PROCESSING_INSTRUCTION);
- action.setImageDescriptor(imageDescriptorCache.getImageDescriptor(new Integer(Node.PROCESSING_INSTRUCTION_NODE)));
- return action;
- }
-
-
- protected Action createAddSchemaInfoAction(Element element) {
- return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_ADD_SCHEMA_INFORMATION);
- }
-
-
- protected Action createDeleteAction(List selection) {
- DeleteAction deleteAction = new DeleteAction(selection);
- deleteAction.setEnabled(selection.size() > 0);
- return deleteAction;
- }
-
-
- public DOMContentBuilder createDOMContentBuilder(Document document) {
- DOMContentBuilderImpl builder = new DOMContentBuilderImpl(document);
- return builder;
- }
-
-
- protected Action createEditAttributeAction(Attr attr, CMAttributeDeclaration ad) {
- return new EditAttributeAction(this, attr.getOwnerElement(), attr, XMLUIMessages._UI_MENU_EDIT_ATTRIBUTE, XMLUIMessages._UI_MENU_EDIT_ATTRIBUTE_TITLE);
- }
-
-
- protected Action createEditDoctypeAction(DocumentType doctype) {
- return new EditDoctypeAction(fModel, doctype, fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_DOCTYPE);
- }
-
-
- protected Action createEditProcessingInstructionAction(ProcessingInstruction pi) {
- return new EditProcessingInstructionAction(this, pi, XMLUIMessages._UI_MENU_EDIT_PROCESSING_INSTRUCTION, XMLUIMessages._UI_MENU_EDIT_PROCESSING_INSTRUCTION_TITLE);
- }
-
-
- protected Action createEditSchemaInfoAction(Element element) {
- return new EditSchemaInfoAction(this, element.getOwnerDocument(), fModel.getBaseLocation(), XMLUIMessages._UI_MENU_EDIT_NAMESPACES);
- }
-
-
- protected Action createRenameAction(Node node) {
- Action result = null;
- if (node instanceof Element) {
- result = new EditElementAction(this, (Element) node, XMLUIMessages._UI_MENU_RENAME, XMLUIMessages._UI_MENU_RENAME_TITLE);
- }
- return result;
- }
-
-
- protected Action createReplaceAction(Node parent, CMNode cmnode, int startIndex, int endIndex) {
- return new ReplaceNodeAction(parent, cmnode, startIndex, endIndex);
- }
-
- public void endNodeAction(NodeAction action) {
- fModel.endRecording(action);
- }
-
-
-
- public void fillContextMenu(IMenuManager menuManager, ISelection selection) {
- try {
- List selectionList = new ArrayList();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection es = (IStructuredSelection) selection;
- selectionList.addAll(es.toList());
- }
-
- contributeActions(menuManager, selectionList);
- }
- catch (Exception e) {
- e.printStackTrace();
- }
- }
-
- /**
- *
- */
- public String getLabel(Node parent, CMNode cmnode) {
- String result = "?" + cmnode + "?"; //$NON-NLS-1$ //$NON-NLS-2$
- if (cmnode != null) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=155800
- result = cmnode.getNodeName();
- if(result == null) {
- result = (String) cmnode.getProperty("description"); //$NON-NLS-1$
- }
- if (result == null || result.length() == 0) {
- if (cmnode.getNodeType() == CMNode.GROUP) {
- CMDescriptionBuilder descriptionBuilder = new CMDescriptionBuilder();
- result = descriptionBuilder.buildDescription(cmnode);
- }
- else {
- result = DOMNamespaceHelper.computeName(cmnode, parent, null);
- }
- }
- }
- return result;
- }
-
-
- public IStructuredModel getModel() {
- return fModel;
- }
-
-
- public Shell getWorkbenchWindowShell() {
- return XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
-
- public void insert(Node parent, CMNode cmnode, int index) {
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- DOMContentBuilder builder = createDOMContentBuilder(document);
- builder.setBuildPolicy(DOMContentBuilder.BUILD_ONLY_REQUIRED_CONTENT);
- builder.build(parent, cmnode);
- insertNodesAtIndex(parent, builder.getResult(), index);
- }
-
-
- public void insertNodesAtIndex(Node parent, List list, int index) {
- insertNodesAtIndex(parent, list, index, true);
- }
-
-
- public void insertNodesAtIndex(Node parent, List list, int index, boolean format) {
- NodeList nodeList = parent.getChildNodes();
- if (index == -1) {
- index = nodeList.getLength();
- }
- Node refChild = (index < nodeList.getLength()) ? nodeList.item(index) : null;
-
- // here we consider the case where the previous node is a 'white
- // space' Text node
- // we should really do the insert before this node
- //
- int prevIndex = index - 1;
- Node prevChild = (prevIndex < nodeList.getLength()) ? nodeList.item(prevIndex) : null;
- if (isWhitespaceTextNode(prevChild)) {
- refChild = prevChild;
- }
-
- for (Iterator i = list.iterator(); i.hasNext();) {
- Node newNode = (Node) i.next();
-
- if (newNode.getNodeType() == Node.ATTRIBUTE_NODE) {
- Element parentElement = (Element) parent;
- parentElement.setAttributeNode((Attr) newNode);
- }
- else {
- parent.insertBefore(newNode, refChild);
- }
- }
-
- boolean formatDeep = false;
- for (Iterator i = list.iterator(); i.hasNext();) {
- Node newNode = (Node) i.next();
- if (newNode.getNodeType() == Node.ELEMENT_NODE) {
- formatDeep = true;
- }
-
- if (format) {
- reformat(newNode, formatDeep);
- }
- }
-
- setViewerSelection(list);
- }
-
-
- /**
- * This method is abstract since currently, the sed editor is required to
- * perform formating and we don't want to create a dependency on the sed
- * editor.
- */
- public abstract void reformat(Node parent, boolean deep);
-
-
- public void remove(Node parent, int startIndex, int endIndex) {
- NodeList nodeList = parent.getChildNodes();
- for (int i = endIndex; i >= startIndex; i--) {
- Node node = nodeList.item(i);
- if (node != null) {
- parent.removeChild(node);
- }
- }
- }
-
-
- public void setViewerSelection(List list) {
- if (fViewer != null) {
- fViewer.setSelection(new StructuredSelection(list), true);
- }
- }
-
-
- public void setViewerSelection(Node node) {
- if (fViewer != null) {
- fViewer.setSelection(new StructuredSelection(node), true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java
deleted file mode 100644
index c4f8285df7..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ActionContributorXML.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.IStatusLineManager;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchActionConstants;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
-import org.eclipse.ui.texteditor.RetargetTextEditorAction;
-import org.eclipse.wst.sse.ui.internal.actions.ActionContributor;
-import org.eclipse.wst.sse.ui.internal.actions.ActionDefinitionIds;
-import org.eclipse.wst.sse.ui.internal.actions.StructuredTextEditorActionConstants;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * 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 ActionContributorXML extends ActionContributor {
- private static final String[] EDITOR_IDS = {"org.eclipse.core.runtime.xml.source", "org.eclipse.core.runtime.xml.source2", "org.eclipse.wst.sse.ui.StructuredTextEditor"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- private static final String GO_TO_MATCHING_TAG_ID = "org.eclipse.wst.xml.ui.gotoMatchingTag"; //$NON-NLS-1$
-
- protected RetargetTextEditorAction fCleanupDocument = null;
- protected RetargetTextEditorAction fComment = null;
- protected RetargetTextEditorAction fContentAssist = null;
- protected RetargetTextEditorAction fFindOccurrences = null;
- protected RetargetTextEditorAction fFormatActiveElements = null;
- protected RetargetTextEditorAction fFormatDocument = null;
- protected RetargetTextEditorAction fOpenFileAction = null; // open file
-
- protected RetargetTextEditorAction fUncomment = null;
- private GoToMatchingTagAction fGoToMatchingTagAction;
-
- public ActionContributorXML() {
- super();
-
- ResourceBundle resourceBundle = XMLUIMessages.getResourceBundle();
-
- fContentAssist = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
- fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
-
- // source commands
- fCleanupDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
- fCleanupDocument.setActionDefinitionId(ActionDefinitionIds.CLEANUP_DOCUMENT);
-
- fFormatDocument = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
- fFormatDocument.setActionDefinitionId(ActionDefinitionIds.FORMAT_DOCUMENT);
-
- fFormatActiveElements = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
- fFormatActiveElements.setActionDefinitionId(ActionDefinitionIds.FORMAT_ACTIVE_ELEMENTS);
-
- // navigate commands
- fOpenFileAction = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
- fOpenFileAction.setActionDefinitionId(ActionDefinitionIds.OPEN_FILE);
-
- fFindOccurrences = new RetargetTextEditorAction(resourceBundle, ""); //$NON-NLS-1$
- fFindOccurrences.setActionDefinitionId(ActionDefinitionIds.FIND_OCCURRENCES);
-
- fGoToMatchingTagAction = new GoToMatchingTagAction(resourceBundle, "gotoMatchingTag_", null); //$NON-NLS-1$
- fGoToMatchingTagAction.setActionDefinitionId(GO_TO_MATCHING_TAG_ID);
- fGoToMatchingTagAction.setId(GO_TO_MATCHING_TAG_ID);
- }
-
- /**
- * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToMenu(IMenuManager)
- */
- public void contributeToMenu(IMenuManager menu) {
- // navigate commands
- IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
- if (navigateMenu != null) {
- navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fCommandsSeparator);
- navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fOpenFileAction);
-
- IMenuManager gotoGroup = navigateMenu.findMenuUsingPath(IWorkbenchActionConstants.GO_TO);
- if (gotoGroup != null) {
- gotoGroup.appendToGroup("matchingBegin", fGoToMatchingTagAction); //$NON-NLS-1$
- }
- }
- super.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(fContentAssist);
- editMenu.add(fMenuAdditionsGroupMarker);
- }
-
- // source commands
- String sourceMenuLabel = XMLUIMessages.SourceMenu_label;
- String sourceMenuId = "sourceMenuId"; //$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(fCleanupDocument);
- sourceMenu.add(fFormatDocument);
- sourceMenu.add(fFormatActiveElements);
- sourceMenu.add(fCommandsSeparator);
- sourceMenu.add(fFindOccurrences);
- }
-
- // navigate commands
- IMenuManager navigateMenu = menu.findMenuUsingPath(IWorkbenchActionConstants.M_NAVIGATE);
- if (navigateMenu != null) {
- navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fCommandsSeparator);
- navigateMenu.appendToGroup(IWorkbenchActionConstants.OPEN_EXT, fOpenFileAction);
-
- IMenuManager gotoGroup = navigateMenu.findMenuUsingPath(IWorkbenchActionConstants.GO_TO);
- if (gotoGroup != null) {
- gotoGroup.add(fGotoMatchingBracketAction);
- gotoGroup.add(fGoToMatchingTagAction);
- gotoGroup.add(new Separator());
- }
- }
-*/
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.edit.util.ActionContributor#getExtensionIDs()
- */
- protected String[] getExtensionIDs() {
- return EDITOR_IDS;
- }
-
- /**
- * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(IEditorPart)
- */
- public void setActiveEditor(IEditorPart activeEditor) {
- if (getActiveEditorPart() == activeEditor) {
- return;
- }
- super.setActiveEditor(activeEditor);
-
- IActionBars actionBars = getActionBars();
- if (actionBars != null) {
- IStatusLineManager statusLineManager = actionBars.getStatusLineManager();
- if (statusLineManager != null) {
- statusLineManager.setMessage(null);
- statusLineManager.setErrorMessage(null);
- }
- }
-
- ITextEditor textEditor = getTextEditor(activeEditor);
-
- fContentAssist.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS));
-
- fCleanupDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT));
- fFormatDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT));
- fFormatActiveElements.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS));
- fCleanupDocument.setEnabled((textEditor != null) && textEditor.isEditable());
- fFormatDocument.setEnabled((textEditor != null) && textEditor.isEditable());
- fFormatActiveElements.setEnabled((textEditor != null) && textEditor.isEditable());
-
- fOpenFileAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE));
-
- fFindOccurrences.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FIND_OCCURRENCES));
-
- fGoToMatchingTagAction.setEditor(textEditor);
- if (textEditor != null) {
- textEditor.setAction(GO_TO_MATCHING_TAG_ID, fGoToMatchingTagAction);
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.ISourceViewerActionBarContributor#setViewerSpecificContributionsEnabled(boolean)
- */
- public void setViewerSpecificContributionsEnabled(boolean enabled) {
- super.setViewerSpecificContributionsEnabled(enabled);
-
- fContentAssist.setEnabled(enabled);
- // cleanup and format document actions do not rely on source viewer
- // being enabled
- // fCleanupDocument.setEnabled(enabled);
- // fFormatDocument.setEnabled(enabled);
-
- fFormatActiveElements.setEnabled(enabled);
- fOpenFileAction.setEnabled(enabled);
- fFindOccurrences.setEnabled(enabled);
-
- fGoToMatchingTagAction.setEnabled(enabled);
- fGotoMatchingBracketAction.setEnabled(enabled);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java
deleted file mode 100644
index a038376bea..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/AddBlockCommentActionXMLDelegate.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.xml.core.internal.document.CommentImpl;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Add block comment action delegate for XML editor
- */
-public class AddBlockCommentActionXMLDelegate extends AbstractCommentActionXMLDelegate {
-
- public void init(IAction action) {
- if (action != null) {
- action.setText(XMLUIMessages.AddBlockComment_label);
- action.setToolTipText(XMLUIMessages.AddBlockComment_tooltip);
- action.setDescription(XMLUIMessages.AddBlockComment_description);
- }
- }
-
- void processAction(IDocument document, ITextSelection textSelection) {
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
- if (model != null) {
- try {
- IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset());
- IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength());
-
- if (selectionStartIndexedRegion == null) {
- return;
- }
- if ((selectionEndIndexedRegion == null) && (textSelection.getLength() > 0)) {
- selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength() - 1);
- }
- if (selectionEndIndexedRegion == null) {
- return;
- }
-
- int openCommentOffset = selectionStartIndexedRegion.getStartOffset();
- int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() + OPEN_COMMENT.length();
-
-
- if ((textSelection.getLength() == 0) && (selectionStartIndexedRegion instanceof CommentImpl)) {
- return;
- }
-
- model.beginRecording(this, XMLUIMessages.AddBlockComment_tooltip);
- model.aboutToChangeModel();
-
- try {
- document.replace(openCommentOffset, 0, OPEN_COMMENT);
- document.replace(closeCommentOffset, 0, CLOSE_COMMENT);
- removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length());
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- finally {
- model.changedModel();
- model.endRecording(this);
- }
- }
- finally {
- model.releaseFromEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java
deleted file mode 100644
index 4629a23803..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/BaseNodeActionManager.java
+++ /dev/null
@@ -1,519 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-import org.w3c.dom.ProcessingInstruction;
-
-public abstract class BaseNodeActionManager {
-
-
- /**
- * MyMenuManager
- */
- public static class MyMenuManager extends MenuManager {
- protected String title;
-
- public MyMenuManager(String s) {
- super(s);
- title = s;
- }
-
- public boolean isEnabled() {
- return !isEmpty();
- }
-
- public String toString() {
- return title;
- }
- }
-
- public static DocumentType getDoctype(Node node) {
- Document document = (node.getNodeType() == Node.DOCUMENT_NODE) ? (Document) node : node.getOwnerDocument();
- return document.getDoctype();
- }
-
- protected MenuBuilder menuBuilder = new MenuBuilder();
- protected IStructuredModel fModel;
- protected ModelQuery modelQuery;
-
- protected BaseNodeActionManager(IStructuredModel model, ModelQuery modelQuery) {
- this.fModel = model;
- this.modelQuery = modelQuery;
- }
-
-
- protected void addActionHelper(IMenuManager menu, List modelQueryActionList) {
- List actionList = new Vector();
- for (Iterator i = modelQueryActionList.iterator(); i.hasNext();) {
- ModelQueryAction action = (ModelQueryAction) i.next();
- if (action.getCMNode() != null) {
- int cmNodeType = action.getCMNode().getNodeType();
- if (action.getKind() == ModelQueryAction.INSERT) {
- switch (cmNodeType) {
- case CMNode.ATTRIBUTE_DECLARATION : {
- actionList.add(createAddAttributeAction((Element) action.getParent(), (CMAttributeDeclaration) action.getCMNode()));
- break;
- }
- case CMNode.ELEMENT_DECLARATION : {
- actionList.add(createAddElementAction(action.getParent(), (CMElementDeclaration) action.getCMNode(), action.getStartIndex()));
- break;
- }
- }
- }
- else if (action.getKind() == ModelQueryAction.REPLACE) {
- if ((action.getParent() != null) && (action.getCMNode() != null)) {
- actionList.add(createReplaceAction(action.getParent(), action.getCMNode(), action.getStartIndex(), action.getEndIndex()));
- }
- }
- }
- }
- menuBuilder.populateMenu(menu, actionList, false);
- }
-
- protected void contributeAction(IMenuManager menu, Action action) {
- if (action != null) {
- menu.add(action);
- }
- }
-
-
- public void contributeActions(IMenuManager menu, List selection) {
- int editMode = modelQuery.getEditMode();
- int ic = ModelQuery.INCLUDE_CHILD_NODES;
- int vc = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.VALIDITY_STRICT : ModelQuery.VALIDITY_NONE;
-
- List implicitlySelectedNodeList = null;
-
- if (selection.size() > 0) {
- implicitlySelectedNodeList = getSelectedNodes(selection, true);
-
- // contribute delete actions
- contributeDeleteActions(menu, implicitlySelectedNodeList, ic, vc);
- }
-
- if (selection.size() == 1) {
- Node node = (Node) selection.get(0);
-
- // contribute edit actions
- contributeEditActions(menu, node);
-
- // contribute add child actions
- contributeAddChildActions(menu, node, ic, vc);
-
- // contribute add before actions
- contributeAddSiblingActions(menu, node, ic, vc);
- }
-
- if (selection.size() > 0) {
- // contribute replace actions
- contributeReplaceActions(menu, implicitlySelectedNodeList, ic, vc);
- }
-
- if (selection.size() == 0) {
- Document document = ((IDOMModel) fModel).getDocument();
- contributeAddDocumentChildActions(menu, document, ic, vc);
- contributeEditGrammarInformationActions(menu, document);
- }
- }
-
-
- protected void contributeAddChildActions(IMenuManager menu, Node node, int ic, int vc) {
- int nodeType = node.getNodeType();
-
- if (nodeType == Node.ELEMENT_NODE) {
- // 'Add Child...' and 'Add Attribute...' actions
- //
- Element element = (Element) node;
-
- IMenuManager addAttributeMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_ATTRIBUTE);
- IMenuManager addChildMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_CHILD);
- menu.add(addAttributeMenu);
- menu.add(addChildMenu);
-
- CMElementDeclaration ed = modelQuery.getCMElementDeclaration(element);
- if (ed != null) {
- // add insert attribute actions
- //
- List modelQueryActionList = new ArrayList();
- modelQuery.getInsertActions(element, ed, -1, ModelQuery.INCLUDE_ATTRIBUTES, vc, modelQueryActionList);
- addActionHelper(addAttributeMenu, modelQueryActionList);
-
- // add insert child node actions
- //
- modelQueryActionList = new ArrayList();
- modelQuery.getInsertActions(element, ed, -1, ic, vc, modelQueryActionList);
- addActionHelper(addChildMenu, modelQueryActionList);
- }
-
- // add PI and COMMENT
- contributePIAndCommentActions(addChildMenu, element, ed, -1);
-
- // add PCDATA, CDATA_SECTION
- contributeTextNodeActions(addChildMenu, element, ed, -1);
-
- // add NEW ELEMENT
- contributeUnconstrainedAddElementAction(addChildMenu, element, ed, -1);
-
- // add ATTRIBUTE
- contributeUnconstrainedAttributeActions(addAttributeMenu, element, ed);
- }
- }
-
-
- protected void contributeAddDocumentChildActions(IMenuManager menu, Document document, int ic, int vc) {
- IMenuManager addChildMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_CHILD);
- menu.add(addChildMenu);
-
- // add PI and COMMENT
- contributePIAndCommentActions(addChildMenu, document, -1);
-
- // add NEW ELEMENT
- contributeUnconstrainedAddElementAction(addChildMenu, document, -1);
- }
-
-
- protected void contributeAddSiblingActions(IMenuManager menu, Node node, int ic, int vc) {
- IMenuManager addBeforeMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_BEFORE);
- IMenuManager addAfterMenu = new MyMenuManager(XMLUIMessages._UI_MENU_ADD_AFTER);
- menu.add(addBeforeMenu);
- menu.add(addAfterMenu);
-
- Node parentNode = node.getParentNode();
- if (parentNode != null) {
- int index = getIndex(parentNode, node);
- if (parentNode.getNodeType() == Node.ELEMENT_NODE) {
- Element parentElement = (Element) parentNode;
- CMElementDeclaration parentED = modelQuery.getCMElementDeclaration(parentElement);
- if (parentED != null) {
- // 'Add Before...' and 'Add After...' actions
- //
- List modelQueryActionList = new ArrayList();
- modelQuery.getInsertActions(parentElement, parentED, index, ic, vc, modelQueryActionList);
- addActionHelper(addBeforeMenu, modelQueryActionList);
-
- modelQueryActionList = new ArrayList();
- modelQuery.getInsertActions(parentElement, parentED, index + 1, ic, vc, modelQueryActionList);
- addActionHelper(addAfterMenu, modelQueryActionList);
- }
-
- // add COMMENT and PI before and after
- contributePIAndCommentActions(addBeforeMenu, parentElement, parentED, index);
- contributePIAndCommentActions(addAfterMenu, parentElement, parentED, index + 1);
-
- // add PCDATA, CDATA_SECTION before and after
- contributeTextNodeActions(addBeforeMenu, parentElement, parentED, index);
- contributeTextNodeActions(addAfterMenu, parentElement, parentED, index + 1);
-
- // add NEW ELEMENT before and after
- contributeUnconstrainedAddElementAction(addBeforeMenu, parentElement, parentED, index);
- contributeUnconstrainedAddElementAction(addAfterMenu, parentElement, parentED, index + 1);
- }
- else if (parentNode.getNodeType() == Node.DOCUMENT_NODE) {
- Document document = (Document) parentNode;
- CMDocument cmDocument = modelQuery.getCorrespondingCMDocument(parentNode);
- if (cmDocument != null) {
- // add possible root element insertions
- //
- List modelQueryActionList = new ArrayList();
- modelQuery.getInsertActions(document, cmDocument, index, ic, vc, modelQueryActionList);
- addActionHelper(addAfterMenu, modelQueryActionList);
-
- modelQueryActionList = new ArrayList();
- modelQuery.getInsertActions(document, cmDocument, index + 1, ic, vc, modelQueryActionList);
- addActionHelper(addAfterMenu, modelQueryActionList);
- }
-
- // add COMMENT and PI before and after
- contributePIAndCommentActions(addBeforeMenu, document, index);
- contributePIAndCommentActions(addAfterMenu, document, index + 1);
-
- // add ELEMENT before and after
- contributeUnconstrainedAddElementAction(addBeforeMenu, document, index);
- contributeUnconstrainedAddElementAction(addAfterMenu, document, index + 1);
- }
- }
- }
-
- protected void contributeDeleteActions(IMenuManager menu, List list, int ic, int vc) {
- boolean canRemove = modelQuery.canRemove(list, vc);
-
-
- // a delete action with an empty list will produce a disabled menu
- // item
- //
- List resultList = canRemove ? list : Collections.EMPTY_LIST;
- contributeAction(menu, createDeleteAction(resultList));
- }
-
-
- protected void contributeEditActions(IMenuManager menu, Node node) {
- contributeEditGrammarInformationActions(menu, node);
-
- if (node.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) {
- contributeAction(menu, createEditProcessingInstructionAction((ProcessingInstruction) node));
- }
- else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- contributeAction(menu, createEditAttributeAction((Attr) node, null));
- }
- }
-
-
- protected void contributeEditGrammarInformationActions(IMenuManager menu, Node node) {
- Document document = node.getNodeType() == Node.DOCUMENT_NODE ? (Document) node : node.getOwnerDocument();
-
- DocumentType doctype = getDoctype(node);
- if (doctype == null) {
- contributeAction(menu, createAddDoctypeAction(document, -1));
- }
-
- if (node.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- contributeAction(menu, createEditDoctypeAction((DocumentType) node));
- }
-
- if ((doctype == null) && (getRootElement(document) != null)) {
- contributeAction(menu, createEditSchemaInfoAction(getRootElement(document)));
- }
- }
-
- protected void contributePIAndCommentActions(IMenuManager menu, Document document, int index) {
- // test to make sure that the index isn't before the XML declaration
- //
- contributeAction(menu, createAddCommentAction(document, index));
- contributeAction(menu, createAddProcessingInstructionAction(document, index));
- }
-
-
- protected void contributePIAndCommentActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) {
- if ((parentEd == null) || isCommentAllowed(parentEd)) {
- contributeAction(menu, createAddCommentAction(parentElement, index));
- contributeAction(menu, createAddProcessingInstructionAction(parentElement, index));
- }
- }
-
-
- protected void contributeReplaceActions(IMenuManager menu, List selectedNodeList, int ic, int vc) {
- // 'Replace With...' actions
- //
- IMenuManager replaceWithMenu = new MyMenuManager(XMLUIMessages._UI_MENU_REPLACE_WITH);
- menu.add(replaceWithMenu);
-
- if ((modelQuery.getEditMode() == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) && (selectedNodeList.size() > 0)) {
- Node node = (Node) selectedNodeList.get(0);
- Node parentNode = node.getParentNode();
- if ((parentNode != null) && (parentNode.getNodeType() == Node.ELEMENT_NODE)) {
- Element parentElement = (Element) parentNode;
- CMElementDeclaration parentED = modelQuery.getCMElementDeclaration(parentElement);
- if (parentED != null) {
- List replaceActionList = new Vector();
- modelQuery.getReplaceActions(parentElement, parentED, selectedNodeList, ic, vc, replaceActionList);
- addActionHelper(replaceWithMenu, replaceActionList);
- }
- }
- }
- }
-
- protected void contributeTextNodeActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) {
- if ((parentEd == null) || isTextAllowed(parentEd)) {
- CMDataType dataType = parentEd != null ? parentEd.getDataType() : null;
- contributeAction(menu, createAddPCDataAction(parentElement, dataType, index));
- contributeAction(menu, createAddCDataSectionAction(parentElement, index));
- }
- }
-
-
- protected void contributeUnconstrainedAddElementAction(IMenuManager menu, Document document, int index) {
- if (isUnconstrainedActionAllowed()) {
- if (getRootElement(document) == null) {
- int xmlDeclarationIndex = -1;
- int doctypeIndex = -1;
- NodeList nodeList = document.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++) {
- Node node = nodeList.item(i);
- int nodeType = node.getNodeType();
- if (nodeType == Node.DOCUMENT_TYPE_NODE) {
- doctypeIndex = i;
- break;
- }
- else if (nodeType == Node.PROCESSING_INSTRUCTION_NODE) {
- ProcessingInstruction pi = (ProcessingInstruction) node;
- if (pi.getTarget().equalsIgnoreCase("xml") && (xmlDeclarationIndex == -1)) { //$NON-NLS-1$
- xmlDeclarationIndex = i;
- }
- }
- }
-
- if (((xmlDeclarationIndex == -1) || (index > xmlDeclarationIndex)) && ((doctypeIndex == -1) || (index > doctypeIndex))) {
- contributeAction(menu, createAddElementAction(document, null, index));
- }
- }
- }
- }
-
-
- protected void contributeUnconstrainedAddElementAction(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) {
- if (isUnconstrainedActionAllowed()) {
- if ((parentEd == null) || (parentEd.getProperty("isInferred") == Boolean.TRUE) || ((modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) && isElementAllowed(parentEd))) { //$NON-NLS-1$
- contributeAction(menu, createAddElementAction(parentElement, null, index));
- }
- }
- }
-
-
- protected void contributeUnconstrainedAttributeActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd) {
- if (isUnconstrainedActionAllowed()) {
- if ((parentEd == null) || (parentEd.getProperty("isInferred") == Boolean.TRUE) || (modelQuery.getEditMode() != ModelQuery.EDIT_MODE_CONSTRAINED_STRICT)) { //$NON-NLS-1$
- contributeAction(menu, createAddAttributeAction(parentElement, null));
- }
- }
- }
-
- abstract protected Action createAddAttributeAction(Element parent, CMAttributeDeclaration ad);
-
- abstract protected Action createAddCDataSectionAction(Node parent, int index);
-
- abstract protected Action createAddCommentAction(Node parent, int index);
-
- abstract protected Action createAddDoctypeAction(Document parent, int index);
-
- abstract protected Action createAddElementAction(Node parent, CMElementDeclaration ed, int index);
-
- abstract protected Action createAddPCDataAction(Node parent, CMDataType dataType, int index);
-
- abstract protected Action createAddProcessingInstructionAction(Node parent, int index);
-
- abstract protected Action createAddSchemaInfoAction(Element element);
-
- abstract protected Action createDeleteAction(List selection);
-
- abstract protected Action createEditAttributeAction(Attr attribute, CMAttributeDeclaration ad);
-
- abstract protected Action createEditDoctypeAction(DocumentType doctype);
-
- abstract protected Action createEditProcessingInstructionAction(ProcessingInstruction pi);
-
- abstract protected Action createEditSchemaInfoAction(Element element);
-
- abstract protected Action createRenameAction(Node node);
-
- abstract protected Action createReplaceAction(Node parent, CMNode cmnode, int startIndex, int endIndex);
-
-
- public int getIndex(Node parentNode, Node child) {
- NodeList nodeList = parentNode.getChildNodes();
- int index = -1;
- int size = nodeList.getLength();
- for (int i = 0; i < size; i++) {
- if (nodeList.item(i) == child) {
- index = i;
- break;
- }
- }
- return index;
- }
-
-
- public Node getRefChildNodeAtIndex(Node parent, int index) {
- NodeList nodeList = parent.getChildNodes();
- Node refChild = ((index >= 0) && (index < nodeList.getLength())) ? nodeList.item(index) : null;
- return refChild;
- }
-
-
- protected Element getRootElement(Document document) {
- Element result = null;
- NodeList nodeList = document.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++) {
- Node node = nodeList.item(i);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- result = (Element) node;
- break;
- }
- }
- return result;
- }
-
-
- protected List getSelectedNodes(List list, boolean includeTextNodes) {
- List result = new ArrayList(0);
- for (Iterator i = list.iterator(); i.hasNext();) {
- Object object = i.next();
- if (object instanceof Node) {
- Node node = (Node) object;
- if (node.getNodeType() == Node.TEXT_NODE) {
- if (includeTextNodes) {
- result.add(object);
- }
- }
- else {
- result.add(node);
- }
- }
- }
- return result;
- }
-
-
- protected boolean isCommentAllowed(CMElementDeclaration parentEd) {
- int contentType = parentEd.getContentType();
- return (contentType == CMElementDeclaration.ELEMENT) || (contentType == CMElementDeclaration.MIXED) || (contentType == CMElementDeclaration.PCDATA) || (contentType == CMElementDeclaration.ANY);
- }
-
-
- protected boolean isElementAllowed(CMElementDeclaration parentEd) {
- int contentType = parentEd.getContentType();
- return (contentType == CMElementDeclaration.ELEMENT) || (contentType == CMElementDeclaration.MIXED) || (contentType == CMElementDeclaration.ANY);
- }
-
-
- protected boolean isTextAllowed(CMElementDeclaration parentEd) {
- int contentType = parentEd.getContentType();
- return (contentType == CMElementDeclaration.MIXED) || (contentType == CMElementDeclaration.PCDATA) || (contentType == CMElementDeclaration.ANY);
- }
-
-
- protected boolean isUnconstrainedActionAllowed() {
- return true;
- }
-
-
- protected boolean isWhitespaceTextNode(Node node) {
- return (node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getNodeValue().trim().length() == 0);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java
deleted file mode 100644
index d91a815d7b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupActionXMLDelegate.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.custom.BusyIndicator;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.IActionDelegate2;
-import org.eclipse.ui.IEditorActionDelegate;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IViewActionDelegate;
-import org.eclipse.ui.IViewPart;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.SSEUIMessages;
-import org.eclipse.wst.xml.core.internal.cleanup.CleanupProcessorXML;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Cleanup action delegate for CSS editor
- */
-public class CleanupActionXMLDelegate implements IEditorActionDelegate, IActionDelegate2, IViewActionDelegate {
- private IEditorPart fEditor;
- private IStructuredCleanupProcessor fCleanupProcessor;
-
- public void setActiveEditor(IAction action, IEditorPart targetEditor) {
- fEditor = targetEditor;
- }
-
- public void dispose() {
- // nulling out just in case
- fEditor = null;
- fCleanupProcessor = null;
- }
-
- public void init(IAction action) {
- if (action != null) {
- action.setText(XMLUIMessages.CleanupDocument_label);
- action.setToolTipText(XMLUIMessages.CleanupDocument_tooltip);
- action.setDescription(XMLUIMessages.CleanupDocument_description);
- }
- }
-
- public void runWithEvent(IAction action, Event event) {
- run(action);
- }
-
- public void init(IViewPart view) {
- // do nothing
- }
-
- public void run(IAction action) {
- if (fEditor instanceof ITextEditor) {
- final ITextEditor editor = (ITextEditor) fEditor;
- Dialog cleanupDialog = new CleanupDialogXML(editor.getSite().getShell());
- if (cleanupDialog.open() == Window.OK) {
- // setup runnable
- Runnable runnable = new Runnable() {
- public void run() {
- IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor();
- if (cleanupProcessor != null) {
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
- if (model != null) {
- cleanupProcessor.cleanupModel(model);
- }
- }
- finally {
- if (model != null) {
- model.releaseFromEdit();
- }
- }
- }
- }
- };
-
- // TODO: make independent of 'model'.
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForEdit(editor.getDocumentProvider().getDocument(editor.getEditorInput()));
- if (model != null) {
- // begin recording
- ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
- model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength());
-
- // tell the model that we are about to make a big
- // model change
- model.aboutToChangeModel();
-
- // run
- BusyIndicator.showWhile(fEditor.getEditorSite().getWorkbenchWindow().getShell().getDisplay(), runnable);
- }
- }
- finally {
- if (model != null) {
- // tell the model that we are done with the big
- // model
- // change
- model.changedModel();
-
- // end recording
- ITextSelection selection = (ITextSelection) editor.getSelectionProvider().getSelection();
- model.endRecording(this, selection.getOffset(), selection.getLength());
- model.releaseFromEdit();
- }
- }
- }
- }
- }
-
- public void selectionChanged(IAction action, ISelection selection) {
- // do nothing
- }
-
- IStructuredCleanupProcessor getCleanupProcessor() {
- if (fCleanupProcessor == null) {
- fCleanupProcessor = new CleanupProcessorXML();
- }
-
- return fCleanupProcessor;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java
deleted file mode 100644
index fa75ab93c0..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/CleanupDialogXML.java
+++ /dev/null
@@ -1,211 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-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.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-public class CleanupDialogXML extends Dialog implements SelectionListener {
- protected Button fCheckBoxCompressEmptyElementTags;
- protected Button fCheckBoxConvertEOLCodes;
- protected Button fCheckBoxFormatSource;
- protected Button fCheckBoxInsertMissingTags;
- protected Button fCheckBoxInsertRequiredAttrs;
- protected Button fCheckBoxQuoteAttrValues;
- protected Button fCheckBoxInsertXMLDeclaration;
- protected IStructuredModel fModel = null;
- protected Preferences fPreferences = null;
- protected Button fRadioButtonAttrNameCaseAsis;
- protected Button fRadioButtonAttrNameCaseLower;
- protected Button fRadioButtonAttrNameCaseUpper;
- protected Button fRadioButtonConvertEOLMac;
- protected Button fRadioButtonConvertEOLUnix;
- protected Button fRadioButtonConvertEOLWindows;
-
- protected Button fRadioButtonTagNameCaseAsis;
- protected Button fRadioButtonTagNameCaseLower;
- protected Button fRadioButtonTagNameCaseUpper;
-
- public CleanupDialogXML(Shell shell) {
-
- super(shell);
- }
-
- public Control createDialogArea(Composite parent) {
-
- getShell().setText(XMLUIMessages.Cleanup_UI_);
- Composite composite = new Composite(parent, SWT.NULL);
- createDialogAreaInComposite(composite);
- initializeOptions();
- return composite;
- }
-
- protected void createDialogAreaInComposite(Composite composite) {
-
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.CLEANUP_XML_HELPID); // use
- // XML
- // specific
- // help
-
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.makeColumnsEqualWidth = true;
- composite.setLayout(layout);
-
- // Compress empty element tags
- fCheckBoxCompressEmptyElementTags = new Button(composite, SWT.CHECK);
- fCheckBoxCompressEmptyElementTags.setText(XMLUIMessages.Compress_empty_element_tags_UI_);
- fCheckBoxCompressEmptyElementTags.addSelectionListener(this);
-
- // Insert missing required attrs
- fCheckBoxInsertRequiredAttrs = new Button(composite, SWT.CHECK);
- fCheckBoxInsertRequiredAttrs.setText(XMLUIMessages.Insert_required_attributes_UI_);
- fCheckBoxInsertRequiredAttrs.addSelectionListener(this);
-
- // Insert missing begin/end tags
- fCheckBoxInsertMissingTags = new Button(composite, SWT.CHECK);
- fCheckBoxInsertMissingTags.setText(XMLUIMessages.Insert_missing_tags_UI_);
- fCheckBoxInsertMissingTags.addSelectionListener(this);
-
- // Quote attribute values
- fCheckBoxQuoteAttrValues = new Button(composite, SWT.CHECK);
- fCheckBoxQuoteAttrValues.setText(XMLUIMessages.Quote_attribute_values_UI_);
- fCheckBoxQuoteAttrValues.addSelectionListener(this);
-
- // Format source
- fCheckBoxFormatSource = new Button(composite, SWT.CHECK);
- fCheckBoxFormatSource.setText(XMLUIMessages.Format_source_UI_);
- fCheckBoxFormatSource.addSelectionListener(this);
-
- fCheckBoxInsertXMLDeclaration = new Button(composite, SWT.CHECK);
- fCheckBoxInsertXMLDeclaration.setText(XMLUIMessages.Insert_XML_decl);
- fCheckBoxInsertXMLDeclaration.addSelectionListener(this);
-
- // Convert EOL code
- fCheckBoxConvertEOLCodes = new Button(composite, SWT.CHECK);
- fCheckBoxConvertEOLCodes.setText(XMLUIMessages.Convert_EOL_codes_UI_);
- fCheckBoxConvertEOLCodes.addSelectionListener(this);
- Composite EOLCodes = new Composite(composite, SWT.NULL);
- GridLayout hLayout = new GridLayout();
- hLayout.numColumns = 3;
- EOLCodes.setLayout(hLayout);
- fRadioButtonConvertEOLWindows = new Button(EOLCodes, SWT.RADIO);
- fRadioButtonConvertEOLWindows.setText(XMLUIMessages.EOL_Windows_UI);
- fRadioButtonConvertEOLWindows.addSelectionListener(this);
- fRadioButtonConvertEOLUnix = new Button(EOLCodes, SWT.RADIO);
- fRadioButtonConvertEOLUnix.setText(XMLUIMessages.EOL_Unix_UI);
- fRadioButtonConvertEOLUnix.addSelectionListener(this);
- fRadioButtonConvertEOLMac = new Button(EOLCodes, SWT.RADIO);
- fRadioButtonConvertEOLMac.setText(XMLUIMessages.EOL_Mac_UI);
- fRadioButtonConvertEOLMac.addSelectionListener(this);
- }
-
- protected void enableEOLCodeRadios(boolean enable) {
-
- if ((fRadioButtonConvertEOLWindows != null) && (fRadioButtonConvertEOLUnix != null) && (fRadioButtonConvertEOLMac != null)) {
- fRadioButtonConvertEOLWindows.setEnabled(enable);
- fRadioButtonConvertEOLUnix.setEnabled(enable);
- fRadioButtonConvertEOLMac.setEnabled(enable);
- if (!fRadioButtonConvertEOLWindows.getSelection() && !fRadioButtonConvertEOLUnix.getSelection() && !fRadioButtonConvertEOLMac.getSelection()) {
- fRadioButtonConvertEOLWindows.setSelection(true);
- }
- }
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void initializeOptions() {
-
- fCheckBoxCompressEmptyElementTags.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS));
- fCheckBoxInsertRequiredAttrs.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS));
- fCheckBoxInsertMissingTags.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.INSERT_MISSING_TAGS));
- fCheckBoxQuoteAttrValues.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.QUOTE_ATTR_VALUES));
- fCheckBoxFormatSource.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.FORMAT_SOURCE));
- fCheckBoxConvertEOLCodes.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.CONVERT_EOL_CODES));
- fCheckBoxInsertXMLDeclaration.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.FIX_XML_DECLARATION));
- String EOLCode = getModelPreferences().getString(XMLCorePreferenceNames.CLEANUP_EOL_CODE);
- if (EOLCode.compareTo(CommonEncodingPreferenceNames.LF) == 0) {
- fRadioButtonConvertEOLUnix.setSelection(true);
- }
- else if (EOLCode.compareTo(CommonEncodingPreferenceNames.CR) == 0) {
- fRadioButtonConvertEOLMac.setSelection(true);
- }
- else {
- fRadioButtonConvertEOLWindows.setSelection(true);
- }
- enableEOLCodeRadios(fCheckBoxConvertEOLCodes.getSelection());
- }
-
- protected void okPressed() {
-
- storeOptions();
- super.okPressed();
- }
-
- public void setModel(IStructuredModel model) {
-
- fModel = model;
- }
-
- protected void storeOptions() {
-
- getModelPreferences().setValue(XMLCorePreferenceNames.COMPRESS_EMPTY_ELEMENT_TAGS, fCheckBoxCompressEmptyElementTags.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.INSERT_REQUIRED_ATTRS, fCheckBoxInsertRequiredAttrs.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.INSERT_MISSING_TAGS, fCheckBoxInsertMissingTags.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.QUOTE_ATTR_VALUES, fCheckBoxQuoteAttrValues.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.FORMAT_SOURCE, fCheckBoxFormatSource.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.CONVERT_EOL_CODES, fCheckBoxConvertEOLCodes.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.FIX_XML_DECLARATION, fCheckBoxInsertXMLDeclaration.getSelection());
- if (fRadioButtonConvertEOLUnix.getSelection()) {
- getModelPreferences().setValue(XMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.LF);
- }
- else if (fRadioButtonConvertEOLMac.getSelection()) {
- getModelPreferences().setValue(XMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.CR);
- }
- else {
- getModelPreferences().setValue(XMLCorePreferenceNames.CLEANUP_EOL_CODE, CommonEncodingPreferenceNames.CRLF);
- }
- // explicitly save plugin preferences so values are stored
- XMLCorePlugin.getDefault().savePluginPreferences();
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
-
- widgetSelected(e);
- }
-
- public void widgetSelected(SelectionEvent e) {
-
- getButton(OK).setEnabled(((fRadioButtonTagNameCaseLower != null) && (fRadioButtonTagNameCaseLower.getSelection() || fRadioButtonTagNameCaseUpper.getSelection())) || ((fRadioButtonAttrNameCaseLower != null) && (fRadioButtonAttrNameCaseLower.getSelection() || fRadioButtonAttrNameCaseUpper.getSelection())) || fCheckBoxInsertMissingTags.getSelection() || fCheckBoxQuoteAttrValues.getSelection() || fCheckBoxFormatSource.getSelection() || fCheckBoxConvertEOLCodes.getSelection() || ((fRadioButtonConvertEOLUnix != null) && (fRadioButtonConvertEOLUnix.getSelection() || fRadioButtonConvertEOLMac.getSelection() || fRadioButtonConvertEOLWindows.getSelection())));
- if (e.widget == fCheckBoxConvertEOLCodes) {
- enableEOLCodeRadios(fCheckBoxConvertEOLCodes.getSelection());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java
deleted file mode 100644
index 0cdc771453..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditAttributeAction.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditAttributeDialog;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-
-public class EditAttributeAction extends NodeAction {
- protected static ImageDescriptor imageDescriptor;
-
- public static ImageDescriptor createImageDescriptor() {
- if (imageDescriptor == null) {
- imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- }
- return imageDescriptor;
- }
-
- protected Attr attr;
- protected AbstractNodeActionManager manager;
- protected Element ownerElement;
- protected String title;
-
- public EditAttributeAction(AbstractNodeActionManager manager, Element ownerElement, Attr attr, String actionLabel, String title) {
- this.manager = manager;
- this.ownerElement = ownerElement;
- this.attr = attr;
- this.title = title;
- setText(actionLabel);
- // assume if attr is null then this is an 'Add' that requires action
- // an icons... otherwise this is an edit
- if (attr == null) {
- setImageDescriptor(createImageDescriptor());
- }
- }
-
- public String getUndoDescription() {
- return title;
- }
-
- public void run() {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- if (validateEdit(manager.getModel(), shell)) {
- manager.beginNodeAction(this);
- EditAttributeDialog dialog = new EditAttributeDialog(shell, ownerElement, attr);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- if (attr != null) {
- ownerElement.removeAttributeNode(attr);
- }
- Document document = ownerElement.getOwnerDocument();
- Attr newAttribute = document.createAttribute(dialog.getAttributeName());
- newAttribute.setValue(dialog.getAttributeValue());
- ownerElement.setAttributeNode(newAttribute);
- manager.setViewerSelection(newAttribute);
- }
- manager.endNodeAction(this);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java
deleted file mode 100644
index 4ce515c692..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditDoctypeAction.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.document.DocumentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocumentType;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditDoctypeDialog;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * EditDoctypeAction
- */
-public class EditDoctypeAction extends NodeAction {
- protected DocumentType doctype;
- protected Document document;
- protected IStructuredModel model;
- protected String resourceLocation;
- protected String title;
-
- /**
- * This constructor is used to create a new doctype.
- */
- public EditDoctypeAction(IStructuredModel model, Document document, String resourceLocation, String title) {
- setText(title);
- this.model = model;
- this.document = document;
- this.resourceLocation = resourceLocation;
- this.title = title;
- }
-
- /**
- * This constructor is used to edit an exisitng doctype.
- */
- public EditDoctypeAction(IStructuredModel model, DocumentType doctype, String resourceLocation, String title) {
- setText(title);
- this.model = model;
- this.doctype = doctype;
- this.resourceLocation = resourceLocation;
- this.title = title;
- }
-
-
- protected DocumentType createDoctype(EditDoctypeDialog dialog, Document document) {
- DocumentType result = null;
- if (document instanceof DocumentImpl) {
- IDOMDocument documentImpl = (IDOMDocument) document;
- IDOMDocumentType doctypeImpl = (IDOMDocumentType) documentImpl.createDoctype(dialog.getName());
- doctypeImpl.setPublicId(dialog.getPublicId());
- doctypeImpl.setSystemId(dialog.getSystemId());
- result = doctypeImpl;
- }
- return result;
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
-
- protected String getRootElementName(Document document) {
- Element rootElement = null;
- NodeList nodeList = document.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++) {
- Node childNode = nodeList.item(i);
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- rootElement = (Element) childNode;
- break;
- }
- }
- return rootElement != null ? rootElement.getNodeName() : XMLUIMessages._UI_LABEL_ROOT_ELEMENT_VALUE;
- }
-
- public String getUndoDescription() {
- return title;
- }
-
-
- protected void insertDoctype(DocumentType doctype, Document document) {
- Node refChild = null;
- NodeList nodeList = document.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++) {
- Node childNode = nodeList.item(i);
- if ((childNode.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) || (childNode.getNodeType() == Node.COMMENT_NODE)) {
- // continue on to the nextNode
- }
- else {
- refChild = childNode;
- break;
- }
- }
-
- document.insertBefore(doctype, refChild);
- // manager.reformat(doctype, false);
- }
-
- public void run() {
- Shell shell = getDisplay().getActiveShell();
- if (validateEdit(model, shell)) {
- model.beginRecording(this, getUndoDescription());
- // Shell shell =
- // XMLCommonUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditDoctypeDialog dialog = showEditDoctypeDialog(shell);
-
- if (dialog.getReturnCode() == Window.OK) {
- if (doctype != null) {
- updateDoctype(dialog, doctype);
- }
- else if (document != null) {
- DocumentType doctype = createDoctype(dialog, document);
- if (doctype != null) {
- insertDoctype(doctype, document);
- }
- }
- }
- model.endRecording(this);
- }
- }
-
- protected EditDoctypeDialog showEditDoctypeDialog(Shell shell) {
- EditDoctypeDialog dialog = null;
-
- if (doctype != null) {
- dialog = new EditDoctypeDialog(shell, doctype);
- if (title == null) {
- title = XMLUIMessages._UI_LABEL_EDIT_DOCTYPE;
- }
- }
- else if (document != null) {
- String rootElementName = getRootElementName(document);
- dialog = new EditDoctypeDialog(shell, rootElementName, "", rootElementName + ".dtd"); //$NON-NLS-1$ //$NON-NLS-2$
- if (title == null) {
- title = XMLUIMessages._UI_MENU_ADD_DTD_INFORMATION_TITLE;
- }
- }
-
- dialog.setComputeSystemId((doctype == null) || (doctype.getSystemId() == null) || (doctype.getSystemId().trim().length() == 0));
-
- dialog.setErrorChecking(false);// !model.getType().equals(IStructuredModel.HTML));
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.setResourceLocation(new Path(resourceLocation));
- dialog.open();
-
- return dialog;
- }
-
-
- protected void updateDoctype(EditDoctypeDialog dialog, DocumentType doctype) {
- if (doctype instanceof IDOMDocumentType) {
- IDOMDocumentType doctypeImpl = (IDOMDocumentType) doctype;
- if (doctypeImpl.getName().equals(dialog.getName())) {
- doctypeImpl.setPublicId(dialog.getPublicId());
- doctypeImpl.setSystemId(dialog.getSystemId());
- }
- else {
- // we need to create a new one and remove the old
- //
- Document document = doctype.getOwnerDocument();
- DocumentType newDoctype = createDoctype(dialog, document);
- document.insertBefore(newDoctype, doctype);
- document.removeChild(doctype);
- // manager.reformat(newDoctype, false);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java
deleted file mode 100644
index 21b55fe3d4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditElementAction.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditElementDialog;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-public class EditElementAction extends NodeAction {
-
- protected static ImageDescriptor imageDescriptor;
-
- public static ImageDescriptor createImageDescriptor() {
- if (imageDescriptor == null) {
- imageDescriptor = XMLEditorPluginImageHelper.getInstance().getImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- }
- return imageDescriptor;
- }
-
- protected Element element;
- protected int insertionIndex = -1;
- protected AbstractNodeActionManager manager;
- protected Node parent;
- protected String title;
-
- public EditElementAction(AbstractNodeActionManager manager, Element element, String actionLabel, String dialogTitle) {
- this(manager, element.getParentNode(), -1, element, actionLabel, dialogTitle);
- }
-
- protected EditElementAction(AbstractNodeActionManager manager, Node parent, int index, Element element, String actionLabel, String title) {
- this.manager = manager;
- this.parent = parent;
- this.insertionIndex = index;
- this.element = element;
- this.title = title;
- setText(actionLabel);
- if (element == null) {
- setImageDescriptor(createImageDescriptor());
- }
- }
-
- public EditElementAction(AbstractNodeActionManager manager, Node parent, int index, String actionLabel, String title) {
- this(manager, parent, index, null, actionLabel, title);
- }
-
- public String getUndoDescription() {
- return title;
- }
-
- public void run() {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- if (validateEdit(manager.getModel(), shell)) {
- manager.beginNodeAction(this);
- EditElementDialog dialog = new EditElementDialog(shell, element);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- if (element != null) {
- // here we need to do a rename... which seems to be quite hard
- // to do :-(
- if (element instanceof IDOMElement) {
- IDOMElement elementImpl = (IDOMElement) element;
- IDOMModel model = elementImpl.getModel();
- String oldName = elementImpl.getNodeName();
- String newName = dialog.getElementName();
- setStructuredDocumentRegionElementName(model, elementImpl.getStartStructuredDocumentRegion(), oldName, newName);
- setStructuredDocumentRegionElementName(model, elementImpl.getEndStructuredDocumentRegion(), oldName, newName);
- }
- }
- else {
- Element newElement = document.createElement(dialog.getElementName());
- NodeList nodeList = parent.getChildNodes();
- int nodeListLength = nodeList.getLength();
- Node refChild = (insertionIndex < nodeListLength) && (insertionIndex >= 0) ? nodeList.item(insertionIndex) : null;
- parent.insertBefore(newElement, refChild);
- manager.reformat(newElement, false);
- manager.setViewerSelection(newElement);
- }
- }
- manager.endNodeAction(this);
- }
- }
-
- protected void setStructuredDocumentRegionElementName(IDOMModel model, IStructuredDocumentRegion flatNode, String oldName, String newName) {
- if (flatNode != null) {
- String string = flatNode.getText();
- int index = string.indexOf(oldName);
- if (index != -1) {
- index += flatNode.getStart();
- model.getStructuredDocument().replaceText(this, index, oldName.length(), newName);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java
deleted file mode 100644
index 5578cf2aea..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditProcessingInstructionAction.java
+++ /dev/null
@@ -1,98 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditProcessingInstructionDialog;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.ProcessingInstruction;
-
-/**
- * EditProcessingInstructionAction
- */
-public class EditProcessingInstructionAction extends NodeAction {
- protected Node childRef;
- protected AbstractNodeActionManager manager;
- protected Node parent;
- protected ProcessingInstruction pi;
- protected String title;
-
- /**
- * This constructor is used to add a new ProcessingInstruction
- */
- public EditProcessingInstructionAction(AbstractNodeActionManager manager, Node parent, Node childRef, String actionLabel, String title) {
- setText(actionLabel);
- this.manager = manager;
- this.parent = parent;
- this.childRef = childRef;
- this.title = title;
- }
-
- /**
- * This constructor is used to edit a ProcessingInstruction
- */
- public EditProcessingInstructionAction(AbstractNodeActionManager manager, ProcessingInstruction pi, String actionLabel, String title) {
- setText(actionLabel);
- this.manager = manager;
- this.pi = pi;
- this.parent = pi.getParentNode();
- this.title = title;
- }
-
- public String getUndoDescription() {
- return title;
- }
-
- public void run() {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- if (validateEdit(manager.getModel(), shell)) {
- manager.beginNodeAction(this);
-
-
- EditProcessingInstructionDialog dialog = null;
- if (pi != null) {
- dialog = new EditProcessingInstructionDialog(shell, pi);
- }
- else {
- dialog = new EditProcessingInstructionDialog(shell, XMLUIMessages._UI_PI_TARGET_VALUE, XMLUIMessages._UI_PI_DATA_VALUE);
- }
-
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- if (pi != null) {
- childRef = pi;
- }
-
- Document document = parent.getNodeType() == Node.DOCUMENT_NODE ? (Document) parent : parent.getOwnerDocument();
- Node newNode = document.createProcessingInstruction(dialog.getTarget(), dialog.getData());
- parent.insertBefore(newNode, childRef);
-
- if (pi != null) {
- parent.removeChild(pi);
- }
-
- manager.reformat(newNode, false);
- manager.setViewerSelection(newNode);
- }
- manager.endNodeAction(this);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java
deleted file mode 100644
index c07557a90d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/EditSchemaInfoAction.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceInfoManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditSchemaInfoDialog;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * EditDoctypeAction
- */
-public class EditSchemaInfoAction extends NodeAction {
- protected AbstractNodeActionManager manager;
- protected DOMNamespaceInfoManager namespaceInfoManager = new DOMNamespaceInfoManager();
- protected Node node;
- protected String resourceLocation;
- protected String title;
-
- public EditSchemaInfoAction(AbstractNodeActionManager manager, Node node, String resourceLocation, String title) {
- this.manager = manager;
- this.node = node;
- setText(title);
- this.resourceLocation = resourceLocation;
- this.title = title;
- }
-
- protected Map createPrefixMapping(List oldList, List newList) {
- Map map = new Hashtable();
-
- Hashtable oldURIToPrefixTable = new Hashtable();
- for (Iterator i = oldList.iterator(); i.hasNext();) {
- NamespaceInfo oldInfo = (NamespaceInfo) i.next();
- oldURIToPrefixTable.put(oldInfo.uri, oldInfo);
- }
-
- for (Iterator i = newList.iterator(); i.hasNext();) {
- NamespaceInfo newInfo = (NamespaceInfo) i.next();
- NamespaceInfo oldInfo = (NamespaceInfo) oldURIToPrefixTable.get(newInfo.uri != null ? newInfo.uri : ""); //$NON-NLS-1$
-
-
- // if oldInfo is non null ... there's a matching URI in the old
- // set
- // we can use its prefix to detemine out mapping
- //
- // if oldInfo is null ... we use the 'oldCopy' we stashed away
- // assuming that the user changed the URI and the prefix
- if (oldInfo == null) {
- oldInfo = (NamespaceInfo) newInfo.getProperty("oldCopy"); //$NON-NLS-1$
- }
-
- if (oldInfo != null) {
- String newPrefix = newInfo.prefix != null ? newInfo.prefix : ""; //$NON-NLS-1$
- String oldPrefix = oldInfo.prefix != null ? oldInfo.prefix : ""; //$NON-NLS-1$
- if (!oldPrefix.equals(newPrefix)) {
- map.put(oldPrefix, newPrefix);
- }
- }
- }
- return map;
- }
-
- public Element getElement(Node node) {
- Element result = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- result = (Element) node;
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- result = getRootElement((Document) node);
- }
- return result;
- }
-
-
- public Element getRootElement(Document document) {
- Element rootElement = null;
- NodeList nodeList = document.getChildNodes();
- int nodeListLength = nodeList.getLength();
- for (int i = 0; i < nodeListLength; i++) {
- Node childNode = nodeList.item(i);
- if (childNode.getNodeType() == Node.ELEMENT_NODE) {
- rootElement = (Element) childNode;
- break;
- }
- }
- return rootElement;
- }
-
- public String getUndoDescription() {
- return title;
- }
-
- public void run() {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- if (validateEdit(manager.getModel(), shell)) {
- manager.beginNodeAction(this);
-
- // todo... change constructor to take an element
- Element element = getElement(node);
- if (element != null) {
- EditSchemaInfoDialog dialog = new EditSchemaInfoDialog(shell, new Path(resourceLocation));
-
- List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(element);
- List oldNamespaceInfoList = NamespaceInfo.cloneNamespaceInfoList(namespaceInfoList);
-
- // here we store a copy of the old info for each NamespaceInfo
- // this info will be used in createPrefixMapping() to figure out
- // how to update the document
- // in response to these changes
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- NamespaceInfo oldCopy = new NamespaceInfo(info);
- info.setProperty("oldCopy", oldCopy); //$NON-NLS-1$
- }
-
- dialog.setNamespaceInfoList(namespaceInfoList);
- dialog.create();
- // dialog.getShell().setSize(500, 300);
- dialog.getShell().setText(XMLUIMessages._UI_MENU_EDIT_SCHEMA_INFORMATION_TITLE);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- List newInfoList = dialog.getNamespaceInfoList();
- namespaceInfoManager.removeNamespaceInfo(element);
- namespaceInfoManager.addNamespaceInfo(element, newInfoList, false);
-
- // see if we need to rename any prefixes
- Map prefixMapping = createPrefixMapping(oldNamespaceInfoList, namespaceInfoList);
- if (prefixMapping.size() > 0) {
- try {
- manager.getModel().aboutToChangeModel();
- ReplacePrefixAction replacePrefixAction = new ReplacePrefixAction(manager, element, prefixMapping);
- replacePrefixAction.run();
- }
- finally {
- manager.getModel().changedModel();
- }
- }
- }
- }
- manager.endNodeAction(this);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/GoToMatchingTagAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/GoToMatchingTagAction.java
deleted file mode 100644
index 5d7e7a373f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/GoToMatchingTagAction.java
+++ /dev/null
@@ -1,301 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.text.ITextSelection;
-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.viewers.IPostSelectionProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.texteditor.IDocumentProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- * Moves the cursor to the end tag if it is in a start tag, and vice versa.
- * Also updates the matching tag annotation in the active editor.
- *
- * @author nitin
- *
- */
-class GoToMatchingTagAction extends TextEditorAction {
-
- private class UpdateListener implements ISelectionChangedListener {
- public void selectionChanged(SelectionChangedEvent event) {
- updateFor(event.getSelection());
- }
- }
-
- private static final String ANNOTATION_TYPE = "org.eclipse.wst.xml.ui.matching.tag"; //$NON-NLS-1$
- private ISelectionChangedListener fUpdateListener = null;
- static final boolean DEBUG = false;
-
- /**
- * @param bundle
- * @param prefix
- * @param editor
- * @param style
- */
- GoToMatchingTagAction(ResourceBundle bundle, String prefix, ITextEditor editor) {
- super(bundle, prefix, editor);
- fUpdateListener = new UpdateListener();
- }
-
- void removeAnnotation(boolean allMatching) {
- ITextEditor textEditor = getTextEditor();
- if (textEditor == null) {
- if (DEBUG) {
- System.out.println("no editor"); //$NON-NLS-1$
- }
- return;
- }
- IDocumentProvider documentProvider = textEditor.getDocumentProvider();
- if (documentProvider == null) {
- if (DEBUG) {
- System.out.println("no document provider"); //$NON-NLS-1$
- }
- return;
- }
- IAnnotationModel annotationModel = documentProvider.getAnnotationModel(textEditor.getEditorInput());
- if (annotationModel == null) {
- if (DEBUG) {
- System.out.println("no annotation model"); //$NON-NLS-1$
- }
- return;
- }
-
- Iterator annotationIterator = annotationModel.getAnnotationIterator();
- List oldAnnotations = new ArrayList();
- while (annotationIterator.hasNext()) {
- Annotation annotation = (Annotation) annotationIterator.next();
- if (ANNOTATION_TYPE.equals(annotation.getType())) {
- annotation.markDeleted(true);
- /**
- * Sometimes it is supported, sometime's it is not. Confusing.
- */
- try {
- annotationIterator.remove();
- }
- catch (UnsupportedOperationException e) {
- oldAnnotations.add(annotation);
- }
- if (DEBUG) {
- System.out.println("removed " + annotation); //$NON-NLS-1$
- }
- if (!allMatching)
- break;
- }
- }
- if (!oldAnnotations.isEmpty()) {
- int size = oldAnnotations.size();
- for (int i = 0; i < size; i++) {
- annotationModel.removeAnnotation((Annotation) oldAnnotations.get(i));
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
- */
- public void runWithEvent(Event event) {
- super.runWithEvent(event);
- if (getTextEditor() == null)
- return;
-
- ISelection selection = getTextEditor().getSelectionProvider().getSelection();
- if (!selection.isEmpty() && selection instanceof IStructuredSelection && selection instanceof ITextSelection) {
- Object o = ((IStructuredSelection) selection).getFirstElement();
- if (o instanceof IDOMNode) {
- int offset = ((ITextSelection) selection).getOffset();
- IStructuredDocumentRegion matchRegion = null;
- if (((Node) o).getNodeType() == Node.ATTRIBUTE_NODE) {
- o = ((Attr) o).getOwnerElement();
- }
-
- int targetOffset = -1;
- if (o instanceof IDOMNode) {
- IDOMNode node = (IDOMNode) o;
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null && startStructuredDocumentRegion.containsOffset(offset)) {
- matchRegion = ((IDOMNode) o).getEndStructuredDocumentRegion();
- if (matchRegion != null)
- targetOffset = matchRegion.getStartOffset() + 2;
- }
- else {
- IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null && endStructuredDocumentRegion.containsOffset(offset)) {
- matchRegion = ((IDOMNode) o).getStartStructuredDocumentRegion();
- if (matchRegion != null)
- targetOffset = matchRegion.getStartOffset() + 1;
- }
- }
- }
-
- if (targetOffset >= 0) {
- getTextEditor().getSelectionProvider().setSelection(new TextSelection(targetOffset, 0));
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.TextEditorAction#setEditor(org.eclipse.ui.texteditor.ITextEditor)
- */
- public void setEditor(ITextEditor editor) {
- ITextEditor textEditor = getTextEditor();
- if (textEditor != null) {
- removeAnnotation(true);
-
- ISelectionProvider selectionProvider = textEditor.getSelectionProvider();
- if (selectionProvider instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) selectionProvider).removePostSelectionChangedListener(fUpdateListener);
- }
- }
- super.setEditor(editor);
- if (editor != null) {
- ISelectionProvider selectionProvider = editor.getSelectionProvider();
- if (selectionProvider instanceof IPostSelectionProvider) {
- ((IPostSelectionProvider) selectionProvider).addPostSelectionChangedListener(fUpdateListener);
- }
-
- updateFor(selectionProvider.getSelection());
- }
- }
-
- public void update() {
- setEnabled(true);
-
- }
-
- void updateFor(ISelection selection) {
- ITextEditor textEditor = getTextEditor();
- if (textEditor == null) {
- if (DEBUG) {
- System.out.println("no editor"); //$NON-NLS-1$
- }
- return;
- }
- IDocumentProvider documentProvider = textEditor.getDocumentProvider();
- if (documentProvider == null) {
- if (DEBUG) {
- System.out.println("no document provider"); //$NON-NLS-1$
- }
- return;
- }
- IAnnotationModel annotationModel = documentProvider.getAnnotationModel(textEditor.getEditorInput());
- if (annotationModel == null || !(annotationModel instanceof IAnnotationModelExtension)) {
- if (DEBUG) {
- System.out.println("no annotation model"); //$NON-NLS-1$
- }
- return;
- }
-
- List oldAnnotations = new ArrayList(2);
- Iterator annotationIterator = annotationModel.getAnnotationIterator();
- while (annotationIterator.hasNext()) {
- Annotation annotation = (Annotation) annotationIterator.next();
- if (ANNOTATION_TYPE.equals(annotation.getType())) {
- annotation.markDeleted(true);
- if (DEBUG) {
- System.out.println("removing " + annotation); //$NON-NLS-1$
- }
- oldAnnotations.add(annotation);
- }
- }
-
- Map newAnnotations = new HashMap();
- if (!selection.isEmpty() && selection instanceof IStructuredSelection && selection instanceof ITextSelection) {
- Object o = ((IStructuredSelection) selection).getFirstElement();
- if (o instanceof IDOMNode) {
- int offset = ((ITextSelection) selection).getOffset();
- IStructuredDocumentRegion matchRegion = null;
- if (((Node) o).getNodeType() == Node.ATTRIBUTE_NODE) {
- o = ((Attr) o).getOwnerElement();
- }
-
- Position pStart = null;
- Position pEnd = null;
- String tag = ""; //$NON-NLS-1$
- if (o instanceof IDOMNode) {
- IDOMNode node = (IDOMNode) o;
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if (startStructuredDocumentRegion != null && startStructuredDocumentRegion.containsOffset(offset)) {
- if (startStructuredDocumentRegion.getNumberOfRegions() > 1) {
- ITextRegion nameRegion = startStructuredDocumentRegion.getRegions().get(1);
- pStart = new Position(startStructuredDocumentRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
- tag = startStructuredDocumentRegion.getText(nameRegion);
- }
- matchRegion = ((IDOMNode) o).getEndStructuredDocumentRegion();
- if (matchRegion != null && matchRegion.getNumberOfRegions() > 1) {
- ITextRegion nameRegion = matchRegion.getRegions().get(1);
- pEnd = new Position(matchRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
- }
- }
- else {
- IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion();
- if (endStructuredDocumentRegion != null && endStructuredDocumentRegion.containsOffset(offset)) {
- if (endStructuredDocumentRegion.getNumberOfRegions() > 1) {
- ITextRegion nameRegion = endStructuredDocumentRegion.getRegions().get(1);
- pEnd = new Position(endStructuredDocumentRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
- tag = endStructuredDocumentRegion.getText(nameRegion);
- }
- matchRegion = ((IDOMNode) o).getStartStructuredDocumentRegion();
- if (matchRegion != null && matchRegion.getNumberOfRegions() > 1) {
- ITextRegion nameRegion = matchRegion.getRegions().get(1);
- pStart = new Position(matchRegion.getStartOffset(nameRegion), nameRegion.getTextLength());
- }
- }
- }
- }
- if (pStart != null && pEnd != null) {
- Annotation annotation = new Annotation(ANNOTATION_TYPE, false, NLS.bind(XMLUIMessages.gotoMatchingTag_start, tag));
- newAnnotations.put(annotation, pStart);
- if (DEBUG) {
- System.out.println("adding " + annotation); //$NON-NLS-1$
- }
- annotation = new Annotation(ANNOTATION_TYPE, false, NLS.bind(XMLUIMessages.gotoMatchingTag_end, tag));
- newAnnotations.put(annotation, pEnd);
- if (DEBUG) {
- System.out.println("adding " + annotation); //$NON-NLS-1$
- }
- }
- }
- }
- ((IAnnotationModelExtension) annotationModel).replaceAnnotations((Annotation[]) oldAnnotations.toArray(new Annotation[oldAnnotations.size()]), newAnnotations);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java
deleted file mode 100644
index 78f3ceb017..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/MenuBuilder.java
+++ /dev/null
@@ -1,146 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import com.ibm.icu.text.Collator;
-import java.util.Arrays;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.MenuManager;
-
-
-public class MenuBuilder {
-
-
- protected Comparator comparator = new Comparator() {
-
- public int compare(Object o1, Object o2) {
- return Collator.getInstance().compare(getSortKey(o1), getSortKey(o2));
- }
-
- protected String getSortKey(Object o) {
- String result = ""; //$NON-NLS-1$
- if (o instanceof IAction) {
- IAction action = (IAction) o;
- result = action.getText();
- }
- // else if (o instanceof MenuData)
- // {
- // result = "z" + ((MenuData)o).name;
- // }
- return result;
- }
- };
-
-
- protected void createAlphebeticalGrouping(IMenuManager menu, List actionList) {
- Object[] array = actionList.toArray();
- if (array.length > 0) {
- Arrays.sort(array, comparator);
- }
-
- int groupSize = 15;
- int minGroupSize = 5;
- int numberOfGroups = (array.length / groupSize) + ((array.length % groupSize > minGroupSize) ? 1 : 0);
-
- for (int i = 0; i < numberOfGroups; i++) {
- boolean isLastGroup = (i == (numberOfGroups - 1));
- int firstIndex = i * groupSize;
- int lastIndex = isLastGroup ? array.length - 1 : i * groupSize + groupSize - 1;
- Action firstAction = (Action) array[firstIndex];
- Action lastAction = (Action) array[lastIndex];
- MenuManager submenu = new MenuManager(firstAction.getText() + " - " + lastAction.getText()); //$NON-NLS-1$
- menu.add(submenu);
- for (int j = firstIndex; j <= lastIndex; j++) {
- submenu.add((Action) array[j]);
- }
- }
- }
-
-
- public void populateMenu(IMenuManager menu, List actionList, boolean createTiered) {
- // sort the actions
- if (actionList.size() < 25) {
- Object[] array = actionList.toArray();
- if (array.length > 0) {
- Arrays.sort(array, comparator);
- }
- for (int i = 0; i < array.length; i++) {
- menu.add((Action) array[i]);
- }
- }
- else {
- createAlphebeticalGrouping(menu, actionList);
- }
- }
-
- /*
- * protected void createPropertyGrouping(IMenuManager menu, List
- * actionList) { MenuDataTable menuDataTable = new MenuDataTable();
- *
- * for (Iterator i = actionList.iterator(); i.hasNext(); ) { String
- * groupName = null; Action action = (Action)i.next(); if (action
- * instanceof NodeAction) { groupName =
- * ((NodeAction)action).getGroupName(); } if (groupName == null) {
- * groupName = ""; } MenuData menuData =
- * menuDataTable.lookupOrCreate(groupName, "");
- * menuData.childList.add(action); } populateMenu(menu,
- * menuDataTable.getRoot()); }
- *
- *
- * protected void populateMenu(MenuManager menuManager, MenuData menuData) {
- * for (Iterator i = menuData.childList.iterator(); i.hasNext(); ) {
- * Object o = i.next(); if (o instanceof Action) {
- * menuManager.add((Action)o); } else if (o instanceof MenuData) {
- * MenuData childMenuData = (MenuData)o; MenuManager childMenuManager =
- * new MenuManager(childMenuData.name); menuManager.add(childMenuManager);
- * populateMenu(childMenuManager, childMenuData); } } }
- *
- *
- * public MenuDataTable { protected Hashtable table = new Hashtable();
- * protected MenuData root;
- *
- * public MenuDataTable() { root = lookupOrCreateMenuData(null, null); }
- *
- * protected MenuData lookupMenuData(String name) { String key = name !=
- * null ? name : ""; return (MenuData)menuDataTable.get(key); }
- *
- * protected MenuData lookupOrCreateMenuData(String name, String
- * parentName) { String key = name != null ? name : ""; MenuData menuData =
- * (MenuData)menuDataTable.get(key); if (menuData == null) { menuData =
- * new MenuData(name, parentName); menuDataTable.put(key, menuData); }
- * return menuData; }
- *
- * public MenuData getRoot() { return root; } }
- *
- *
- * protected class MenuData { public String name; public String
- * parentName; public List childList = new Vector();
- *
- * MenuData(String name, String parentName) { this.name = name;
- * this.parentName = parentName; }
- *
- * protected void sort() { Object[] array = childList.toArray(); if
- * (array.length > 0 ) { Arrays.sort(array, comparator); } childList =
- * Arrays.asList(array);
- *
- * for (Iterator i = childList.iterator(); i.hasNext(); ) { Object o =
- * i.next(); if (o instanceof MenuData) { ((MenuData)o).sort(); } } } }
- */
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java
deleted file mode 100644
index 1ce764ac29..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/NodeAction.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.action.Action;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-
-public abstract class NodeAction extends Action {
-
- public String getSortKey() {
- return null;
- }
-
- /**
- * Checks that the resource backing the model is writeable utilizing <code>validateEdit</code>
- * on a given <tt>IWorkspace</tt>.
- *
- * @param model the model to be checked
- * @param context the shell context for which <code>validateEdit</code> will be run
- * @return boolean result of checking <code>validateEdit</code>. If the resource is unwriteable, <code>status.isOK()</code>
- * will return true; otherwise, false.
- */
- protected final boolean validateEdit(IStructuredModel model, Shell context) {
- if (model != null && model.getBaseLocation() != null) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
- return !file.isAccessible() || ResourcesPlugin.getWorkspace().validateEdit(new IFile[] {file}, context).isOK();
- }
- return false; //$NON-NLS-1$
- }
-
- public abstract String getUndoDescription();
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java
deleted file mode 100644
index 473e5f257f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/RemoveBlockCommentActionXMLDelegate.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.xml.core.internal.document.CommentImpl;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Remove block comment action delegate for XML editor
- */
-public class RemoveBlockCommentActionXMLDelegate extends AbstractCommentActionXMLDelegate {
-
- void processAction(IDocument document, ITextSelection textSelection) {
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
- if (model != null) {
- try {
- IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset());
- IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength());
-
- if ((selectionStartIndexedRegion == null) || (selectionEndIndexedRegion == null)) {
- return;
- }
-
- int openCommentOffset = selectionStartIndexedRegion.getStartOffset();
- int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() - OPEN_COMMENT.length() - CLOSE_COMMENT.length();
-
- model.beginRecording(this, XMLUIMessages.RemoveBlockComment_tooltip);
- model.aboutToChangeModel();
-
- try {
- if (textSelection.getLength() == 0) {
- if (selectionStartIndexedRegion instanceof CommentImpl) {
- document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- }
- }
- else {
- if (selectionStartIndexedRegion instanceof CommentImpl) {
- document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- }
-
- if (selectionEndIndexedRegion instanceof CommentImpl) {
- document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- }
- }
- removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length());
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- finally {
- model.changedModel();
- model.endRecording(this);
- }
- }
- finally {
- model.releaseFromEdit();
- }
- }
- }
-
- public void init(IAction action) {
- if (action != null) {
- action.setText(XMLUIMessages.RemoveBlockComment_label);
- action.setToolTipText(XMLUIMessages.RemoveBlockComment_tooltip);
- action.setDescription(XMLUIMessages.RemoveBlockComment_description);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java
deleted file mode 100644
index 18599bdf82..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ReplacePrefixAction.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Vector;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMVisitor;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-
-public class ReplacePrefixAction extends NodeAction {
-
- class NodeCollectingDOMVisitor extends DOMVisitor {
- public List list = new Vector();
-
- protected boolean isPrefixChangedNeeded(Node node) {
- String key = node.getPrefix() != null ? node.getPrefix() : ""; //$NON-NLS-1$
- return prefixMapping.get(key) != null;
- }
-
- public void visitAttr(Attr attr) {
- /*
- * if (isPrefixChangedNeeded(element)) { list.add(attr); }
- */
- }
-
- protected void visitElement(Element element) {
- super.visitElement(element);
- if (isPrefixChangedNeeded(element)) {
- list.add(element);
- }
- }
- }
-
- protected static ImageDescriptor imageDescriptor;
- protected Element element;
- protected AbstractNodeActionManager manager;
- protected Map prefixMapping;
-
- public ReplacePrefixAction(AbstractNodeActionManager manager, Element element, Map prefixMapping) {
- this.manager = manager;
- this.element = element;
- this.prefixMapping = prefixMapping;
- }
-
- public String getUndoDescription() {
- return ""; //$NON-NLS-1$
- }
-
- public void run() {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- if (validateEdit(manager.getModel(), shell)) {
- NodeCollectingDOMVisitor visitor = new NodeCollectingDOMVisitor();
- visitor.visitNode(element);
- for (Iterator i = visitor.list.iterator(); i.hasNext();) {
- Node node = (Node) i.next();
- String key = node.getPrefix() != null ? node.getPrefix() : ""; //$NON-NLS-1$
- String newPrefix = (String) prefixMapping.get(key);
- if (newPrefix != null) {
- node.setPrefix(newPrefix);
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/SiblingNavigationAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/SiblingNavigationAction.java
deleted file mode 100644
index a08b44f60e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/SiblingNavigationAction.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Event;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.TextEditorAction;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- * Provides navigation to next/previous DOM sibling Nodes
- *
- * @author nitin
- *
- */
-class SiblingNavigationAction extends TextEditorAction {
-
- private boolean fForward;
-
- /**
- * @param bundle
- * @param prefix
- * @param editor
- */
- SiblingNavigationAction(ResourceBundle bundle, String prefix, ITextEditor editor, boolean forward) {
- super(bundle, prefix, editor);
- fForward = forward;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.Action#runWithEvent(org.eclipse.swt.widgets.Event)
- */
- public void runWithEvent(Event event) {
- super.runWithEvent(event);
- if (getTextEditor() == null)
- return;
-
- ISelection selection = getTextEditor().getSelectionProvider().getSelection();
- if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
- Object o = ((IStructuredSelection) selection).getFirstElement();
- if (o instanceof Node) {
- Node sibling = null;
-
- if (((Node) o).getNodeType() == Node.ATTRIBUTE_NODE) {
- o = ((Attr) o).getOwnerElement();
- }
- if (fForward) {
- sibling = ((Node) o).getNextSibling();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getNextSibling();
- }
- if (sibling == null) {
- sibling = ((Node) o).getParentNode().getFirstChild();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getNextSibling();
- }
- }
- }
- else {
- sibling = ((Node) o).getPreviousSibling();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getPreviousSibling();
- }
- if (sibling == null) {
- sibling = ((Node) o).getParentNode().getLastChild();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getPreviousSibling();
- }
- }
- }
-
- // The only child is a Text Node, go to the parent Node
- if (((Node) o).getNodeType() == Node.TEXT_NODE && o.equals(sibling)) {
- sibling = ((Node) o).getParentNode();
- }
-
-
- if (sibling != null) {
- getTextEditor().getSelectionProvider().setSelection(new StructuredSelection(sibling));
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.TextEditorAction#update()
- */
- public void update() {
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java
deleted file mode 100644
index 09d81d1840..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/actions/ToggleCommentActionXMLDelegate.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.actions;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Toggle comment action delegate for XML editor
- */
-public class ToggleCommentActionXMLDelegate extends AbstractCommentActionXMLDelegate {
- public void init(IAction action) {
- if (action != null) {
- action.setText(XMLUIMessages.ToggleComment_label);
- action.setToolTipText(XMLUIMessages.ToggleComment_tooltip);
- action.setDescription(XMLUIMessages.ToggleComment_description);
- }
- }
-
- void processAction(IDocument document, ITextSelection textSelection) {
- // get text selection lines info
- int selectionStartLine = textSelection.getStartLine();
- int selectionEndLine = textSelection.getEndLine();
- try {
- int selectionEndLineOffset = document.getLineOffset(selectionEndLine);
- int selectionEndOffset = textSelection.getOffset() + textSelection.getLength();
-
- // adjust selection end line
- if ((selectionEndLine > selectionStartLine) && (selectionEndLineOffset == selectionEndOffset)) {
- selectionEndLine--;
- }
-
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
-
- // save the selection position since it will be changing
- Position selectionPosition = null;
- boolean updateStartOffset = false;
- try {
- selectionPosition = new Position(textSelection.getOffset(), textSelection.getLength());
- document.addPosition(selectionPosition);
-
- // extra check if commenting from beginning of line
- int selectionStartLineOffset = document.getLineOffset(selectionStartLine);
- if ((textSelection.getLength() > 0) && (selectionStartLineOffset == textSelection.getOffset()) && !isCommentLine(document, selectionStartLine)) {
- updateStartOffset = true;
- }
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
-
- processAction(document, selectionStartLine, selectionEndLine);
-
- updateCurrentSelection(selectionPosition, document, updateStartOffset);
- }
-
- private void processAction(IDocument document, int selectionStartLine, int selectionEndLine) {
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
- if (model != null) {
- try {
- model.beginRecording(this, XMLUIMessages.ToggleComment_tooltip);
- model.aboutToChangeModel();
-
- for (int i = selectionStartLine; i <= selectionEndLine; i++) {
- try {
- if (document.getLineLength(i) > 0) {
- if (isCommentLine(document, i)) {
- int lineOffset = document.getLineOffset(i);
- IRegion region = document.getLineInformation(i);
- String string = document.get(region.getOffset(), region.getLength());
- int openCommentOffset = lineOffset + string.indexOf(OPEN_COMMENT);
- int closeCommentOffset = lineOffset + string.indexOf(CLOSE_COMMENT) - OPEN_COMMENT.length();
- uncomment(document, openCommentOffset, closeCommentOffset);
- }
- else {
- int openCommentOffset = document.getLineOffset(i);
- int lineDelimiterLength = document.getLineDelimiter(i) == null ? 0 : document.getLineDelimiter(i).length();
- int closeCommentOffset = openCommentOffset + document.getLineLength(i) - lineDelimiterLength + OPEN_COMMENT.length();
- comment(document, openCommentOffset, closeCommentOffset);
- }
- }
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- }
- finally {
- model.changedModel();
- model.endRecording(this);
- model.releaseFromEdit();
- }
- }
- }
-
- private boolean isCommentLine(IDocument document, int line) {
- boolean isComment = false;
-
- try {
- IRegion region = document.getLineInformation(line);
- String string = document.get(region.getOffset(), region.getLength()).trim();
- isComment = (string.length() >= OPEN_COMMENT.length() + CLOSE_COMMENT.length()) && string.startsWith(OPEN_COMMENT) && string.endsWith(CLOSE_COMMENT);
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- return isComment;
- }
-
- private void comment(IDocument document, int openCommentOffset, int closeCommentOffset) {
- try {
- document.replace(openCommentOffset, 0, OPEN_COMMENT);
- document.replace(closeCommentOffset, 0, CLOSE_COMMENT);
- removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length());
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
-
- private void uncomment(IDocument document, int openCommentOffset, int closeCommentOffset) {
- try {
- document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
-
- private void updateCurrentSelection(Position selectionPosition, IDocument document, boolean updateStartOffset) {
- if (fEditor instanceof ITextEditor) {
- // update the selection if text selection changed
- if (selectionPosition != null) {
- ITextSelection selection = null;
- if (updateStartOffset) {
- selection = new TextSelection(document, selectionPosition.getOffset() - OPEN_COMMENT.length(), selectionPosition.getLength() + OPEN_COMMENT.length());
- }
- else {
- selection = new TextSelection(document, selectionPosition.getOffset(), selectionPosition.getLength());
- }
- ISelectionProvider provider = ((ITextEditor) fEditor).getSelectionProvider();
- if (provider != null) {
- provider.setSelection(selection);
- }
- document.removePosition(selectionPosition);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java
deleted file mode 100644
index 1b416ccc2c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/AutoEditStrategyForTabs.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.autoedit;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.ConfigurableLineTracker;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ILineTracker;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.TextUtilities;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension3;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.ui.internal.Logger;
-
-/**
- * AutoEditStrategy to handle characters inserted when Tab key is pressed
- */
-public class AutoEditStrategyForTabs implements IAutoEditStrategy {
- private final String TAB_CHARACTER = "\t"; //$NON-NLS-1$
-
- public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- // if not in smart insert mode just ignore
- if (!isSmartInsertMode()) {
- return;
- }
-
- // spaces for tab character
- if ((command.length == 0) && (command.text != null) && (command.text.length() > 0) && (command.text.indexOf(TAB_CHARACTER) != -1)) {
- smartInsertForTab(command, document);
- }
- }
-
- /**
- * Insert spaces for tabs
- *
- * @param command
- */
- private void smartInsertForTab(DocumentCommand command, IDocument document) {
- // tab key was pressed. now check preferences to see if need to insert
- // spaces instead of tab
- int indentationWidth = getIndentationWidth();
- if (indentationWidth > -1) {
- String originalText = command.text;
- StringBuffer newText = new StringBuffer(originalText);
-
- // determine where in line this command begins
- int lineOffset = -1;
- try {
- IRegion lineInfo = document.getLineInformationOfOffset(command.offset);
- lineOffset = command.offset - lineInfo.getOffset();
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
-
- ILineTracker lineTracker = getLineTracker(document, originalText);
-
- int startIndex = 0;
- int index = newText.indexOf(TAB_CHARACTER);
- while (index != -1) {
- String indent = getIndentString(indentationWidth, lineOffset, lineTracker, index);
-
- // replace \t character with spaces
- newText.replace(index, index + 1, indent);
- if (lineTracker != null) {
- try {
- lineTracker.replace(index, 1, indent);
- }
- catch (BadLocationException e) {
- // if something goes wrong with replacing text, just
- // reset to current string
- lineTracker.set(newText.toString());
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
-
- startIndex = index + indent.length();
- index = newText.indexOf(TAB_CHARACTER, startIndex);
- }
- command.text = newText.toString();
- }
- }
-
- /**
- * Calculate number of spaces for next tab stop
- */
- private String getIndentString(int indentationWidth, int lineOffset, ILineTracker lineTracker, int index) {
- int indentSize = indentationWidth;
- int offsetInLine = -1;
- if (lineTracker != null) {
- try {
- IRegion lineInfo = lineTracker.getLineInformationOfOffset(index);
- if ((lineInfo.getOffset() == 0) && (lineOffset > -1)) {
- offsetInLine = lineOffset + index;
- }
- else {
- offsetInLine = index - lineInfo.getOffset();
- }
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- else {
- if (lineOffset > -1) {
- offsetInLine = lineOffset + index;
- }
- }
- if ((offsetInLine > -1) && (indentationWidth > 0)) {
- int remainder = offsetInLine % indentationWidth;
- indentSize = indentationWidth - remainder;
- }
-
- StringBuffer indent = new StringBuffer();
- for (int i = 0; i < indentSize; i++) {
- indent.append(' ');
- }
- return indent.toString();
- }
-
- /**
- * Set up a line tracker for text within command if text is multi-line
- */
- private ILineTracker getLineTracker(IDocument document, String originalText) {
- ConfigurableLineTracker lineTracker = null;
- int[] delims = TextUtilities.indexOf(document.getLegalLineDelimiters(), originalText, 0);
- if ((delims[0] != -1) || (delims[1] != -1)) {
- lineTracker = new ConfigurableLineTracker(document.getLegalLineDelimiters());
- lineTracker.set(originalText);
- }
- return lineTracker;
- }
-
- /**
- * Return true if active editor is in smart insert mode, false otherwise
- *
- * @return boolean
- */
- private boolean isSmartInsertMode() {
- boolean isSmartInsertMode = false;
-
- ITextEditor textEditor = null;
- IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
- if (window != null) {
- IWorkbenchPage page = window.getActivePage();
- if (page != null) {
- IEditorPart editor = page.getActiveEditor();
- if (editor != null) {
- if (editor instanceof ITextEditor) {
- textEditor = (ITextEditor) editor;
- }
- else {
- textEditor = (ITextEditor) editor.getAdapter(ITextEditor.class);
- }
- }
- }
- }
-
- // check if smart insert mode
- if ((textEditor instanceof ITextEditorExtension3) && (((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT)) {
- isSmartInsertMode = true;
- }
- return isSmartInsertMode;
- }
-
- /**
- * Returns indentation width if using spaces for indentation, -1 otherwise
- *
- * @return int
- */
- private int getIndentationWidth() {
- int width = -1;
-
- Preferences preferences = XMLCorePlugin.getDefault().getPluginPreferences();
- if (XMLCorePreferenceNames.SPACE.equals(preferences.getString(XMLCorePreferenceNames.INDENTATION_CHAR))) {
- width = preferences.getInt(XMLCorePreferenceNames.INDENTATION_SIZE);
- }
-
- return width;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java
deleted file mode 100644
index 267084e6a8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/autoedit/StructuredAutoEditStrategyXML.java
+++ /dev/null
@@ -1,285 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.autoedit;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentCommand;
-import org.eclipse.jface.text.IAutoEditStrategy;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.IWorkbenchWindow;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.ui.texteditor.ITextEditorExtension3;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.w3c.dom.Node;
-
-/**
- * Automatically inserts closing comment tag or end tag when appropriate.
- */
-public class StructuredAutoEditStrategyXML implements IAutoEditStrategy {
- /*
- * NOTE: copies of this class exists in
- * org.eclipse.wst.xml.ui.internal.autoedit
- * org.eclipse.wst.html.ui.internal.autoedit
- */
- public void customizeDocumentCommand(IDocument document, DocumentCommand command) {
- Object textEditor = getActiveTextEditor();
- if (!((textEditor instanceof ITextEditorExtension3) && (((ITextEditorExtension3) textEditor).getInsertMode() == ITextEditorExtension3.SMART_INSERT))) {
- return;
- }
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model != null) {
- if (command.text != null) {
- smartInsertCloseElement(command, document, model);
- smartInsertForComment(command, document, model);
- smartInsertForEndTag(command, document, model);
- smartRemoveEndTag(command, document, model);
- }
- }
- }
- finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
- }
-
- private boolean isPreferenceEnabled(String key) {
- return (key != null && XMLUIPlugin.getDefault().getPreferenceStore().getBoolean(key));
- }
-
- private boolean isCommentNode(IDOMNode node) {
- return ((node != null) && (node instanceof IDOMElement) && ((IDOMElement) node).isCommentTag());
- }
-
- private boolean isDocumentNode(IDOMNode node) {
- return ((node != null) && (node.getNodeType() == Node.DOCUMENT_NODE));
- }
-
- /**
- * Attempts to clean up an end-tag if a start-tag is converted into an empty-element
- * tag (e.g., <node />) and the original element was empty.
- *
- * @param command the document command describing the change
- * @param document the document that will be changed
- * @param model the model based on the document
- */
- private void smartRemoveEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
- try {
- // An opening tag is now a self-terminated end-tag
- if ("/".equals(command.text) && ">".equals(document.get(command.offset, 1)) && isPreferenceEnabled(XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS)) { //$NON-NLS-1$ //$NON-NLS-2$
- IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset);
- if (node != null && !node.hasChildNodes()) {
- IStructuredDocumentRegion region = node.getFirstStructuredDocumentRegion();
- if(region.getFirstRegion().getType() == DOMRegionContext.XML_TAG_OPEN && command.offset <= region.getEnd()) {
-
- /* if the region before the command offset is a an attribute value region
- * check to see if it has both and opening and closing quote
- */
- ITextRegion prevTextRegion = region.getRegionAtCharacterOffset(command.offset-1);
- boolean inUnclosedAttValueRegion = false;
- if(prevTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- //get the text of the attribute value region
- String prevText = region.getText(prevTextRegion);
- inUnclosedAttValueRegion = (prevText.startsWith("'") && ((prevText.length() == 1) || !prevText.endsWith("'"))) ||
- (prevText.startsWith("\"") && ((prevText.length() == 1) || !prevText.endsWith("\"")));
- }
-
- //if command offset is in an unclosed attribute value region then done remove the end tag
- if(!inUnclosedAttValueRegion) {
- region = node.getEndStructuredDocumentRegion();
- if (region != null && region.isEnded()) {
- document.replace(region.getStartOffset(), region.getLength(), ""); //$NON-NLS-1$
- }
- }
- }
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
-
- private void smartInsertForComment(DocumentCommand command, IDocument document, IStructuredModel model) {
- try {
- if (command.text.equals("-") && (document.getLength() >= 3) && document.get(command.offset - 3, 3).equals("<!-") && isPreferenceEnabled(XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS)) { //$NON-NLS-1$ //$NON-NLS-2$
- command.text += " -->"; //$NON-NLS-1$
- command.shiftsCaret = false;
- command.caretOffset = command.offset + 2;
- command.doit = false;
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
-
- }
-
- /**
- * Attempts to insert the end tag when completing a start-tag with the '&gt;' character.
- *
- * @param command
- * @param document
- * @param model
- */
- private void smartInsertCloseElement(DocumentCommand command, IDocument document, IStructuredModel model) {
- try {
- // Check terminating start tag, but ignore empty-element tags
- if (command.text.equals(">") && document.getLength() > 0 && document.getChar(command.offset - 1) != '/' && isPreferenceEnabled(XMLUIPreferenceNames.TYPING_COMPLETE_ELEMENTS)) { //$NON-NLS-1$
- IDOMNode node = (IDOMNode) model.getIndexedRegion(command.offset - 1);
- boolean isClosedByParent = false;
- // Only insert an end-tag if necessary. Because of the way the document is parsed, it is possible for a child tag with the same
- // name as an ancestor to be paired with the end-tag of an ancestor, so the ancestors must be checked for an unclosed tag.
- if (node != null && node.getNodeType() == Node.ELEMENT_NODE && (!node.isClosed() || (isClosedByParent = hasUnclosedAncestor(node)))) {
- IStructuredDocumentRegion region = node.getEndStructuredDocumentRegion();
- if (region != null && region.getRegions().size() > 0 && region.getRegions().get(0).getType() == DOMRegionContext.XML_END_TAG_OPEN && !isClosedByParent)
- return;
- command.text += "</" + getElementName(node, command.offset) + ">"; //$NON-NLS-1$ //$NON-NLS-2$
- command.shiftsCaret = false;
- command.caretOffset = command.offset + 1;
- }
-
- }
- } catch (BadLocationException e) {
- e.printStackTrace();
- }
- }
-
- /**
- * Get the element name that will be created by closing the start tag. Defaults
- * to the node's nodeName.
- * @param node the node that is being edited
- * @param offset the offset in the document where the start tag is closed
- * @return The element name of the tag
- */
- private String getElementName(IDOMNode node, int offset) {
- String name = null;
-
- IStructuredDocumentRegion region = node.getFirstStructuredDocumentRegion();
- ITextRegion textRegion = region.getRegionAtCharacterOffset(offset);
- if (textRegion != null && textRegion.getType() == DOMRegionContext.XML_TAG_NAME) {
- int nameStart = region.getStartOffset(textRegion);
- String regionText = region.getText(textRegion);
- int length = offset - nameStart;
- if (length <= regionText.length())
- name = regionText.substring(0, length);
- }
-
- // Default to the node name
- if (name == null)
- name = node.getNodeName();
- return name;
- }
-
- private void smartInsertForEndTag(DocumentCommand command, IDocument document, IStructuredModel model) {
- try {
- if (command.text.equals("/") && (document.getLength() >= 1) && document.get(command.offset - 1, 1).equals("<") && isPreferenceEnabled(XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS)) { //$NON-NLS-1$ //$NON-NLS-2$
- IDOMNode parentNode = (IDOMNode) ((IDOMNode) model.getIndexedRegion(command.offset - 1)).getParentNode();
- if (isCommentNode(parentNode)) {
- // loop and find non comment node parent
- while ((parentNode != null) && isCommentNode(parentNode)) {
- parentNode = (IDOMNode) parentNode.getParentNode();
- }
- }
-
- if (!isDocumentNode(parentNode)) {
- // only add end tag if one does not already exist or if
- // add '/' does not create one already
- IStructuredDocumentRegion endTagStructuredDocumentRegion = parentNode.getEndStructuredDocumentRegion();
- IDOMNode ancestor = parentNode;
- boolean smartInsertForEnd = false;
- if(endTagStructuredDocumentRegion != null) {
- // Look for ancestors by the same name that are missing end tags
- while((ancestor = (IDOMNode) ancestor.getParentNode()) != null) {
- if(ancestor.getEndStructuredDocumentRegion() == null && parentNode.getNodeName().equals(ancestor.getNodeName())) {
- smartInsertForEnd = true;
- break;
- }
- }
- }
- if (endTagStructuredDocumentRegion == null || smartInsertForEnd) {
- StringBuffer toAdd = new StringBuffer(parentNode.getNodeName());
- if (toAdd.length() > 0) {
- toAdd.append(">"); //$NON-NLS-1$
- String suffix = toAdd.toString();
- if ((document.getLength() < command.offset + suffix.length()) || (!suffix.equals(document.get(command.offset, suffix.length())))) {
- command.text += suffix;
- }
- }
- }
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
-
- /**
- * Checks if <code>node</code> has an unclosed ancestor by the same name
- *
- * @param node the node to check
- * @return true if <code>node</code> has an unclosed parent with the same node name
- */
- private boolean hasUnclosedAncestor(IDOMNode node) {
- IDOMNode parent = (IDOMNode) node.getParentNode();
- while (parent != null && parent.getNodeType() != Node.DOCUMENT_NODE && parent.getNodeName().equals(node.getNodeName())) {
- if (!parent.isClosed())
- return true;
- parent = (IDOMNode) parent.getParentNode();
- }
- return false;
- }
-
- /**
- * Return the active text editor if possible, otherwise the active editor
- * part.
- *
- * @return Object
- */
- private Object getActiveTextEditor() {
- IWorkbenchWindow window = PlatformUI.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.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
deleted file mode 100644
index e2c878ba9a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentAssistProcessor.java
+++ /dev/null
@@ -1,2509 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.eclipse.jface.text.ITextViewer;
-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.osgi.util.NLS;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.encoding.ContentTypeEncodingPreferences;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor;
-import org.eclipse.wst.sse.ui.internal.IReleasable;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMEntityDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.eclipse.wst.xml.ui.internal.taginfo.MarkupTagInfoProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * @deprecated This class is no longer used locally and will be removed in the future
- * @see StructuredContentAssistProcessor
- */
-abstract public class AbstractContentAssistProcessor implements IContentAssistProcessor, IReleasable {
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- private class DOMJSPRegionContextsPrivateCopy {
- private static final String JSP_CLOSE = "JSP_CLOSE"; //$NON-NLS-1$
- private static final String JSP_COMMENT_CLOSE = "JSP_COMMENT_CLOSE"; //$NON-NLS-1$
-
- private static final String JSP_COMMENT_OPEN = "JSP_COMMENT_OPEN"; //$NON-NLS-1$
- private static final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
- private static final String JSP_DIRECTIVE_CLOSE = "JSP_DIRECTIVE_CLOSE"; //$NON-NLS-1$
- private static final String JSP_DIRECTIVE_NAME = "JSP_DIRECTIVE_NAME"; //$NON-NLS-1$
-
- private static final String JSP_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
- private static final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
-
- private static final String JSP_ROOT_TAG_NAME = "JSP_ROOT_TAG_NAME"; //$NON-NLS-1$
-
- private static final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
-
- }
-
- protected static final String INTERNALERROR = XMLUIMessages.SEVERE_internal_error_occu_UI_;
- protected static final String UNKNOWN_ATTR = XMLUIMessages.No_known_attribute__UI_;
- protected static final String UNKNOWN_CONTEXT = XMLUIMessages.Content_Assist_not_availab_UI_;
- protected char completionProposalAutoActivationCharacters[] = null;
- protected char contextInformationAutoActivationCharacters[] = null;
- private AttributeContextInformationProvider fAttributeInfoProvider = null;
- private AttributeContextInformationPresenter fContextInformationPresenter = null;
-
- protected String fErrorMessage = null;
- protected XMLContentModelGenerator fGenerator;
- // protected IResource resource = null;
- protected MarkupTagInfoProvider fInfoProvider = null;
- protected ITextViewer fTextViewer = null;
-
- private final boolean showValues = true;
-
- public AbstractContentAssistProcessor() {
- init();
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- IStructuredDocumentRegion sdRegion = contentAssistRequest.getDocumentRegion();
- // retrieve the list of attributes
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- }
- attributes = allAttributes;
-
- String matchString = contentAssistRequest.getMatchString();
-
- // check whether an attribute really exists for the replacement
- // offsets AND if it possesses a value
- boolean attrAtLocationHasValue = false;
- NamedNodeMap attrs = node.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- AttrImpl existingAttr = (AttrImpl) attrs.item(i);
- ITextRegion name = existingAttr.getNameRegion();
-
- if ((sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) && (existingAttr.getValueRegion() != null)) {
- attrAtLocationHasValue = true;
- break;
- }
- }
-
- // only add proposals for the attributes whose names begin with
- // the matchstring
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i);
-
- int isRequired = 0;
- if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
- isRequired = XMLRelevanceConstants.R_REQUIRED;
- }
-
- boolean showAttribute = true;
- showAttribute = showAttribute && beginsWith(getRequiredName(node, attrDecl), matchString.trim());
- AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
- ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null;
- // nameRegion.getEndOffset() + 1 is required to allow for
- // matches against the full name of an existing Attr
- showAttribute = showAttribute && ((attr == null) || ((nameRegion != null) && (sdRegion.getStartOffset(nameRegion) <= contentAssistRequest.getReplacementBeginPosition()) && (sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength())));
- if (showAttribute) {
- Image attrImage = CMImageUtil.getImage(attrDecl);
- if (attrImage == null) {
- if (isRequired > 0) {
- attrImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATT_REQ_OBJ);
- }
- else {
- attrImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- }
- }
-
- String proposedText = null;
- String proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
- CustomCompletionProposal proposal = null;
- // attribute is at this location and already exists
- if (attrAtLocationHasValue) {
- // only propose the name
- proposedText = getRequiredName(node, attrDecl);
- proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), attrImage, proposedText, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true);
- }
- // no attribute exists or is elsewhere, generate
- // minimally
- else {
- Attr existingAttrNode = (Attr) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
- String value = null;
- if (existingAttrNode != null) {
- value = existingAttrNode.getNodeValue();
- }
- if ((value != null) && (value.length() > 0)) {
- proposedText = getRequiredName(node, attrDecl);
- }
- else {
- proposedText = getRequiredText(node, attrDecl);
- }
- proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), attrDecl.getNodeName().length() + 2, attrImage,
- // if the value isn't empty (no empty set of
- // quotes), show it
- // BUG 203494, content strings may have "", but not be empty
- // An empty string is when there's no content between double quotes
- // and there is no single quote that may be encasing a double quote
- (showValues && (proposedText.lastIndexOf('\"') - proposedText.indexOf('\"') == 1 && proposedText.indexOf('\'') == -1)) ? getRequiredName(node, attrDecl) : proposedText,
- null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired);
- }
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- else {
- setErrorMessage(NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{node.getNodeName()})));
- }
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
-
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
-
- // Find the attribute region and name for which this position should
- // have a value proposed
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if (i < 0) {
- return;
- }
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- break;
- }
- }
-
- // the name region is REQUIRED to do anything useful
- if (nameRegion != null) {
- // Retrieve the declaration
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
-
- // String attributeName = nameRegion.getText();
- String attributeName = open.getText(nameRegion);
-
- CMAttributeDeclaration attrDecl = null;
-
- // No CMElementDeclaration means no attribute metadata, but
- // retrieve the
- // declaration for the attribute otherwise
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes) {
- private Map caseInsensitive;
-
- private Map getCaseInsensitiveMap() {
- if(caseInsensitive == null)
- caseInsensitive = new HashMap();
- return caseInsensitive;
- }
-
- public CMNode getNamedItem(String name) {
- CMNode node = super.getNamedItem(name);
- if (node == null) {
- node = (CMNode) getCaseInsensitiveMap().get(name.toLowerCase(Locale.US));
- }
- return node;
- }
-
- public void put(CMNode cmNode) {
- super.put(cmNode);
- getCaseInsensitiveMap().put(cmNode.getNodeName().toLowerCase(Locale.US), cmNode);
- }
- };
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- }
- attributes = allAttributes;
-
- String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
- if (attributes != null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
- if (attrDecl == null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attributeName);
- }
- }
- if (attrDecl == null) {
- setErrorMessage(UNKNOWN_ATTR, attributeName);
- }
- }
-
- String currentValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();
- String proposedInfo = null;
- Image image = CMImageUtil.getImage(attrDecl);
- if (image == null) {
- if ((attrDecl != null) && (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED)) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATT_REQ_OBJ);
- }
- else {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- }
- }
-
- if ((attrDecl != null) && (attrDecl.getAttrType() != null)) {
- // attribute is known, prompt with values from the declaration
- proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
- List possibleValues = getPossibleDataTypeValues(node, attrDecl);
- String defaultValue = attrDecl.getAttrType().getImpliedValue();
- if (possibleValues.size() > 0 || defaultValue != null) {
- // ENUMERATED VALUES
- String matchString = contentAssistRequest.getMatchString();
- if (matchString == null) {
- matchString = ""; //$NON-NLS-1$
- }
- if ((matchString.length() > 0) && (matchString.startsWith("\"") || matchString.startsWith("'"))) {
- matchString = matchString.substring(1);
- }
- boolean currentValid = false;
-
- // d210858, if the region's a container, don't suggest the
- // enumerated values as they probably won't help
- boolean existingComplicatedValue = (contentAssistRequest.getRegion() != null) && (contentAssistRequest.getRegion() instanceof ITextRegionContainer);
- if (!existingComplicatedValue) {
- int rOffset = contentAssistRequest.getReplacementBeginPosition();
- int rLength = contentAssistRequest.getReplacementLength();
- for (Iterator j = possibleValues.iterator(); j.hasNext();) {
- String possibleValue = (String) j.next();
- if(!possibleValue.equals(defaultValue)) {
- currentValid = currentValid || possibleValue.equals(currentValue);
- if ((matchString.length() == 0) || possibleValue.startsWith(matchString)) {
- String rString = "\"" + possibleValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
- CustomCompletionProposal proposal = new CustomCompletionProposal(rString, rOffset, rLength, possibleValue.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM), rString, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if(defaultValue != null && ((matchString.length() == 0) || defaultValue.startsWith(matchString))) {
- String rString = "\"" + defaultValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
- CustomCompletionProposal proposal = new CustomCompletionProposal(rString, rOffset, rLength, defaultValue.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DEFAULT), rString, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) || (attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) && (attrDecl.getAttrType().getImpliedValue() != null)) {
- // FIXED values
- String value = attrDecl.getAttrType().getImpliedValue();
- if ((value != null) && (value.length() > 0)) {
- String rValue = "\"" + value + "\"";//$NON-NLS-2$//$NON-NLS-1$
- CustomCompletionProposal proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- if ((currentValue.length() > 0) && !value.equals(currentValue)) {
- rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
- proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- else {
- // unknown attribute, so supply nice empty values
- proposedInfo = getAdditionalInfo(null, elementDecl);
- CustomCompletionProposal proposal = null;
- if ((currentValue != null) && (currentValue.length() > 0)) {
- String rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
- proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- else {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
- }
-
- protected void addCommentProposal(ContentAssistRequest contentAssistRequest) {
- contentAssistRequest.addProposal(new CustomCompletionProposal("<!-- -->", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 5, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_COMMENT), NLS.bind(XMLUIMessages.Comment__, (new Object[]{" <!-- -->"})), //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_COMMENT));
- }
-
- /**
- * Add all of the element declarations int the CMContent object into one
- * big list.
- */
- protected void addContent(List contentList, CMContent content) {
- if (content == null) {
- return;
- }
- if (content instanceof CMGroup) {
- CMNodeList children = ((CMGroup) content).getChildNodes();
- if (children == null) {
- return;
- }
- for (int i = 0; i < children.getLength(); i++) {
- CMNode child = children.item(i);
- if (child.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- contentList.add(child);
- }
- else {
- if (child.getNodeType() == CMNode.GROUP) {
- addContent(contentList, (CMContent) child);
- }
- else {
- throw new IllegalArgumentException("Unknown content child: " + child); //$NON-NLS-1$
- }
- }
- }
- }
- else {
- contentList.add(content);
- }
- }
-
- protected void addDocTypeProposal(ContentAssistRequest contentAssistRequest) {
- // if a DocumentElement exists, use that for the root Element name
- String rootname = "unspecified"; //$NON-NLS-1$
- if (contentAssistRequest.getNode().getOwnerDocument().getDocumentElement() != null) {
- rootname = contentAssistRequest.getNode().getOwnerDocument().getDocumentElement().getNodeName();
- }
-
- String proposedText = "<!DOCTYPE " + rootname + " PUBLIC \"//UNKNOWN/\" \"unknown.dtd\">"; //$NON-NLS-1$ //$NON-NLS-2$
- ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 10, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DOCTYPE), "<!DOCTYPE ... >", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_DOCTYPE);
- // TODO provide special documentation on doc type
- contentAssistRequest.addProposal(proposal);
- }
-
- /**
- * Add the proposals for a completely empty document
- */
- protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
- // nothing
- }
-
- /**
- * Add the proposals for the name in an end tag
- */
- protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest) {
-
- if (contentAssistRequest.getStartOffset() + contentAssistRequest.getRegion().getTextLength() < contentAssistRequest.getReplacementBeginPosition()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC), NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_END_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- else {
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- Node aNode = contentAssistRequest.getNode();
- String matchString = contentAssistRequest.getMatchString();
- if (matchString.startsWith("</")) {
- matchString = matchString.substring(2);
- }
- while (aNode != null) {
- if (aNode.getNodeType() == Node.ELEMENT_NODE) {
- if (aNode.getNodeName().startsWith(matchString)) {
- IDOMNode aXMLNode = (IDOMNode) aNode;
- CMElementDeclaration ed = modelQuery.getCMElementDeclaration((Element) aNode);
- if ((aXMLNode.getEndStructuredDocumentRegion() == null) && ((ed == null) || (ed.getContentType() != CMElementDeclaration.EMPTY))) {
- String replacementText = aNode.getNodeName();
- String displayText = replacementText;
- String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
- if(!contentAssistRequest.getDocumentRegion().isEnded()) {
- replacementText += ">"; //$NON-NLS-1$
- }
- CustomCompletionProposal proposal = null;
- // double check to see if the region acted upon is
- // a tag name; replace it if so
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- if (contentAssistRequest.getRegion().getType() == DOMRegionContext.XML_TAG_NAME) {
- proposal = new CustomCompletionProposal(replacementText, contentAssistRequest.getStartOffset(), contentAssistRequest.getRegion().getTextLength(), replacementText.length(), image, displayText, null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
- }
- else {
- proposal = new CustomCompletionProposal(replacementText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), replacementText.length(), image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{"'" + displayText + "'"})), //$NON-NLS-1$ //$NON-NLS-2$
- null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
- }
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- aNode = aNode.getParentNode();
- }
- }
- }
-
- /**
- * Prompt for end tags to a non-empty Node that hasn't ended Handles these
- * cases: <br>
- * <tagOpen>| <br>
- * <tagOpen>< |<br>
- * <tagOpen></ |
- *
- * @param contentAssistRequest
- */
- protected void addEndTagProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
-
- if (isCommentNode(node)) {
- // loop and find non comment node parent
- while ((node != null) && isCommentNode(node)) {
- node = (IDOMNode) node.getParentNode();
- }
- }
-
- // node is already closed
- if (node.isClosed()) {
- // loop and find non comment unclose node parent
- while ((node != null) && node.isClosed()) {
- node = (IDOMNode) node.getParentNode();
- }
- }
- // there were no unclosed tags
- if (node == null) {
- return;
- }
-
- // data to create a CustomCompletionProposal
- String replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
- int replaceBegin = contentAssistRequest.getReplacementBeginPosition();
- int replaceLength = contentAssistRequest.getReplacementLength();
- int cursorOffset = node.getNodeName().length() + 1;
- String displayString = ""; //$NON-NLS-1$
- String proposedInfo = ""; //$NON-NLS-1$
- Image image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
-
- setErrorMessage(null);
- boolean addProposal = false;
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- // ////////////////////////////////////////////////////////////////////////////////////
- IStructuredDocument sDoc = (IStructuredDocument) fTextViewer.getDocument();
- IStructuredDocumentRegion xmlEndTagOpen = sDoc.getRegionAtCharacterOffset(contentAssistRequest.getReplacementBeginPosition());
- // skip backward to "<", "</", or the (unclosed) start tag, null
- // if not found
- String type = ""; //$NON-NLS-1$
- while ((xmlEndTagOpen != null) && ((type = xmlEndTagOpen.getType()) != DOMRegionContext.XML_END_TAG_OPEN) && (type != DOMRegionContext.XML_TAG_CLOSE) && !needsEndTag(xmlEndTagOpen) && (type != DOMRegionContext.XML_TAG_OPEN)) {
- xmlEndTagOpen = xmlEndTagOpen.getPrevious();
- }
-
- if (xmlEndTagOpen == null) {
- return;
- }
-
- node = (IDOMNode) node.getModel().getIndexedRegion(xmlEndTagOpen.getStartOffset());
- node = (IDOMNode) node.getParentNode();
-
- if (isStartTag(xmlEndTagOpen)) {
- // this is the case for a start tag w/out end tag
- // eg:
- // <p>
- // <% String test = "test"; %>
- // |
- if (needsEndTag(xmlEndTagOpen)) {
- String tagName = getTagName(xmlEndTagOpen);
- xmlEndTagOpen.getTextEndOffset();
- replaceLength = 0;
- replaceText = "</" + tagName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
- // replaceText = "</" + node.getNodeName() + ">";
- // //$NON-NLS-1$ $NON-NLS-2$
- cursorOffset = tagName.length() + 3;
- displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{tagName}));
- addProposal = true;
- }
- }
- else if (type == DOMRegionContext.XML_END_TAG_OPEN) {
- // this is the case for: <tag> </ |
- // possibly <tag> </ |<anotherTag>
- // should only be replacing white space...
- replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
- replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
- cursorOffset = replaceText.length();
- replaceBegin = xmlEndTagOpen.getTextEndOffset();
- displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{node.getNodeName()}));
- addProposal = true;
- }
- else if (type == DOMRegionContext.XML_TAG_OPEN) {
- // this is the case for: <tag> < |
- replaceText = "/" + node.getNodeName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
- cursorOffset = replaceText.length();
- // replaceText = "/" + node.getNodeName() + ">"; //$NON-NLS-1$
- // $NON-NLS-2$
- // should only be replacing white space...
- replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
- replaceBegin = xmlEndTagOpen.getTextEndOffset();
- displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{"/" + node.getNodeName()})); //$NON-NLS-1$
- addProposal = true;
- }
- }
- // ////////////////////////////////////////////////////////////////////////////////////
- // sometimes the node is not null, but
- // getNodeValue() is null, put in a null check
- else if ((node.getNodeValue() != null) && (node.getNodeValue().indexOf("</") != -1)) { //$NON-NLS-1$
- // the case where "</" is started, but the nodes comes in as a
- // text node (instead of element)
- // like this: <tag> </|
- Node parent = node.getParentNode();
- if ((parent != null) && (parent.getNodeType() != Node.DOCUMENT_NODE)) {
- replaceText = parent.getNodeName() + ">"; //$NON-NLS-1$
- cursorOffset = replaceText.length();
- displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{parent.getNodeName()}));
- setErrorMessage(null);
- addProposal = true;
- }
- }
- // ////////////////////////////////////////////////////////////////////////////////////
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
- if (addProposal == true) {
- CustomCompletionProposal proposal = new CustomCompletionProposal(replaceText, replaceBegin, replaceLength, cursorOffset, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_END_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- protected void addEntityProposals(ContentAssistRequest contentAssistRequest, int documentPosition, ITextRegion completionRegion, IDOMNode treeNode) {
- ICompletionProposal[] eps = computeEntityReferenceProposals(documentPosition, completionRegion, treeNode);
- for (int i = 0; (eps != null) && (i < eps.length); i++) {
- contentAssistRequest.addProposal(eps[i]);
- }
- }
-
- protected void addEntityProposals(Vector proposals, Properties map, String key, int nodeOffset, IStructuredDocumentRegion sdRegion, ITextRegion completionRegion) {
- if (map == null) {
- return;
- }
- String entityName = ""; //$NON-NLS-1$
- String entityValue = ""; //$NON-NLS-1$
- Image entityIcon = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENTITY_REFERENCE);
- String replacementText = ""; //$NON-NLS-1$
- String displayString = ""; //$NON-NLS-1$
- Enumeration keys = map.keys();
-
- while ((keys != null) && keys.hasMoreElements()) {
- entityName = (String) keys.nextElement();
- entityValue = map.getProperty(entityName);
- // filter based on partial entity string...
- if (entityName.toLowerCase().startsWith(key.toLowerCase()) || key.trim().equals("")) //$NON-NLS-1$
- {
- // figure out selection...if text is selected, add it to
- // selection length
- int selectionLength = nodeOffset;
- if (fTextViewer != null) {
- selectionLength += fTextViewer.getSelectedRange().y;
- }
- // create a new proposal for entity string...
- replacementText = "&" + entityName + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- displayString = "&" + entityName + "; (" + entityValue + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ICompletionProposal cp = new CustomCompletionProposal(replacementText, sdRegion.getStartOffset(completionRegion), selectionLength, replacementText.length(), entityIcon, displayString, null, null, XMLRelevanceConstants.R_ENTITY);
- if (cp != null) {
- proposals.add(cp);
- }
- }
- }
- }
-
- protected void addPCDATAProposal(String nodeName, ContentAssistRequest contentAssistRequest) {
- CustomCompletionProposal proposal = new CustomCompletionProposal("<![CDATA[]]>", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 9, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_CDATASECTION), "CDATA Section", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_CDATA);
- contentAssistRequest.addProposal(proposal);
-
- proposal = new CustomCompletionProposal(nodeName, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), nodeName.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT), "#PCDATA", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_CDATA);
- contentAssistRequest.addProposal(proposal);
- }
-
- protected void addStartDocumentProposals(ContentAssistRequest contentAssistRequest) {
- Node aNode = contentAssistRequest.getNode();
- boolean xmlpiFound = false;
- Document owningDocument = aNode.getOwnerDocument();
- // ==> // int xmlpiNodePosition = -1;
-
- // make sure xmlpi is root element
- // don't want doctype proposal if XMLPI isn't first element...
- Node first = owningDocument.getFirstChild();
- boolean xmlpiIsFirstElement = ((first != null) && (first.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE));
- boolean insertDoctype = xmlpiIsFirstElement;
-
- for (Node child = owningDocument.getFirstChild(); child != null; child = child.getNextSibling()) {
- boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$
- xmlpiFound = xmlpiFound || xmlpi;
- if (xmlpiFound) {
- if (child instanceof IDOMNode) {
- // ==> // int xmlpiNodePosition =
- // ((XMLNode)child).getEndOffset();
- }
- // skip white space and text
- while (((child = child.getNextSibling()) != null) && (child.getNodeType() == Node.TEXT_NODE)) {
- // just skipping
- }
- // check if theres a node inbetween XMLPI and cursor position
- if ((child != null) && (child instanceof IDOMNode)) {
- if ((contentAssistRequest.getReplacementBeginPosition() >= ((IDOMNode) child).getEndOffset()) || !xmlpiIsFirstElement) {
- insertDoctype = false;
- }
- }
- break;
- }
- }
-
- if (xmlpiFound && (owningDocument.getDoctype() == null) && isCursorAfterXMLPI(contentAssistRequest) && insertDoctype) {
- addDocTypeProposal(contentAssistRequest);
- }
- }
-
- /**
- * Close an unclosed start tag
- */
- protected void addTagCloseProposals(ContentAssistRequest contentAssistRequest) {
- IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
- if (node.getNodeType() == Node.ELEMENT_NODE) {
-
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
- String proposedInfo = (elementDecl != null) ? getAdditionalInfo(null, elementDecl) : null;
- int contentType = (elementDecl != null) ? elementDecl.getContentType() : CMElementDeclaration.ANY;
- // if it's XML and content doesn't HAVE to be element, add "/>"
- // proposal.
- boolean endWithSlashBracket = (getXML(node) && (contentType != CMElementDeclaration.ELEMENT));
-
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- // is the start tag ended properly?
- if ((contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion()) && !(node.getFirstStructuredDocumentRegion()).isEnded()) {
- setErrorMessage(null);
- // Is this supposed to be an empty tag? Note that if we can't
- // tell, we assume it's not.
- if ((elementDecl != null) && (elementDecl.getContentType() == CMElementDeclaration.EMPTY)) {
- // prompt with a self-closing end character if needed
- CustomCompletionProposal proposal = new CustomCompletionProposal(getContentGenerator().getStartTagClose(node, elementDecl), contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the length --
- // always insert
- // contentAssistRequest.getReplacementLength(),
- 0, getContentGenerator().getStartTagClose(node, elementDecl).length(), image, NLS.bind(XMLUIMessages.Close_with___, (new Object[]{getContentGenerator().getStartTagClose(node, elementDecl)})), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- else {
- // prompt with a close for the start tag
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the
- // length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
-
- // prompt with the closer for the start tag and an end tag
- // if one is not present
- if (node.getEndStructuredDocumentRegion() == null) {
- // make sure tag name is actually what it thinks it
- // is...(eg. <%@ vs. <jsp:directive)
- IStructuredDocumentRegion sdr = contentAssistRequest.getDocumentRegion();
- String openingTagText = (sdr != null) ? sdr.getFullText() : ""; //$NON-NLS-1$
- if ((openingTagText != null) && (openingTagText.indexOf(node.getNodeName()) != -1)) {
- proposal = new CustomCompletionProposal("></" + node.getNodeName() + ">", //$NON-NLS-2$//$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to
- // ignore the length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[]{node.getNodeName()})), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- // prompt with slash bracket "/>" incase if it's a self
- // ending tag
- if (endWithSlashBracket) {
- proposal = new CustomCompletionProposal("/>", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore
- // the length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 2, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" \"/>\""})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG + 1); // +1
- // to
- // bring
- // to
- // top
- // of
- // list
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- else if ((contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion()) && !node.getLastStructuredDocumentRegion().isEnded()) {
- setErrorMessage(null);
- // prompt with a closing end character for the end tag
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the
- // length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- String error = null;
-
- // (nsd) This is only valid at the document element level
- // only valid if it's XML (check added 2/17/2004)
- if ((parent != null) && (parent.getNodeType() == Node.DOCUMENT_NODE) && ((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest)) {
- return;
- }
- // only want proposals if cursor is after doctype...
- if (!isCursorAfterDoctype(contentAssistRequest)) {
- return;
- }
-
- // fix for meta-info comment nodes.. they currently "hide" other
- // proposals because the don't
- // have a content model (so can't propose any children..)
- if ((parent != null) && (parent instanceof IDOMNode) && isCommentNode((IDOMNode) parent)) {
- // loop and find non comment node?
- while ((parent != null) && isCommentNode((IDOMNode) parent)) {
- parent = parent.getParentNode();
- }
- }
-
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- // XSD-specific ability - no filtering
- CMDataType childType = parentDecl.getDataType();
- if (childType != null) {
- String[] childStrings = childType.getEnumeratedValues();
- String defaultValue = childType.getImpliedValue();
- if (childStrings != null || defaultValue != null) {
- // the content string is the sole valid child...so
- // replace the rest
- int begin = contentAssistRequest.getReplacementBeginPosition();
- int length = contentAssistRequest.getReplacementLength();
- if (parent instanceof IDOMNode) {
- if (((IDOMNode) parent).getLastStructuredDocumentRegion() != ((IDOMNode) parent).getFirstStructuredDocumentRegion()) {
- begin = ((IDOMNode) parent).getFirstStructuredDocumentRegion().getEndOffset();
- length = ((IDOMNode) parent).getLastStructuredDocumentRegion().getStartOffset() - begin;
- }
- }
- String proposedInfo = getAdditionalInfo(parentDecl, childType);
- for (int i = 0; i < childStrings.length; i++) {
- if(!childStrings[i].equals(defaultValue))
- {
- CustomCompletionProposal textProposal = new CustomCompletionProposal(childStrings[i], begin, length, childStrings[i].length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM), childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(textProposal);
- }
- }
- if(defaultValue != null) {
- CustomCompletionProposal textProposal = new CustomCompletionProposal(defaultValue, begin, length, defaultValue.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DEFAULT), defaultValue, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(textProposal);
- }
- }
- }
- }
- if ((parentDecl != null) && (parentDecl.getContentType() == CMElementDeclaration.PCDATA)) {
- addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest);
- }
- else {
- // retrieve the list of all possible children within this
- // parent context
- cmnodes = getAvailableChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
-
- // retrieve the list of the possible children within this
- // parent context and at this index
- List strictCMNodeSuggestions = null;
- if (XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY))) {
- strictCMNodeSuggestions = getValidChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
- }
- Iterator nodeIterator = cmnodes.iterator();
- if (!nodeIterator.hasNext()) {
- if (getCMElementDeclaration(parent) != null) {
- error = NLS.bind(XMLUIMessages._Has_no_available_child, (new Object[]{parent.getNodeName()}));
- }
- else {
- error = NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{parent.getNodeName()}));
- }
- }
- String matchString = contentAssistRequest.getMatchString();
- // chop off any leading <'s and whitespace from the
- // matchstring
- while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) {
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- }
- while (nodeIterator.hasNext()) {
- Object o = nodeIterator.next();
- if (o instanceof CMElementDeclaration) {
- CMElementDeclaration elementDecl = (CMElementDeclaration) o;
- // only add proposals for the child element's that
- // begin with the matchstring
- String tagname = getRequiredName(parent, elementDecl);
- boolean isStrictCMNodeSuggestion = strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false;
-
- Image image = CMImageUtil.getImage(elementDecl);
-
- if (image == null) {
- if (strictCMNodeSuggestions != null) {
- image = isStrictCMNodeSuggestion ? XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_EMPHASIZED) : XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_DEEMPHASIZED);
- }
- else {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- }
-
- // int markupAdjustment =
- // getContentGenerator().getMinimalStartTagLength(parent,
- // elementDecl);
- if (beginsWith(tagname, matchString)) {
- String proposedText = getRequiredText(parent, elementDecl);
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
- // place cursor in first empty quotes
- int markupAdjustment = getCursorPositionForProposedText(proposedText);
-
- String proposedInfo = getAdditionalInfo(parentDecl, elementDecl);
- int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION : XMLRelevanceConstants.R_TAG_INSERTION;
- CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null) {
- setErrorMessage(error);
- }
- else if ((contentAssistRequest.getMatchString() != null) && (contentAssistRequest.getMatchString().length() > 0)) {
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\"."
- }
- else {
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()})));
- }
- }
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- // Can only prompt with elements if the cursor position is past
- // the XML processing
- // instruction and DOCTYPE declaration
- boolean xmlpiFound = false;
- boolean doctypeFound = false;
- int minimumOffset = -1;
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
-
- boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$
- boolean doctype = child.getNodeType() == Node.DOCUMENT_TYPE_NODE;
- if (xmlpi || (doctype && (minimumOffset < 0))) {
- minimumOffset = ((IDOMNode) child).getFirstStructuredDocumentRegion().getStartOffset() + ((IDOMNode) child).getFirstStructuredDocumentRegion().getTextLength();
- }
- xmlpiFound = xmlpiFound || xmlpi;
- doctypeFound = doctypeFound || doctype;
- }
-
- if (contentAssistRequest.getReplacementBeginPosition() >= minimumOffset) {
- List childDecls = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childDecls.size(); i++) {
- CMElementDeclaration ed = (CMElementDeclaration) childDecls.get(i);
- if (ed != null) {
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedText = getRequiredText(parent, ed);
- String tagname = getRequiredName(parent, ed);
- // account for the &lt; and &gt;
- int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, ed);
- String proposedInfo = getAdditionalInfo(null, ed);
- CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), markupAdjustment, image, tagname, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- }
-
- protected void addTagNameProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- String error = null;
- String matchString = contentAssistRequest.getMatchString();
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- // retrieve the list of children
- // validActions = getAvailableChildrenAtIndex((Element) parent,
- // childPosition);
- cmnodes = getAvailableChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
- Iterator nodeIterator = cmnodes.iterator();
- // chop off any leading <'s and whitespace from the matchstring
- while ((matchString.length() > 0) && (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) {
- //$NON-NLS-1$
- matchString = matchString.substring(1);
- }
- if (!nodeIterator.hasNext()) {
- error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}));
- }
- while (nodeIterator.hasNext()) {
- CMNode elementDecl = (CMNode) nodeIterator.next();
- if (elementDecl != null) {
- // only add proposals for the child element's that begin
- // with the matchstring
- String proposedText = null;
- int cursorAdjustment = 0;
-
- // do a check to see if partial attributes of partial tag
- // names are in list
- if (((node != null) && (node.getAttributes() != null) && (node.getAttributes().getLength() > 0) && attributeInList(node, parent, elementDecl)) || ((node.getNodeType() != Node.TEXT_NODE) && node.getFirstStructuredDocumentRegion().isEnded())) {
-
- proposedText = getRequiredName(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- }
- else {
- proposedText = getRequiredName(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- if (elementDecl instanceof CMElementDeclaration) {
- CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
- StringBuffer sb = new StringBuffer();
- getContentGenerator().generateTag(parent, ed, sb);
- // since it's a name proposal, assume '<' is
- // already there
- // only return the rest of the tag
- proposedText = sb.toString().substring(1);
- cursorAdjustment = getCursorPositionForProposedText(proposedText);
-
- // cursorAdjustment = proposedText.length() +
- // 1;
- // proposedText += "></" +
- // getRequiredName(parent, elementDecl) + ">";
- // //$NON-NLS-2$//$NON-NLS-1$
- }
- }
- if (beginsWith(proposedText, matchString)) {
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
- CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, elementDecl), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null) {
- setErrorMessage(error);
- }
- else if ((contentAssistRequest.getMatchString() != null) && (contentAssistRequest.getMatchString().length() > 0)) {
- setErrorMessage(NLS.bind(XMLUIMessages.No_known_child_tag_names, (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- //$NON-NLS-1$ = "No known child tag names of <{0}> begin with \"{1}\""
- }
- else {
- setErrorMessage(NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()})));
- }
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- List childElements = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childElements.size(); i++) {
- CMNode ed = (CMNode) childElements.get(i);
- if (ed == null) {
- continue;
- }
- String proposedText = null;
- int cursorAdjustment = 0;
- if (ed instanceof CMElementDeclaration) {
- // proposedText = getRequiredName(parent, ed);
- StringBuffer sb = new StringBuffer();
- getContentGenerator().generateTag(parent, (CMElementDeclaration) ed, sb);
- // tag starts w/ '<', but we want to compare to name
- proposedText = sb.toString().substring(1);
-
- if (!beginsWith(proposedText, matchString)) {
- continue;
- }
-
- cursorAdjustment = getCursorPositionForProposedText(proposedText);
-
- String proposedInfo = getAdditionalInfo(null, ed);
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
- CustomCompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), cursorAdjustment, image, getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
-
- /**
- * this is the position the cursor should be in after the proposal is
- * applied
- *
- * @param proposedText
- * @return the position the cursor should be in after the proposal is
- * applied
- */
- private int getCursorPositionForProposedText(String proposedText) {
- int cursorAdjustment;
- cursorAdjustment = proposedText.indexOf("\"\"") + 1; //$NON-NLS-1$
- // otherwise, after the first tag
- if (cursorAdjustment == 0) {
- cursorAdjustment = proposedText.indexOf('>') + 1;
- }
- if (cursorAdjustment == 0) {
- cursorAdjustment = proposedText.length() + 1;
- }
-
- return cursorAdjustment;
- }
-
- /**
- * @deprecated XML proposal is added via xml declaration template instead
- */
- protected void addXMLProposal(ContentAssistRequest contentAssistRequest) {
- String proposedText = "<?xml version=\"1.0\" encoding=\"" + ContentTypeEncodingPreferences.getUserPreferredCharsetName(ContentTypeIdForXML.ContentTypeID_XML) + "\"?>"; //$NON-NLS-2$//$NON-NLS-1$
- ICompletionProposal proposal = new CustomCompletionProposal(proposedText, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), proposedText.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION), proposedText, null, null, XMLRelevanceConstants.R_XML_DECLARATION);
- // TODO add special XML proposal info
- contentAssistRequest.addProposal(proposal);
- }
-
- /**
- * This method determines if any of the attributes in the proposed XMLNode
- * node, are possible values of attributes from possible Elements at this
- * point in the document according to the Content Model.
- *
- * @param node
- * the element with attributes that you would like to test if
- * are possible for possible Elements at this point
- * @param cmnode
- * possible element at this point in the document (depending on
- * what 'node' is) true if any attributes of 'node' match any
- * possible attributes from 'cmnodes' list.
- */
- protected boolean attributeInList(IDOMNode node, Node parent, CMNode cmnode) {
- if ((node == null) || (parent == null) || (cmnode == null)) {
- return false;
- }
- String elementMatchString = node.getNodeName();
- String cmnodeName = getRequiredName(parent, cmnode);// cmnode.getNodeName();
- if (node instanceof Element) {
- NamedNodeMap map = ((Element) node).getAttributes();
- String attrMatchString = ""; //$NON-NLS-1$
- CMNamedNodeMap cmattrMap = null;
- // iterate attribute possibilities for partially started node
- for (int i = 0; (map != null) && (i < map.getLength()); i++) {
- attrMatchString = map.item(i).getNodeName();
- // filter on whatever user typed for element name already
- if (beginsWith(cmnodeName, elementMatchString)) {
- if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- cmattrMap = ((CMElementDeclaration) cmnode).getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(cmattrMap);
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, (CMElementDeclaration) cmnode, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode adnode = (CMNode) nodes.get(k);
- if (adnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(adnode);
- }
- }
- cmattrMap = allAttributes;
-
- // iterate possible attributes from a cmnode in
- // proposal list
- for (int k = 0; (cmattrMap != null) && (k < cmattrMap.getLength()); k++) {
- // check if name matches
- if (cmattrMap.item(k).getNodeName().equals(attrMatchString)) {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
-
- protected boolean beginsWith(String aString, String prefix) {
- if ((aString == null) || (prefix == null)) {
- return true;
- }
- // (pa) matching independent of case to be consistant with Java
- // editor CA
- return aString.toLowerCase().startsWith(prefix.toLowerCase());
- }
-
- protected ContentAssistRequest computeAttributeProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (documentPosition < sdRegion.getStartOffset(completionRegion)) {
- // setup to insert new attributes
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // Setup to replace an existing attribute name
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addAttributeNameProposals(contentAssistRequest);
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- if ((node.getFirstStructuredDocumentRegion() != null) && (!node.getFirstStructuredDocumentRegion().isEnded())) {
- addTagCloseProposals(contentAssistRequest);
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeAttributeValueProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if ((documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) && (sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() != sdRegion.getStartOffset(completionRegion) + completionRegion.getLength())) {
- // setup to add a new attribute at the documentPosition
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- addAttributeNameProposals(contentAssistRequest);
- if ((actualNode.getFirstStructuredDocumentRegion() != null) && !actualNode.getFirstStructuredDocumentRegion().isEnded()) {
- addTagCloseProposals(contentAssistRequest);
- }
- }
- else {
- // setup to replace the existing value
- if (!nodeAtOffset.getFirstStructuredDocumentRegion().isEnded() && (documentPosition < sdRegion.getStartOffset(completionRegion))) {
- // if the IStructuredDocumentRegion isn't closed and the
- // cursor is in front of the value, add
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- addAttributeNameProposals(contentAssistRequest);
- }
- else {
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- addAttributeValueProposals(contentAssistRequest);
- }
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) {
- ContentAssistRequest contentAssistRequest = null;
- String regionType = completionRegion.getType();
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- // Handle the most common and best supported cases
- if ((xmlnode.getNodeType() == Node.ELEMENT_NODE) || (xmlnode.getNodeType() == Node.DOCUMENT_NODE)) {
- if (regionType == DOMRegionContext.XML_TAG_OPEN) {
- contentAssistRequest = computeTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_TAG_NAME) {
- contentAssistRequest = computeTagNameProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- contentAssistRequest = computeAttributeProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- contentAssistRequest = computeEqualsProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if ((regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) && (documentPosition == sdRegion.getTextEndOffset()) && (sdRegion.getText(completionRegion).endsWith("\"") || sdRegion.getText(completionRegion).endsWith("\'"))) //$NON-NLS-1$ //$NON-NLS-2$
- {
- // this is for when the cursor is at the end of the closing
- // quote for an attribute..
- IDOMNode actualNode = (IDOMNode) xmlnode.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagCloseProposals(contentAssistRequest);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- contentAssistRequest = computeAttributeValueProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if ((regionType == DOMRegionContext.XML_TAG_CLOSE) || (regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE))) {
- contentAssistRequest = computeTagCloseProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if (regionType == DOMRegionContext.XML_END_TAG_OPEN) {
- contentAssistRequest = computeEndTagOpenProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
- else if ((regionType == DOMRegionContext.XML_CONTENT) || (regionType == DOMRegionContext.XML_CHAR_REFERENCE) || (regionType == DOMRegionContext.XML_ENTITY_REFERENCE) || (regionType == DOMRegionContext.XML_PE_REFERENCE)) {
- contentAssistRequest = computeContentProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- }
-
- // These ITextRegion types begin DOM Elements as well and although
- // internally harder to assist,
- // text insertions directly before them can be made
- else if ((documentPosition == sdRegion.getStartOffset(completionRegion)) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || (regionType == DOMRegionContext.XML_DECLARATION_OPEN) || (regionType == DOMRegionContext.XML_PI_OPEN) || (regionType == DOMRegionContext.XML_COMMENT_OPEN) || (regionType == DOMRegionContext.XML_CDATA_OPEN))) {
- contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode));
- addStartDocumentProposals(contentAssistRequest);
- }
- }
- // Not a Document or Element? (odd cases go here for now)
- else if (isCloseRegion(completionRegion)) {
- contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion) + completionRegion.getLength(), 0, matchString);
- addStartDocumentProposals(contentAssistRequest);
- if (documentPosition >= sdRegion.getTextEndOffset(completionRegion)) {
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode) + 1);
- }
- }
- else if ((documentPosition == sdRegion.getStartOffset(completionRegion)) && (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) || regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || (regionType == DOMRegionContext.XML_DECLARATION_OPEN) || (regionType == DOMRegionContext.XML_PI_OPEN) || (regionType == DOMRegionContext.XML_COMMENT_OPEN) || (regionType == DOMRegionContext.XML_CDATA_OPEN))) {
- contentAssistRequest = newContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(treeNode));
- addStartDocumentProposals(contentAssistRequest);
- }
- return contentAssistRequest;
- }
-
- /**
- * CONTENT ASSIST STARTS HERE
- *
- * Return a list of proposed code completions based on the specified
- * location within the document that corresponds to the current cursor
- * position within the text-editor control.
- *
- * @param textViewer
- * @param documentPosition -
- * the cursor location within the document
- *
- * an array of ICompletionProposals
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) {
-
- setErrorMessage(null);
-
- fTextViewer = textViewer;
-
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition);
-
- Node node = (Node) treeNode;
- while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) {
- node = node.getParentNode();
- }
- IDOMNode xmlnode = (IDOMNode) node;
-
- ContentAssistRequest contentAssistRequest = null;
-
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- ITextRegion completionRegion = getCompletionRegion(documentPosition, node);
-
- String matchString = getMatchString(sdRegion, completionRegion, documentPosition);
-
- // Handle empty Documents
- if (completionRegion == null) {
- if (((treeNode == null) || (((Node) treeNode).getNodeType() == Node.DOCUMENT_NODE)) && (completionRegion == null) && ((xmlnode == null) || (xmlnode.getChildNodes() == null) || (xmlnode.getChildNodes().getLength() == 0))) {
- IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(textViewer.getDocument());
- try {
- if (sModel != null) {
- IDOMDocument docNode = ((IDOMModel) sModel).getDocument();
- contentAssistRequest = newContentAssistRequest(docNode, docNode, sdRegion, completionRegion, documentPosition, 0, null);
- addEmptyDocumentProposals(contentAssistRequest);
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- if (contentAssistRequest == null) {
- Logger.logException(new IllegalStateException("problem getting model")); //$NON-NLS-1$
- return new ICompletionProposal[0];
- }
- return contentAssistRequest.getCompletionProposals();
- }
- // MASSIVE ERROR CONDITION
- Logger.logException(new IllegalStateException("completion region was null")); //$NON-NLS-1$
- setErrorMessage(INTERNALERROR);
- contentAssistRequest = newContentAssistRequest((Node) treeNode, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
- return contentAssistRequest.getCompletionProposals();
- }
-
-
- // catch documents where no region can be determined
- if ((xmlnode.getNodeType() == Node.DOCUMENT_NODE) && ((completionRegion == null) || (xmlnode.getChildNodes() == null) || (xmlnode.getChildNodes().getLength() == 0))) {
- contentAssistRequest = computeStartDocumentProposals(documentPosition, matchString, completionRegion, (IDOMNode) treeNode, xmlnode);
- return contentAssistRequest.getCompletionProposals();
- }
-
- // compute normal proposals
- contentAssistRequest = computeCompletionProposals(documentPosition, matchString, completionRegion, (IDOMNode) treeNode, xmlnode);
- if (contentAssistRequest == null) {
- contentAssistRequest = newContentAssistRequest((Node) treeNode, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
- if (Debug.displayWarnings) {
- System.out.println(UNKNOWN_CONTEXT + " " + completionRegion.getType() + "@" + documentPosition); //$NON-NLS-2$//$NON-NLS-1$
- }
- setErrorMessage(UNKNOWN_CONTEXT);
- }
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=123892
- * Only set this error message if nothing else was already set
- **/
- if (contentAssistRequest.getProposals().size() == 0 && getErrorMessage() == null) {
- setErrorMessage(UNKNOWN_CONTEXT);
- }
-
- return contentAssistRequest.getCompletionProposals();
- }
-
- protected ContentAssistRequest computeContentProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
-
- // setup to add children at the content node's position
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, getStructuredDocumentRegion(documentPosition), completionRegion, documentPosition, 0, matchString);
- if ((node != null) && (node.getNodeType() == Node.DOCUMENT_NODE) && (((Document) node).getDoctype() == null)) {
- addStartDocumentProposals(contentAssistRequest);
- }
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- addEndTagProposals(contentAssistRequest);
- }
- // entities?
- addEntityProposals(contentAssistRequest, documentPosition, completionRegion, node);
- // addEntityProposals(contentAssistRequest);
- return contentAssistRequest;
- }
-
- /**
- * Returns information about possible contexts based on the specified
- * location within the document that corresponds to the current cursor
- * position within the text viewer.
- *
- * @param viewer
- * the viewer whose document is used to compute the possible
- * contexts an array of context information objects or
- * <code>null</code> if no context could be found
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- if (fAttributeInfoProvider == null) {
- fAttributeInfoProvider = new AttributeContextInformationProvider((IStructuredDocument) viewer.getDocument(), (AttributeContextInformationPresenter) getContextInformationValidator());
- }
- return fAttributeInfoProvider.getAttributeInformation(documentOffset);
- }
-
- protected ContentAssistRequest computeEndTagOpenProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- int completionRegionStart = sdRegion.getStartOffset(completionRegion);
- int completionRegionLength = completionRegion.getLength();
- IStructuredDocumentRegion sdRegionAtCompletionOffset = node.getStructuredDocument().getRegionAtCharacterOffset(completionRegionStart + completionRegionLength);
- ITextRegion regionAtEndOfCompletion = sdRegionAtCompletionOffset.getRegionAtCharacterOffset(completionRegionStart + completionRegionLength);
-
- if ((documentPosition != completionRegionStart) && (regionAtEndOfCompletion != null) && (regionAtEndOfCompletion.getType() == DOMRegionContext.XML_TAG_NAME)) {
- ITextRegion nameRegion = regionAtEndOfCompletion;
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(nameRegion), nameRegion.getTextLength(), matchString);
- }
- else {
- if (nodeAtOffset.getFirstStructuredDocumentRegion() == sdRegion) {
- // abnormal case, this unmatched end tag will be a sibling
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // normal case, this end tag is the parent
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, nodeAtOffset, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- }
- // if (documentPosition >= sdRegion.getStartOffset(completionRegion) +
- // completionRegion.getTextLength())
- addEndTagProposals(contentAssistRequest);
- // else
- if (completionRegionStart == documentPosition) {
- // positioned at start of end tag
- addTagInsertionProposals(contentAssistRequest, node.getChildNodes().getLength());
- }
- return contentAssistRequest;
- }
-
- /**
- * return all possible EntityReferenceProposals (according to current
- * position in doc)
- */
- protected ICompletionProposal[] computeEntityReferenceProposals(int documentPosition, ITextRegion completionRegion, IDOMNode treeNode) {
- // only handle XML content for now
- Vector proposals = new Vector(); // ICompletionProposals
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if ((completionRegion != null) && (completionRegion.getType() == DOMRegionContext.XML_CONTENT)) {
- int nodeOffset = documentPosition - sdRegion.getStartOffset(completionRegion);
- String regionText = sdRegion.getFullText(completionRegion);
-
- // if directly to the right of a &, region will be null, need to
- // move to
- // the previous region...there might be a better way to do this
- if ((regionText != null) && regionText.trim().equals("") && (documentPosition > 0)) { //$NON-NLS-1$
- IStructuredDocumentRegion prev = treeNode.getStructuredDocument().getRegionAtCharacterOffset(documentPosition - 1);
- if ((prev != null) && prev.getText().equals("&")) { //$NON-NLS-1$
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=206680
- // examine previous region
- sdRegion = prev;
- completionRegion = prev.getLastRegion();
- regionText = prev.getFullText();
- nodeOffset = 1;
- }
- }
-
- // string must start w/ &
- if ((regionText != null) && regionText.startsWith("&")) { //$NON-NLS-1$
- String key = (nodeOffset > 0) ? regionText.substring(1, nodeOffset) : ""; //$NON-NLS-1$
-
- // get entity proposals, passing in the appropriate start
- // string
- ModelQuery mq = ModelQueryUtil.getModelQuery(((Node) treeNode).getOwnerDocument());
- if (mq != null) {
- CMDocument xmlDoc = mq.getCorrespondingCMDocument(treeNode);
- CMNamedNodeMap cmmap = null;
- Properties entities = null;
- if (xmlDoc != null) {
- cmmap = xmlDoc.getEntities();
- }
- if (cmmap != null) {
- entities = mapToProperties(cmmap);
- }
- else // 224787 in absence of content model, just use
- // minimal 5 entities
- {
- entities = new Properties();
- entities.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("apos", "'"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
- }
- addEntityProposals(proposals, entities, key, nodeOffset, sdRegion, completionRegion);
- }
- }
- }
- return (ICompletionProposal[]) ((proposals.size() > 0) ? proposals.toArray(new ICompletionProposal[proposals.size()]) : null);
- }
-
- protected ContentAssistRequest computeEqualsProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- ITextRegion valueRegion = node.getStartStructuredDocumentRegion().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) + completionRegion.getLength());
- if ((valueRegion != null) && (valueRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) && (sdRegion.getStartOffset(valueRegion) <= documentPosition)) {
- // replace the adjacent attribute value
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, valueRegion, sdRegion.getStartOffset(valueRegion), valueRegion.getTextLength(), matchString);
- }
- else {
- // append an attribute value after the '='
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- addAttributeValueProposals(contentAssistRequest);
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeStartDocumentProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- // setup for a non-empty document, but one that hasn't been formally
- // started
- ContentAssistRequest contentAssistRequest = null;
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, getStructuredDocumentRegion(documentPosition), completionRegion, documentPosition, 0, matchString);
- addStartDocumentProposals(contentAssistRequest);
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeTagCloseProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- if ((node.getNodeType() == Node.DOCUMENT_NODE) || (documentPosition >= sdRegion.getEndOffset())) {
- // this is a content request as the documentPosition is AFTER the
- // end of the closing region
- if ((node == nodeAtOffset) && (node.getParentNode() != null)) {
- node = (IDOMNode) node.getParentNode();
- }
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() == null)) {
- addEndTagProposals(contentAssistRequest);
- }
- }
- else {
- // at the start of the tag's close or within it
- ITextRegion closeRegion = sdRegion.getLastRegion();
- boolean insideTag = !sdRegion.isEnded() || (documentPosition <= sdRegion.getStartOffset(closeRegion));
- if (insideTag) {
- // this is a request for completions within a tag
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() != null)) {
- addTagCloseProposals(contentAssistRequest);
- }
- if (sdRegion == nodeAtOffset.getFirstStructuredDocumentRegion()) {
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- addAttributeNameProposals(contentAssistRequest);
- }
- }
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeTagNameProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()) {
- // completing the *first* tag in "<tagname1 |<tagname2"
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- if (actualNode != null) {
- if (actualNode.getFirstStructuredDocumentRegion() == sdRegion) {
- // start tag
- if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // it's attributes
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- if (node.getStructuredDocument().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getType() == DOMRegionContext.XML_TAG_OPEN) {
- addAttributeNameProposals(contentAssistRequest);
- }
- addTagCloseProposals(contentAssistRequest);
- }
- else {
- // it's name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(actualNode));
- }
- }
- else {
- if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // insert name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // replace name
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest);
- }
- }
- }
- else {
- if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
- // unclosed tag with only a name; should prompt for attributes
- // and a close instead
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- addAttributeNameProposals(contentAssistRequest);
- addTagCloseProposals(contentAssistRequest);
- }
- else {
- if (sdRegion.getRegions().get(0).getType() != DOMRegionContext.XML_END_TAG_OPEN) {
- int replaceLength = documentPosition - sdRegion.getStartOffset(completionRegion);
- contentAssistRequest = newContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), replaceLength, matchString);
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- }
- else {
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(documentPosition);
- if (actualNode != null) {
- if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest);
- }
- }
- }
- }
- return contentAssistRequest;
- }
-
- protected ContentAssistRequest computeTagOpenProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode nodeAtOffset, IDOMNode node) {
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion() || sdRegion.getPrevious() != null && sdRegion.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) {
- // completing the *first* XML_TAG_OPEN in "<<tagname"
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- if (actualNode != null) {
- if(sdRegion.getFirstRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN) {
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- if(actualNode.hasChildNodes())
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(actualNode.getLastChild()));
- else
- addTagNameProposals(contentAssistRequest, 0);
- }
- else {
- contentAssistRequest = newContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(actualNode));
- }
- addEndTagProposals(contentAssistRequest); // (pa) 220850
- }
- }
- else {
- if (documentPosition == sdRegion.getStartOffset(completionRegion)) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- // at the start of an existing tag, right before the '<'
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- addEndTagProposals(contentAssistRequest);
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- // at the opening of the VERY first tag with a '<'
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- addStartDocumentProposals(contentAssistRequest);
- }
- }
- else {
- // within the white space
- ITextRegion name = getNameRegion(node.getStartStructuredDocumentRegion());
- // (pa) ITextRegion refactor
- // if (name != null && name.containsOffset(documentPosition))
- // {
- if ((name != null) && ((sdRegion.getStartOffset(name) <= documentPosition) && (sdRegion.getEndOffset(name) >= documentPosition)) && (sdRegion.getLastRegion().getType() == DOMRegionContext.XML_TAG_CLOSE || sdRegion.getLastRegion().getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)){
- // replace the existing name
- contentAssistRequest = newContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(name), name.getTextLength(), matchString);
- }
- else {
- // insert a valid new name, or possibly an end tag
- contentAssistRequest = newContentAssistRequest(nodeAtOffset, ((Node) nodeAtOffset).getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addEndTagProposals(contentAssistRequest);
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- }
- addTagNameProposals(contentAssistRequest, getElementPositionForModelQuery(nodeAtOffset));
- }
- }
- return contentAssistRequest;
- }
-
- /**
- * Retreives cmnode's documentation to display in the completion
- * proposal's additional info. If no documentation exists for cmnode, try
- * displaying parentOrOwner's documentation
- *
- * String any documentation information to display for cmnode.
- * <code>null</code> if there is nothing to display.
- */
- protected String getAdditionalInfo(CMNode parentOrOwner, CMNode cmnode) {
- String addlInfo = null;
-
- if (cmnode == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return null;
- }
-
- addlInfo = getInfoProvider().getInfo(cmnode);
- if ((addlInfo == null) && (parentOrOwner != null)) {
- addlInfo = getInfoProvider().getInfo(parentOrOwner);
- }
- return addlInfo;
- }
-
- // returns a list of ModelQueryActions
- protected List getAvailableChildrenAtIndex(Element parent, int index, int validityChecking) {
- List list = new ArrayList();
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
- // taken from ActionManagers
- // int editMode = modelQuery.getEditMode();
- int editMode = ModelQuery.EDIT_MODE_UNCONSTRAINED;
- int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES | ModelQuery.INCLUDE_SEQUENCE_GROUPS : ModelQuery.INCLUDE_CHILD_NODES;
- modelQuery.getInsertActions(parent, parentDecl, index, ic, validityChecking, list);
- }
- return list;
- }
-
- // returns a list of CMElementDeclarations
- protected List getAvailableRootChildren(Document document, int childIndex) {
- List list = null;
-
- // extract the valid 'root' node name from the DocumentType Node
- DocumentType docType = document.getDoctype();
- String rootName = null;
- if (docType != null) {
- rootName = docType.getNodeName();
- }
- if (rootName == null) {
- return new ArrayList(0);
- }
-
- for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) {
- // make sure the "root" Element isn't already present
- // is it required to be an Element?
- if ((child.getNodeType() == Node.ELEMENT_NODE) && stringsEqual(child.getNodeName(), rootName)) {
- // if the node is missing either the start or end tag, don't
- // count it as present
- if ((child instanceof IDOMNode) && ((((IDOMNode) child).getStartStructuredDocumentRegion() == null) || (((IDOMNode) child).getEndStructuredDocumentRegion() == null))) {
- continue;
- }
- if (Debug.displayInfo) {
- System.out.println(rootName + " already present!"); //$NON-NLS-1$
- }
- setErrorMessage(NLS.bind(XMLUIMessages.The_document_element__, (new Object[]{rootName})));
- return new ArrayList(0);
- }
- }
-
- list = new ArrayList(1);
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery != null) {
- CMDocument cmdoc = modelQuery.getCorrespondingCMDocument(document);
- if (cmdoc != null) {
- if (rootName != null) {
- CMElementDeclaration rootDecl = (CMElementDeclaration) cmdoc.getElements().getNamedItem(rootName);
- if (rootDecl != null) {
- list.add(rootDecl);
- }
- else {
- // supply the given document name anyway, even if it
- // is an error
- list.add(new SimpleCMElementDeclaration(rootName));
- if (Debug.displayInfo || Debug.displayWarnings) {
- System.out.println("No definition found for " + rootName + " in " + docType.getPublicId() + "/" + docType.getSystemId()); //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
- String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- if (location.length() > 0) {
- setErrorMessage(NLS.bind(XMLUIMessages.No_definition_for_in, (new Object[]{rootName, location})));
- }
- else {
- setErrorMessage(NLS.bind(XMLUIMessages.No_definition_for, (new Object[]{rootName})));
- }
- }
- }
- }
- else {
- if (Debug.displayInfo || Debug.displayWarnings) {
- System.out.println("No content model found."); //$NON-NLS-1$
- }
- //$NON-NLS-1$
- //$NON-NLS-1$
- String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- //$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- if (location.length() > 0) {
- setErrorMessage(NLS.bind(XMLUIMessages.No_content_model_for, (new Object[]{location})));
- }
- else {
- setErrorMessage(XMLUIMessages.No_content_model_found_UI_);
- }
- }
- }
-
- return list;
- }
-
- protected CMElementDeclaration getCMElementDeclaration(Node node) {
- CMElementDeclaration result = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- if (modelQuery != null) {
- result = modelQuery.getCMElementDeclaration((Element) node);
- }
- }
- return result;
- }
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of possible completions.
- *
- * the auto activation characters for completion proposal or
- * <code>null</code> if no auto activation is desired
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return completionProposalAutoActivationCharacters;
- }
-
- protected ITextRegion getCompletionRegion(int offset, IStructuredDocumentRegion sdRegion) {
- ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset);
- if (region == null) {
- return null;
- }
-
- if (sdRegion.getStartOffset(region) == offset) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) && (sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- region = sdRegion.getPrevious().getRegionAtCharacterOffset(offset - 1);
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(offset - 1);
- if ((previousRegion != null) && (previousRegion != region) && (previousRegion.getTextLength() == previousRegion.getLength())) {
- region = previousRegion;
- }
- }
- }
- else {
- // The offset is NOT at the beginning of the region
- if (offset > sdRegion.getStartOffset(region) + region.getTextLength()) {
- // Is the offset within the whitespace after the text in this
- // region?
- // If so, use the next region
- ITextRegion nextRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) + region.getLength());
- if (nextRegion != null) {
- region = nextRegion;
- }
- }
- else {
- // Is the offset within the important text for this region?
- // If so, then we've already got the right one.
- }
- }
-
- // valid WHITE_SPACE region handler (#179924)
- if ((region != null) && (region.getType() == DOMRegionContext.WHITE_SPACE)) {
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1);
- if (previousRegion != null) {
- region = previousRegion;
- }
- }
-
- return region;
- }
-
- /**
- * Return the region whose content's require completion. This is something
- * of a misnomer as sometimes the user wants to be prompted for contents
- * of a non-existant ITextRegion, such as for enumerated attribute values
- * following an '=' sign.
- */
- protected ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
- if (domnode == null) {
- return null;
- }
-
- ITextRegion region = null;
- int offset = documentPosition;
- IStructuredDocumentRegion flatNode = null;
- IDOMNode node = (IDOMNode) domnode;
-
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- if (node.getStructuredDocument().getLength() == 0) {
- return null;
- }
- ITextRegion result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
- while (result == null) {
- offset--;
- result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
- }
- return result;
- }
-
- IStructuredDocumentRegion startTag = node.getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endTag = node.getEndStructuredDocumentRegion();
-
- // Determine if the offset is within the start
- // IStructuredDocumentRegion, end IStructuredDocumentRegion, or
- // somewhere within the Node's XML content.
- if ((startTag != null) && (startTag.getStartOffset() <= offset) && (offset < startTag.getStartOffset() + startTag.getLength())) {
- flatNode = startTag;
- }
- else if ((endTag != null) && (endTag.getStartOffset() <= offset) && (offset < endTag.getStartOffset() + endTag.getLength())) {
- flatNode = endTag;
- }
-
- if (flatNode != null) {
- // the offset is definitely within the start or end tag, continue
- // on and find the region
- region = getCompletionRegion(offset, flatNode);
- }
- else {
- // the docPosition is neither within the start nor the end, so it
- // must be content
- flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(offset);
- // (pa) ITextRegion refactor
- // if (flatNode.contains(documentPosition)) {
- if ((flatNode.getStartOffset() <= documentPosition) && (flatNode.getEndOffset() >= documentPosition)) {
- // we're interesting in completing/extending the previous
- // IStructuredDocumentRegion if the current
- // IStructuredDocumentRegion isn't plain content or if it's
- // preceded by an orphan '<'
- if ((offset == flatNode.getStartOffset()) && (flatNode.getPrevious() != null) && (((flatNode.getRegionAtCharacterOffset(documentPosition) != null) && (flatNode.getRegionAtCharacterOffset(documentPosition).getType() != DOMRegionContext.XML_CONTENT)) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) || (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- region = flatNode.getPrevious().getLastRegion();
- }
- else if (flatNode.getEndOffset() == documentPosition) {
- region = flatNode.getLastRegion();
- }
- else {
- region = flatNode.getFirstRegion();
- }
- }
- else {
- // catch end of document positions where the docPosition isn't
- // in a IStructuredDocumentRegion
- region = flatNode.getLastRegion();
- }
- }
-
- return region;
- }
-
- /**
- * Provided by default. Subclasses may override with their own
- * implementations.
- *
- * @see AbstractContentAssistProcessor#getContentGenerator()
- */
- public XMLContentModelGenerator getContentGenerator() {
- if (fGenerator == null) {
- fGenerator = new XMLContentModelGenerator();
- }
- return fGenerator;
- }
-
- /**
- * Returns the characters which when entered by the user should
- * automatically trigger the presentation of context information.
- *
- * the auto activation characters for presenting context information or
- * <code>null</code> if no auto activation is desired
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return contextInformationAutoActivationCharacters;
- }
-
- /**
- * Returns a validator used to determine when displayed context
- * information should be dismissed. May only return <code>null</code> if
- * the processor is incapable of computing context information.
- *
- * a context information validator, or <code>null</code> if the
- * processor is incapable of computing context information
- */
- public IContextInformationValidator getContextInformationValidator() {
- if (fContextInformationPresenter == null) {
- fContextInformationPresenter = new AttributeContextInformationPresenter();
- }
- return fContextInformationPresenter;
- }
-
- protected int getElementPosition(Node child) {
- Node parent = child.getParentNode();
- if (parent == null) {
- return 0;
- }
-
- NodeList children = parent.getChildNodes();
- if (children == null) {
- return 0;
- }
- int count = 0;
-
- for (int i = 0; i < children.getLength(); i++) {
- if (children.item(i) == child) {
- return count;
- }
- else {
- // if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
- count++;
- }
- }
- return 0;
- }
-
- private int getElementPositionForModelQuery(Node child) {
- return getElementPosition(child);
- // return -1;
- }
-
- /**
- * Return the reason why computeProposals was not able to find any
- * completions.
- *
- * an error message or null if no error occurred
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /**
- * @param iResource
- */
- // public void initialize(IResource iResource) {
- // this.resource = iResource;
- // }
- /**
- * Gets the infoProvider.
- *
- * fInfoProvider and if fInfoProvider was <code>null</code> create a new
- * instance
- */
- public MarkupTagInfoProvider getInfoProvider() {
- if (fInfoProvider == null) {
- fInfoProvider = new MarkupTagInfoProvider();
- }
- return fInfoProvider;
- }
-
- protected String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
- if ((aRegion == null) || isCloseRegion(aRegion)) {
- return ""; //$NON-NLS-1$
- }
- String matchString = null;
- String regionType = aRegion.getType();
- if ((regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (regionType == DOMRegionContext.XML_TAG_OPEN) || (offset > parent.getStartOffset(aRegion) + aRegion.getTextLength())) {
- matchString = ""; //$NON-NLS-1$
- }
- else if (regionType == DOMRegionContext.XML_CONTENT) {
- matchString = ""; //$NON-NLS-1$
- }
- else {
- if ((parent.getText(aRegion).length() > 0) && (parent.getStartOffset(aRegion) < offset)) {
- matchString = parent.getText(aRegion).substring(0, offset - parent.getStartOffset(aRegion));
- }
- else {
- matchString = ""; //$NON-NLS-1$
- }
- }
- return matchString;
- }
-
- protected ITextRegion getNameRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null) {
- return null;
- }
- Iterator regionList = flatNode.getRegions().iterator();
- while (regionList.hasNext()) {
- ITextRegion region = (ITextRegion) regionList.next();
- if (isNameRegion(region)) {
- return region;
- }
- }
- return null;
- }
-
- /**
- * Retrieves all of the possible valid values for this attribute
- * declaration
- */
- protected List getPossibleDataTypeValues(Node node, CMAttributeDeclaration ad) {
- List list = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element = (Element) node;
- String[] dataTypeValues = null;
- // The ModelQuery may not be available if the corresponding
- // adapter
- // is absent
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if (modelQuery != null) {
- dataTypeValues = modelQuery.getPossibleDataTypeValues(element, ad);
- }
- else {
- if (ad.getAttrType() != null) {
- dataTypeValues = ad.getAttrType().getEnumeratedValues();
- }
- }
- if (dataTypeValues != null) {
- list = new ArrayList(dataTypeValues.length);
- for (int i = 0; i < dataTypeValues.length; i++) {
- list.add(dataTypeValues[i]);
- }
- }
- }
- if (list == null) {
- list = new ArrayList(0);
- }
- return list;
- }
-
- protected String getRequiredName(Node parentOrOwner, CMNode cmnode) {
- if ((cmnode == null) || (parentOrOwner == null)) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- return getContentGenerator().getRequiredName(parentOrOwner, cmnode);
- }
-
- protected String getRequiredText(Node parentOrOwner, CMAttributeDeclaration attrDecl) {
- if (attrDecl == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null attribute declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- StringBuffer buff = new StringBuffer();
- getContentGenerator().generateRequiredAttribute(parentOrOwner, attrDecl, buff);
- return buff.toString();
- }
-
- protected String getRequiredText(Node parentOrOwner, CMElementDeclaration elementDecl) {
- if (elementDecl == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null attribute declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- StringBuffer buff = new StringBuffer();
- getContentGenerator().generateTag(parentOrOwner, elementDecl, buff);
- return buff.toString();
- }
-
- /**
- * StructuredTextViewer must be set before using this.
- */
- public IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- // (pa) ITextRegion refactor defect 245190
- // return
- // (IStructuredDocumentRegion)ContentAssistUtils.getNodeAt((StructuredTextViewer)fTextViewer,
- // pos);
- return ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
- }
-
- private String getTagName(IStructuredDocumentRegion sdRegion) {
- ITextRegionList regions = sdRegion.getRegions();
- ITextRegion region = null;
- String name = ""; //$NON-NLS-1$
- for (int i = 0; i < regions.size(); i++) {
- region = regions.get(i);
- if (region.getType() == DOMRegionContext.XML_TAG_NAME) {
- name = sdRegion.getText(region);
- break;
- }
- }
- return name;
- }
-
- // returns a list of CMNodes that are available within this parent context
- // Given the grammar shown below and a snippet of XML code (where the '|'
- // indicated the cursor position)
- // the list would return all of the element declarations that are
- // potential child elements of Foo.
- //
- // grammar : Foo -> (A, B, C)
- // snippet : <Foo><A>|
- // result : {A, B, C}
- //
- // TODO cs... do we need to pass in the 'kindOfAction'? Seems to me we
- // could assume it's always an insert.
- protected List getAvailableChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
- List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_NONE);
- Iterator iterator = modelQueryActions.iterator();
- List cmnodes = new Vector();
- while (iterator.hasNext()) {
- ModelQueryAction action = (ModelQueryAction) iterator.next();
- if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
- CMNode actionCMNode = action.getCMNode();
- if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
- cmnodes.add(actionCMNode);
- }
- }
- }
- return cmnodes;
- }
-
- // returns a list of CMNodes that can be validly inserted at this
- // childPosition
- // Given the grammar shown below and a snippet of XML code (where the '|'
- // indicated the cursor position)
- // the list would return only the element declarations can be inserted
- // while maintaing validity of the content.
- //
- // grammar : Foo -> (A, B, C)
- // snippet : <Foo><A>|
- // result : {B}
- //
- protected List getValidChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
- List modelQueryActions = getAvailableChildrenAtIndex(parent, childPosition, ModelQuery.VALIDITY_STRICT);
- Iterator iterator = modelQueryActions.iterator();
- List cmnodes = new Vector();
- while (iterator.hasNext()) {
- ModelQueryAction action = (ModelQueryAction) iterator.next();
- if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
- CMNode actionCMNode = action.getCMNode();
- if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
- cmnodes.add(actionCMNode);
- }
- }
- }
- return cmnodes;
- }
-
- /**
- * Similar to the call in HTMLContentAssistProcessor. Pass in a node, it
- * tells you if the document is XML type.
- *
- * @param node
- *
- */
- protected boolean getXML(Node node) {
- if (node == null) {
- return false;
- }
-
- Document doc = null;
- doc = (node.getNodeType() != Node.DOCUMENT_NODE) ? node.getOwnerDocument() : ((Document) node);
-
- return (doc instanceof IDOMDocument) && ((IDOMDocument) doc).isXMLType();
- }
-
- // Initialize local settings
- protected void init() {
- // implement in subclasses
- }
-
- protected boolean isCloseRegion(ITextRegion region) {
- String type = region.getType();
- return ((type == DOMRegionContext.XML_PI_CLOSE) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) || (type == DOMRegionContext.XML_CDATA_CLOSE) || (type == DOMRegionContext.XML_COMMENT_CLOSE) || (type == DOMRegionContext.XML_ATTLIST_DECL_CLOSE) || (type == DOMRegionContext.XML_ELEMENT_DECL_CLOSE) || (type == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE) || (type == DOMJSPRegionContextsPrivateCopy.JSP_CLOSE) || (type == DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_CLOSE) || (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE)) || (type == DOMRegionContext.XML_DECLARATION_CLOSE));
- }
-
- /*
- * This is to determine if a tag is a special meta-info comment tag that
- * shows up as an ELEMENT
- */
- private boolean isCommentNode(IDOMNode node) {
- return ((node != null) && (node instanceof IDOMElement) && ((IDOMElement) node).isCommentTag());
- }
-
- /**
- * Checks if cursor position is after doctype tag...
- *
- * @param car
- *
- */
- protected boolean isCursorAfterDoctype(ContentAssistRequest car) {
- Node aNode = car.getNode();
- Document parent = aNode.getOwnerDocument();
- int xmldoctypeNodePosition = -1;
- boolean isAfterDoctype = true;
-
- if (parent == null) {
- return true; // blank document case
- }
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child instanceof IDOMNode) {
- if (child.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- xmldoctypeNodePosition = ((IDOMNode) child).getEndOffset();
- isAfterDoctype = (car.getReplacementBeginPosition() >= xmldoctypeNodePosition);
- break;
- }
- }
- }
- return isAfterDoctype;
- }
-
- /**
- * This method can check if the cursor is after the XMLPI
- *
- * @param car
- *
- */
- protected boolean isCursorAfterXMLPI(ContentAssistRequest car) {
- Node aNode = car.getNode();
- boolean xmlpiFound = false;
- Document parent = aNode.getOwnerDocument();
- int xmlpiNodePosition = -1;
- boolean isAfterXMLPI = false;
-
- if (parent == null) {
- return true; // blank document case
- }
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$
- xmlpiFound = xmlpiFound || xmlpi;
- if (xmlpiFound) {
- if (child instanceof IDOMNode) {
- xmlpiNodePosition = ((IDOMNode) child).getEndOffset();
- isAfterXMLPI = (car.getReplacementBeginPosition() >= xmlpiNodePosition);
- }
- break;
- }
- }
- return isAfterXMLPI;
- }
-
- protected boolean isNameRegion(ITextRegion region) {
- String type = region.getType();
- return ((type == DOMRegionContext.XML_TAG_NAME) || (type == DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_NAME) || (type == DOMRegionContext.XML_ELEMENT_DECL_NAME) || (type == DOMRegionContext.XML_DOCTYPE_NAME) || (type == DOMRegionContext.XML_ATTLIST_DECL_NAME) || (type == DOMJSPRegionContextsPrivateCopy.JSP_ROOT_TAG_NAME) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_NAME));
- }
-
- protected boolean isQuote(String string) {
- String trimmed = string.trim();
- if (trimmed.length() > 0) {
- return (trimmed.charAt(0) == '\'') || (trimmed.charAt(0) == '"');
- }
- return false;
- }
-
- private boolean isSelfClosed(IStructuredDocumentRegion startTag) {
- ITextRegionList regions = startTag.getRegions();
- return regions.get(regions.size() - 1).getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE;
- }
-
- private boolean isStartTag(IStructuredDocumentRegion sdRegion) {
- boolean result = false;
- if (sdRegion.getRegions().size() > 0) {
- ITextRegion r = sdRegion.getRegions().get(0);
- result = (r.getType() == DOMRegionContext.XML_TAG_OPEN) && sdRegion.isEnded();
- }
- return result;
- }
-
- protected Properties mapToProperties(CMNamedNodeMap map) {
- Properties p = new Properties();
- for (int i = 0; i < map.getLength(); i++) {
- CMEntityDeclaration decl = (CMEntityDeclaration) map.item(i);
- p.put(decl.getName(), decl.getValue());
- }
- return p;
- }
-
- /**
- * Gets the corresponding XMLNode, and checks if it's closed.
- *
- * @param startTag
- *
- */
- private boolean needsEndTag(IStructuredDocumentRegion startTag) {
- boolean result = false;
- IStructuredModel sModel = StructuredModelManager.getModelManager().getExistingModelForRead(fTextViewer.getDocument());
- try {
- if (sModel != null) {
- IDOMNode xmlNode = (IDOMNode) sModel.getIndexedRegion(startTag.getStart());
- if (!isStartTag(startTag)) {
- result = false;
- }
- else if (isSelfClosed(startTag)) {
- result = false;
- }
- else if (!xmlNode.isContainer()) {
- result = false;
- }
- else {
- result = xmlNode.getEndStructuredDocumentRegion() == null;
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- return result;
- }
-
- protected ContentAssistRequest newContentAssistRequest(Node node, Node possibleParent, IStructuredDocumentRegion documentRegion, ITextRegion completionRegion, int begin, int length, String filter) {
- return new ContentAssistRequest(node, possibleParent, documentRegion, completionRegion, begin, length, filter);
- }
-
- public void release() {
- fGenerator = null;
- }
-
- /**
- * Set the reason why computeProposals was not able to find any
- * completions.
- */
- public void setErrorMessage(String errorMessage) {
- fErrorMessage = errorMessage;
- }
-
- /**
- * Set the reason why computeProposals was not able to find any
- * completions.
- */
- protected void setErrorMessage(String errorMessage, String append) {
- setErrorMessage(errorMessage + append);
- }
-
- /**
- * Set the reason why computeProposals was not able to find any
- * completions.
- */
- protected void setErrorMessage(String errorMessage, String prepend, String append) {
- setErrorMessage(prepend + errorMessage + append);
- }
-
- protected boolean stringsEqual(String a, String b) {
- // (pa) 221190 matching independent of case to be consistant with Java
- // editor CA
- return a.equalsIgnoreCase(b);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java
deleted file mode 100644
index 7884482852..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractContentModelGenerator.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.w3c.dom.Node;
-
-
-public abstract class AbstractContentModelGenerator {
-
- public static boolean generateChildren = false;
-
- public AbstractContentModelGenerator() {
- super();
- }
-
- public abstract void generateAttribute(CMAttributeDeclaration attrDecl, StringBuffer buffer);
-
- protected void generateAttributes(CMElementDeclaration elementDecl, StringBuffer buffer) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
- if (attributes == null) {
- return;
- }
- for (int i = 0; i < attributes.getLength(); i++) {
- generateAttribute((CMAttributeDeclaration) attributes.item(i), buffer);
- }
- return;
- }
-
- protected abstract void generateEndTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer);
-
- public void generateRequiredChildren(Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if (generateChildren) {
- }
- return;
- }
-
- protected abstract void generateStartTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer);
-
- public void generateTag(Node parent, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if ((elementDecl == null) || (buffer == null)) {
- return;
- }
-
- String tagName = getRequiredName(parent, elementDecl);
-
- generateStartTag(tagName, parent, elementDecl, buffer);
- generateRequiredChildren(parent, elementDecl, buffer);
- generateEndTag(tagName, parent, elementDecl, buffer);
- return;
- }
-
- public abstract int getMinimalStartTagLength(Node node, CMElementDeclaration elementDecl);
-
- public String getRequiredName(Node ownerNode, CMNode cmnode) {
- if (ownerNode != null) {
- return DOMNamespaceHelper.computeName(cmnode, ownerNode, null);
- }
- return cmnode.getNodeName();
- }
-
- public abstract String getStartTagClose(Node parentNode, CMElementDeclaration elementDecl);
-
- protected boolean requiresAttributes(CMElementDeclaration ed) {
- CMNamedNodeMap attributes = ed.getAttributes();
- if (attributes == null) {
- return false;
- }
- for (int i = 0; i < attributes.getLength(); i++) {
- if (((CMAttributeDeclaration) attributes.item(i)).getUsage() == CMAttributeDeclaration.REQUIRED) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLCompletionProposalComputer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLCompletionProposalComputer.java
deleted file mode 100644
index 82b23cef32..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLCompletionProposalComputer.java
+++ /dev/null
@@ -1,1134 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
-import org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * <p>Implements the framework for making proposals in XML type documents. Deals with
- * all the nastiness needed to figure out where in an XML type document the content
- * assist was invoked and then calls one of many abstract methods depending on the
- * area the content assist was invoked. In this way implementers only have to worry about
- * implementing what to do in each situation while not having to deal with figuring out
- * which situation the content assist was invoked in.</p>
- *
- * @base org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor
- * @see DefaultXMLCompletionProposalComputer
- */
-public abstract class AbstractXMLCompletionProposalComputer implements ICompletionProposalComputer {
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- private class DOMJSPRegionContextsPrivateCopy {
- private static final String JSP_CLOSE = "JSP_CLOSE"; //$NON-NLS-1$
- private static final String JSP_COMMENT_CLOSE = "JSP_COMMENT_CLOSE"; //$NON-NLS-1$
-
- private static final String JSP_COMMENT_OPEN = "JSP_COMMENT_OPEN"; //$NON-NLS-1$
- private static final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
- private static final String JSP_DIRECTIVE_CLOSE = "JSP_DIRECTIVE_CLOSE"; //$NON-NLS-1$
- private static final String JSP_DIRECTIVE_NAME = "JSP_DIRECTIVE_NAME"; //$NON-NLS-1$
-
- private static final String JSP_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
- private static final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
-
- private static final String JSP_ROOT_TAG_NAME = "JSP_ROOT_TAG_NAME"; //$NON-NLS-1$
-
- private static final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
- }
-
- private AttributeContextInformationProvider fAttributeInfoProvider;
- private AttributeContextInformationPresenter fContextInformationPresenter;
-
- private String fErrorMessage;
- private ITextViewer fTextViewer;
-
- public AbstractXMLCompletionProposalComputer() {
- fAttributeInfoProvider = null;
- fContextInformationPresenter = null;
- fErrorMessage = null;
- fTextViewer = null;
- }
-
- /**
- * <p>Return a list of proposed code completions based on the specified
- * location within the document that corresponds to the current cursor
- * position within the text-editor control.</p>
- *
- * @see org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer#computeCompletionProposals(org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
- */
- public List computeCompletionProposals(
- CompletionProposalInvocationContext context,
- IProgressMonitor monitor) {
-
- ITextViewer textViewer = context.getViewer();
- int documentPosition = context.getInvocationOffset();
-
- setErrorMessage(null);
-
- fTextViewer = textViewer;
-
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition);
-
- Node node = (Node) treeNode;
- while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) {
- node = node.getParentNode();
- }
- IDOMNode xmlnode = (IDOMNode) node;
-
- ContentAssistRequest contentAssistRequest = null;
-
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- ITextRegion completionRegion = getCompletionRegion(documentPosition, node);
-
- String matchString = getMatchString(sdRegion, completionRegion, documentPosition);
-
- // Handle empty Documents
- if (completionRegion == null) {
- if (((treeNode == null) || (((Node) treeNode).getNodeType() == Node.DOCUMENT_NODE)) && (completionRegion == null) &&
- ((xmlnode == null) || (xmlnode.getChildNodes() == null) || (xmlnode.getChildNodes().getLength() == 0))) {
-
- IStructuredModel sModel = null;
- try {
- if(textViewer.getDocument() instanceof IStructuredDocument) {
- sModel = StructuredModelManager.getModelManager().getModelForRead((IStructuredDocument)textViewer.getDocument());
- }
- if (sModel != null) {
- IDOMDocument docNode = ((IDOMModel) sModel).getDocument();
- contentAssistRequest = new ContentAssistRequest(docNode, docNode, sdRegion, completionRegion, documentPosition, 0, null);
- addEmptyDocumentProposals(contentAssistRequest, context);
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- if (contentAssistRequest == null) {
- Logger.logException(new IllegalStateException("problem getting model")); //$NON-NLS-1$
- return new ArrayList(0);
- }
-
- ICompletionProposal[] props = contentAssistRequest.getCompletionProposals();
- return (props != null) ? Arrays.asList(props) : new ArrayList(0);
- }
- // MASSIVE ERROR CONDITION
- Logger.logException(new IllegalStateException("completion region was null")); //$NON-NLS-1$
- setErrorMessage(XMLUIMessages.SEVERE_internal_error_occu_UI_);
- contentAssistRequest = new ContentAssistRequest((Node) treeNode, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
- ICompletionProposal[] props = contentAssistRequest.getCompletionProposals();
- return (props != null) ? Arrays.asList(props) : new ArrayList(0);
- }
-
-
- // catch documents where no region can be determined
- if ((xmlnode.getNodeType() == Node.DOCUMENT_NODE) && ((completionRegion == null) ||
- (xmlnode.getChildNodes() == null) || (xmlnode.getChildNodes().getLength() == 0))) {
-
- contentAssistRequest = computeStartDocumentProposals(matchString, completionRegion,
- (IDOMNode) treeNode,xmlnode, context);
- ICompletionProposal[] props = contentAssistRequest.getCompletionProposals();
- return (props != null) ? Arrays.asList(props) : new ArrayList(0);
- }
-
- // compute normal proposals
- contentAssistRequest = computeCompletionProposals(matchString, completionRegion, (IDOMNode) treeNode, xmlnode, context);
- if (contentAssistRequest == null) {
- contentAssistRequest = new ContentAssistRequest((Node) treeNode, node.getParentNode(), sdRegion, completionRegion, documentPosition, 0, ""); //$NON-NLS-1$
- setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
- }
-
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=123892
- * Only set this error message if nothing else was already set
- **/
- if (contentAssistRequest.getProposals().size() == 0 && getErrorMessage() == null) {
- setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
- }
-
- ICompletionProposal[] props = contentAssistRequest.getCompletionProposals();
- return (props != null) ? Arrays.asList(props) : new ArrayList(0);
- }
-
- /**
- * <p>Returns information about possible contexts based on the specified
- * location within the document that corresponds to the current cursor
- * position within the text viewer.</p>
- *
- * @see org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer#computeContextInformation(org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext, org.eclipse.core.runtime.IProgressMonitor)
- */
- public List computeContextInformation(
- CompletionProposalInvocationContext context,
- IProgressMonitor monitor) {
-
- if (fAttributeInfoProvider == null) {
- fAttributeInfoProvider = new AttributeContextInformationProvider((IStructuredDocument)context.getDocument(),
- (AttributeContextInformationPresenter) getContextInformationValidator());
- }
- return Arrays.asList(fAttributeInfoProvider.getAttributeInformation(context.getInvocationOffset()));
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer#getErrorMessage()
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- /**
- * Add proposals for attribute names
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addAttributeNameProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Add proposals for attribute values
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addAttributeValueProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Add comment proposals
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addCommentProposal(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Add the proposals for a completely empty document
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Add the proposals for the name in an end tag
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addEndTagNameProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Prompt for end tags to a non-empty Node that hasn't ended Handles these
- * cases: <br>
- * <tagOpen>| <br>
- * <tagOpen>< |<br>
- * <tagOpen></ |
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addEndTagProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Add entity proposals
- *
- * @param contentAssistRequest
- * @param completionRegion
- * @param treeNode
- * @param context
- */
- protected abstract void addEntityProposals(ContentAssistRequest contentAssistRequest,
- ITextRegion completionRegion, IDOMNode treeNode, CompletionProposalInvocationContext context);
-
- /**
- * add entity proposals
- *
- * @param proposals
- * @param map
- * @param key
- * @param nodeOffset
- * @param sdRegion
- * @param completionRegion
- * @param context
- */
- protected abstract void addEntityProposals(Vector proposals, Properties map, String key,
- int nodeOffset, IStructuredDocumentRegion sdRegion, ITextRegion completionRegion,
- CompletionProposalInvocationContext context);
-
- /**
- * Add PCData proposals
- *
- * @param nodeName
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addPCDATAProposal(String nodeName, ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Add start document proposals
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addStartDocumentProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Close an unclosed start tag
- *
- * @param contentAssistRequest
- * @param context
- */
- protected abstract void addTagCloseProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context);
-
- /**
- * Add tag insertion proposals
- *
- * @param contentAssistRequest
- * @param childPosition
- * @param context
- */
- protected abstract void addTagInsertionProposals(ContentAssistRequest contentAssistRequest,
- int childPosition, CompletionProposalInvocationContext context);
-
- /**
- * Add tag name proposals
- *
- * @param contentAssistRequest
- * @param childPosition
- * @param context
- */
- protected abstract void addTagNameProposals(ContentAssistRequest contentAssistRequest,
- int childPosition, CompletionProposalInvocationContext context);
-
- /**
- * @param errorMessage the reason why computeProposals was not able to find any
- * completions.
- */
- protected void setErrorMessage(String errorMessage) {
- fErrorMessage = errorMessage;
- }
-
- /**
- * <p>This does all the magic of figuring out where in the XML type document
- * the content assist was invoked and then calling the corresponding method
- * to add the correct proposals</p>
- *
- * <p><b>NOTE: </b>if overriding be sure to make super call back to this method otherwise
- * you will loose all of the proposals generated by this method</p>
- *
- * @param matchString
- * @param completionRegion
- * @param treeNode
- * @param xmlnode
- * @param context
- *
- * @return {@link ContentAssistRequest} that now has all the proposals in it
- */
- protected ContentAssistRequest computeCompletionProposals(String matchString, ITextRegion completionRegion,
- IDOMNode treeNode, IDOMNode xmlnode, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
-
- ContentAssistRequest contentAssistRequest = null;
- String regionType = completionRegion.getType();
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- // Handle the most common and best supported cases
- if ((xmlnode.getNodeType() == Node.ELEMENT_NODE) || (xmlnode.getNodeType() == Node.DOCUMENT_NODE)) {
- if (regionType == DOMRegionContext.XML_TAG_OPEN) {
- contentAssistRequest = computeTagOpenProposals(matchString, completionRegion, treeNode, xmlnode, context);
- }
- else if (regionType == DOMRegionContext.XML_TAG_NAME) {
- contentAssistRequest = computeTagNameProposals(matchString, completionRegion,
- treeNode, xmlnode, context);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- contentAssistRequest = computeAttributeProposals(matchString, completionRegion, treeNode, xmlnode, context);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- contentAssistRequest = computeEqualsProposals(matchString, completionRegion,
- treeNode, xmlnode, context);
- }
- else if ((regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) && (documentPosition == sdRegion.getTextEndOffset()) &&
- (sdRegion.getText(completionRegion).endsWith("\"") || sdRegion.getText(completionRegion).endsWith("\'"))) { //$NON-NLS-1$ //$NON-NLS-2$
- // this is for when the cursor is at the end of the closing
- // quote for an attribute..
- IDOMNode actualNode = (IDOMNode) xmlnode.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagCloseProposals(contentAssistRequest, context);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- contentAssistRequest = computeAttributeValueProposals(matchString, completionRegion, treeNode, xmlnode, context);
- }
- else if ((regionType == DOMRegionContext.XML_TAG_CLOSE) || (regionType == DOMRegionContext.XML_EMPTY_TAG_CLOSE) ||
- (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE))) {
-
- contentAssistRequest = computeTagCloseProposals(matchString, completionRegion, treeNode, xmlnode, context);
- }
- else if (regionType == DOMRegionContext.XML_END_TAG_OPEN) {
- contentAssistRequest = computeEndTagOpenProposals(matchString, completionRegion,
- treeNode, xmlnode, context);
- }
- else if ((regionType == DOMRegionContext.XML_CONTENT) || (regionType == DOMRegionContext.XML_CHAR_REFERENCE) ||
- (regionType == DOMRegionContext.XML_ENTITY_REFERENCE) || (regionType == DOMRegionContext.XML_PE_REFERENCE)) {
-
- contentAssistRequest = computeContentProposals(matchString, completionRegion,
- treeNode, xmlnode, context);
- }
-
- // These ITextRegion types begin DOM Elements as well and although
- // internally harder to assist,
- // text insertions directly before them can be made
- else if ((documentPosition == sdRegion.getStartOffset(completionRegion)) &&
- (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) ||
- (regionType == DOMRegionContext.XML_DECLARATION_OPEN) ||
- (regionType == DOMRegionContext.XML_PI_OPEN) ||
- (regionType == DOMRegionContext.XML_COMMENT_OPEN) ||
- (regionType == DOMRegionContext.XML_CDATA_OPEN))) {
-
- contentAssistRequest = new ContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPosition(treeNode), context);
- addStartDocumentProposals(contentAssistRequest, context);
- }
- }
- // Not a Document or Element? (odd cases go here for now)
- else if (isCloseRegion(completionRegion)) {
- contentAssistRequest = new ContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion) + completionRegion.getLength(), 0, matchString);
- addStartDocumentProposals(contentAssistRequest, context);
- if (documentPosition >= sdRegion.getTextEndOffset(completionRegion)) {
- addTagInsertionProposals(contentAssistRequest, getElementPosition(treeNode) + 1, context);
- }
- }
- else if ((documentPosition == sdRegion.getStartOffset(completionRegion)) &&
- (regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN) ||
- regionType.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) ||
- (regionType == DOMRegionContext.XML_DECLARATION_OPEN) ||
- (regionType == DOMRegionContext.XML_PI_OPEN) ||
- (regionType == DOMRegionContext.XML_COMMENT_OPEN) ||
- (regionType == DOMRegionContext.XML_CDATA_OPEN))) {
-
- contentAssistRequest = new ContentAssistRequest(treeNode, xmlnode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPosition(treeNode), context);
- addStartDocumentProposals(contentAssistRequest, context);
- }
- return contentAssistRequest;
- }
-
- /**
- * <p>Similar to {@link #computeCompletionProposals(CompletionProposalInvocationContext, IProgressMonitor)} only specificly for
- * attribute proposals</p>
- *
- * <p>Implementers should not override this method, it is made available to implementers so that if they override
- * {@link #computeCompletionProposals(String, ITextRegion, IDOMNode, IDOMNode, CompletionProposalInvocationContext)}
- * they can call this method if needed</p>
- *
- * @param matchString
- * @param completionRegion
- * @param nodeAtOffset
- * @param node
- * @param context
- * @return
- */
- protected final ContentAssistRequest computeAttributeProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
-
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (documentPosition < sdRegion.getStartOffset(completionRegion)) {
- // setup to insert new attributes
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // Setup to replace an existing attribute name
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- }
- addAttributeNameProposals(contentAssistRequest, context);
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- if ((node.getFirstStructuredDocumentRegion() != null) && (!node.getFirstStructuredDocumentRegion().isEnded())) {
- addTagCloseProposals(contentAssistRequest, context);
- }
- return contentAssistRequest;
- }
-
- /**
- * <p>this is the position the cursor should be in after the proposal is
- * applied</p>
- *
- * @param proposedText
- * @return the position the cursor should be in after the proposal is
- * applied
- */
- protected static int getCursorPositionForProposedText(String proposedText) {
- int cursorAdjustment;
- cursorAdjustment = proposedText.indexOf("\"\"") + 1; //$NON-NLS-1$
- // otherwise, after the first tag
- if (cursorAdjustment == 0) {
- cursorAdjustment = proposedText.indexOf('>') + 1;
- }
- if (cursorAdjustment == 0) {
- cursorAdjustment = proposedText.length() + 1;
- }
-
- return cursorAdjustment;
- }
-
- /**
- * <p>helpful utility method for determining if one string starts with another one.
- * This is case insensitive. If either are null then result is <code>true</code></p>
- *
- * @param aString the string to check to see if it starts with the given prefix
- * @param prefix check that the given string starts with this prefix
- *
- * @return <code>true</code> if the given string starts with the given prefix,
- * <code>false</code> otherwise
- */
- protected static boolean beginsWith(String aString, String prefix) {
- if ((aString == null) || (prefix == null)) {
- return true;
- }
- return aString.toLowerCase().startsWith(prefix.toLowerCase());
- }
-
- private ContentAssistRequest computeAttributeValueProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
-
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if ((documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) && (sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength() != sdRegion.getStartOffset(completionRegion) + completionRegion.getLength())) {
- // setup to add a new attribute at the documentPosition
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- addAttributeNameProposals(contentAssistRequest, context);
- if ((actualNode.getFirstStructuredDocumentRegion() != null) && !actualNode.getFirstStructuredDocumentRegion().isEnded()) {
- addTagCloseProposals(contentAssistRequest, context);
- }
- }
- else {
- // setup to replace the existing value
- if (!nodeAtOffset.getFirstStructuredDocumentRegion().isEnded() && (documentPosition < sdRegion.getStartOffset(completionRegion))) {
- // if the IStructuredDocumentRegion isn't closed and the
- // cursor is in front of the value, add
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- addAttributeNameProposals(contentAssistRequest, context);
- }
- else {
- int replaceLength = completionRegion.getTextLength();
-
- //if container region, be sure replace length is only the attribute value region not the entire container
- if(completionRegion instanceof ITextRegionContainer){
- ITextRegion openRegion = ((ITextRegionContainer) completionRegion).getFirstRegion();
- ITextRegion closeRegion = ((ITextRegionContainer) completionRegion).getLastRegion();
-
- /*
- * check to see if the container is opened the same way its closed.
- * Such as:
- * <img src=' '
- * But not:
- * <img src='
- *
- * </body>
- * </html>
- * In the latter case we only want to replace the opening text of the container
- * Admittedly crude test, but effective.
- */
- if(openRegion.getType() != closeRegion.getType()) {
- replaceLength = openRegion.getTextLength();
- }
- }
-
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion,
- completionRegion, sdRegion.getStartOffset(completionRegion),
- replaceLength, matchString);
-
- addAttributeValueProposals(contentAssistRequest, context);
- }
- }
- return contentAssistRequest;
- }
-
- private ContentAssistRequest computeContentProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
- ContentAssistRequest contentAssistRequest = null;
-
- // setup to add children at the content node's position
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, getStructuredDocumentRegion(documentPosition), completionRegion, documentPosition, 0, matchString);
- if ((node != null) && (node.getNodeType() == Node.DOCUMENT_NODE) && (((Document) node).getDoctype() == null)) {
- addStartDocumentProposals(contentAssistRequest, context);
- }
- addTagInsertionProposals(contentAssistRequest, getElementPosition(nodeAtOffset), context);
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- addEndTagProposals(contentAssistRequest, context);
- }
- // entities?
- addEntityProposals(contentAssistRequest, completionRegion, node, context);
- // addEntityProposals(contentAssistRequest);
- return contentAssistRequest;
- }
-
- private ContentAssistRequest computeEndTagOpenProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- int completionRegionStart = sdRegion.getStartOffset(completionRegion);
- int completionRegionLength = completionRegion.getLength();
- IStructuredDocumentRegion sdRegionAtCompletionOffset = node.getStructuredDocument().getRegionAtCharacterOffset(completionRegionStart + completionRegionLength);
- ITextRegion regionAtEndOfCompletion = sdRegionAtCompletionOffset.getRegionAtCharacterOffset(completionRegionStart + completionRegionLength);
-
- if ((documentPosition != completionRegionStart) && (regionAtEndOfCompletion != null) && (regionAtEndOfCompletion.getType() == DOMRegionContext.XML_TAG_NAME)) {
- ITextRegion nameRegion = regionAtEndOfCompletion;
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(nameRegion), nameRegion.getTextLength(), matchString);
- }
- else {
- if (nodeAtOffset.getFirstStructuredDocumentRegion() == sdRegion) {
- // abnormal case, this unmatched end tag will be a sibling
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, nodeAtOffset.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // normal case, this end tag is the parent
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, nodeAtOffset, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- }
- // if (documentPosition >= sdRegion.getStartOffset(completionRegion) +
- // completionRegion.getTextLength())
- addEndTagProposals(contentAssistRequest, context);
- // else
- if (completionRegionStart == documentPosition) {
- // positioned at start of end tag
- addTagInsertionProposals(contentAssistRequest, node.getChildNodes().getLength(), context);
- }
- return contentAssistRequest;
- }
-
-
- private ContentAssistRequest computeEqualsProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- ITextRegion valueRegion = node.getStartStructuredDocumentRegion().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) + completionRegion.getLength());
- if ((valueRegion != null) && (valueRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) && (sdRegion.getStartOffset(valueRegion) <= documentPosition)) {
- // replace the adjacent attribute value
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, valueRegion, sdRegion.getStartOffset(valueRegion), valueRegion.getTextLength(), matchString);
- }
- else {
- // append an attribute value after the '='
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- addAttributeValueProposals(contentAssistRequest, context);
- return contentAssistRequest;
- }
-
- private ContentAssistRequest computeStartDocumentProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
-
- // setup for a non-empty document, but one that hasn't been formally
- // started
- ContentAssistRequest contentAssistRequest = null;
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node,
- getStructuredDocumentRegion(documentPosition), completionRegion,
- documentPosition, 0, matchString);
- addStartDocumentProposals(contentAssistRequest, context);
- return contentAssistRequest;
- }
-
- private ContentAssistRequest computeTagCloseProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- if ((node.getNodeType() == Node.DOCUMENT_NODE) || (documentPosition >= sdRegion.getEndOffset())) {
- // this is a content request as the documentPosition is AFTER the
- // end of the closing region
- if ((node == nodeAtOffset) && (node.getParentNode() != null)) {
- node = (IDOMNode) node.getParentNode();
- }
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPosition(nodeAtOffset), context);
- if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() == null)) {
- addEndTagProposals(contentAssistRequest, context);
- }
- }
- else {
- // at the start of the tag's close or within it
- ITextRegion closeRegion = sdRegion.getLastRegion();
- boolean insideTag = !sdRegion.isEnded() || (documentPosition <= sdRegion.getStartOffset(closeRegion));
- if (insideTag) {
- // this is a request for completions within a tag
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion, documentPosition, 0, matchString);
- if ((node.getNodeType() != Node.DOCUMENT_NODE) && (node.getEndStructuredDocumentRegion() != null)) {
- addTagCloseProposals(contentAssistRequest, context);
- }
- if (sdRegion == nodeAtOffset.getFirstStructuredDocumentRegion()) {
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- addAttributeNameProposals(contentAssistRequest, context);
- }
- }
- }
- return contentAssistRequest;
- }
-
- private ContentAssistRequest computeTagNameProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
-
- if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion()) {
- // completing the *first* tag in "<tagname1 |<tagname2"
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- if (actualNode != null) {
- if (actualNode.getFirstStructuredDocumentRegion() == sdRegion) {
- // start tag
- if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // it's attributes
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition - matchString.length(), matchString.length(), matchString);
- if (node.getStructuredDocument().getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getRegionAtCharacterOffset(sdRegion.getStartOffset(completionRegion) - 1).getType() == DOMRegionContext.XML_TAG_OPEN) {
- addAttributeNameProposals(contentAssistRequest, context);
- }
- addTagCloseProposals(contentAssistRequest, context);
- }
- else {
- // it's name
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode.getParentNode(),
- sdRegion, completionRegion, documentPosition - matchString.length(),
- matchString.length(), matchString);
- addTagNameProposals(contentAssistRequest, getElementPosition(actualNode),
- context);
- }
- }
- else {
- if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getLength()) {
- // insert name
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode.getParentNode(),
- sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- // replace name
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode.getParentNode(),
- sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion),
- completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest, context);
- }
- }
- }
- else {
- if (documentPosition > sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
- // unclosed tag with only a name; should prompt for attributes
- // and a close instead
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node, sdRegion, completionRegion,
- documentPosition - matchString.length(), matchString.length(), matchString);
- addAttributeNameProposals(contentAssistRequest, context);
- addTagCloseProposals(contentAssistRequest, context);
- }
- else {
- if (sdRegion.getRegions().get(0).getType() != DOMRegionContext.XML_END_TAG_OPEN) {
- int replaceLength = documentPosition - sdRegion.getStartOffset(completionRegion);
- contentAssistRequest = new ContentAssistRequest(node, node.getParentNode(), sdRegion,
- completionRegion, sdRegion.getStartOffset(completionRegion), replaceLength, matchString);
- addTagNameProposals(contentAssistRequest, getElementPosition(nodeAtOffset), context);
- }
- else {
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(documentPosition);
- if (actualNode != null) {
- if (documentPosition >= sdRegion.getStartOffset(completionRegion) + completionRegion.getTextLength()) {
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode.getParentNode(),
- sdRegion, completionRegion, documentPosition, 0, matchString);
- }
- else {
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode.getParentNode(),
- sdRegion, completionRegion, sdRegion.getStartOffset(completionRegion),
- completionRegion.getTextLength(), matchString);
- }
- addEndTagNameProposals(contentAssistRequest, context);
- }
- }
- }
- }
- return contentAssistRequest;
- }
-
- private ContentAssistRequest computeTagOpenProposals(String matchString, ITextRegion completionRegion,
- IDOMNode nodeAtOffset, IDOMNode node, CompletionProposalInvocationContext context) {
-
- int documentPosition = context.getInvocationOffset();
- ContentAssistRequest contentAssistRequest = null;
- IStructuredDocumentRegion sdRegion = getStructuredDocumentRegion(documentPosition);
- if (sdRegion != nodeAtOffset.getFirstStructuredDocumentRegion() || sdRegion.getPrevious() != null && sdRegion.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) {
- // completing the *first* XML_TAG_OPEN in "<<tagname"
- IDOMNode actualNode = (IDOMNode) node.getModel().getIndexedRegion(sdRegion.getStartOffset(completionRegion));
- if (actualNode != null) {
- if(sdRegion.getFirstRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN) {
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode, sdRegion, completionRegion, documentPosition, 0, matchString);
- if(actualNode.hasChildNodes())
- addTagNameProposals(contentAssistRequest,
- getElementPosition(actualNode.getLastChild()), context);
- else
- addTagNameProposals(contentAssistRequest, 0, context);
- }
- else {
- contentAssistRequest = new ContentAssistRequest(actualNode, actualNode.getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addTagNameProposals(contentAssistRequest, getElementPosition(actualNode), context);
- }
- addEndTagProposals(contentAssistRequest, context); // (pa) 220850
- }
- }
- else {
- if (documentPosition == sdRegion.getStartOffset(completionRegion)) {
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- // at the start of an existing tag, right before the '<'
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node.getParentNode(), sdRegion,
- completionRegion, documentPosition, 0, matchString);
- addTagInsertionProposals(contentAssistRequest, getElementPosition(nodeAtOffset), context);
- addEndTagProposals(contentAssistRequest, context);
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- // at the opening of the VERY first tag with a '<'
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, node.getParentNode(), sdRegion,
- completionRegion, sdRegion.getStartOffset(completionRegion), completionRegion.getTextLength(), matchString);
- addStartDocumentProposals(contentAssistRequest, context);
- }
- }
- else {
- // within the white space
- ITextRegion name = getNameRegion(node.getStartStructuredDocumentRegion());
- // (pa) ITextRegion refactor
- // if (name != null && name.containsOffset(documentPosition))
- // {
- if ((name != null) &&
- ((sdRegion.getStartOffset(name) <= documentPosition) && (sdRegion.getEndOffset(name) >= documentPosition)) &&
- (sdRegion.getLastRegion().getType() == DOMRegionContext.XML_TAG_CLOSE || sdRegion.getLastRegion().getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)){
-
- // replace the existing name
- contentAssistRequest = new ContentAssistRequest(node, node.getParentNode(), sdRegion, completionRegion, sdRegion.getStartOffset(name), name.getTextLength(), matchString);
- }
- else {
- // insert a valid new name, or possibly an end tag
- contentAssistRequest = new ContentAssistRequest(nodeAtOffset, ((Node) nodeAtOffset).getParentNode(), sdRegion, completionRegion, documentPosition, 0, matchString);
- addEndTagProposals(contentAssistRequest, context);
- contentAssistRequest.setReplacementBeginPosition(documentPosition);
- contentAssistRequest.setReplacementLength(0);
- }
- addTagNameProposals(contentAssistRequest, getElementPosition(nodeAtOffset), context);
- }
- }
- return contentAssistRequest;
- }
-
- private ITextRegion getCompletionRegion(int offset, IStructuredDocumentRegion sdRegion) {
- ITextRegion region = sdRegion.getRegionAtCharacterOffset(offset);
- if (region == null) {
- return null;
- }
-
- if (sdRegion.getStartOffset(region) == offset) {
- // The offset is at the beginning of the region
- if ((sdRegion.getStartOffset(region) == sdRegion.getStartOffset()) && (sdRegion.getPrevious() != null) && (!sdRegion.getPrevious().isEnded())) {
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- region = sdRegion.getPrevious().getRegionAtCharacterOffset(offset - 1);
- }
- else {
- // Is there no separating whitespace from the previous region?
- // If not,
- // then that region is the important one
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(offset - 1);
- if ((previousRegion != null) && (previousRegion != region) && (previousRegion.getTextLength() == previousRegion.getLength())) {
- region = previousRegion;
- }
- }
- }
- else {
- // The offset is NOT at the beginning of the region
- if (offset > sdRegion.getStartOffset(region) + region.getTextLength()) {
- // Is the offset within the whitespace after the text in this
- // region?
- // If so, use the next region
- ITextRegion nextRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) + region.getLength());
- if (nextRegion != null) {
- region = nextRegion;
- }
- }
- else {
- // Is the offset within the important text for this region?
- // If so, then we've already got the right one.
- }
- }
-
- // valid WHITE_SPACE region handler (#179924)
- if ((region != null) && (region.getType() == DOMRegionContext.WHITE_SPACE)) {
- ITextRegion previousRegion = sdRegion.getRegionAtCharacterOffset(sdRegion.getStartOffset(region) - 1);
- if (previousRegion != null) {
- region = previousRegion;
- }
- }
-
- return region;
- }
-
- /**
- * Return the region whose content's require completion. This is something
- * of a misnomer as sometimes the user wants to be prompted for contents
- * of a non-existant ITextRegion, such as for enumerated attribute values
- * following an '=' sign.
- */
- private ITextRegion getCompletionRegion(int documentPosition, Node domnode) {
- if (domnode == null) {
- return null;
- }
-
- ITextRegion region = null;
- int offset = documentPosition;
- IStructuredDocumentRegion flatNode = null;
- IDOMNode node = (IDOMNode) domnode;
-
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- if (node.getStructuredDocument().getLength() == 0) {
- return null;
- }
- ITextRegion result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
- while (result == null) {
- offset--;
- result = node.getStructuredDocument().getRegionAtCharacterOffset(offset).getRegionAtCharacterOffset(offset);
- }
- return result;
- }
-
- IStructuredDocumentRegion startTag = node.getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endTag = node.getEndStructuredDocumentRegion();
-
- // Determine if the offset is within the start
- // IStructuredDocumentRegion, end IStructuredDocumentRegion, or
- // somewhere within the Node's XML content.
- if ((startTag != null) && (startTag.getStartOffset() <= offset) && (offset < startTag.getStartOffset() + startTag.getLength())) {
- flatNode = startTag;
- }
- else if ((endTag != null) && (endTag.getStartOffset() <= offset) && (offset < endTag.getStartOffset() + endTag.getLength())) {
- flatNode = endTag;
- }
-
- if (flatNode != null) {
- // the offset is definitely within the start or end tag, continue
- // on and find the region
- region = getCompletionRegion(offset, flatNode);
- }
- else {
- // the docPosition is neither within the start nor the end, so it
- // must be content
- flatNode = node.getStructuredDocument().getRegionAtCharacterOffset(offset);
- // (pa) ITextRegion refactor
- // if (flatNode.contains(documentPosition)) {
- if ((flatNode.getStartOffset() <= documentPosition) && (flatNode.getEndOffset() >= documentPosition)) {
- // we're interesting in completing/extending the previous
- // IStructuredDocumentRegion if the current
- // IStructuredDocumentRegion isn't plain content or if it's
- // preceded by an orphan '<'
- if ((offset == flatNode.getStartOffset()) &&
- (flatNode.getPrevious() != null) &&
- (((flatNode.getRegionAtCharacterOffset(documentPosition) != null) &&
- (flatNode.getRegionAtCharacterOffset(documentPosition).getType() != DOMRegionContext.XML_CONTENT)) ||
- (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_TAG_OPEN) ||
- (flatNode.getPrevious().getLastRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN))) {
-
- // Is the region also the start of the node? If so, the
- // previous IStructuredDocumentRegion is
- // where to look for a useful region.
- region = flatNode.getPrevious().getLastRegion();
- }
- else if (flatNode.getEndOffset() == documentPosition) {
- region = flatNode.getLastRegion();
- }
- else {
- region = flatNode.getFirstRegion();
- }
- }
- else {
- // catch end of document positions where the docPosition isn't
- // in a IStructuredDocumentRegion
- region = flatNode.getLastRegion();
- }
- }
-
- return region;
- }
-
- private int getElementPosition(Node child) {
- Node parent = child.getParentNode();
- if (parent == null) {
- return 0;
- }
-
- NodeList children = parent.getChildNodes();
- if (children == null) {
- return 0;
- }
- int count = 0;
-
- for (int i = 0; i < children.getLength(); i++) {
- if (children.item(i) == child) {
- return count;
- }
- else {
- // if (children.item(i).getNodeType() == Node.ELEMENT_NODE)
- count++;
- }
- }
- return 0;
- }
-
- private String getMatchString(IStructuredDocumentRegion parent, ITextRegion aRegion, int offset) {
- if ((aRegion == null) || isCloseRegion(aRegion)) {
- return ""; //$NON-NLS-1$
- }
- String matchString = null;
- String regionType = aRegion.getType();
- if ((regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (regionType == DOMRegionContext.XML_TAG_OPEN) || (offset > parent.getStartOffset(aRegion) + aRegion.getTextLength())) {
- matchString = ""; //$NON-NLS-1$
- }
- else if (regionType == DOMRegionContext.XML_CONTENT) {
- matchString = ""; //$NON-NLS-1$
- }
- else {
- if ((parent.getText(aRegion).length() > 0) && (parent.getStartOffset(aRegion) < offset)) {
- matchString = parent.getText(aRegion).substring(0, offset - parent.getStartOffset(aRegion));
- }
- else {
- matchString = ""; //$NON-NLS-1$
- }
- }
- return matchString;
- }
-
- private ITextRegion getNameRegion(IStructuredDocumentRegion flatNode) {
- if (flatNode == null) {
- return null;
- }
- Iterator regionList = flatNode.getRegions().iterator();
- while (regionList.hasNext()) {
- ITextRegion region = (ITextRegion) regionList.next();
- if (isNameRegion(region)) {
- return region;
- }
- }
- return null;
- }
-
- private boolean isCloseRegion(ITextRegion region) {
- String type = region.getType();
- return ((type == DOMRegionContext.XML_PI_CLOSE) ||
- (type == DOMRegionContext.XML_TAG_CLOSE) ||
- (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE) ||
- (type == DOMRegionContext.XML_CDATA_CLOSE) ||
- (type == DOMRegionContext.XML_COMMENT_CLOSE) ||
- (type == DOMRegionContext.XML_ATTLIST_DECL_CLOSE) ||
- (type == DOMRegionContext.XML_ELEMENT_DECL_CLOSE) ||
- (type == DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE) ||
- (type == DOMJSPRegionContextsPrivateCopy.JSP_CLOSE) ||
- (type == DOMJSPRegionContextsPrivateCopy.JSP_COMMENT_CLOSE) ||
- (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_CLOSE)) ||
- (type == DOMRegionContext.XML_DECLARATION_CLOSE));
- }
-
- private boolean isNameRegion(ITextRegion region) {
- String type = region.getType();
- return ((type == DOMRegionContext.XML_TAG_NAME) ||
- (type == DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_NAME) ||
- (type == DOMRegionContext.XML_ELEMENT_DECL_NAME) ||
- (type == DOMRegionContext.XML_DOCTYPE_NAME) ||
- (type == DOMRegionContext.XML_ATTLIST_DECL_NAME) ||
- (type == DOMJSPRegionContextsPrivateCopy.JSP_ROOT_TAG_NAME) ||
- type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_NAME));
- }
-
- /**
- * Returns a validator used to determine when displayed context
- * information should be dismissed. May only return <code>null</code> if
- * the processor is incapable of computing context information.
- *
- * a context information validator, or <code>null</code> if the
- * processor is incapable of computing context information
- */
- private IContextInformationValidator getContextInformationValidator() {
- if (fContextInformationPresenter == null) {
- fContextInformationPresenter = new AttributeContextInformationPresenter();
- }
- return fContextInformationPresenter;
- }
-
- /**
- * StructuredTextViewer must be set before using this.
- */
- private IStructuredDocumentRegion getStructuredDocumentRegion(int pos) {
- return ContentAssistUtils.getStructuredDocumentRegion(fTextViewer, pos);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLModelQueryCompletionProposalComputer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLModelQueryCompletionProposalComputer.java
deleted file mode 100644
index 82a68e9020..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AbstractXMLModelQueryCompletionProposalComputer.java
+++ /dev/null
@@ -1,1834 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Properties;
-import java.util.Vector;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMEntityDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.document.AttrImpl;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.eclipse.wst.xml.ui.internal.taginfo.MarkupTagInfoProvider;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Document;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-
-/**
- * <p>Implementation of an {@link AbstractXMLCompletionProposalComputer} that uses {@link ModelQuery}s
- * to make its proposals.</p>
- *
- * @base org.eclipse.wst.xml.ui.internal.contentassist.AbstractContentAssistProcessor
- */
-public abstract class AbstractXMLModelQueryCompletionProposalComputer extends AbstractXMLCompletionProposalComputer {
-
- private static MarkupTagInfoProvider infoProvider = new MarkupTagInfoProvider();
-
- /**
- * <p>Default constructor</p>
- */
- public AbstractXMLModelQueryCompletionProposalComputer() {
- }
-
- /**
- * <p>default is to do nothing</p>
- *
- * @see org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer#sessionEnded()
- */
- public void sessionEnded() {
- //default is to do nothing
- }
-
- /**
- * <p>default is to do nothing</p>
- *
- * @see org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer#sessionStarted()
- */
- public void sessionStarted() {
- //default is to do nothing
- }
-
- /**
- * @return {@link XMLContentModelGenerator} used to generate proposals
- */
- protected abstract XMLContentModelGenerator getContentGenerator();
-
- /**
- * <p>Given a {@link CMNode} generated by a model query should decide if the
- * action is valid for this implementation of the model query proposal computer</p>
- *
- * <p>This is needed because {@link ModelQuery}s return a lot of {@link CMNode}s that
- * can come from multiple sources and a particular computer may not want to propose
- * all of the actions as content assist proposals</p>
- *
- * @param action {@link CMNode} to decide if it is valid as a result
- * for this model query proposal computer
- *
- * @return <code>true</code> if the given {@link CMNode} is valid for this
- * computer, <code>false</code> otherwise
- */
- protected abstract boolean validModelQueryNode(CMNode node);
-
- protected void addAttributeNameProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- IStructuredDocumentRegion sdRegion = contentAssistRequest.getDocumentRegion();
- // retrieve the list of attributes
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
- if (elementDecl != null) {
- CMNamedNodeMapImpl attributes = new CMNamedNodeMapImpl(elementDecl.getAttributes());
- addModelQueryAttributeDeclarations(node, elementDecl,attributes);
-
- String matchString = contentAssistRequest.getMatchString();
-
- // check whether an attribute really exists for the replacement
- // offsets AND if it possesses a value
- boolean attrAtLocationHasValue = false;
- NamedNodeMap attrs = node.getAttributes();
- for (int i = 0; i < attrs.getLength(); i++) {
- AttrImpl existingAttr = (AttrImpl) attrs.item(i);
- ITextRegion name = existingAttr.getNameRegion();
-
- if ((sdRegion.getStartOffset(name) <= contentAssistRequest.getReplacementBeginPosition()) &&
- (sdRegion.getStartOffset(name) + name.getLength() >= contentAssistRequest.getReplacementBeginPosition() + contentAssistRequest.getReplacementLength()) &&
- (existingAttr.getValueRegion() != null)) {
-
- attrAtLocationHasValue = true;
- break;
- }
- }
-
- // only add proposals for the attributes whose names begin with the matchstring
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributes.item(i);
-
- if(validModelQueryNode(attrDecl)) {
- int isRequired = 0;
- if (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) {
- isRequired = XMLRelevanceConstants.R_REQUIRED;
- }
-
- boolean showAttribute = true;
- showAttribute = showAttribute && beginsWith(getRequiredName(node, attrDecl), matchString.trim());
- AttrImpl attr = (AttrImpl) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
- ITextRegion nameRegion = attr != null ? attr.getNameRegion() : null;
- // nameRegion.getEndOffset() + 1 is required to allow for
- // matches against the full name of an existing Attr
- showAttribute = showAttribute && ((attr == null) ||
- ((nameRegion != null) &&
- (sdRegion.getStartOffset(nameRegion) <=
- contentAssistRequest.getReplacementBeginPosition()) &&
- (sdRegion.getStartOffset(nameRegion) + nameRegion.getLength() >=
- (contentAssistRequest.getReplacementBeginPosition() +
- contentAssistRequest.getReplacementLength()) )));
- if (showAttribute) {
- //get the proposal image
- Image attrImage = CMImageUtil.getImage(attrDecl);
- if (attrImage == null) {
- if (isRequired > 0) {
- attrImage = this.getRequiredAttributeImage();
- } else {
- attrImage = this.getNotRequiredAttributeImage();
- }
- }
-
- String proposedText = null;
- String proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
- CustomCompletionProposal proposal = null;
- // attribute is at this location and already exists
- if (attrAtLocationHasValue) {
- // only propose the name
- proposedText = getRequiredName(node, attrDecl);
- proposal = new CustomCompletionProposal(
- proposedText, contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), proposedText.length(),
- attrImage, proposedText, null, proposedInfo,
- XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired, true);
- }
- // no attribute exists or is elsewhere, generate
- // minimally
- else {
- Attr existingAttrNode = (Attr) node.getAttributes().getNamedItem(getRequiredName(node, attrDecl));
- String value = null;
- if (existingAttrNode != null) {
- value = existingAttrNode.getNodeValue();
- }
- if ((value != null) && (value.length() > 0)) {
- proposedText = getRequiredName(node, attrDecl);
- }
- else {
- proposedText = getRequiredText(node, attrDecl);
- }
- proposal = new CustomCompletionProposal(proposedText,
- contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(),
- attrDecl.getNodeName().length() + 2, attrImage,
- // if the value isn't empty (no empty set of quotes), show it
- // BUG 203494, content strings may have "", but not be empty
- // An empty string is when there's no content between double quotes
- // and there is no single quote that may be encasing a double quote
- ((proposedText.lastIndexOf('\"') - proposedText.indexOf('\"') == 1 &&
- proposedText.indexOf('\'') == -1)) ? getRequiredName(node, attrDecl) : proposedText,
- null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_NAME + isRequired);
- }
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- }
- else {
- setErrorMessage(NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{node.getNodeName()})));
- }
- }
-
- protected void addAttributeValueProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
-
- // Find the attribute region and name for which this position should
- // have a value proposed
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(contentAssistRequest.getRegion());
- if (i < 0) {
- return;
- }
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- break;
- }
- }
-
- // the name region is REQUIRED to do anything useful
- if (nameRegion != null) {
- // Retrieve the declaration
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
-
- // String attributeName = nameRegion.getText();
- String attributeName = open.getText(nameRegion);
-
- CMAttributeDeclaration attrDecl = null;
-
- // No CMElementDeclaration means no attribute metadata, but retrieve the
- // declaration for the attribute otherwise
- if (elementDecl != null) {
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(elementDecl.getAttributes()) {
- private Map caseInsensitive;
-
- private Map getCaseInsensitiveMap() {
- if(caseInsensitive == null)
- caseInsensitive = new HashMap();
- return caseInsensitive;
- }
-
- public CMNode getNamedItem(String name) {
- CMNode node = super.getNamedItem(name);
- if (node == null) {
- node = (CMNode) getCaseInsensitiveMap().get(name.toLowerCase(Locale.US));
- }
- return node;
- }
-
- public void put(CMNode cmNode) {
- super.put(cmNode);
- getCaseInsensitiveMap().put(cmNode.getNodeName().toLowerCase(Locale.US), cmNode);
- }
- };
- this.addModelQueryAttributeDeclarations(node, elementDecl, allAttributes);
-
- String noprefixName = DOMNamespaceHelper.getUnprefixedName(attributeName);
- if (allAttributes != null) {
- attrDecl = (CMAttributeDeclaration) allAttributes.getNamedItem(noprefixName);
- if (attrDecl == null) {
- attrDecl = (CMAttributeDeclaration) allAttributes.getNamedItem(attributeName);
- }
- }
- if (attrDecl == null) {
- setErrorMessage(XMLUIMessages.No_known_attribute__UI_ + attributeName);
- }
- }
-
- String currentValue = node.getAttributes().getNamedItem(attributeName).getNodeValue();
- String proposedInfo = null;
- //get proposal image
- Image image = CMImageUtil.getImage(attrDecl);
- if (image == null) {
- if ((attrDecl != null) && (attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED)) {
- image = this.getRequiredAttributeImage();
- } else {
- image = this.getNotRequiredAttributeImage();
- }
- }
-
- if ((attrDecl != null) && (attrDecl.getAttrType() != null)) {
- // attribute is known, prompt with values from the declaration
- proposedInfo = getAdditionalInfo(elementDecl, attrDecl);
- List possibleValues = getPossibleDataTypeValues(node, attrDecl);
- String defaultValue = attrDecl.getAttrType().getImpliedValue();
- if (possibleValues.size() > 0 || defaultValue != null) {
- // ENUMERATED VALUES
- String matchString = contentAssistRequest.getMatchString();
- if (matchString == null) {
- matchString = ""; //$NON-NLS-1$
- }
- if ((matchString.length() > 0) && (matchString.startsWith("\"") || matchString.startsWith("'"))) { //$NON-NLS-1$ //$NON-NLS-2$
- matchString = matchString.substring(1);
- }
- boolean currentValid = false;
-
- //create suggestions for enumerated values
- int rOffset = contentAssistRequest.getReplacementBeginPosition();
- int rLength = contentAssistRequest.getReplacementLength();
- for (Iterator j = possibleValues.iterator(); j.hasNext();) {
- String possibleValue = (String) j.next();
- if(!possibleValue.equals(defaultValue)) {
- currentValid = currentValid || possibleValue.equals(currentValue);
- if ((matchString.length() == 0) || possibleValue.startsWith(matchString)) {
- String rString = "\"" + possibleValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- rString, rOffset, rLength, possibleValue.length() + 1,
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM),
- rString, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if(defaultValue != null && ((matchString.length() == 0) || defaultValue.startsWith(matchString))) {
- String rString = "\"" + defaultValue + "\""; //$NON-NLS-1$ //$NON-NLS-2$
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- rString, rOffset, rLength, defaultValue.length() + 1,
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DEFAULT),
- rString, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) ||
- (attrDecl.getAttrType().getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) &&
- (attrDecl.getAttrType().getImpliedValue() != null)) {
-
- // FIXED values
- String value = attrDecl.getAttrType().getImpliedValue();
- if ((value != null) && (value.length() > 0)) {
- String rValue = "\"" + value + "\"";//$NON-NLS-2$//$NON-NLS-1$
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- rValue, contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), rValue.length() + 1,
- image, rValue, null, proposedInfo,
- XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- if ((currentValue.length() > 0) && !value.equals(currentValue)) {
- rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
- proposal = new CustomCompletionProposal(rValue, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), rValue.length() + 1, image, rValue, null, proposedInfo, XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- else {
- // unknown attribute, so supply nice empty values
- proposedInfo = getAdditionalInfo(null, elementDecl);
- CustomCompletionProposal proposal = null;
- if ((currentValue != null) && (currentValue.length() > 0)) {
- String rValue = "\"" + currentValue + "\""; //$NON-NLS-2$//$NON-NLS-1$
- proposal = new CustomCompletionProposal(rValue,
- contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), 1, image,
- rValue, null, proposedInfo,
- XMLRelevanceConstants.R_XML_ATTRIBUTE_VALUE);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- else {
- setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
- }
- }
-
- protected void addCommentProposal(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- contentAssistRequest.addProposal(new CustomCompletionProposal("<!-- -->", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), 5,
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_COMMENT),
- NLS.bind(XMLUIMessages.Comment__, (new Object[]{" <!-- -->"})), //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_COMMENT));
- }
-
-
-
- /**
- * Add the proposals for the name in an end tag
- */
- protected void addEndTagNameProposals(ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- if (contentAssistRequest.getStartOffset() + contentAssistRequest.getRegion().getTextLength() < contentAssistRequest.getReplacementBeginPosition()) {
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 1, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC), NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_END_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- else {
- Node aNode = contentAssistRequest.getNode();
- String matchString = contentAssistRequest.getMatchString();
- if (matchString.startsWith("</")) { //$NON-NLS-1$
- matchString = matchString.substring(2);
- }
- while (aNode != null) {
- if (aNode.getNodeType() == Node.ELEMENT_NODE) {
- if (aNode.getNodeName().startsWith(matchString)) {
- IDOMNode aXMLNode = (IDOMNode) aNode;
- CMElementDeclaration ed = getCMElementDeclaration(aNode);
- if ((aXMLNode.getEndStructuredDocumentRegion() == null) && ((ed == null) || (ed.getContentType() != CMElementDeclaration.EMPTY))) {
- String replacementText = aNode.getNodeName();
- String displayText = replacementText;
- String proposedInfo = (ed != null) ? getAdditionalInfo(null, ed) : null;
- if(!contentAssistRequest.getDocumentRegion().isEnded()) {
- replacementText += ">"; //$NON-NLS-1$
- }
- CustomCompletionProposal proposal = null;
- // double check to see if the region acted upon is
- // a tag name; replace it if so
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = this.getGenericTagImage();
- }
- if (contentAssistRequest.getRegion().getType() == DOMRegionContext.XML_TAG_NAME) {
- proposal = new CustomCompletionProposal(
- replacementText, contentAssistRequest.getStartOffset(),
- contentAssistRequest.getRegion().getTextLength(),
- replacementText.length(), image, displayText, null,
- proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
- }
- else {
- proposal = new CustomCompletionProposal(
- replacementText,
- contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(),
- replacementText.length(), image,
- NLS.bind(XMLUIMessages.Close_with__,
- (new Object[]{"'" + displayText + "'"})), //$NON-NLS-1$ //$NON-NLS-2$
- null, proposedInfo, XMLRelevanceConstants.R_END_TAG_NAME);
- }
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- aNode = aNode.getParentNode();
- }
- }
- }
-
- /**
- * Prompt for end tags to a non-empty Node that hasn't ended Handles these
- * cases: <br>
- * <tagOpen>| <br>
- * <tagOpen>< |<br>
- * <tagOpen></ |
- *
- * @param contentAssistRequest
- */
- protected void addEndTagProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
-
- if (isCommentNode(node)) {
- // loop and find non comment node parent
- while ((node != null) && isCommentNode(node)) {
- node = (IDOMNode) node.getParentNode();
- }
- }
-
- // node is already closed
- if (node.isClosed()) {
- // loop and find non comment unclose node parent
- while ((node != null) && node.isClosed()) {
- node = (IDOMNode) node.getParentNode();
- }
- }
- // there were no unclosed tags
- if (node == null) {
- return;
- }
-
- // data to create a CustomCompletionProposal
- String replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
- int replaceBegin = contentAssistRequest.getReplacementBeginPosition();
- int replaceLength = contentAssistRequest.getReplacementLength();
- int cursorOffset = node.getNodeName().length() + 1;
- String displayString = ""; //$NON-NLS-1$
- String proposedInfo = ""; //$NON-NLS-1$
- Image image = this.getGenericTagImage();
-
- setErrorMessage(null);
- boolean addProposal = false;
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- // ////////////////////////////////////////////////////////////////////////////////////
- IStructuredDocument sDoc = (IStructuredDocument) context.getDocument();
- IStructuredDocumentRegion xmlEndTagOpen = sDoc.getRegionAtCharacterOffset(contentAssistRequest.getReplacementBeginPosition());
- // skip backward to "<", "</", or the (unclosed) start tag, null if not found
- String type = ""; //$NON-NLS-1$
- while ((xmlEndTagOpen != null) &&
- ((type = xmlEndTagOpen.getType()) != DOMRegionContext.XML_END_TAG_OPEN) &&
- (type != DOMRegionContext.XML_TAG_CLOSE) && !needsEndTag(xmlEndTagOpen, context) &&
- (type != DOMRegionContext.XML_TAG_OPEN)) {
-
- xmlEndTagOpen = xmlEndTagOpen.getPrevious();
- }
-
- if (xmlEndTagOpen == null) {
- return;
- }
-
- node = (IDOMNode) node.getModel().getIndexedRegion(xmlEndTagOpen.getStartOffset());
- node = (IDOMNode) node.getParentNode();
-
- if (isStartTag(xmlEndTagOpen)) {
- // this is the case for a start tag w/out end tag
- // eg:
- // <p>
- // <% String test = "test"; %>
- // |
- if (needsEndTag(xmlEndTagOpen, context)) {
- String tagName = getTagName(xmlEndTagOpen);
- xmlEndTagOpen.getTextEndOffset();
- replaceLength = 0;
- replaceText = "</" + tagName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
- cursorOffset = tagName.length() + 3;
- displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{tagName}));
- addProposal = true;
- }
- }
- else if (type == DOMRegionContext.XML_END_TAG_OPEN) {
- // this is the case for: <tag> </ |
- // possibly <tag> </ |<anotherTag>
- // should only be replacing white space...
- replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
- replaceText = node.getNodeName() + ">"; //$NON-NLS-1$
- cursorOffset = replaceText.length();
- replaceBegin = xmlEndTagOpen.getTextEndOffset();
- displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{node.getNodeName()}));
- addProposal = true;
- }
- else if (type == DOMRegionContext.XML_TAG_OPEN) {
- // this is the case for: <tag> < |
- replaceText = "/" + node.getNodeName() + ">"; //$NON-NLS-1$ //$NON-NLS-2$ $NON-NLS-2$
- cursorOffset = replaceText.length();
-
- // should only be replacing white space...
- replaceLength = (replaceBegin > xmlEndTagOpen.getTextEndOffset()) ? replaceBegin - xmlEndTagOpen.getTextEndOffset() : 0;
- replaceBegin = xmlEndTagOpen.getTextEndOffset();
- displayString = NLS.bind(XMLUIMessages.End_with_, (new Object[]{"/" + node.getNodeName()})); //$NON-NLS-1$
- addProposal = true;
- }
- }
- // ////////////////////////////////////////////////////////////////////////////////////
- // sometimes the node is not null, but
- // getNodeValue() is null, put in a null check
- else if ((node.getNodeValue() != null) && (node.getNodeValue().indexOf("</") != -1)) { //$NON-NLS-1$
- // the case where "</" is started, but the nodes comes in as a
- // text node (instead of element)
- // like this: <tag> </|
- Node parent = node.getParentNode();
- if ((parent != null) && (parent.getNodeType() != Node.DOCUMENT_NODE)) {
- replaceText = parent.getNodeName() + ">"; //$NON-NLS-1$
- cursorOffset = replaceText.length();
- displayString = NLS.bind(XMLUIMessages.End_with__, (new Object[]{parent.getNodeName()}));
- setErrorMessage(null);
- addProposal = true;
- }
- }
- // ////////////////////////////////////////////////////////////////////////////////////
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
- }
- if (addProposal == true) {
- CustomCompletionProposal proposal = new CustomCompletionProposal(replaceText, replaceBegin, replaceLength, cursorOffset, image, displayString, null, proposedInfo, XMLRelevanceConstants.R_END_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
-
- protected void addEntityProposals(
- ContentAssistRequest contentAssistRequest,
- ITextRegion completionRegion, IDOMNode treeNode,
- CompletionProposalInvocationContext context) {
-
- ICompletionProposal[] eps = computeEntityReferenceProposals(completionRegion,
- treeNode, context);
- for (int i = 0; (eps != null) && (i < eps.length); i++) {
- contentAssistRequest.addProposal(eps[i]);
- }
- }
-
- protected void addEntityProposals(Vector proposals, Properties map,
- String key, int nodeOffset, IStructuredDocumentRegion sdRegion,
- ITextRegion completionRegion,
- CompletionProposalInvocationContext context) {
-
- if (map == null) {
- return;
- }
- String entityName = ""; //$NON-NLS-1$
- String entityValue = ""; //$NON-NLS-1$
- Image entityIcon = this.getEntityReferenceImage();
- String replacementText = ""; //$NON-NLS-1$
- String displayString = ""; //$NON-NLS-1$
- Enumeration keys = map.keys();
-
- while ((keys != null) && keys.hasMoreElements()) {
- entityName = (String) keys.nextElement();
- entityValue = map.getProperty(entityName);
- // filter based on partial entity string...
- if (entityName.toLowerCase().startsWith(key.toLowerCase()) || key.trim().equals("")) //$NON-NLS-1$
- {
- // figure out selection...if text is selected, add it to
- // selection length
- int selectionLength = nodeOffset;
- if (context.getViewer() != null) {
- selectionLength += context.getViewer().getSelectedRange().y;
- }
- // create a new proposal for entity string...
- replacementText = "&" + entityName + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- displayString = "&" + entityName + "; (" + entityValue + ")"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- ICompletionProposal cp = new CustomCompletionProposal(replacementText, sdRegion.getStartOffset(completionRegion), selectionLength, replacementText.length(), entityIcon, displayString, null, null, XMLRelevanceConstants.R_ENTITY);
- if (cp != null) {
- proposals.add(cp);
- }
- }
- }
- }
-
- protected void addPCDATAProposal(String nodeName,
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- CustomCompletionProposal proposal = new CustomCompletionProposal("<![CDATA[]]>", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), 9, XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_CDATASECTION), "CDATA Section", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_CDATA);
- contentAssistRequest.addProposal(proposal);
-
- proposal = new CustomCompletionProposal(nodeName, contentAssistRequest.getReplacementBeginPosition(), contentAssistRequest.getReplacementLength(), nodeName.length(), XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT), "#PCDATA", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_CDATA);
- contentAssistRequest.addProposal(proposal);
- }
-
- protected void addStartDocumentProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- //determine if XMLPI is first element
- Node aNode = contentAssistRequest.getNode();
- Document owningDocument = aNode.getOwnerDocument();
- Node first = owningDocument.getFirstChild();
- boolean xmlpiIsFirstElement = ((first != null) && (first.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE));
-
- // make sure xmlpi is root element don't want doctype proposal if XMLPI isn't first element...
- if (xmlpiIsFirstElement && (owningDocument.getDoctype() == null) &&
- isCursorAfterXMLPI(contentAssistRequest)) {
-
- addDocTypeProposal(contentAssistRequest, context);
- }
- }
-
- /**
- * Close an unclosed start tag
- */
- protected void addTagCloseProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- IDOMNode node = (IDOMNode) contentAssistRequest.getParent();
- if (node.getNodeType() == Node.ELEMENT_NODE) {
-
- CMElementDeclaration elementDecl = getCMElementDeclaration(node);
- String proposedInfo = (elementDecl != null) ? getAdditionalInfo(null, elementDecl) : null;
- int contentType = (elementDecl != null) ? elementDecl.getContentType() : CMElementDeclaration.ANY;
- // if it's XML and content doesn't HAVE to be element, add "/>" proposal.
- boolean endWithSlashBracket = (isXMLNode(node) && (contentType != CMElementDeclaration.ELEMENT));
-
- //get the image
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- image = this.getGenericTagImage();
- }
-
- // is the start tag ended properly?
- if ((contentAssistRequest.getDocumentRegion() == node.getFirstStructuredDocumentRegion()) && !(node.getFirstStructuredDocumentRegion()).isEnded()) {
- setErrorMessage(null);
- // Is this supposed to be an empty tag? Note that if we can't
- // tell, we assume it's not.
- if ((elementDecl != null) && (elementDecl.getContentType() == CMElementDeclaration.EMPTY)) {
- // prompt with a self-closing end character if needed
- // this is one of the few times to ignore the length -- always insert
- // contentAssistRequest.getReplacementLength()
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- getContentGenerator().getStartTagClose(node, elementDecl),
- contentAssistRequest.getReplacementBeginPosition(), 0,
- getContentGenerator().getStartTagClose(node, elementDecl).length(), image,
- NLS.bind(XMLUIMessages.Close_with___,(new Object[]{getContentGenerator().getStartTagClose(node, elementDecl)})),
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- else {
- // prompt with a close for the start tag
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the
- // length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
-
- // prompt with the closer for the start tag and an end tag if one is not present
- if (node.getEndStructuredDocumentRegion() == null) {
- // make sure tag name is actually what it thinks it
- // is...(eg. <%@ vs. <jsp:directive)
- IStructuredDocumentRegion sdr = contentAssistRequest.getDocumentRegion();
- String openingTagText = (sdr != null) ? sdr.getFullText() : ""; //$NON-NLS-1$
- if ((openingTagText != null) && (openingTagText.indexOf(node.getNodeName()) != -1)) {
- proposal = new CustomCompletionProposal("></" + node.getNodeName() + ">", //$NON-NLS-2$//$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to
- // ignore the length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with____, (new Object[]{node.getNodeName()})), null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- // prompt with slash bracket "/>" incase if it's a self ending tag
- if (endWithSlashBracket) {
- proposal = new CustomCompletionProposal("/>", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore
- // the length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 2, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" \"/>\""})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG + 1); // +1
- // to bring to top of list
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- else if ((contentAssistRequest.getDocumentRegion() == node.getLastStructuredDocumentRegion()) && !node.getLastStructuredDocumentRegion().isEnded()) {
- setErrorMessage(null);
- // prompt with a closing end character for the end tag
- CustomCompletionProposal proposal = new CustomCompletionProposal(">", //$NON-NLS-1$
- contentAssistRequest.getReplacementBeginPosition(),
- // this is one of the few times to ignore the length -- always insert
- // contentAssistRequest.getReplacementLength(),
- 0, 1, image, NLS.bind(XMLUIMessages.Close_with__, (new Object[]{" '>'"})), //$NON-NLS-1$
- null, proposedInfo, XMLRelevanceConstants.R_CLOSE_TAG);
- contentAssistRequest.addProposal(proposal);
- }
- }
- else if (node.getNodeType() == Node.DOCUMENT_NODE) {
- setErrorMessage(XMLUIMessages.Content_Assist_not_availab_UI_);
- }
- }
-
- protected void addTagInsertionProposals(
- ContentAssistRequest contentAssistRequest, int childPosition,
- CompletionProposalInvocationContext context) {
-
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- String error = null;
-
- // (nsd) This is only valid at the document element level
- // only valid if it's XML (check added 2/17/2004)
- if ((parent != null) && (parent.getNodeType() == Node.DOCUMENT_NODE) &&
- ((IDOMDocument) parent).isXMLType() && !isCursorAfterXMLPI(contentAssistRequest)) {
- return;
- }
- // only want proposals if cursor is after doctype...
- if (!isCursorAfterDoctype(contentAssistRequest)) {
- return;
- }
-
- // fix for meta-info comment nodes.. they currently "hide" other
- // proposals because the don't
- // have a content model (so can't propose any children..)
- if ((parent != null) && (parent instanceof IDOMNode) && isCommentNode((IDOMNode) parent)) {
- // loop and find non comment node?
- while ((parent != null) && isCommentNode((IDOMNode) parent)) {
- parent = parent.getParentNode();
- }
- }
-
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- // XSD-specific ability - no filtering
- CMDataType childType = parentDecl.getDataType();
- if (childType != null) {
- String[] childStrings = childType.getEnumeratedValues();
- String defaultValue = childType.getImpliedValue();
- if (childStrings != null || defaultValue != null) {
- // the content string is the sole valid child...so replace the rest
- int begin = contentAssistRequest.getReplacementBeginPosition();
- int length = contentAssistRequest.getReplacementLength();
- if (parent instanceof IDOMNode) {
- if (((IDOMNode) parent).getLastStructuredDocumentRegion() != ((IDOMNode) parent).getFirstStructuredDocumentRegion()) {
- begin = ((IDOMNode) parent).getFirstStructuredDocumentRegion().getEndOffset();
- length = ((IDOMNode) parent).getLastStructuredDocumentRegion().getStartOffset() - begin;
- }
- }
- String proposedInfo = getAdditionalInfo(parentDecl, childType);
- for (int i = 0; i < childStrings.length; i++) {
- if(!childStrings[i].equals(defaultValue)) {
- CustomCompletionProposal textProposal = new CustomCompletionProposal(
- childStrings[i],begin, length, childStrings[i].length(),
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENUM),
- childStrings[i], null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(textProposal);
- }
- }
- if(defaultValue != null) {
- CustomCompletionProposal textProposal = new CustomCompletionProposal(
- defaultValue, begin, length, defaultValue.length(),
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DEFAULT),
- defaultValue, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(textProposal);
- }
- }
- }
- }
- if ((parentDecl != null) && (parentDecl.getContentType() == CMElementDeclaration.PCDATA)) {
- addPCDATAProposal(parentDecl.getNodeName(), contentAssistRequest, context);
- }
- else {
- // retrieve the list of all possible children within this parent context
- cmnodes = getAvailableChildElementDeclarations((Element) parent, childPosition,ModelQueryAction.INSERT);
-
- // retrieve the list of the possible children within this
- // parent context and at this index
- List strictCMNodeSuggestions = null;
- if (XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY))) {
- strictCMNodeSuggestions = getValidChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
- }
- Iterator nodeIterator = cmnodes.iterator();
- if (!nodeIterator.hasNext()) {
- if (getCMElementDeclaration(parent) != null) {
- error = NLS.bind(XMLUIMessages._Has_no_available_child, (new Object[]{parent.getNodeName()}));
- }
- else {
- error = NLS.bind(XMLUIMessages.Element__is_unknown, (new Object[]{parent.getNodeName()}));
- }
- }
- String matchString = contentAssistRequest.getMatchString();
- // chop off any leading <'s and whitespace from the matchstring
- while ((matchString.length() > 0) &&
- (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) { //$NON-NLS-1$
-
- matchString = matchString.substring(1);
- }
- while (nodeIterator.hasNext()) {
- Object o = nodeIterator.next();
- if (o instanceof CMElementDeclaration) {
- CMElementDeclaration elementDecl =(CMElementDeclaration) o;
- // only add proposals for the child element's that
- // begin with the matchstring
- String tagname = getRequiredName(parent, elementDecl);
- boolean isStrictCMNodeSuggestion =
- strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false;
-
- //get the proposal image
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- if (strictCMNodeSuggestions != null) {
- image = isStrictCMNodeSuggestion ? this.getEmphasizedTagImage() : this.getDeemphasizedTagImage();
- } else {
- image = this.getGenericTagImage();
- }
- }
-
- if (beginsWith(tagname, matchString)) {
- String proposedText = getRequiredText(parent, elementDecl);
-
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
- // place cursor in first empty quotes
- int markupAdjustment = getCursorPositionForProposedText(proposedText);
-
- String proposedInfo = getAdditionalInfo(parentDecl, elementDecl);
- int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_INSERTION : XMLRelevanceConstants.R_TAG_INSERTION;
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- proposedText, contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), markupAdjustment,
- image, tagname, null, proposedInfo, relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null) {
- setErrorMessage(error);
- }
- else if ((contentAssistRequest.getMatchString() != null) &&
- (contentAssistRequest.getMatchString().length() > 0)) {
-
- setErrorMessage(NLS.bind(
- XMLUIMessages.No_known_child_tag,
- (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- }
- else {
- setErrorMessage(NLS.bind(
- XMLUIMessages.__Has_no_known_child,
- (new Object[]{parent.getNodeName()})));
- }
- }
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- // Can only prompt with elements if the cursor position is past
- // the XML processing
- // instruction and DOCTYPE declaration
- boolean xmlpiFound = false;
- boolean doctypeFound = false;
- int minimumOffset = -1;
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
-
- boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$
- boolean doctype = child.getNodeType() == Node.DOCUMENT_TYPE_NODE;
- if (xmlpi || (doctype && (minimumOffset < 0))) {
- minimumOffset = ((IDOMNode) child).getFirstStructuredDocumentRegion().getStartOffset() + ((IDOMNode) child).getFirstStructuredDocumentRegion().getTextLength();
- }
- xmlpiFound = xmlpiFound || xmlpi;
- doctypeFound = doctypeFound || doctype;
- }
-
- if (contentAssistRequest.getReplacementBeginPosition() >= minimumOffset) {
- List childDecls = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childDecls.size(); i++) {
- CMElementDeclaration ed = (CMElementDeclaration) childDecls.get(i);
- if (ed != null) {
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = this.getGenericTagImage();
- }
- String proposedText = getRequiredText(parent, ed);
- String tagname = getRequiredName(parent, ed);
- // account for the &lt; and &gt;
- int markupAdjustment = getContentGenerator().getMinimalStartTagLength(parent, ed);
- String proposedInfo = getAdditionalInfo(null, ed);
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- proposedText, contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), markupAdjustment, image,
- tagname, null, proposedInfo, XMLRelevanceConstants.R_TAG_INSERTION);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
- }
-
- protected void addTagNameProposals(
- ContentAssistRequest contentAssistRequest, int childPosition,
- CompletionProposalInvocationContext context) {
-
- List cmnodes = null;
- Node parent = contentAssistRequest.getParent();
- IDOMNode node = (IDOMNode) contentAssistRequest.getNode();
- String error = null;
- String matchString = contentAssistRequest.getMatchString();
- if (parent.getNodeType() == Node.ELEMENT_NODE) {
- // retrieve the list of children
- // validActions = getAvailableChildrenAtIndex((Element) parent,
- // childPosition);
- cmnodes = getAvailableChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
- List strictCMNodeSuggestions = null;
- if (XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT.equals(XMLUIPlugin.getInstance().getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY))) {
- strictCMNodeSuggestions = getValidChildElementDeclarations((Element) parent, childPosition, ModelQueryAction.INSERT);
- }
-
- Iterator nodeIterator = cmnodes.iterator();
- // chop off any leading <'s and whitespace from the matchstring
- while ((matchString.length() > 0) &&
- (Character.isWhitespace(matchString.charAt(0)) || beginsWith(matchString, "<"))) { //$NON-NLS-1$
-
- matchString = matchString.substring(1);
- }
- if (!nodeIterator.hasNext()) {
- error = NLS.bind(XMLUIMessages.__Has_no_known_child, (new Object[]{parent.getNodeName()}));
- }
- while (nodeIterator.hasNext()) {
- CMNode elementDecl = (CMNode) nodeIterator.next();
- if (elementDecl != null) {
- // only add proposals for the child element's that begin with the matchstring
- String proposedText = null;
- int cursorAdjustment = 0;
-
- //determine if strict suggestion
- boolean isStrictCMNodeSuggestion =
- strictCMNodeSuggestions != null ? strictCMNodeSuggestions.contains(elementDecl) : false;
-
- // do a check to see if partial attributes of partial tag names are in list
- if (((node != null) && (node.getAttributes() != null) &&
- (node.getAttributes().getLength() > 0) &&
- attributeInList(node, parent, elementDecl)) ||
- ((node.getNodeType() != Node.TEXT_NODE) &&
- node.getFirstStructuredDocumentRegion().isEnded())) {
-
- proposedText = getRequiredName(parent, elementDecl);
- cursorAdjustment = proposedText.length();
- }
- else {
- proposedText = getRequiredName(parent, elementDecl);
-
- cursorAdjustment = proposedText.length();
- if (elementDecl instanceof CMElementDeclaration) {
- CMElementDeclaration ed = (CMElementDeclaration) elementDecl;
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=89811
- StringBuffer sb = new StringBuffer();
- getContentGenerator().generateTag(parent, ed, sb);
- // since it's a name proposal, assume '<' is already there
- // only return the rest of the tag
- proposedText = sb.toString().substring(1);
- cursorAdjustment = getCursorPositionForProposedText(proposedText);
- }
- }
- if (beginsWith(proposedText, matchString)) {
- //get the proposal image
- Image image = CMImageUtil.getImage(elementDecl);
- if (image == null) {
- if (strictCMNodeSuggestions != null) {
- image = isStrictCMNodeSuggestion ? this.getEmphasizedTagImage() : this.getDeemphasizedTagImage();
- } else {
- image = this.getGenericTagImage();
- }
- }
- int relevance = isStrictCMNodeSuggestion ? XMLRelevanceConstants.R_STRICTLY_VALID_TAG_NAME : XMLRelevanceConstants.R_TAG_NAME;
- String proposedInfo = getAdditionalInfo(getCMElementDeclaration(parent), elementDecl);
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- proposedText, contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
- getRequiredName(parent, elementDecl), null, proposedInfo,
- relevance);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- if (contentAssistRequest.getProposals().size() == 0) {
- if (error != null) {
- setErrorMessage(error);
- }
- else if ((contentAssistRequest.getMatchString() != null) && (contentAssistRequest.getMatchString().length() > 0)) {
- setErrorMessage(NLS.bind(
- XMLUIMessages.No_known_child_tag_names,
- (new Object[]{parent.getNodeName(), contentAssistRequest.getMatchString()})));
- }
- else {
- setErrorMessage(NLS.bind(
- XMLUIMessages.__Has_no_known_child,
- (new Object[]{parent.getNodeName()})));
- }
- }
- }
- else if (parent.getNodeType() == Node.DOCUMENT_NODE) {
- List childElements = getAvailableRootChildren((Document) parent, childPosition);
- for (int i = 0; i < childElements.size(); i++) {
- CMNode ed = (CMNode) childElements.get(i);
- if (ed == null) {
- continue;
- }
- String proposedText = null;
- int cursorAdjustment = 0;
- if (ed instanceof CMElementDeclaration) {
- // proposedText = getRequiredName(parent, ed);
- StringBuffer sb = new StringBuffer();
- getContentGenerator().generateTag(parent, (CMElementDeclaration) ed, sb);
- // tag starts w/ '<', but we want to compare to name
- proposedText = sb.toString().substring(1);
-
- if (!beginsWith(proposedText, matchString)) {
- continue;
- }
-
- cursorAdjustment = getCursorPositionForProposedText(proposedText);
-
- String proposedInfo = getAdditionalInfo(null, ed);
- Image image = CMImageUtil.getImage(ed);
- if (image == null) {
- image = this.getGenericTagImage();
- }
- CustomCompletionProposal proposal = new CustomCompletionProposal(
- proposedText, contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), cursorAdjustment, image,
- getRequiredName(parent, ed), null, proposedInfo, XMLRelevanceConstants.R_TAG_NAME);
- contentAssistRequest.addProposal(proposal);
- }
- }
- }
- }
-
- protected void addEmptyDocumentProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- //by default do nothing
- }
-
- /**
- * <p>Implementers are allowed to override</p>
- *
- * @return the proposal image to display for generic tag proposals
- */
- protected Image getGenericTagImage() {
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC);
- }
-
- /**
- * <p>Implementers are allowed to override</p>
- *
- * @return the proposal image to display for emphasized tag proposals
- */
- protected Image getEmphasizedTagImage() {
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_EMPHASIZED);
- }
-
- /**
- * <p>Implementers are allowed to override</p>
- *
- * @return the proposal image to display for de-emphasized tag proposals
- */
- protected Image getDeemphasizedTagImage() {
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC_DEEMPHASIZED);
- }
-
- /**
- * <p>Implementers are allowed to override</p>
- *
- * @return the proposal image to display for entity reference proposals
- */
- protected Image getEntityReferenceImage() {
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ENTITY_REFERENCE);
- }
-
- /**
- * <p>Implementers are allowed to override</p>
- *
- * @return the proposal image to display for not required attributes
- */
- protected Image getNotRequiredAttributeImage() {
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- }
-
- /**
- * <p>Implementers are allowed to override</p>
- *
- * @return the proposal image to display for required attributes
- */
- protected Image getRequiredAttributeImage() {
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ATT_REQ_OBJ);
- }
-
- /**
- * This method can check if the cursor is after the XMLPI
- *
- * @param car
- */
- protected boolean isCursorAfterXMLPI(ContentAssistRequest car) {
- Node aNode = car.getNode();
- boolean xmlpiFound = false;
- Document parent = aNode.getOwnerDocument();
- int xmlpiNodePosition = -1;
- boolean isAfterXMLPI = false;
-
- if (parent == null) {
- return true; // blank document case
- }
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- boolean xmlpi = ((child.getNodeType() == Node.PROCESSING_INSTRUCTION_NODE) && child.getNodeName().equals("xml")); //$NON-NLS-1$
- xmlpiFound = xmlpiFound || xmlpi;
- if (xmlpiFound) {
- if (child instanceof IDOMNode) {
- xmlpiNodePosition = ((IDOMNode) child).getEndOffset();
- isAfterXMLPI = (car.getReplacementBeginPosition() >= xmlpiNodePosition);
- }
- break;
- }
- }
- return isAfterXMLPI;
- }
-
- private String getRequiredName(Node parentOrOwner, CMNode cmnode) {
- if ((cmnode == null) || (parentOrOwner == null)) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- return getContentGenerator().getRequiredName(parentOrOwner, cmnode);
- }
-
- private String getRequiredText(Node parentOrOwner, CMAttributeDeclaration attrDecl) {
- if (attrDecl == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null attribute declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- StringBuffer buff = new StringBuffer();
- getContentGenerator().generateRequiredAttribute(parentOrOwner, attrDecl, buff);
- return buff.toString();
- }
-
- private String getRequiredText(Node parentOrOwner, CMElementDeclaration elementDecl) {
- if (elementDecl == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null attribute declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return ""; //$NON-NLS-1$
- }
- StringBuffer buff = new StringBuffer();
- getContentGenerator().generateTag(parentOrOwner, elementDecl, buff);
- return buff.toString();
- }
-
- /**
- * Retrieves all of the possible valid values for this attribute
- * declaration
- */
- private List getPossibleDataTypeValues(Node node, CMAttributeDeclaration ad) {
- List list = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- Element element = (Element) node;
- String[] dataTypeValues = null;
- // The ModelQuery may not be available if the corresponding
- // adapter
- // is absent
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if (modelQuery != null) {
- dataTypeValues = modelQuery.getPossibleDataTypeValues(element, ad);
- }
- else {
- if (ad.getAttrType() != null) {
- dataTypeValues = ad.getAttrType().getEnumeratedValues();
- }
- }
- if (dataTypeValues != null) {
- list = new ArrayList(dataTypeValues.length);
- for (int i = 0; i < dataTypeValues.length; i++) {
- list.add(dataTypeValues[i]);
- }
- }
- }
- if (list == null) {
- list = new ArrayList(0);
- }
- return list;
- }
-
- /**
- * This is to determine if a tag is a special meta-info comment tag that
- * shows up as an ELEMENT
- *
- * @param node
- * @return
- */
- private boolean isCommentNode(IDOMNode node) {
- return ((node != null) && (node instanceof IDOMElement) && ((IDOMElement) node).isCommentTag());
- }
-
- private boolean isStartTag(IStructuredDocumentRegion sdRegion) {
- boolean result = false;
- if (sdRegion.getRegions().size() > 0) {
- ITextRegion r = sdRegion.getRegions().get(0);
- result = (r.getType() == DOMRegionContext.XML_TAG_OPEN) && sdRegion.isEnded();
- }
- return result;
- }
-
- /**
- * Gets the corresponding XMLNode, and checks if it's closed.
- *
- * @param startTag
- *
- */
- private boolean needsEndTag(IStructuredDocumentRegion startTag,
- CompletionProposalInvocationContext context) {
-
- boolean result = false;
- IStructuredModel sModel =
- StructuredModelManager.getModelManager().getExistingModelForRead(context.getDocument());
- try {
- if (sModel != null) {
- IDOMNode xmlNode = (IDOMNode) sModel.getIndexedRegion(startTag.getStart());
- if (!isStartTag(startTag)) {
- result = false;
- }
- else if (isSelfClosed(startTag)) {
- result = false;
- }
- else if (!xmlNode.isContainer()) {
- result = false;
- }
- else {
- result = xmlNode.getEndStructuredDocumentRegion() == null;
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- return result;
- }
-
- private boolean isSelfClosed(IStructuredDocumentRegion startTag) {
- ITextRegionList regions = startTag.getRegions();
- return regions.get(regions.size() - 1).getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE;
- }
-
- private String getTagName(IStructuredDocumentRegion sdRegion) {
- ITextRegionList regions = sdRegion.getRegions();
- ITextRegion region = null;
- String name = ""; //$NON-NLS-1$
- for (int i = 0; i < regions.size(); i++) {
- region = regions.get(i);
- if (region.getType() == DOMRegionContext.XML_TAG_NAME) {
- name = sdRegion.getText(region);
- break;
- }
- }
- return name;
- }
-
- /**
- * return all possible EntityReferenceProposals (according to current
- * position in doc)
- */
- private ICompletionProposal[] computeEntityReferenceProposals(ITextRegion completionRegion,
- IDOMNode treeNode,CompletionProposalInvocationContext context) {
-
- // only handle XML content for now
- int documentPosition = context.getInvocationOffset();
- Vector proposals = new Vector(); // ICompletionProposals
- IStructuredDocumentRegion sdRegion =
- ContentAssistUtils.getStructuredDocumentRegion(context.getViewer(), context.getInvocationOffset());
- if ((completionRegion != null) && (completionRegion.getType() == DOMRegionContext.XML_CONTENT)) {
- int nodeOffset = documentPosition - sdRegion.getStartOffset(completionRegion);
- String regionText = sdRegion.getFullText(completionRegion);
-
- // if directly to the right of a &, region will be null, need to
- // move to
- // the previous region...there might be a better way to do this
- if ((regionText != null) && regionText.trim().equals("") && (documentPosition > 0)) { //$NON-NLS-1$
- IStructuredDocumentRegion prev = treeNode.getStructuredDocument().getRegionAtCharacterOffset(documentPosition - 1);
- if ((prev != null) && prev.getText().equals("&")) { //$NON-NLS-1$
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=206680
- // examine previous region
- sdRegion = prev;
- completionRegion = prev.getLastRegion();
- regionText = prev.getFullText();
- nodeOffset = 1;
- }
- }
-
- // string must start w/ &
- if ((regionText != null) && regionText.startsWith("&")) { //$NON-NLS-1$
- String key = (nodeOffset > 0) ? regionText.substring(1, nodeOffset) : ""; //$NON-NLS-1$
-
- // get entity proposals, passing in the appropriate start
- // string
- ModelQuery mq = ModelQueryUtil.getModelQuery(((Node) treeNode).getOwnerDocument());
- if (mq != null) {
- CMDocument xmlDoc = mq.getCorrespondingCMDocument(treeNode);
- CMNamedNodeMap cmmap = null;
- Properties entities = null;
- if (xmlDoc != null) {
- cmmap = xmlDoc.getEntities();
- }
- if (cmmap != null) {
- entities = mapToProperties(cmmap);
- }
- else // 224787 in absence of content model, just use
- // minimal 5 entities
- {
- entities = new Properties();
- entities.put("quot", "\""); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("apos", "'"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("amp", "&"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("lt", "<"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("gt", ">"); //$NON-NLS-1$ //$NON-NLS-2$
- entities.put("nbsp", " "); //$NON-NLS-1$ //$NON-NLS-2$
- }
- addEntityProposals(proposals, entities, key,
- nodeOffset, sdRegion, completionRegion, context);
- }
- }
- }
- return (ICompletionProposal[]) ((proposals.size() > 0) ? proposals.toArray(new ICompletionProposal[proposals.size()]) : null);
- }
-
- /**
- * Similar to the call in HTMLContentAssistProcessor. Pass in a node, it
- * tells you if the document is XML type.
- *
- * @param node
- *
- */
- private boolean isXMLNode(Node node) {
- if (node == null) {
- return false;
- }
-
- Document doc = null;
- doc = (node.getNodeType() != Node.DOCUMENT_NODE) ? node.getOwnerDocument() : ((Document) node);
-
- return (doc instanceof IDOMDocument) && ((IDOMDocument) doc).isXMLType();
- }
-
- /**
- * Checks if cursor position is after doctype tag...
- *
- * @param car
- *
- */
- private boolean isCursorAfterDoctype(ContentAssistRequest car) {
- Node aNode = car.getNode();
- Document parent = aNode.getOwnerDocument();
- int xmldoctypeNodePosition = -1;
- boolean isAfterDoctype = true;
-
- if (parent == null) {
- return true; // blank document case
- }
-
- for (Node child = parent.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child instanceof IDOMNode) {
- if (child.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- xmldoctypeNodePosition = ((IDOMNode) child).getEndOffset();
- isAfterDoctype = (car.getReplacementBeginPosition() >= xmldoctypeNodePosition);
- break;
- }
- }
- }
- return isAfterDoctype;
- }
-
- /**
- * returns a list of CMElementDeclarations
- *
- * @param document
- * @param childIndex
- * @return
- */
- private List getAvailableRootChildren(Document document, int childIndex) {
- List list = null;
-
- // extract the valid 'root' node name from the DocumentType Node
- DocumentType docType = document.getDoctype();
- String rootName = null;
- if (docType != null) {
- rootName = docType.getNodeName();
- }
- if (rootName == null) {
- return new ArrayList(0);
- }
-
- for (Node child = document.getFirstChild(); child != null; child = child.getNextSibling()) {
- // make sure the "root" Element isn't already present
- // is it required to be an Element?
- if ((child.getNodeType() == Node.ELEMENT_NODE) && child.getNodeName().equalsIgnoreCase(rootName)) {
- // if the node is missing either the start or end tag, don't
- // count it as present
- if ((child instanceof IDOMNode) && ((((IDOMNode) child).getStartStructuredDocumentRegion() == null) || (((IDOMNode) child).getEndStructuredDocumentRegion() == null))) {
- continue;
- }
- if (Debug.displayInfo) {
- System.out.println(rootName + " already present!"); //$NON-NLS-1$
- }
- setErrorMessage(NLS.bind(XMLUIMessages.The_document_element__, (new Object[]{rootName})));
- return new ArrayList(0);
- }
- }
-
- list = new ArrayList(1);
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(document);
- if (modelQuery != null) {
- CMDocument cmdoc = modelQuery.getCorrespondingCMDocument(document);
- if (cmdoc != null) {
- if (rootName != null) {
- CMElementDeclaration rootDecl = (CMElementDeclaration) cmdoc.getElements().getNamedItem(rootName);
- if (rootDecl != null) {
- list.add(rootDecl);
- }
- else {
- // supply the given document name anyway, even if it
- // is an error
- list.add(new SimpleCMElementDeclaration(rootName));
-
- String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (location.length() > 0) {
- setErrorMessage(NLS.bind(
- XMLUIMessages.No_definition_for_in,
- (new Object[]{rootName, location})));
- }
- else {
- setErrorMessage(NLS.bind(
- XMLUIMessages.No_definition_for,
- (new Object[]{rootName})));
- }
- }
- }
- }
- else {
- String location = "" + (docType.getPublicId() != null ? docType.getPublicId() + "/" : "") + (docType.getSystemId() != null ? docType.getSystemId() : ""); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
- if (location.length() > 0) {
- setErrorMessage(NLS.bind(
- XMLUIMessages.No_content_model_for,
- (new Object[]{location})));
- }
- else {
- setErrorMessage(XMLUIMessages.No_content_model_found_UI_);
- }
- }
- }
-
- return list;
- }
-
- /**
- * This method determines if any of the attributes in the proposed XMLNode
- * node, are possible values of attributes from possible Elements at this
- * point in the document according to the Content Model.
- *
- * @param node
- * the element with attributes that you would like to test if
- * are possible for possible Elements at this point
- * @param cmnode
- * possible element at this point in the document (depending on
- * what 'node' is) true if any attributes of 'node' match any
- * possible attributes from 'cmnodes' list.
- */
- private boolean attributeInList(IDOMNode node, Node parent, CMNode cmnode) {
- if ((node == null) || (parent == null) || (cmnode == null)) {
- return false;
- }
- String elementMatchString = node.getNodeName();
- String cmnodeName = getRequiredName(parent, cmnode);// cmnode.getNodeName();
- if (node instanceof Element) {
- NamedNodeMap map = ((Element) node).getAttributes();
- String attrMatchString = ""; //$NON-NLS-1$
- // iterate attribute possibilities for partially started node
- for (int i = 0; (map != null) && (i < map.getLength()); i++) {
- attrMatchString = map.item(i).getNodeName();
- // filter on whatever user typed for element name already
- if (beginsWith(cmnodeName, elementMatchString)) {
- if (cmnode.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- CMNamedNodeMapImpl attributes = new CMNamedNodeMapImpl(((CMElementDeclaration) cmnode).getAttributes());
- this.addModelQueryAttributeDeclarations(
- node,((CMElementDeclaration) cmnode),attributes);
-
- // iterate possible attributes from a cmnode in
- // proposal list
- for (int k = 0; (attributes != null) && (k < attributes.getLength()); k++) {
- // check if name matches
- if (attributes.item(k).getNodeName().equals(attrMatchString)) {
- return true;
- }
- }
- }
- }
- }
- }
- return false;
- }
-
- private Properties mapToProperties(CMNamedNodeMap map) {
- Properties p = new Properties();
- for (int i = 0; i < map.getLength(); i++) {
- CMEntityDeclaration decl = (CMEntityDeclaration) map.item(i);
- p.put(decl.getName(), decl.getValue());
- }
- return p;
- }
-
- /**
- * <p>Adds model query attribute declaration proposals</p>
- *
- * @param node
- * @param elementDecl
- * @param allAttributes
- */
- private void addModelQueryAttributeDeclarations(IDOMNode node,
- CMElementDeclaration elementDecl, CMNamedNodeMapImpl allAttributes) {
-
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- nodes = filterAvailableModelQueryCMNodes(nodes);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- }
- }
-
- /**
- * returns a list of CMNodes that are available within this parent context
- * Given the grammar shown below and a snippet of XML code (where the '|'
- * indicated the cursor position)
- * the list would return all of the element declarations that are
- * potential child elements of Foo.
- *
- * grammar : Foo -> (A, B, C)
- * snippet : <Foo><A>|
- * result : {A, B, C}
- *
- * TODO cs... do we need to pass in the 'kindOfAction'? Seems to me we
- * could assume it's always an insert.
- *
- * @param parent
- * @param childPosition
- * @param kindOfAction
- * @return
- */
- private List getAvailableChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
- List modelQueryActions = getAvailableModelQueryActionsAtIndex(parent, childPosition, ModelQuery.VALIDITY_NONE);
- Iterator iterator = modelQueryActions.iterator();
- List cmnodes = new Vector();
- while (iterator.hasNext()) {
- ModelQueryAction action = (ModelQueryAction) iterator.next();
- if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
- CMNode actionCMNode = action.getCMNode();
- if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
- cmnodes.add(actionCMNode);
- }
- }
- }
- return cmnodes;
- }
-
- /**
- * returns a list of CMNodes that can be validly inserted at this
- * childPosition
- * Given the grammar shown below and a snippet of XML code (where the '|'
- * indicated the cursor position)
- * the list would return only the element declarations can be inserted
- * while maintaing validity of the content.
- *
- * grammar : Foo -> (A, B, C)
- * snippet : <Foo><A>|
- * result : {B}
- *
- * @param parent
- * @param childPosition
- * @param kindOfAction
- * @return
- */
- private List getValidChildElementDeclarations(Element parent, int childPosition, int kindOfAction) {
- List modelQueryActions = getAvailableModelQueryActionsAtIndex(parent, childPosition, ModelQuery.VALIDITY_STRICT);
- Iterator iterator = modelQueryActions.iterator();
- List cmnodes = new Vector();
- while (iterator.hasNext()) {
- ModelQueryAction action = (ModelQueryAction) iterator.next();
- if ((childPosition < 0) || (((action.getStartIndex() <= childPosition) && (childPosition <= action.getEndIndex())) && (action.getKind() == kindOfAction))) {
- CMNode actionCMNode = action.getCMNode();
- if ((actionCMNode != null) && !cmnodes.contains(actionCMNode)) {
- cmnodes.add(actionCMNode);
- }
- }
- }
- return cmnodes;
- }
-
- /**
- * returns a list of ModelQueryActions
- *
- * @param parent
- * @param index
- * @param validityChecking
- * @return
- */
- private List getAvailableModelQueryActionsAtIndex(Element parent, int index, int validityChecking) {
- List list = new ArrayList();
- CMElementDeclaration parentDecl = getCMElementDeclaration(parent);
- if (parentDecl != null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument());
- // taken from ActionManagers
- // int editMode = modelQuery.getEditMode();
- int editMode = ModelQuery.EDIT_MODE_UNCONSTRAINED;
- int ic = (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) ? ModelQuery.INCLUDE_CHILD_NODES | ModelQuery.INCLUDE_SEQUENCE_GROUPS : ModelQuery.INCLUDE_CHILD_NODES;
- modelQuery.getInsertActions(parent, parentDecl, index, ic, validityChecking, list);
- }
-
- list = filterAvailableModelQueryActions(list);
- return list;
- }
-
- /**
- * <p>Filters out any model query actions that are not valid for this
- * implementation of the model query computer based on the {@link CMNode}
- * of the action.</p>
- *
- * @param modelQueryActions
- * @return the filtered list of {@link ModelQueryAction}s
- */
- private List filterAvailableModelQueryActions(List modelQueryActions) {
- List filtered = new ArrayList(modelQueryActions.size());
-
- Iterator iterator = modelQueryActions.iterator();
- while (iterator.hasNext()) {
- ModelQueryAction action = (ModelQueryAction) iterator.next();
- if(validModelQueryNode(action.getCMNode())) {
- filtered.add(action);
- }
- }
-
- return filtered;
- }
-
- /**
- * <p>Filters out any model query {@link CMNode}s that are not valid for this
- * implementation of the model query computer</p>
- *
- * @param modelQueryNodes
- * @return the filtered list of {@link CMNode}s
- */
- private List filterAvailableModelQueryCMNodes(List modelQueryNodes) {
- List filtered = new ArrayList(modelQueryNodes.size());
-
- Iterator iterator = modelQueryNodes.iterator();
- while (iterator.hasNext()) {
- CMNode node = (CMNode) iterator.next();
- if(validModelQueryNode(node)) {
- filtered.add(node);
- }
- }
-
- return filtered;
- }
-
- /**
- * <p>Adds a generic doc type proposal</p>
- *
- * @param contentAssistRequest
- * @param context
- */
- private void addDocTypeProposal(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- // if a DocumentElement exists, use that for the root Element name
- String rootname = "unspecified"; //$NON-NLS-1$
- if (contentAssistRequest.getNode().getOwnerDocument().getDocumentElement() != null) {
- rootname = contentAssistRequest.getNode().getOwnerDocument().getDocumentElement().getNodeName();
- }
-
- String proposedText = "<!DOCTYPE " + rootname + " PUBLIC \"//UNKNOWN/\" \"unknown.dtd\">"; //$NON-NLS-1$ //$NON-NLS-2$
- ICompletionProposal proposal = new CustomCompletionProposal(
- proposedText, contentAssistRequest.getReplacementBeginPosition(),
- contentAssistRequest.getReplacementLength(), 10,
- XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DOCTYPE),
- "<!DOCTYPE ... >", //$NON-NLS-1$
- null, null, XMLRelevanceConstants.R_DOCTYPE);
- // TODO provide special documentation on doc type
- contentAssistRequest.addProposal(proposal);
- }
-
- public static CMElementDeclaration getCMElementDeclaration(Node node) {
- CMElementDeclaration result = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- if (modelQuery != null) {
- result = modelQuery.getCMElementDeclaration((Element) node);
- }
- }
- return result;
- }
-
- /**
- * Retrieves cmnode's documentation to display in the completion
- * proposal's additional info. If no documentation exists for cmnode, try
- * displaying parentOrOwner's documentation
- *
- * String any documentation information to display for cmnode.
- * <code>null</code> if there is nothing to display.
- */
- public static String getAdditionalInfo(CMNode parentOrOwner, CMNode cmnode) {
- String addlInfo = null;
-
- if (cmnode == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return null;
- }
-
- addlInfo = infoProvider.getInfo(cmnode);
- if ((addlInfo == null) && (parentOrOwner != null)) {
- addlInfo = infoProvider.getInfo(parentOrOwner);
- }
- return addlInfo;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java
deleted file mode 100644
index 66e514ae24..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformation.java
+++ /dev/null
@@ -1,115 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationExtension;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.ui.internal.util.Assert;
-
-
-/**
- * Implementation of IContextInformation. Adds knowledge about the information
- * display string such as required attributes for this context.
- *
- * @author pavery
- */
-public class AttributeContextInformation implements IContextInformation, IContextInformationExtension {
- private HashMap fAttr2RangeMap;
- /** The name of the context */
- private String fContextDisplayString;
- /** The image to be displayed */
- private Image fImage;
- /** The information to be displayed */
- private String fInformationDisplayString;
- private int fPosition = -1;
-
- /**
- * Creates a new context information with an image.
- *
- * @param image
- * the image to display when presenting the context information
- * @param contextDisplayString
- * the string to be used when presenting the context
- * @param informationDisplayString
- * the string to be displayed when presenting the context
- * information, may not be <code>null</code>
- */
- public AttributeContextInformation(Image image, String contextDisplayString, String informationDisplayString, HashMap attr2RangeMap) {
- Assert.isNotNull(informationDisplayString, "illegal argument: informationDisplayString can not be null"); //$NON-NLS-1$
-
- fImage = image;
- fContextDisplayString = contextDisplayString;
- fInformationDisplayString = informationDisplayString;
- fAttr2RangeMap = attr2RangeMap;
- }
-
- /**
- * Creates a new context information without an image.
- *
- * @param contextDisplayString
- * the string to be used when presenting the context
- * @param informationDisplayString
- * the string to be displayed when presenting the context
- * information
- */
- public AttributeContextInformation(String contextDisplayString, String informationDisplayString, HashMap attr2RangeMap) {
- this(null, contextDisplayString, informationDisplayString, attr2RangeMap);
- }
-
- /**
- * Maps (String -> Position). The attribute name to the Text position.
- *
- *
- */
- public HashMap getAttr2RangeMap() {
- return fAttr2RangeMap;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformation#getContextDisplayString()
- */
- public String getContextDisplayString() {
- if (fContextDisplayString != null) {
- return fContextDisplayString;
- }
- return fInformationDisplayString;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationExtension#getContextInformationPosition()
- */
- public int getContextInformationPosition() {
- return fPosition;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformation#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformation#getInformationDisplayString()
- */
- public String getInformationDisplayString() {
- return fInformationDisplayString;
- }
-
- public void setContextInformationPosition(int position) {
- fPosition = position;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java
deleted file mode 100644
index acd660bb20..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationPresenter.java
+++ /dev/null
@@ -1,122 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextPresentation;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformationPresenter;
-import org.eclipse.jface.text.contentassist.IContextInformationValidator;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.custom.StyleRange;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-/**
- * Responsible for the presentation of the context info popup. This includes
- * text style, and when the window should close.
- *
- * @author pavery
- */
-public class AttributeContextInformationPresenter implements IContextInformationPresenter, IContextInformationValidator {
- private int fDocumentPosition = -1;
-
- private IContextInformation fInfo = null;
- private ContextInfoModelUtil fModelUtil = null;
- private ITextViewer fViewer = null;
-
- public AttributeContextInformationPresenter() {
- super();
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationValidator#install(org.eclipse.jface.text.contentassist.IContextInformation,
- * org.eclipse.jface.text.ITextViewer, int)
- */
- public void install(IContextInformation info, ITextViewer viewer, int documentPosition) {
- fInfo = info;
- fViewer = viewer;
- fDocumentPosition = documentPosition;
- fModelUtil = new ContextInfoModelUtil((IStructuredDocument) fViewer.getDocument());
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationValidator#isContextInformationValid(int)
- */
- public boolean isContextInformationValid(int documentPosition) {
- // determine whether or not this context info should still be
- // showing...
- // if cursor still within the element it's valid...
- boolean result = false;
- if (fModelUtil != null) {
- IStructuredDocumentRegion startRegion = fModelUtil.getXMLNode(fDocumentPosition).getStartStructuredDocumentRegion();
- int start = startRegion.getStartOffset();
- int end = startRegion.getEndOffset();
- result = (documentPosition < end) && (documentPosition > start + 1);
- }
- return result;
- }
-
- /**
- * @see org.eclipse.jface.text.contentassist.IContextInformationPresenter#updatePresentation(int,
- * org.eclipse.jface.text.TextPresentation)
- */
- public boolean updatePresentation(int documentPosition, TextPresentation presentation) {
- presentation.clear();
-
- if (!(fInfo instanceof AttributeContextInformation)) {
- return false;
- }
-
- // iterate existing attributes from current node
- IDOMNode xmlNode = fModelUtil.getXMLNode(documentPosition);
- IStructuredDocumentRegion sdRegion = xmlNode.getFirstStructuredDocumentRegion();
- ITextRegionList regions = sdRegion.getRegions();
- ITextRegion r = null;
- String attrName = ""; //$NON-NLS-1$
- Object temp = null;
- Position p = null;
- HashMap map = ((AttributeContextInformation) fInfo).getAttr2RangeMap();
-
- // so we can add ranges in order
- StyleRange[] sorted = new StyleRange[fInfo.getInformationDisplayString().length()];
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- attrName = sdRegion.getText(r);
- temp = map.get(attrName);
- if (temp != null) {
- p = (Position) temp;
- sorted[p.offset] = new StyleRange(p.offset, p.length, null, null, SWT.BOLD);
- }
- }
- }
- // style ranges need to be added in order
- StyleRange sr = null;
- for (int i = 0; i < sorted.length; i++) {
- sr = sorted[i];
- if (sr != null) {
- presentation.addStyleRange(sr);
- }
- }
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
deleted file mode 100644
index f18d7c88df..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/AttributeContextInformationProvider.java
+++ /dev/null
@@ -1,231 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashMap;
-import java.util.List;
-
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.contentassist.ContextInformation;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMContent;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMGroup;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * Calculates attribute context information based on a StructuedDocument and
- * document position.
- *
- * @author pavery
- */
-public class AttributeContextInformationProvider {
- private final IContextInformation[] EMPTY_CONTEXT_INFO = new IContextInformation[0];
- private Comparator fComparator;
-
- private IStructuredDocument fDocument = null;
- private ContextInfoModelUtil fModelUtil = null;
-
- public AttributeContextInformationProvider(IStructuredDocument doc, AttributeContextInformationPresenter presenter) {
- fDocument = doc;
- fModelUtil = new ContextInfoModelUtil(fDocument);
- }
-
- /**
- * @param sdRegion
- *
- */
- private boolean canProposeInfo(IStructuredDocumentRegion sdRegion) {
- if ((sdRegion != null) && isEndTag(sdRegion)) {
- return false;
- }
- else {
- return true;
- }
- }
-
- public IContextInformation[] getAttributeInformation(int offset) {
- /*
- * need to take care of special cases w/ ambiguous regions <tag>|
- * </tag> also end tags..
- */
- IContextInformation[] results = EMPTY_CONTEXT_INFO;
-
- IStructuredDocumentRegion sdRegion = fModelUtil.getDocument().getRegionAtCharacterOffset(offset);
- if (!canProposeInfo(sdRegion)) {
- return EMPTY_CONTEXT_INFO;
- }
-
- IDOMNode node = fModelUtil.getXMLNode(offset);
- if (node != null) {
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE :
- results = getInfoForElement(node);
- break;
- // future...
- // case Node.TEXT_NODE :
- // results = getInfoForText(node);
- // break;
- }
- }
- return results;
- }
-
- /**
- * Returns a comparator that compares CMAttributeDeclaration names.
- *
- * the comparator
- */
- private Comparator getCMAttributeComparator() {
- if (fComparator == null) {
- fComparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- return ((CMAttributeDeclaration) o1).getAttrName().compareTo(((CMAttributeDeclaration) o2).getAttrName());
- }
- };
- }
- return fComparator;
- }
-
- /**
- * @param node
- *
- */
- private IContextInformation[] getInfoForElement(IDOMNode node) {
- IContextInformation[] results = EMPTY_CONTEXT_INFO;
- CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) node);
- if (decl != null) {
- CMNamedNodeMap attributes = decl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, decl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attributes = allAttributes;
-
- String attrContextString = node.getNodeName();
- StringBuffer attrInfo = new StringBuffer(" "); //$NON-NLS-1$
- String name = ""; //$NON-NLS-1$
- HashMap attrPosMap = new HashMap();
- int pos = 0;
- int length = 0;
- int numPerLine = 8;
-
- CMAttributeDeclaration[] sortedAttrs = getSortedAttributes(attributes);
-
- for (int i = 0; i < sortedAttrs.length; i++) {
- name = sortedAttrs[i].getAttrName();
- length = name.length();
- pos = attrInfo.length();
-
- attrInfo.append(name);
-
- if (sortedAttrs[i].getUsage() == CMAttributeDeclaration.REQUIRED) {
- attrInfo.append("*"); //$NON-NLS-1$
- length++;
- }
- if (i < attributes.getLength() - 1) {
- attrInfo.append(" "); //$NON-NLS-1$
- if ((i != 0) && (i % numPerLine == 0)) {
- attrInfo.append("\n "); //$NON-NLS-1$
- }
- }
- attrPosMap.put(name, new Position(pos, length));
- }
- if (!attrInfo.toString().trim().equals("")) {
- return new IContextInformation[]{new AttributeContextInformation(attrContextString, attrInfo.toString(), attrPosMap)};
- }
- }
- return results;
- }
-
- /**
- * @param node
- *
- */
- IContextInformation[] getInfoForText(IDOMNode node) {
- Node parent = node.getParentNode();
- String contextString = node.getNodeName();
- StringBuffer info = new StringBuffer(" "); //$NON-NLS-1$
- if ((parent != null) && (parent.getNodeType() == Node.ELEMENT_NODE)) {
- CMElementDeclaration decl = fModelUtil.getModelQuery().getCMElementDeclaration((Element) parent);
- CMContent content = decl.getContent();
- if (content instanceof CMGroup) {
- CMGroup cmGroup = (CMGroup) content;
- CMNodeList children = cmGroup.getChildNodes();
- CMNode cmNode = null;
- for (int i = 0; i < children.getLength(); i++) {
- cmNode = children.item(i);
- contextString = cmNode.getNodeName();
- if (contextString != null) {
- info.append("<" + cmNode.getNodeName() + ">"); //$NON-NLS-1$ //$NON-NLS-2$
- if (i < children.getLength() - 1) {
- info.append(" "); //$NON-NLS-1$
- }
- }
- }
- }
- }
- if (!info.toString().trim().equals("")) {
- return new IContextInformation[]{new ContextInformation(contextString, info.toString())};
- }
- else {
- return EMPTY_CONTEXT_INFO;
- }
- }
-
- /**
- * Returns sorted array of CMAttributeDeclarations.
- *
- * @param attributes
- *
- */
- private CMAttributeDeclaration[] getSortedAttributes(CMNamedNodeMap attributes) {
- List sorted = new ArrayList();
- for (int i = 0; i < attributes.getLength(); i++) {
- sorted.add(attributes.item(i));
- }
- Collections.sort(sorted, getCMAttributeComparator());
- return (CMAttributeDeclaration[]) sorted.toArray(new CMAttributeDeclaration[sorted.size()]);
- }
-
- /**
- * @param sdRegion
- *
- */
- private boolean isEndTag(IStructuredDocumentRegion sdRegion) {
- ITextRegionList regions = sdRegion.getRegions();
- return regions.get(0).getType() == DOMRegionContext.XML_END_TAG_OPEN;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java
deleted file mode 100644
index 6a1d3af534..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContentAssistRequest.java
+++ /dev/null
@@ -1,260 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionCollection;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.w3c.dom.Node;
-
-
-public class ContentAssistRequest {
- protected IStructuredDocumentRegion documentRegion = null;
- protected List macros = new ArrayList();
- protected String matchString;
- protected Node node = null;
- protected Node parent = null;
- protected List proposals = new ArrayList();
- protected ITextRegion region = null;
- protected int replacementBeginPosition;
- protected int replacementLength;
-
- // private Boolean separate = null; // (pa) not used
- // private Boolean sort = null; // (pa) not used
- /**
- * XMLContentAssistRequest constructor comment.
- */
- public ContentAssistRequest(Node node, Node parent, IStructuredDocumentRegion documentRegion, ITextRegion completionRegion, int begin, int length, String filter) {
- super();
- setNode(node);
- setParent(parent);
- setDocumentRegion(documentRegion);
- setRegion(completionRegion);
- setMatchString(filter);
- setReplacementBeginPosition(begin);
- setReplacementLength(length);
- }
-
- public void addMacro(ICompletionProposal newProposal) {
- macros.add(newProposal);
- }
-
- public void addProposal(ICompletionProposal newProposal) {
- proposals.add(newProposal);
- }
-
- public ICompletionProposal[] getCompletionProposals() {
- ICompletionProposal results[] = null;
- if ((getProposals().size() > 0) || (getMacros().size() > 0)) {
- List allProposals = new ArrayList();
- if (!shouldSeparate()) {
- allProposals.addAll(getProposals());
- // should be empty, as all macros should have gone into the
- // proposal list
- allProposals.addAll(getMacros());
- allProposals = sortProposals(allProposals);
- }
- else {
- allProposals.addAll(sortProposals(getProposals()));
- allProposals.addAll(sortProposals(getMacros()));
- }
-
- results = new ICompletionProposal[allProposals.size()];
- for (int i = 0; i < allProposals.size(); i++) {
- results[i] = (ICompletionProposal) allProposals.get(i);
- }
- }
- return results;
- }
-
-
- public IStructuredDocumentRegion getDocumentRegion() {
- return documentRegion;
- }
-
- /**
- *
- * @return java.util.List
- */
- public java.util.List getMacros() {
- return macros;
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String getMatchString() {
- return matchString;
- }
-
- /**
- *
- * @return org.w3c.dom.Node
- */
- public org.w3c.dom.Node getNode() {
- return node;
- }
-
- /**
- *
- * @return org.w3c.dom.Node
- */
- public org.w3c.dom.Node getParent() {
- return parent;
- }
-
- /**
- *
- * @return java.util.List
- */
- public java.util.List getProposals() {
- return proposals;
- }
-
- public ITextRegion getRegion() {
- return region;
- }
-
- /**
- *
- * @return int
- */
- public int getReplacementBeginPosition() {
- return replacementBeginPosition;
- }
-
- /**
- * @return int
- */
- public int getReplacementLength() {
- return replacementLength;
- }
-
- public int getStartOffset() {
- if ((getDocumentRegion() != null) && (getRegion() != null)) {
- return ((ITextRegionCollection) getDocumentRegion()).getStartOffset(getRegion());
- }
- return -1;
- }
-
- public String getText() {
- if ((getDocumentRegion() != null) && (getRegion() != null)) {
- return ((ITextRegionCollection) getDocumentRegion()).getText(getRegion());
- }
- return ""; //$NON-NLS-1$
- }
-
- public int getTextEndOffset() {
- if ((getDocumentRegion() != null) && (getRegion() != null)) {
- return ((ITextRegionCollection) getDocumentRegion()).getTextEndOffset(getRegion());
- }
- return -1;
- }
-
- /**
- * @param region
- */
- public void setDocumentRegion(IStructuredDocumentRegion region) {
- documentRegion = region;
- }
-
- /**
- *
- * @param newMatchString
- * java.lang.String
- */
- public void setMatchString(java.lang.String newMatchString) {
- matchString = newMatchString;
- }
-
- /**
- *
- * @param newNode
- * org.w3c.dom.Node
- */
- public void setNode(org.w3c.dom.Node newNode) {
- node = newNode;
- }
-
- /**
- *
- * @param newParent
- * org.w3c.dom.Node
- */
- public void setParent(org.w3c.dom.Node newParent) {
- parent = newParent;
- }
-
- /**
- *
- * @param newRegion
- */
- public void setRegion(ITextRegion newRegion) {
- region = newRegion;
- }
-
- /**
- *
- * @param newReplacementBeginPosition
- * int
- */
- public void setReplacementBeginPosition(int newReplacementBeginPosition) {
- replacementBeginPosition = newReplacementBeginPosition;
- }
-
-
- public void setReplacementLength(int newReplacementLength) {
- replacementLength = newReplacementLength;
- }
-
- public boolean shouldSeparate() {
- /*
- * if (separate == null) { PreferenceManager manager =
- * getPreferenceManager(); if(manager == null) { separate =
- * Boolean.FALSE; } else { Element caSettings =
- * manager.getElement(PreferenceNames.CONTENT_ASSIST); separate = new
- * Boolean(caSettings.getAttribute(PreferenceNames.SEPARATE).equals(PreferenceNames.TRUE)); } }
- * return separate.booleanValue();
- */
- return false;
- }
-
- protected List sortProposals(List proposalsIn) {
- Collections.sort(proposalsIn, new ProposalComparator());
- return proposalsIn;
-
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String toString() {
- return "Node: " + getNode() //$NON-NLS-1$
- + "\nParent: " + getParent() //$NON-NLS-1$
- + "\nStructuredDocumentRegion: " + StringUtils.escape(getDocumentRegion().toString()) //$NON-NLS-1$
- + "\nRegion: " + getRegion() //$NON-NLS-1$
- + "\nMatch string: '" + StringUtils.escape(getMatchString()) + "'" //$NON-NLS-2$//$NON-NLS-1$
- + "\nOffsets: [" + getReplacementBeginPosition() + "-" + (getReplacementBeginPosition() + getReplacementLength()) + "]\n"; //$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java
deleted file mode 100644
index a48e75337b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ContextInfoModelUtil.java
+++ /dev/null
@@ -1,66 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-
-
-/**
- * @author pavery
- */
-public class ContextInfoModelUtil {
- IStructuredDocument fDocument = null;
-
- ContextInfoModelUtil(IStructuredDocument doc) {
- fDocument = doc;
- }
-
- public IStructuredDocument getDocument() {
- return fDocument;
- }
-
- public ModelQuery getModelQuery() {
- ModelQuery mq = null;
-
- IStructuredModel xmlModel = null;
- try {
- xmlModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- mq = ModelQueryUtil.getModelQuery(xmlModel);
- }
- finally {
- if (xmlModel != null) {
- xmlModel.releaseFromRead();
- }
- }
- return mq;
- }
-
- public IDOMNode getXMLNode(int offset) {
- IStructuredModel xmlModel = null;
- IDOMNode xmlNode = null;
- try {
- xmlModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- xmlNode = (IDOMNode) xmlModel.getIndexedRegion(offset);
- }
- finally {
- if (xmlModel != null)
- xmlModel.releaseFromRead();
- }
- return xmlNode;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java
deleted file mode 100644
index f19dd90858..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/CustomTemplateProposal.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.jface.text.templates.TemplateProposal;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceCompletionProposal;
-
-/**
- * Purpose of this class is to make the additional proposal info into content
- * fit for an HTML viewer (by escaping characters)
- */
-class CustomTemplateProposal extends TemplateProposal implements IRelevanceCompletionProposal {
- // copies of this class exist in:
- // org.eclipse.jst.jsp.ui.internal.contentassist
- // org.eclipse.wst.html.ui.internal.contentassist
- // org.eclipse.wst.xml.ui.internal.contentassist
-
- public CustomTemplateProposal(Template template, TemplateContext context, IRegion region, Image image, int relevance) {
- super(template, context, region, image, relevance);
- }
-
- public String getAdditionalProposalInfo() {
- String additionalInfo = super.getAdditionalProposalInfo();
- return StringUtils.convertToHTMLContent(additionalInfo);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/DefaultXMLCompletionProposalComputer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/DefaultXMLCompletionProposalComputer.java
deleted file mode 100644
index 5b4024ff53..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/DefaultXMLCompletionProposalComputer.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.Properties;
-import java.util.Vector;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-
-/**
- * <p>Default implementation of the {@link AbstractXMLCompletionProposalComputer}, defaults are to do nothing</p>
- */
-public class DefaultXMLCompletionProposalComputer extends
- AbstractXMLCompletionProposalComputer {
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer#sessionEnded()
- */
- public void sessionEnded() {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.sse.ui.contentassist.ICompletionProposalComputer#sessionStarted()
- */
- public void sessionStarted() {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addAttributeNameProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addAttributeNameProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addAttributeValueProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addAttributeValueProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addCommentProposal(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addCommentProposal(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addDocTypeProposal(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addDocTypeProposal(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addEmptyDocumentProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addEmptyDocumentProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addEndTagNameProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addEndTagNameProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addEndTagProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addEndTagProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addEntityProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion, org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addEntityProposals(
- ContentAssistRequest contentAssistRequest,
- ITextRegion completionRegion, IDOMNode treeNode,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addEntityProposals(java.util.Vector, java.util.Properties, java.lang.String, int, org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion, org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addEntityProposals(Vector proposals, Properties map,
- String key, int nodeOffset, IStructuredDocumentRegion sdRegion,
- ITextRegion completionRegion,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addPCDATAProposal(java.lang.String, org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addPCDATAProposal(String nodeName,
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addStartDocumentProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addStartDocumentProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addTagCloseProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addTagCloseProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addTagInsertionProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, int, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addTagInsertionProposals(
- ContentAssistRequest contentAssistRequest, int childPosition,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-
- /**
- * Default behavior is do to nothing.
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLCompletionProposalComputer#addTagNameProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, int, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addTagNameProposals(
- ContentAssistRequest contentAssistRequest, int childPosition,
- CompletionProposalInvocationContext context) {
- //default behavior is to do nothing
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java
deleted file mode 100644
index c713a224d0..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NoRegionContentAssistProcessor.java
+++ /dev/null
@@ -1,275 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.ITypedRegion;
-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.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.internal.IReleasable;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-
-
-/**
- * ContentAssistProcessor to handle special cases in content assist where the
- * partitioner cannot determine a partition type at the current cursor
- * position (usually at EOF).
- *
- * @author pavery
- * @deprecated This class is no longer used locally and will be removed in the future
- */
-public class NoRegionContentAssistProcessor implements IContentAssistProcessor, IReleasable {
-
- private static final boolean DEBUG = false;
- protected char completionProposalAutoActivationCharacters[] = null;
- protected char contextInformationAutoActivationCharacters[] = null;
-
- private final ICompletionProposal[] EMPTY_PROPOSAL_SET = new ICompletionProposal[0];
- protected String fErrorMessage = null;
- private HashMap fNameToProcessorMap = null;
- private HashMap fPartitionToProcessorMap = null;
-
- public NoRegionContentAssistProcessor() {
- super();
- }
-
- protected void addPartitionProcessor(String key, IContentAssistProcessor processor) {
- addProcessor(getPartitionToProcessorMap(), key, processor);
- }
-
- protected void addNameProcessor(String key, IContentAssistProcessor processor) {
- addProcessor(getNameToProcessorMap(), key, processor);
- }
-
- protected IContentAssistProcessor getPartitionProcessor(String key) {
- return (IContentAssistProcessor) getPartitionToProcessorMap().get(key);
- }
-
- /**
- * Ensures release if it's a duplicate partition type.
- *
- * @param map
- * @param key
- * @param processor
- */
- private void addProcessor(HashMap map, String key, IContentAssistProcessor processor) {
- Object o = map.remove(key);
- if (o != null) {
- if (o instanceof IReleasable) {
- ((IReleasable) o).release();
- }
- }
- map.put(key, processor);
- }
-
- /**
- * Figures out what the correct ICompletionProposalProcessor is and
- * computesCompletionProposals on that.
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
- IContentAssistProcessor p = null;
- ICompletionProposal[] results = EMPTY_PROPOSAL_SET;
-
- p = guessContentAssistProcessor(viewer, documentOffset);
- if (p != null) {
- results = p.computeCompletionProposals(viewer, documentOffset);
- }
-
- return (results != null) ? results : EMPTY_PROPOSAL_SET;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
- // get context info from processor that we end up using...
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return completionProposalAutoActivationCharacters;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters()
- */
- public char[] getContextInformationAutoActivationCharacters() {
- return contextInformationAutoActivationCharacters;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator()
- */
- public IContextInformationValidator getContextInformationValidator() {
- // return the validator for the content assist processor that we
- // used...
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage()
- */
- public String getErrorMessage() {
- return fErrorMessage;
- }
-
- private HashMap getNameToProcessorMap() {
- if (fNameToProcessorMap == null) {
- fNameToProcessorMap = new HashMap();
- initNameToProcessorMap();
- }
- return fNameToProcessorMap;
- }
-
- private HashMap getPartitionToProcessorMap() {
- if (fPartitionToProcessorMap == null) {
- fPartitionToProcessorMap = new HashMap();
- initPartitionToProcessorMap();
- }
- return fPartitionToProcessorMap;
- }
-
- /**
- * Gives you the document partition type (String) for the given
- * StructuredTextViewer and documentPosition.
- *
- * @param viewer
- * @param documentPosition
- * @return String
- */
- protected String getPartitionType(StructuredTextViewer viewer, int documentPosition) {
- IDocument document = viewer.getDocument();
- String partitionType = null;
- ITypedRegion partition = null;
- try {
- partition = document.getPartition(documentPosition);
- partitionType = partition.getType();
- }
- catch (BadLocationException e) {
- partitionType = null;
- }
- return partitionType;
- }
-
- /**
- * Guesses a ContentAssistProcessor based on the TextViewer and
- * documentOffset.
- *
- * @param viewer
- * @param documentOffset
- */
- protected IContentAssistProcessor guessContentAssistProcessor(ITextViewer viewer, int documentOffset) {
- // mapping logic here...
- // look @ previous region
- // look @ previous doc partition type
- // look @ page language
- IContentAssistProcessor p = null;
- IStructuredDocumentRegion sdRegion = ContentAssistUtils.getStructuredDocumentRegion(viewer, documentOffset);
- if (sdRegion != null) {
- String currentRegionType = sdRegion.getType();
- // System.out.println("current region type is >> " +
- // currentRegionType);
- if (currentRegionType == DOMRegionContext.UNDEFINED) {
- IStructuredDocumentRegion sdPrev = sdRegion.getPrevious();
- if (sdPrev != null) {
- if (DEBUG) {
- String prevRegionType = sdPrev.getType();
- System.out.println("previous region type is >> " + prevRegionType); //$NON-NLS-1$
- }
- }
- }
- }
- // working w/ viewer & document partition
- if ((p == null) && (viewer.getDocument().getLength() > 0)) {
- String prevPartitionType = getPartitionType((StructuredTextViewer) viewer, documentOffset - 1);
- // System.out.println("previous partition type is > " +
- // prevPartitionType);
- p = (IContentAssistProcessor) getPartitionToProcessorMap().get(prevPartitionType);
- }
- return p;
- }
-
- /**
- * Inits map for extra ContentAssistProcessors (useBean, get/setProperty)
- */
- protected void initNameToProcessorMap() {
- // nothing to do in this case
- }
-
- /**
- * Adds all relevent ContentAssistProcessors to the partition to processor
- * map (just XML here)
- */
- protected void initPartitionToProcessorMap() {
- XMLContentAssistProcessor xmlProcessor = new XMLContentAssistProcessor();
- addProcessor(getPartitionToProcessorMap(), IXMLPartitions.XML_DEFAULT, xmlProcessor);
- }
-
- public void release() {
- releasePartitionToProcessorMap();
- releaseNameToProcessorMap();
- }
-
- protected void releaseMap(HashMap map) {
- if ((map != null) && !map.isEmpty()) {
- Iterator it = map.keySet().iterator();
- Object key = null;
- while (it.hasNext()) {
- key = it.next();
- if (map.get(key) instanceof IReleasable) {
- ((IReleasable) map.get(key)).release();
- }
- }
- map.clear();
- map = null;
- }
- }
-
- protected void releaseNameToProcessorMap() {
- releaseMap(fNameToProcessorMap);
- }
-
- protected void releasePartitionToProcessorMap() {
- releaseMap(fPartitionToProcessorMap);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java
deleted file mode 100644
index 24a397dcf6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/NonValidatingModelQueryAction.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-public class NonValidatingModelQueryAction implements org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQueryAction {
-
- protected CMNode cmnode = null;
- protected int endIndex = 0;
- protected int kind = INSERT;
- protected int startIndex = 0;
- protected Object userData = null;
-
- /**
- * NonValidatingModelQueryAction constructor comment.
- */
- protected NonValidatingModelQueryAction() {
- super();
- }
-
- /**
- * NonValidatingModelQueryAction constructor comment.
- */
- public NonValidatingModelQueryAction(CMNode newChild, int newKind, int newStart, int newEnd, Object newUserData) {
- super();
- cmnode = newChild;
- kind = newKind;
- startIndex = newStart;
- endIndex = newEnd;
- userData = newUserData;
- }
-
- /**
- * getCMNode method comment.
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMNode getCMNode() {
- return cmnode;
- }
-
- /**
- *
- * @return int
- */
- public int getEndIndex() {
- return endIndex;
- }
-
- /**
- *
- * @return int
- */
- public int getKind() {
- return kind;
- }
-
- /**
- * getParent method comment.
- */
- public org.w3c.dom.Node getParent() {
- return null;
- }
-
- /**
- *
- * @return int
- */
- public int getStartIndex() {
- return startIndex;
- }
-
- /**
- * getUserData method comment.
- */
- public Object getUserData() {
- return null;
- }
-
- /**
- * performAction method comment.
- */
- public void performAction() {
- }
-
- /**
- * setCMNode method comment.
- */
- protected void setCMNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode newNode) {
- cmnode = newNode;
- }
-
- /**
- *
- * @param newEndIndex
- * int
- */
- protected void setEndIndex(int newEndIndex) {
- endIndex = newEndIndex;
- }
-
- /**
- *
- * @param newKind
- * int
- */
- protected void setKind(int newKind) {
- kind = newKind;
- }
-
- /**
- *
- * @param newStartIndex
- * int
- */
- protected void setStartIndex(int newStartIndex) {
- startIndex = newStartIndex;
- }
-
- /**
- * setUserData method comment.
- */
- public void setUserData(Object object) {
- }
-
- /**
- *
- * @return java.lang.String
- */
- public String toString() {
- String actionName = null;
- switch (kind) {
- case INSERT :
- actionName = "INSERT";//$NON-NLS-1$
- break;
- case REMOVE :
- actionName = "REMOVE";//$NON-NLS-1$
- break;
- case REPLACE :
- actionName = "REPLACE";//$NON-NLS-1$
- break;
- default :
- actionName = "UNKNOWN ACTION ";//$NON-NLS-1$
- }
- String nodeName = (cmnode != null) ? getCMNode().getNodeName() : "(unknown)";//$NON-NLS-1$
- return actionName + "=" + nodeName + "(" + startIndex + "..." + endIndex + ")";//$NON-NLS-4$//$NON-NLS-3$//$NON-NLS-2$//$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java
deleted file mode 100644
index ee6e8e8a66..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ProposalComparator.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-
-
-import java.util.Comparator;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceCompletionProposal;
-
-
-public class ProposalComparator implements Comparator {
-
-
- public int compare(Object o1, Object o2) {
- int relevance = 0;
- if ((o1 instanceof IRelevanceCompletionProposal) && (o2 instanceof IRelevanceCompletionProposal)) {
- // sort based on relevance
- IRelevanceCompletionProposal cp1 = (IRelevanceCompletionProposal) o1;
- IRelevanceCompletionProposal cp2 = (IRelevanceCompletionProposal) o2;
-
- relevance = cp2.getRelevance() - cp1.getRelevance();
-
- // if same relevance, secondary sort (lexigraphically)
- if ((relevance == 0) && (o1 instanceof ICompletionProposal) && (o2 instanceof ICompletionProposal)) {
- String displayString1 = ((ICompletionProposal) o1).getDisplayString();
- String displayString2 = ((ICompletionProposal) o2).getDisplayString();
- if ((displayString1 != null) && (displayString2 != null)) {
- // relevance = displayString1.compareTo(displayString2);
- // // this didn't mix caps w/ lowercase
- relevance = com.ibm.icu.text.Collator.getInstance().compare(displayString1, displayString2);
- }
- }
- }
- // otherwise if it's not ISEDRelevanceCompletionProposal, don't sort
- return relevance;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java
deleted file mode 100644
index c371494694..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/ReplaceNameTemplateContext.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.templates.DocumentTemplateContext;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateBuffer;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.TemplateException;
-
-/**
- * Just like DocumentTemplateContext except if an insert offset is passed in,
- * during evaluation, the "prefix" before the template will be checked to see
- * if it matches the template name. If so, overwrite the template name.
- * Otherwise, just insert the template at the insert offset location (by not
- * overwriting the prefix text)
- */
-public class ReplaceNameTemplateContext extends DocumentTemplateContext {
- private int fInsertOffset = -1;
-
- /**
- * Creates a document template context.
- *
- * @param type
- * the context type
- * @param document
- * the document this context applies to
- * @param offset
- * the offset of the document region
- * @param length
- * the length of the document region
- */
- public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, int offset, int length) {
- this(type, document, new Position(offset, length));
- }
-
- /**
- * Creates a document template context. The supplied <code>Position</code>
- * will be queried to compute the <code>getStart</code> and
- * <code>getEnd</code> methods, which will therefore answer updated
- * position data if it is registered with the document.
- *
- * @param type
- * the context type
- * @param document
- * the document this context applies to
- * @param position
- * the position describing the area of the document which forms
- * the template context
- * @since 3.1
- */
- public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, Position position) {
- super(type, document, position);
- }
-
- /**
- * Creates a document template context.
- *
- * @param type
- * the context type
- * @param document
- * the document this context applies to
- * @param offset
- * the offset of the document region
- * @param length
- * the length of the document region
- * @param insertOffset
- * the offset of the document region where insert was
- * originally requested
- */
- public ReplaceNameTemplateContext(TemplateContextType type, IDocument document, int offset, int length, int insertOffset) {
- this(type, document, new Position(offset, length));
- fInsertOffset = insertOffset;
- }
-
- /*
- * @see org.eclipse.jface.text.templates.TemplateContext#evaluate(org.eclipse.jface.text.templates.Template)
- */
- public TemplateBuffer evaluate(Template template) throws BadLocationException, TemplateException {
- TemplateBuffer buffer = super.evaluate(template);
- if (buffer != null) {
- if ((fInsertOffset > -1) && (fInsertOffset > getStart())) {
- String prefix = getDocument().get(getStart(), fInsertOffset - getStart());
- if (!template.getName().startsWith(prefix)) {
- // generate a new buffer that actually contains the
- // text that was going to be overwritten
- buffer = new TemplateBuffer(prefix + buffer.getString(), buffer.getVariables());
- }
- }
- }
- return buffer;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java
deleted file mode 100644
index 41a607aa0e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SimpleCMElementDeclaration.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-
-
-public class SimpleCMElementDeclaration implements org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration {
-
- String fNodeName;
-
- /**
- * SimpleCMELementDeclaration constructor comment.
- */
- public SimpleCMElementDeclaration() {
- super();
- }
-
- public SimpleCMElementDeclaration(String nodeName) {
- super();
- setNodeName(nodeName);
- }
-
- /**
- * getAttributes method
- *
- * @return CMNamedNodeMap
- *
- * Returns CMNamedNodeMap of AttributeDeclaration
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap getAttributes() {
- return null;
- }
-
- /**
- * getCMContent method
- *
- * @return CMContent
- *
- * Returns the root node of this element's content model. This can be an
- * CMElementDeclaration or a CMGroup
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMContent getContent() {
- return null;
- }
-
- /**
- * getContentType method
- *
- * @return int
- *
- * Returns one of : ANY, EMPTY, ELEMENT, MIXED, PCDATA, CDATA.
- */
- public int getContentType() {
- return 0;
- }
-
- /**
- * getDataType method
- *
- * @return java.lang.String
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMDataType getDataType() {
- return null;
- }
-
- /**
- * getElementName method
- *
- * @return java.lang.String
- */
- public String getElementName() {
- return null;
- }
-
- /**
- * getLocalElements method
- *
- * @return CMNamedNodeMap
- *
- * Returns a list of locally defined elements.
- */
- public org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap getLocalElements() {
- return null;
- }
-
- /**
- * getMaxOccur method
- *
- * @return int
- *
- * If -1, it's UNBOUNDED.
- */
- public int getMaxOccur() {
- return 0;
- }
-
- /**
- * getMinOccur method
- *
- * @return int
- *
- * If 0, it's OPTIONAL. If 1, it's REQUIRED.
- */
- public int getMinOccur() {
- return 0;
- }
-
- /**
- *
- * @return java.lang.String
- */
- public java.lang.String getNodeName() {
- return fNodeName;
- }
-
- /**
- * getNodeType method
- *
- * @return int
- *
- * Returns one of :
- *
- */
- public int getNodeType() {
- return 0;
- }
-
- /**
- * getProperty method
- *
- * @return java.lang.Object
- *
- * Returns the object property desciped by the propertyName
- *
- */
- public Object getProperty(String propertyName) {
- return null;
- }
-
- /**
- *
- * @param newNodeName
- * java.lang.String
- */
- public void setNodeName(java.lang.String newNodeName) {
- fNodeName = newNodeName;
- }
-
- /**
- * supports method
- *
- * @return boolean
- *
- * Returns true if the CMNode supports a specified property
- *
- */
- public boolean supports(String propertyName) {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java
deleted file mode 100644
index fe16777023..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/SourceEditorImageHelper.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-/**
- * @deprecated use internal XMLEditorPluginImageHelper or external
- * SharedXMLEditorPluginImageHelper instead
- */
-public class SourceEditorImageHelper {
-
- public SourceEditorImageHelper() {
- super();
- }
-
- public Image createImage(String resource) {
- ImageDescriptor desc = AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, resource);
- Image image = desc.createImage();
- JFaceResources.getImageRegistry().put(resource, image);
- return image;
- }
-
- public Image getImage(String resource) {
- Image image = JFaceResources.getImageRegistry().get(resource);
- if (image == null) {
- image = createImage(resource);
- }
- return image;
- }
-
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java
deleted file mode 100644
index 20d4451819..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistProcessor.java
+++ /dev/null
@@ -1,170 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.eclipse.wst.xml.ui.internal.templates.TemplateContextTypeIdsXML;
-
-/**
- * @deprecated This class is no longer used locally and will be removed in the future
- * @see XMLStructuredContentAssistProcessor
- */
-public class XMLContentAssistProcessor extends AbstractContentAssistProcessor implements IPropertyChangeListener {
-
- protected IPreferenceStore fPreferenceStore = null;
- protected IResource fResource = null;
- private XMLTemplateCompletionProcessor fTemplateProcessor = null;
- private List fTemplateContexts = new ArrayList();
-
- public XMLContentAssistProcessor() {
- super();
- }
-
- protected void addAttributeNameProposals(ContentAssistRequest contentAssistRequest) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE);
- super.addAttributeNameProposals(contentAssistRequest);
- }
-
- protected void addAttributeValueProposals(ContentAssistRequest contentAssistRequest) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE_VALUE);
- super.addAttributeValueProposals(contentAssistRequest);
- }
-
- protected void addEmptyDocumentProposals(ContentAssistRequest contentAssistRequest) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.NEW);
- super.addEmptyDocumentProposals(contentAssistRequest);
- }
-
- protected void addTagInsertionProposals(ContentAssistRequest contentAssistRequest, int childPosition) {
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.TAG);
- super.addTagInsertionProposals(contentAssistRequest, childPosition);
- }
-
- /**
- * Adds templates to the list of proposals
- *
- * @param contentAssistRequest
- * @param context
- */
- private void addTemplates(ContentAssistRequest contentAssistRequest, String context) {
- addTemplates(contentAssistRequest, context, contentAssistRequest.getReplacementBeginPosition());
- }
-
- /**
- * Adds templates to the list of proposals
- *
- * @param contentAssistRequest
- * @param context
- * @param startOffset
- */
- private void addTemplates(ContentAssistRequest contentAssistRequest, String context, int startOffset) {
- if (contentAssistRequest == null) {
- return;
- }
-
- // if already adding template proposals for a certain context type, do
- // not add again
- if (!fTemplateContexts.contains(context)) {
- fTemplateContexts.add(context);
- boolean useProposalList = !contentAssistRequest.shouldSeparate();
-
- if (getTemplateCompletionProcessor() != null) {
- getTemplateCompletionProcessor().setContextType(context);
- ICompletionProposal[] proposals = getTemplateCompletionProcessor().computeCompletionProposals(fTextViewer, startOffset);
- for (int i = 0; i < proposals.length; ++i) {
- if (useProposalList) {
- contentAssistRequest.addProposal(proposals[i]);
- }
- else {
- contentAssistRequest.addMacro(proposals[i]);
- }
- }
- }
- }
- }
-
- protected ContentAssistRequest computeCompletionProposals(int documentPosition, String matchString, ITextRegion completionRegion, IDOMNode treeNode, IDOMNode xmlnode) {
- ContentAssistRequest request = super.computeCompletionProposals(documentPosition, matchString, completionRegion, treeNode, xmlnode);
- // bug115927 use original document position for all/any region
- // templates
- addTemplates(request, TemplateContextTypeIdsXML.ALL, documentPosition);
- return request;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.xml.ui.contentassist.AbstractContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer textViewer, int documentPosition) {
- fTemplateContexts.clear();
- return super.computeCompletionProposals(textViewer, documentPosition);
- }
-
- protected IPreferenceStore getPreferenceStore() {
- if (fPreferenceStore == null) {
- fPreferenceStore = XMLUIPlugin.getDefault().getPreferenceStore();
- }
- return fPreferenceStore;
- }
-
- private XMLTemplateCompletionProcessor getTemplateCompletionProcessor() {
- if (fTemplateProcessor == null) {
- fTemplateProcessor = new XMLTemplateCompletionProcessor();
- }
- return fTemplateProcessor;
- }
-
- protected void init() {
- getPreferenceStore().addPropertyChangeListener(this);
- reinit();
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- String property = event.getProperty();
-
- if ((property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE) == 0) || (property.compareTo(XMLUIPreferenceNames.AUTO_PROPOSE_CODE) == 0)) {
- reinit();
- }
- }
-
- protected void reinit() {
- String key = XMLUIPreferenceNames.AUTO_PROPOSE;
- boolean doAuto = getPreferenceStore().getBoolean(key);
- if (doAuto) {
- key = XMLUIPreferenceNames.AUTO_PROPOSE_CODE;
- completionProposalAutoActivationCharacters = getPreferenceStore().getString(key).toCharArray();
- }
- else {
- completionProposalAutoActivationCharacters = null;
- }
- }
-
- public void release() {
- super.release();
- getPreferenceStore().removePropertyChangeListener(this);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java
deleted file mode 100644
index 4aa4b346c8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentAssistUtilities.java
+++ /dev/null
@@ -1,516 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.util.ScriptLanguageKeys;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.contentassist.CustomCompletionProposal;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.w3c.dom.Document;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * @author pavery
- */
-public class XMLContentAssistUtilities extends ContentAssistUtils {
-
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- private class DOMJSPRegionContextsPrivateCopy {
- private static final String JSP_CLOSE = "JSP_CLOSE"; //$NON-NLS-1$
- private static final String JSP_DECLARATION_OPEN = "JSP_DECLARATION_OPEN"; //$NON-NLS-1$
- private static final String JSP_SCRIPTLET_OPEN = "JSP_SCRIPTLET_OPEN"; //$NON-NLS-1$
- private static final String JSP_EXPRESSION_OPEN = "JSP_EXPRESSION_OPEN"; //$NON-NLS-1$
-
- }
-
-
- public static final String CONTENT = "Content"; //$NON-NLS-1$
- public static final String CONTENT_SCRIPT_TYPE = "Content-Script-Type"; //$NON-NLS-1$
- public static final String HEAD = "HEAD"; //$NON-NLS-1$
- public static final String HTML = "HTML"; //$NON-NLS-1$
- public static final String HTTP_EQUIV = "HTTP-EQUIV"; //$NON-NLS-1$
- public static final String META = "META"; //$NON-NLS-1$
-
- /**
- * A convenience method for getting the closing proposal given the
- * contents (IndexedRegion) of a tag that is started, but possibly not
- * ended
- *
- * @param viewer
- * the text viewer
- * @param documentPosition
- * the cursor position in the viewer
- * @param indexedNode
- * the contents of the tag that is started but possibly not
- * ended
- * @param parentTagName
- * the tag on which you are checkin for an ending tag
- * @param imagePath
- * content assist image relative path
- * @return ICompletionProposal
- */
- public static ICompletionProposal computeJSPEndTagProposal(ITextViewer viewer, int documentPosition, IndexedRegion indexedNode, String parentTagName, String imagePath) {
- ICompletionProposal p = null;
-
- // check if tag is closed
- boolean hasEndTag = true;
- boolean isJSPTag = false;
- IDOMNode xnode = null;
- String tagName = ""; //$NON-NLS-1$
- if (indexedNode instanceof IDOMNode) {
- xnode = ((IDOMNode) indexedNode);
- // it's ended already...
- if (xnode.getEndStructuredDocumentRegion() != null) {
- return null;
- }
- IDOMNode openNode = null;
- if (!xnode.getNodeName().equalsIgnoreCase(parentTagName)) {
- openNode = (IDOMNode) xnode.getParentNode();
- }
- if (openNode != null) {
- if (openNode instanceof IDOMElement) {
- isJSPTag = ((IDOMElement) openNode).isJSPTag();
- }
- tagName = openNode.getNodeName();
- hasEndTag = (openNode.getEndStructuredDocumentRegion() != null);
- }
- }
-
- // it's closed, don't add close tag proposal
- if (!hasEndTag && !isJSPTag) {
-
- // create appropriate close tag text
- String proposedText = "</" + tagName; //$NON-NLS-1$
- String viewerText = viewer.getTextWidget().getText();
- if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2) && (documentPosition >= 2)) {
- String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
- if (last2chars.endsWith("</")) {
- proposedText = tagName;
- }
- else if (last2chars.endsWith("<")) {
- proposedText = "/" + tagName; //$NON-NLS-1$
- }
- }
-
- // create proposal
- p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
- documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG);
- }
- else if (!hasEndTag && isJSPTag) {
-
- // create appropriate close tag text
- String proposedText = "%"; //$NON-NLS-1$
- String viewerText = viewer.getTextWidget().getText();
-
- // TODO (pa) make it smarter to add "%>" or just ">" if % is
- // already there...
- if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2)) {
- String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
- String lastchar = viewerText.substring(documentPosition - 1, documentPosition);
- if (lastchar.equals("%")) //$NON-NLS-1$
- {
- if (last2chars.endsWith("<%")) {
- proposedText = "%"; //$NON-NLS-1$
- }
- else {
- proposedText = ""; //$NON-NLS-1$
- }
- }
- }
-
- // create proposal
- p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
- documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG);
- }
-
- return p;
- }
-
-
- /**
- * A convenience method for getting the closing proposal given the
- * contents (IndexedRegion) of a tag that is started, but possibly not
- * ended
- *
- * @param viewer
- * the text viewer
- * @param documentPosition
- * the cursor position in the viewer
- * @param indexedNode
- * the contents of the tag that is started but possibly not
- * ended
- * @param parentTagName
- * the tag on which you are checkin for an ending tag
- * @param imagePath
- * content assist relative image path
- * @return ICompletionProposal
- */
- public static ICompletionProposal computeXMLEndTagProposal(ITextViewer viewer, int documentPosition, IndexedRegion indexedNode, String parentTagName, String imagePath) {
- ICompletionProposal p = null;
-
- // check if tag is closed
- boolean hasEndTag = true;
- IDOMNode xnode = null;
- String tagName = ""; //$NON-NLS-1$
- if (indexedNode instanceof IDOMNode) {
- xnode = ((IDOMNode) indexedNode);
- // it's ended already...
- if (xnode.getEndStructuredDocumentRegion() != null) {
- return null;
- }
- IDOMNode styleNode = null;
- if (!xnode.getNodeName().equalsIgnoreCase(parentTagName)) {
- styleNode = (IDOMNode) xnode.getParentNode();
- }
- if (styleNode != null) {
- tagName = styleNode.getNodeName();
- hasEndTag = (styleNode.getEndStructuredDocumentRegion() != null);
- }
- }
-
- // it's closed, don't add close tag proposal
- if (!hasEndTag) {
-
- // create appropriate close tag text
- String proposedText = "</" + tagName; //$NON-NLS-1$
- String viewerText = viewer.getTextWidget().getText();
- if ((viewerText.length() >= documentPosition) && (viewerText.length() >= 2) && (documentPosition >= 2)) {
- String last2chars = viewerText.substring(documentPosition - 2, documentPosition);
- if (last2chars.endsWith("</")) {
- proposedText = tagName;
- }
- else if (last2chars.endsWith("<")) {
- proposedText = "/" + tagName; //$NON-NLS-1$
- }
- }
-
- // create proposal
- p = new CustomCompletionProposal(proposedText + ">", //$NON-NLS-1$
- documentPosition, 0, proposedText.length() + 1, XMLEditorPluginImageHelper.getInstance().getImage(imagePath), NLS.bind(XMLUIMessages.End_with_, (new Object[]{proposedText})), null, null, XMLRelevanceConstants.R_END_TAG);
- }
- return p;
- }
-
- private static String getMetaScriptType(Document doc) {
- // Can not just do a Document.getElementsByTagName(String) as this
- // needs
- // to be relatively fast.
- List metas = new ArrayList();
- // check for META tags under the Document
- Node html = null;
- Node head = null;
- Node child = null;
- // ----------------------------------------------------------------------
- // (pa) 20021217
- // cmvc defect 235554
- // performance enhancement: using child.getNextSibling() rather than
- // nodeList(item) for O(n) vs. O(n*n)
- // ----------------------------------------------------------------------
-
- for (child = doc.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- if (child.getNodeName().equalsIgnoreCase(META)) {
- metas.add(child);
- }
- else if (child.getNodeName().equalsIgnoreCase(HTML)) {
- html = child;
- }
- }
- // NodeList children = doc.getChildNodes();
- // for(int i = 0; i < children.getLength(); i++) {
- // child = children.item(i);
- // if(child.getNodeType() != Node.ELEMENT_NODE)
- // continue;
- // if(child.getNodeName().equalsIgnoreCase(META))
- // metas.add(child);
- // else if(child.getNodeName().equalsIgnoreCase(HTML))
- // html = child;
- // }
-
- // check for META tags under HEAD
- if (html != null) {
- for (child = html.getFirstChild(); (child != null) && (head == null); child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- if (child.getNodeName().equalsIgnoreCase(HEAD)) {
- head = child;
- }
- }
- // children = html.getChildNodes();
- // for(int i = 0; i < children.getLength() && head == null; i++) {
- // child = children.item(i);
- // if(child.getNodeType() != Node.ELEMENT_NODE)
- // continue;
- // if(child.getNodeName().equalsIgnoreCase(HEAD))
- // head = child;
- // }
- }
-
- if (head != null) {
- for (head.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.ELEMENT_NODE) {
- continue;
- }
- if (child.getNodeName().equalsIgnoreCase(META)) {
- metas.add(child);
- }
- }
- // children = head.getChildNodes();
- // for(int i = 0 ; i < children.getLength(); i++) {
- // child = children.item(i);
- // if(child.getNodeType() != Node.ELEMENT_NODE)
- // continue;
- // if(child.getNodeName().equalsIgnoreCase(META))
- // metas.add(child);
- // }
- }
-
- return getMetaScriptType(metas);
- }
-
- private static String getMetaScriptType(List metaNodeList) {
- Node meta = null;
- NamedNodeMap attributes = null;
- boolean httpEquiv = false;
- String contentScriptType = null;
-
- for (int i = metaNodeList.size() - 1; i >= 0; i--) {
- meta = (Node) metaNodeList.get(i);
- attributes = meta.getAttributes();
- httpEquiv = false;
- contentScriptType = null;
- for (int j = 0; j < attributes.getLength(); j++) {
- if (attributes.item(j).getNodeName().equalsIgnoreCase(HTTP_EQUIV)) {
- httpEquiv = attributes.item(j).getNodeValue().equalsIgnoreCase(CONTENT_SCRIPT_TYPE);
- }
- else if (attributes.item(j).getNodeName().equalsIgnoreCase(CONTENT)) {
- contentScriptType = attributes.item(j).getNodeValue();
- }
- }
- if (httpEquiv && (contentScriptType != null)) {
- return contentScriptType;
- }
- }
- return null;
- }
-
- /**
- * Returns the scripting language the scriptNode is in Currently returns
- * javascript unless some unknown type or language is specified. Then the
- * unknown type/language is returned
- *
- * @param scriptNode
- */
- public static String getScriptLanguage(Node scriptNode) {
- Node attr = null;
-
- boolean specified = false;
- // try to find a scripting adapter for 'type'
- if ((scriptNode == null) || (scriptNode.getAttributes() == null)) {
- return null;
- }
-
- attr = scriptNode.getAttributes().getNamedItem("type");//$NON-NLS-1$
- if (attr != null) {
- specified = true;
- String type = attr.getNodeValue();
- return lookupScriptType(type);
- }
- // now try to find a scripting adapter for 'language' (deprecated by
- // HTML specifications)
- attr = scriptNode.getAttributes().getNamedItem("language");//$NON-NLS-1$
- if (attr != null) {
- specified = true;
- String language = attr.getNodeValue();
- return lookupScriptLanguage(language);
- }
- // check if one is specified by a META tag at the root level or inside
- // of HEAD
- String type = null;
- if (!specified) {
- type = getMetaScriptType(scriptNode.getOwnerDocument());
- }
- if (type != null) {
- specified = true;
- return lookupScriptType(type);
- }
- // return default
- if (!specified) {
- return ScriptLanguageKeys.JAVASCRIPT;
- }
- return null;
- }
-
- /**
- * Tells you if the flatnode is the %> delimiter
- *
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- public static boolean isJSPCloseDelimiter(IStructuredDocumentRegion fn) {
- if (fn == null) {
- return false;
- }
- return isJSPCloseDelimiter(fn.getType());
- }
-
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- public static boolean isJSPCloseDelimiter(String type) {
- if (type == null) {
- return false;
- }
- return (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_CLOSE) || type.equals(DOMRegionContext.XML_TAG_CLOSE));
- }
-
- /**
- * Tells you if the flatnode is the JSP region <%%>, <%=%>, <%!%>
- *
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- public static boolean isJSPDelimiter(IStructuredDocumentRegion fn) {
- boolean isDelimiter = false;
- String type = fn.getType();
- if (type != null) {
- isDelimiter = isJSPDelimiter(type);
- }
- return isDelimiter;
- }
-
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- public static boolean isJSPDelimiter(String type) {
- if (type == null) {
- return false;
- }
- return (isJSPOpenDelimiter(type) || isJSPCloseDelimiter(type));
- }
-
- /**
- * Tells you if the flatnode is <%, <%=, or <%! ISSUE: this is a bit of
- * hidden JSP knowledge that was implemented this way for expedency.
- * Should be evolved in future to depend on "nestedContext".
- */
- public static boolean isJSPOpenDelimiter(IStructuredDocumentRegion fn) {
- if (fn == null) {
- return false;
- }
- return isJSPOpenDelimiter(fn.getType());
- }
-
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- public static boolean isJSPOpenDelimiter(String type) {
- if (type == null) {
- return false;
- }
- return (type.equals(DOMJSPRegionContextsPrivateCopy.JSP_SCRIPTLET_OPEN) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_DECLARATION_OPEN) || type.equals(DOMJSPRegionContextsPrivateCopy.JSP_EXPRESSION_OPEN));
- }
-
- /**
- * Tells you if the flatnode is the <jsp:scriptlet>, <jsp:expression>, or
- * <jsp:declaration>tag
- *
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- public static boolean isXMLJSPDelimiter(IStructuredDocumentRegion fn) {
- boolean isDelimiter = false;
- if ((fn != null) && (fn instanceof ITextRegionContainer)) {
- Object[] regions = ((ITextRegionContainer) fn).getRegions().toArray();
- ITextRegion temp = null;
- String regionText = ""; //$NON-NLS-1$
- for (int i = 0; i < regions.length; i++) {
- temp = (ITextRegion) regions[i];
- if (temp.getType() == DOMRegionContext.XML_TAG_NAME) {
- regionText = fn.getText(temp);
- if (regionText.equalsIgnoreCase("jsp:scriptlet") || regionText.equalsIgnoreCase("jsp:expression") || regionText.equalsIgnoreCase("jsp:declaration")) {
- isDelimiter = true;
- }
- }
- }
- }
- return isDelimiter;
- }
-
- /**
- * Returns "javascript" if language attribute is some form of javascript,
- * "java" if language attribute is some form of java. Otherwise, just
- * returns type.
- *
- * @param language
- */
- public static String lookupScriptLanguage(String language) {
- for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS.length; i++) {
- if (ScriptLanguageKeys.JAVASCRIPT_LANGUAGE_KEYS[i].equalsIgnoreCase(language)) {
- return ScriptLanguageKeys.JAVASCRIPT;
- }
- }
- for (int i = 0; i < ScriptLanguageKeys.JAVA_LANGUAGE_KEYS.length; i++) {
- if (ScriptLanguageKeys.JAVA_LANGUAGE_KEYS[i].equalsIgnoreCase(language)) {
- return ScriptLanguageKeys.JAVA;
- }
- }
- return language;
- }
-
- /**
- * Returns "javascript" if type (used in <script type="xxx"> is actually
- * javascript type. Otherwise, just returns type
- *
- * @param type
- */
- public static String lookupScriptType(String type) {
- for (int i = 0; i < ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS.length; i++) {
- if (ScriptLanguageKeys.JAVASCRIPT_MIME_TYPE_KEYS[i].equalsIgnoreCase(type)) {
- return ScriptLanguageKeys.JAVASCRIPT;
- }
- }
- return type;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java
deleted file mode 100644
index 2896432813..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLContentModelGenerator.java
+++ /dev/null
@@ -1,154 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Node;
-
-
-public class XMLContentModelGenerator extends AbstractContentModelGenerator {
-
- /**
- * ISSUE: this is a bit of hidden JSP knowledge that was implemented this
- * way for expedency. Should be evolved in future to depend on
- * "nestedContext".
- */
- private class DOMJSPRegionContextsPrivateCopy {
- private static final String JSP_DIRECTIVE_OPEN = "JSP_DIRECTIVE_OPEN"; //$NON-NLS-1$
- }
-
- /**
- * XMLContentModelGenerator constructor comment.
- */
- public XMLContentModelGenerator() {
- super();
- }
-
- public void generateAttribute(CMAttributeDeclaration attrDecl, StringBuffer buffer) {
- if ((attrDecl == null) || (buffer == null)) {
- return;
- }
- int usage = attrDecl.getUsage();
- if (usage == CMAttributeDeclaration.REQUIRED) {
- buffer.append(" "); //$NON-NLS-1$
- generateRequiredAttribute(null, attrDecl, buffer); // todo pass
- // ownerNode as
- // 1st param
- }
- return;
- }
-
- protected void generateEndTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if (elementDecl == null) {
- return;
- }
- if (elementDecl.getContentType() != CMElementDeclaration.EMPTY) {
- buffer.append("</" + tagName + ">");//$NON-NLS-2$//$NON-NLS-1$
- }
- return;
- }
-
- public void generateRequiredAttribute(Node ownerNode, CMAttributeDeclaration attrDecl, StringBuffer buffer) {
- if ((attrDecl == null) || (buffer == null)) {
- return;
- }
-
- // attribute name
- String attributeName = getRequiredName(ownerNode, attrDecl);
- CMDataType attrType = attrDecl.getAttrType();
- String defaultValue = null;
- // = sign
- buffer.append(attributeName + "="); //$NON-NLS-1$
- // attribute value
- if (attrType != null) {
- // insert any value that is implied
- if ((attrType.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (attrType.getImpliedValue() != null)) {
- defaultValue = attrType.getImpliedValue();
- }
- // otherwise, if an enumerated list of values exists, use the
- // first value
- else if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) {
- defaultValue = attrType.getEnumeratedValues()[0];
- }
- }
-
- char attrQuote = '\"';
- // Found a double quote, wrap the attribute in single quotes
- if(defaultValue != null && defaultValue.indexOf(attrQuote) >= 0) {
- attrQuote = '\'';
- }
-
- buffer.append(attrQuote);
- buffer.append(((defaultValue != null) ? defaultValue : "")); //$NON-NLS-1$
- buffer.append(attrQuote);
- return;
- }
-
- protected void generateStartTag(String tagName, Node parentNode, CMElementDeclaration elementDecl, StringBuffer buffer) {
- if ((elementDecl == null) || (buffer == null)) {
- return;
- }
- buffer.append("<" + tagName);//$NON-NLS-1$
- generateAttributes(elementDecl, buffer);
- buffer.append(getStartTagClose(parentNode, elementDecl));
- return;
- }
-
- public int getMinimalStartTagLength(Node node, CMElementDeclaration elementDecl) {
- if (elementDecl == null) {
- return 0;
- }
- if (requiresAttributes(elementDecl)) {
- return getRequiredName(node, elementDecl).length() + 2; // < +
- // name +
- // space
- }
- else {
- return 1 + getRequiredName(node, elementDecl).length() + getStartTagClose(node, elementDecl).length(); // < +
- // name
- // +
- // appropriate
- // close
- }
- }
-
- protected String getOtherClose(Node notATagNode) {
- if (notATagNode instanceof IDOMNode) {
- IStructuredDocumentRegion node = ((IDOMNode) notATagNode).getStartStructuredDocumentRegion();
- if ((node != null) && (node.getNumberOfRegions() > 1) && node.getRegions().get(0).getType().equals(DOMJSPRegionContextsPrivateCopy.JSP_DIRECTIVE_OPEN)) {
- return "%>"; //$NON-NLS-1$
- }
- }
- return null;
- }
-
- public String getStartTagClose(Node parentNode, CMElementDeclaration elementDecl) {
- String other = getOtherClose(parentNode);
- if (other != null) {
- return other;
- }
- if (elementDecl == null) {
- return ">";//$NON-NLS-1$
- }
- if (elementDecl.getContentType() == CMElementDeclaration.EMPTY) {
- return "/>"; //$NON-NLS-1$
- }
- return ">"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java
deleted file mode 100644
index 8fc14570e9..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLRelevanceConstants.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.wst.sse.ui.internal.contentassist.IRelevanceConstants;
-
-
-
-/**
- * some relevance constants for content assist higher relevance means it shows
- * up higher on the list
- */
-public interface XMLRelevanceConstants extends IRelevanceConstants {
-
- int R_CDATA = 400;
- int R_CLOSE_TAG = 1500;
-
- int R_COMMENT = 100;
-
- // moved this above macros
- int R_DOCTYPE = 600;
- int R_END_TAG = 1400;
- int R_END_TAG_NAME = 1100;
- int R_ENTITY = 1000;
- int R_JSP = 500;
-
- int R_JSP_ATTRIBUTE_VALUE = 700;
-
- // (pa) make these the same relevance so proposals are same order for V501
- int R_MACRO = 500;
-
- // add this onto "required" attrs, elements, etc to bubble them up on
- // sorting...
- // CMVC 246618
- int R_REQUIRED = 10;
- int R_TAG_INSERTION = 500;
- int R_STRICTLY_VALID_TAG_INSERTION = 600;
- int R_TAG_NAME = 1200;
- int R_STRICTLY_VALID_TAG_NAME = 1250;
- int R_XML_ATTRIBUTE_NAME = 900;
- int R_XML_ATTRIBUTE_VALUE = 800;
- int R_XML_DECLARATION = 1300;
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLStructuredContentAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLStructuredContentAssistProcessor.java
deleted file mode 100644
index 248936482c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLStructuredContentAssistProcessor.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-
-/**
- * <p>Implementation of {@link StructuredContentAssistProcessor} for XML documents</p>
- *
- * <p>This implementation will react to user preference changes for auto activation
- * characters for XML pages</p>
- *
- * @see StructuredContentAssistProcessor
- */
-public class XMLStructuredContentAssistProcessor extends StructuredContentAssistProcessor {
- /** the auto activation characters for this processor, set by user preference */
- private char[] fCompletionPropoaslAutoActivationCharacters;
-
- /**
- * <p>Constructor</p>
- *
- * @param assistant {@link ContentAssistant} to use
- * @param partitionTypeID the partition type this processor is for
- * @param viewer {@link ITextViewer} this processor is acting in
- */
- public XMLStructuredContentAssistProcessor(ContentAssistant assistant,
- String partitionTypeID, ITextViewer viewer) {
-
- super(assistant, partitionTypeID, viewer, XMLUIPlugin.getDefault().getPreferenceStore());
- getAutoActivationCharacterPreferences();
- }
-
-
- /**
- * @see org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor#getCompletionProposalAutoActivationCharacters()
- */
- public char[] getCompletionProposalAutoActivationCharacters() {
- return this.fCompletionPropoaslAutoActivationCharacters;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.contentassist.StructuredContentAssistProcessor#propertyChange(
- * org.eclipse.jface.util.PropertyChangeEvent)
- */
- public void propertyChange(PropertyChangeEvent event) {
- if(event.getProperty().equals(XMLUIPreferenceNames.AUTO_PROPOSE) ||
- event.getProperty().equals(XMLUIPreferenceNames.AUTO_PROPOSE_CODE)) {
- getAutoActivationCharacterPreferences();
- }
- }
-
-
- protected void getAutoActivationCharacterPreferences() {
- String key = XMLUIPreferenceNames.AUTO_PROPOSE;
- boolean doAuto = getPreferenceStore().getBoolean(key);
- if (doAuto) {
- key = XMLUIPreferenceNames.AUTO_PROPOSE_CODE;
- fCompletionPropoaslAutoActivationCharacters = getPreferenceStore().getString(key).toCharArray();
- }
- else {
- fCompletionPropoaslAutoActivationCharacters = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTagsCompletionProposalComputer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTagsCompletionProposalComputer.java
deleted file mode 100644
index c34a635866..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTagsCompletionProposalComputer.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-
-/**
- * <p>{@link AbstractXMLModelQueryCompletionProposalComputer} used to
- * generate XML tag content assist proposals</p>
- *
- * <p><b>NOTE:</b> Currently this computer does not filter out any of the
- * model query results so it will return all proposals from the model query
- * for the current content type. In the future this may need to change.</p>
- */
-public class XMLTagsCompletionProposalComputer extends
- AbstractXMLModelQueryCompletionProposalComputer {
-
- /** the generated used to generate the proposals */
- protected XMLContentModelGenerator fGenerator;
-
- /**
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLModelQueryCompletionProposalComputer#getContentGenerator()
- */
- protected XMLContentModelGenerator getContentGenerator() {
- if (fGenerator == null) {
- fGenerator = new XMLContentModelGenerator();
- }
- return fGenerator;
- }
-
- /**
- * <p>Filters out any model query actions that are not specific to XML</p>
- * <p><b>NOTE:</b> Currently nothing is filtered so this computer returns all
- * results from the model query for the current content type</p>
- *
- * @see org.eclipse.wst.xml.ui.internal.contentassist.AbstractXMLModelQueryCompletionProposalComputer#validModelQueryNode(org.eclipse.wst.xml.core.internal.contentmodel.CMNode)
- */
- protected boolean validModelQueryNode(CMNode node) {
- return true;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java
deleted file mode 100644
index d0bb83c785..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplateCompletionProcessor.java
+++ /dev/null
@@ -1,168 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.List;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.text.templates.TemplateCompletionProcessor;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.jface.text.templates.TemplateContextType;
-import org.eclipse.jface.text.templates.TemplateException;
-import org.eclipse.jface.text.templates.TemplateProposal;
-import org.eclipse.jface.text.templates.persistence.TemplateStore;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-
-/**
- * <p>Completion computer for XML templates</p>
- */
-class XMLTemplateCompletionProcessor extends TemplateCompletionProcessor {
- private static final class ProposalComparator implements Comparator {
- public int compare(Object o1, Object o2) {
- return ((TemplateProposal) o2).getRelevance() - ((TemplateProposal) o1).getRelevance();
- }
- }
-
- private static final Comparator fgProposalComparator = new ProposalComparator();
- private String fContextTypeId = null;
-
- /*
- * Copied from super class except instead of calling createContext(viewer,
- * region) call createContext(viewer, region, offset) instead
- */
- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int offset) {
-
- ITextSelection selection = (ITextSelection) viewer.getSelectionProvider().getSelection();
-
- // adjust offset to end of normalized selection
- if (selection.getOffset() == offset) {
- offset = selection.getOffset() + selection.getLength();
- }
-
- String prefix = extractPrefix(viewer, offset);
- Region region = new Region(offset - prefix.length(), prefix.length());
- TemplateContext context = createContext(viewer, region, offset);
- if (context == null) {
- return new ICompletionProposal[0];
- }
-
- // name of the selection variables {line, word}_selection
- context.setVariable("selection", selection.getText()); //$NON-NLS-1$
-
- Template[] templates = getTemplates(context.getContextType().getId());
-
- List matches = new ArrayList();
- for (int i = 0; i < templates.length; i++) {
- Template template = templates[i];
- try {
- context.getContextType().validate(template.getPattern());
- }
- catch (TemplateException e) {
- continue;
- }
- if (template.matches(prefix, context.getContextType().getId())) {
- matches.add(createProposal(template, context, (IRegion) region, getRelevance(template, prefix)));
- }
- }
-
- Collections.sort(matches, fgProposalComparator);
-
- return (ICompletionProposal[]) matches.toArray(new ICompletionProposal[matches.size()]);
- }
-
- /**
- * Creates a concrete template context for the given region in the
- * document. This involves finding out which context type is valid at the
- * given location, and then creating a context of this type. The default
- * implementation returns a <code>SmartReplaceTemplateContext</code> for
- * the context type at the given location. This takes the offset at which
- * content assist was invoked into consideration.
- *
- * @param viewer
- * the viewer for which the context is created
- * @param region
- * the region into <code>document</code> for which the
- * context is created
- * @param offset
- * the original offset where content assist was invoked
- * @return a template context that can handle template insertion at the
- * given location, or <code>null</code>
- */
- private TemplateContext createContext(ITextViewer viewer, IRegion region, int offset) {
- // pretty much same code as super.createContext except create
- // SmartReplaceTemplateContext
- TemplateContextType contextType = getContextType(viewer, region);
- if (contextType != null) {
- IDocument document = viewer.getDocument();
- return new ReplaceNameTemplateContext(contextType, document, region.getOffset(), region.getLength(), offset);
- }
- return null;
- }
-
- protected ICompletionProposal createProposal(Template template, TemplateContext context, IRegion region, int relevance) {
- return new CustomTemplateProposal(template, context, region, getImage(template), relevance);
- }
-
- protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) {
- TemplateContextType type = null;
-
- ContextTypeRegistry registry = getTemplateContextRegistry();
- if (registry != null) {
- type = registry.getContextType(fContextTypeId);
- }
-
- return type;
- }
-
- protected Image getImage(Template template) {
- // just return the same image for now
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TAG_MACRO);
- }
-
- private ContextTypeRegistry getTemplateContextRegistry() {
- return XMLUIPlugin.getDefault().getTemplateContextRegistry();
- }
-
- protected Template[] getTemplates(String contextTypeId) {
- Template templates[] = null;
-
- TemplateStore store = getTemplateStore();
- if (store != null) {
- templates = store.getTemplates(contextTypeId);
- }
-
- return templates;
- }
-
- private TemplateStore getTemplateStore() {
- return XMLUIPlugin.getDefault().getTemplateStore();
- }
-
- void setContextType(String contextTypeId) {
- fContextTypeId = contextTypeId;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplatesCompletionProposalComputer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplatesCompletionProposalComputer.java
deleted file mode 100644
index 0ab2300063..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentassist/XMLTemplatesCompletionProposalComputer.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentassist;
-
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext;
-import org.eclipse.wst.xml.ui.internal.templates.TemplateContextTypeIdsXML;
-
-/**
- * <p>Proposal computer used to computer XML template content assist
- * proposals</p>
- */
-public class XMLTemplatesCompletionProposalComputer extends
- DefaultXMLCompletionProposalComputer {
-
- /** <p>The template processor used to create the proposals</p> */
- private XMLTemplateCompletionProcessor fTemplateProcessor = null;
-
- /**
- * Create the computer
- */
- public XMLTemplatesCompletionProposalComputer() {
- super();
- fTemplateProcessor = new XMLTemplateCompletionProcessor();
- }
-
- /**
- * @see org.eclipse.wst.xml.ui.internal.contentassist.DefaultXMLCompletionProposalComputer#addAttributeNameProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addAttributeNameProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE, context);
- }
-
- /**
- * @see org.eclipse.wst.xml.ui.internal.contentassist.DefaultXMLCompletionProposalComputer#addAttributeValueProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addAttributeValueProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.ATTRIBUTE_VALUE, context);
- }
-
- /**
- * @see org.eclipse.wst.xml.ui.internal.contentassist.DefaultXMLCompletionProposalComputer#addEmptyDocumentProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addEmptyDocumentProposals(
- ContentAssistRequest contentAssistRequest,
- CompletionProposalInvocationContext context) {
-
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.NEW, context);
- }
-
- /**
- * @see org.eclipse.wst.xml.ui.internal.contentassist.DefaultXMLCompletionProposalComputer#addTagInsertionProposals(org.eclipse.wst.xml.ui.internal.contentassist.ContentAssistRequest, int, org.eclipse.wst.sse.ui.contentassist.CompletionProposalInvocationContext)
- */
- protected void addTagInsertionProposals(
- ContentAssistRequest contentAssistRequest, int childPosition,
- CompletionProposalInvocationContext context) {
-
- addTemplates(contentAssistRequest, TemplateContextTypeIdsXML.TAG, context);
- }
-
- /**
- * <p>Adds templates to the list of proposals</p>
- *
- * @param contentAssistRequest
- * @param templateContext
- * @param context
- */
- private void addTemplates(ContentAssistRequest contentAssistRequest, String templateContext,
- CompletionProposalInvocationContext context) {
-
- if (contentAssistRequest != null) {
-
- boolean useProposalList = !contentAssistRequest.shouldSeparate();
-
- if (fTemplateProcessor != null) {
- fTemplateProcessor.setContextType(templateContext);
- ICompletionProposal[] proposals =
- fTemplateProcessor.computeCompletionProposals(
- context.getViewer(), context.getInvocationOffset());
- for (int i = 0; i < proposals.length; ++i) {
- if (useProposalList) {
- contentAssistRequest.addProposal(proposals[i]);
- }
- else {
- contentAssistRequest.addMacro(proposals[i]);
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
deleted file mode 100644
index 0ea3570340..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapter.java
+++ /dev/null
@@ -1,257 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.xml.ui.internal.editor.CMImageUtil;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Node;
-
-/**
- * Adapts a DOM node to a JFace viewer.
- */
-public class JFaceNodeAdapter implements IJFaceNodeAdapter {
-
- final static Class ADAPTER_KEY = IJFaceNodeAdapter.class;
-
- /**
- * debug .option
- */
- private static final boolean DEBUG = getDebugValue();
-
- private static boolean getDebugValue() {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/outline"); //$NON-NLS-1$
- boolean result = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- return result;
- }
-
- JFaceNodeAdapterFactory fAdapterFactory;
- RefreshStructureJob fRefreshJob = null;
-
- public JFaceNodeAdapter(JFaceNodeAdapterFactory adapterFactory) {
- super();
- this.fAdapterFactory = adapterFactory;
- }
-
- protected Image createImage(Object object) {
- Image image = null;
- Node node = (Node) object;
- switch (node.getNodeType()) {
- case Node.ELEMENT_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ELEMENT);
- break;
- }
- case Node.ATTRIBUTE_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE);
- break;
- }
- case Node.TEXT_NODE : { // actually, TEXT should never be seen in
- // the tree
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_TXTEXT);
- break;
- }
- case Node.CDATA_SECTION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_CDATASECTION);
- break;
- }
- case Node.ENTITY_REFERENCE_NODE :
- case Node.ENTITY_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_ENTITY);
- break;
- }
- case Node.PROCESSING_INSTRUCTION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION);
- break;
- }
- case Node.COMMENT_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_COMMENT);
- break;
- }
- case Node.DOCUMENT_TYPE_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_DOCTYPE);
- break;
- }
- case Node.NOTATION_NODE : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_NOTATION);
- break;
- }
- default : {
- image = createXMLImageDescriptor(XMLEditorPluginImages.IMG_OBJ_TXTEXT);
- break;
- }
- }
- return image;
- }
-
- protected Image createXMLImageDescriptor(String imageResourceName) {
- return XMLEditorPluginImageHelper.getInstance().getImage(imageResourceName);
- }
-
- public Object[] getChildren(Object object) {
-
- // (pa) 20021217
- // cmvc defect 235554
- // performance enhancement: using child.getNextSibling() rather than
- // nodeList(item) for O(n) vs. O(n*n)
- //
- ArrayList v = new ArrayList();
- if (object instanceof Node) {
- Node node = (Node) object;
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- Node n = child;
- if (n.getNodeType() != Node.TEXT_NODE) {
- v.add(n);
- }
- }
- }
- return v.toArray();
- }
-
- /**
- * 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) {
- return getChildren(node);
- }
-
- /**
- * Fetches the label image specific to this object instance.
- */
- public Image getLabelImage(Object node) {
- Image image = null;
- if (node instanceof Node) {
- // check for an image from the content model
- image = CMImageUtil.getImage(CMImageUtil.getDeclaration((Node) node));
- if (image == null) {
- /*
- * Create/get image based on Node type. Images are cached
- * transparently in this class, subclasses must do this for
- * themselves if they're going to return their own results.
- */
- image = createImage(node);
- }
- }
- return image;
- }
-
- /**
- * Fetches the label text specific to this object instance.
- */
- public String getLabelText(Object node) {
- return getNodeName(node);
- }
-
- private String getNodeName(Object object) {
- StringBuffer nodeName = new StringBuffer();
- if (object instanceof Node) {
- Node node = (Node) object;
- nodeName.append(node.getNodeName());
-
- if (node.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- nodeName.insert(0, "DOCTYPE:"); //$NON-NLS-1$
- }
-
- }
- return nodeName.toString();
- }
-
-
- public Object getParent(Object object) {
- if (object instanceof Node) {
- Node node = (Node) object;
- return node.getParentNode();
- }
- return null;
- }
-
- private synchronized RefreshStructureJob getRefreshJob() {
- if (fRefreshJob == null) {
- fRefreshJob = new RefreshStructureJob();
- }
- return fRefreshJob;
- }
-
-
- public boolean hasChildren(Object object) {
- // (pa) 20021217
- // cmvc defect 235554 > use child.getNextSibling() instead of
- // nodeList(item) for O(n) vs. O(n*n)
- Node node = (Node) object;
- for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
- if (child.getNodeType() != Node.TEXT_NODE) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Allowing the INodeAdapter to compare itself against the type allows it
- * to return true in more than one case.
- */
- public boolean isAdapterForType(Object type) {
- if (type == null) {
- return false;
- }
- return type.equals(ADAPTER_KEY);
- }
-
- /**
- * Called by the object being adapter (the notifier) when something has
- * changed.
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- // future_TODO: the 'uijobs' used in this method were added to solve
- // threading problems when the dom
- // is updated in the background while the editor is open. They may be
- // a bit overkill and not that useful.
- // (That is, may be be worthy of job manager management). If they are
- // found to be important enough to leave in,
- // there's probably some optimization that can be done.
- if (notifier instanceof Node) {
- Collection listeners = fAdapterFactory.getListeners();
- Iterator iterator = listeners.iterator();
-
- while (iterator.hasNext()) {
- Object listener = iterator.next();
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=90637
- // if (notifier instanceof Node && (listener instanceof
- // StructuredViewer) && (eventType ==
- // INodeNotifier.STRUCTURE_CHANGED || (eventType ==
- // INodeNotifier.CHANGE && changedFeature == null))) {
- if ((listener instanceof StructuredViewer) && ((eventType == INodeNotifier.STRUCTURE_CHANGED) || (eventType == INodeNotifier.CONTENT_CHANGED) || (eventType == INodeNotifier.CHANGE))) {
- if (DEBUG) {
- System.out.println("JFaceNodeAdapter notified on event type > " + eventType); //$NON-NLS-1$
- }
-
- // refresh on structural and "unknown" changes
- StructuredViewer structuredViewer = (StructuredViewer) listener;
- // https://w3.opensource.ibm.com/bugzilla/show_bug.cgi?id=5230
- if (structuredViewer.getControl() != null) {
- getRefreshJob().refresh(structuredViewer, (Node) notifier);
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
deleted file mode 100644
index 3943403b34..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeAdapterFactory.java
+++ /dev/null
@@ -1,183 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.wst.sse.core.internal.provisional.AbstractAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.util.Assert;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManagerListener;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.ssemodelquery.ModelQueryAdapter;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-
-/**
- * An adapter factory to create JFaceNodeAdapters. Use this adapter factory
- * with a JFaceAdapterContentProvider to display DOM nodes in a tree.
- */
-public class JFaceNodeAdapterFactory extends AbstractAdapterFactory implements IJFaceNodeAdapterFactory {
- public class CMDocumentManagerListenerImpl implements CMDocumentManagerListener {
- private static final int UPDATE_DELAY = 200;
-
- public void cacheCleared(CMDocumentCache cache) {
- // nothing to do
- }
-
- public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) {
- if ((newStatus == CMDocumentCache.STATUS_LOADED) || (newStatus == CMDocumentCache.STATUS_ERROR)) {
- refreshViewers();
- }
- }
-
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName) {
- if (cmDocumentManager.getPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD)) {
- refreshViewers();
- }
- }
-
- private void refreshViewers() {
- Object[] listeners = getListeners().toArray();
- for (int i = 0; i < listeners.length; i++) {
- if (listeners[i] instanceof StructuredViewer) {
- final StructuredViewer viewer = (StructuredViewer) listeners[i];
- Job refresh = new UIJob(XMLUIMessages.refreshoutline_0) {
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Control refreshControl = viewer.getControl();
- if ((refreshControl != null) && !refreshControl.isDisposed()) {
- viewer.refresh(true);
- }
- return Status.OK_STATUS;
- }
- };
- refresh.setSystem(true);
- refresh.setPriority(Job.SHORT);
- refresh.schedule(UPDATE_DELAY);
- }
- else if (listeners[i] instanceof Viewer) {
- final Viewer viewer = (Viewer) listeners[i];
- Job refresh = new UIJob(XMLUIMessages.refreshoutline_0) {
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Control refreshControl = viewer.getControl();
- if ((refreshControl != null) && !refreshControl.isDisposed()) {
- viewer.refresh();
- }
- return Status.OK_STATUS;
- }
- };
- refresh.setSystem(true);
- refresh.setPriority(Job.SHORT);
- refresh.schedule(UPDATE_DELAY);
- }
- }
- }
- }
-
- private CMDocumentManager cmDocumentManager;
- private CMDocumentManagerListenerImpl fCMDocumentManagerListener = null;
- /**
- * This keeps track of all the listeners.
- */
- private Set fListeners = new HashSet();
-
- protected INodeAdapter singletonAdapter;
-
- public JFaceNodeAdapterFactory() {
- this(IJFaceNodeAdapter.class, true);
- }
-
- public JFaceNodeAdapterFactory(Object adapterKey, boolean registerAdapters) {
- super(adapterKey, registerAdapters);
- }
-
- public synchronized void addListener(Object listener) {
- fListeners.add(listener);
- }
-
- public INodeAdapterFactory copy() {
- return new JFaceNodeAdapterFactory(getAdapterKey(), isShouldRegisterAdapter());
- }
-
- /**
- * Create a new JFace adapter for the DOM node passed in
- */
- protected INodeAdapter createAdapter(INodeNotifier node) {
- if (singletonAdapter == null) {
- // create the JFaceNodeAdapter
- singletonAdapter = new JFaceNodeAdapter(this);
- initAdapter(singletonAdapter, node);
- }
- return singletonAdapter;
- }
-
-
- /**
- * returns "copy" so no one can modify our list. It is a shallow copy.
- */
- public synchronized Collection getListeners() {
- return new ArrayList(fListeners);
- }
-
- protected void initAdapter(INodeAdapter adapter, INodeNotifier node) {
- Assert.isTrue(cmDocumentManager == null);
- Assert.isTrue(fCMDocumentManagerListener == null);
-
- // register for CMDocumentManager events
- ModelQueryAdapter mqadapter = (ModelQueryAdapter) node.getAdapterFor(ModelQueryAdapter.class);
- if (mqadapter != null) {
- ModelQuery mquery = mqadapter.getModelQuery();
- if ((mquery != null) && (mquery.getCMDocumentManager() != null)) {
- cmDocumentManager = mquery.getCMDocumentManager();
- fCMDocumentManagerListener = new CMDocumentManagerListenerImpl();
- cmDocumentManager.addListener(fCMDocumentManagerListener);
- }
- }
- }
-
- public void release() {
- // deregister from CMDocumentManager events
- if ((cmDocumentManager != null) && (fCMDocumentManagerListener != null)) {
- cmDocumentManager.removeListener(fCMDocumentManagerListener);
- }
- fListeners.clear();
- if (singletonAdapter != null && singletonAdapter instanceof JFaceNodeAdapter) {
- RefreshStructureJob refreshJob = ((JFaceNodeAdapter) singletonAdapter).fRefreshJob;
- if (refreshJob != null) {
- refreshJob.cancel();
- }
- }
- }
-
- public synchronized void removeListener(Object listener) {
- fListeners.remove(listener);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
deleted file mode 100644
index f3c5452f80..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeContentProvider.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-
-
-/**
- * An ITreeContentProvider for a TreeViewers used to display DOM nodes. This
- * content provider takes an adapter factory to create JFace adapters for the
- * nodes in the tree.
- */
-public class JFaceNodeContentProvider implements ITreeContentProvider {
-
- public JFaceNodeContentProvider() {
- super();
- }
-
- /**
- * The visual part that is using this content provider is about to be
- * disposed. Deallocate all allocated SWT resources.
- */
- public void dispose() {
- }
-
- /**
- * Returns the JFace adapter for the specified object.
- *
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- if (adaptable instanceof INodeNotifier) {
- INodeAdapter adapter = ((INodeNotifier) adaptable).getAdapterFor(IJFaceNodeAdapter.class);
- if (adapter instanceof IJFaceNodeAdapter) {
- return (IJFaceNodeAdapter) adapter;
- }
- }
- return null;
- }
-
- public Object[] getChildren(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null) {
- return adapter.getChildren(object);
- }
-
- return new Object[0];
- }
-
- public Object[] getElements(Object object) {
- // The root is usually an instance of an XMLStructuredModel in
- // which case we want to extract the document.
- Object topNode = object;
- if (object instanceof IDOMModel) {
- topNode = ((IDOMModel) object).getDocument();
- }
-
- IJFaceNodeAdapter adapter = getAdapter(topNode);
-
- if (adapter != null) {
- return adapter.getElements(topNode);
- }
-
- return new Object[0];
- }
-
- public Object getParent(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null) {
- return adapter.getParent(object);
- }
-
- return null;
- }
-
- public boolean hasChildren(Object object) {
- IJFaceNodeAdapter adapter = getAdapter(object);
-
- if (adapter != null) {
- return adapter.hasChildren(object);
- }
-
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- if ((oldInput != null) && (oldInput instanceof IStructuredModel)) {
- IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) oldInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
- if (factory != null) {
- factory.removeListener(viewer);
- }
- }
- if ((newInput != null) && (newInput instanceof IStructuredModel)) {
- IJFaceNodeAdapterFactory factory = (IJFaceNodeAdapterFactory) ((IStructuredModel) newInput).getFactoryRegistry().getFactoryFor(IJFaceNodeAdapter.class);
- if (factory != null) {
- factory.addListener(viewer);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
deleted file mode 100644
index 6168ddebcf..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/JFaceNodeLabelProvider.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.ColumnLabelProvider;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-
-/**
- * A (column) label provider backed by JFaceNodeAdapters.
- */
-public class JFaceNodeLabelProvider extends ColumnLabelProvider {
- /**
- * JFaceNodeLabelProvider constructor comment.
- */
- public JFaceNodeLabelProvider() {
- super();
- }
-
- /**
- * Returns the JFace adapter for the specified object.
- *
- * @param adaptable
- * java.lang.Object The object to get the adapter for
- */
- protected IJFaceNodeAdapter getAdapter(Object adaptable) {
- if (adaptable instanceof INodeNotifier) {
- INodeAdapter adapter = ((INodeNotifier) adaptable).getAdapterFor(IJFaceNodeAdapter.class);
- if (adapter instanceof IJFaceNodeAdapter) {
- return (IJFaceNodeAdapter) adapter;
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object)
- */
- public Image getImage(Object element) {
- IJFaceNodeAdapter adapter = getAdapter(element);
- if (adapter != null)
- return adapter.getLabelImage(element);
- return super.getImage(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object element) {
- IJFaceNodeAdapter adapter = getAdapter(element);
- if (adapter != null)
- return adapter.getLabelText(element);
- return super.getText(element);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.IBaseLabelProvider#isLabelProperty(java.lang.Object,
- * java.lang.String)
- */
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java
deleted file mode 100644
index 55c93901e5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/RefreshStructureJob.java
+++ /dev/null
@@ -1,368 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.OperationCanceledException;
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * This job holds a queue of updates (affected nodes) for multiple structured
- * viewers. When a new request comes in, the current run is cancelled, the new
- * request is added to the queue, then the job is re-scheduled. Support for
- * multiple structured viewers is required because refresh updates are usually
- * triggered by model changes, and the model may be visible in more than one
- * viewer.
- *
- * @author pavery
- */
-class RefreshStructureJob extends Job {
-
- /** debug flag */
- static final boolean DEBUG;
- private static final long UPDATE_DELAY = 300;
- static {
- String value = Platform.getDebugOption("org.eclipse.wst.sse.ui/debug/refreshStructure"); //$NON-NLS-1$
- DEBUG = (value != null) && value.equalsIgnoreCase("true"); //$NON-NLS-1$
- }
- /** List of refresh requests (Nodes) */
- private final List fRefreshes;
- /** List of update requests (Nodes) */
- private final List fUpdates;
- /** List of update requests (Nodes) */
- private final List fUpdateProperties;
- /** the structured viewers */
- Set fRefreshViewers = new HashSet(3);
- Set fUpdateViewers = new HashSet(3);
-
- public RefreshStructureJob() {
- super(XMLUIMessages.refreshoutline_0);
- setPriority(Job.LONG);
- setSystem(true);
- fRefreshes = new ArrayList(5);
- fUpdates = new ArrayList(5);
- fUpdateProperties = new ArrayList(5);
- }
-
- private synchronized void addUpdateRequest(Node newNodeRequest, String[] updateProperties) {
- /*
- * If we get to here, either from existing request list being zero
- * length, or no exisitng requests "matched" new request, then add the
- * new request.
- */
- fUpdates.add(newNodeRequest);
- fUpdateProperties.add(updateProperties);
- }
-
- private synchronized void addUpdateViewer(StructuredViewer viewer) {
- fUpdateViewers.add(viewer);
- }
-
- private synchronized void addRefreshRequest(Node newNodeRequest) {
- /*
- * note: the caller must NOT pass in null node request (which, since
- * private method, we do not need to gaurd against here, as long as we
- * gaurd against it in calling method.
- */
- int size = fRefreshes.size();
- for (int i = 0; i < size; i++) {
- Node existingNodeRequest = (Node) fRefreshes.get(i);
- /*
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=157427 If we
- * already have a request which equals the new request, discard
- * the new request
- */
- if (existingNodeRequest.equals(newNodeRequest)) {
- return;
- }
- /*
- * If we already have a request which contains the new request,
- * discard the new request
- */
- if (contains(existingNodeRequest, newNodeRequest)) {
- return;
- }
- /*
- * If new request contains any existing requests, replace it with
- * new request. ISSUE: technically, we should replace ALL
- * contained, existing requests (such as if many siblings already
- * que'd up when their common parent is then requested, but, I'm
- * not sure if that occurs much, in practice, or if there's an
- * algorithm to quickly find them all. Actually, I guess we could
- * just go through the _rest_ of the list (i+1 to size) and remove
- * any that are contained by new request ... in future :) .
- */
- if (contains(newNodeRequest, existingNodeRequest)) {
- fRefreshes.set(i, newNodeRequest);
- return;
- }
- }
- /*
- * If we get to here, either from existing request list being zero
- * length, or no exisitng requests "matched" new request, then add the
- * new request.
- */
- fRefreshes.add(newNodeRequest);
- }
-
- private synchronized void addRefreshViewer(StructuredViewer viewer) {
- fRefreshViewers.add(viewer);
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#canceling()
- */
- protected void canceling() {
- fUpdates.clear();
- fUpdateViewers.clear();
- super.canceling();
- }
-
- /**
- * Simple hierarchical containment relationship. Note, this method returns
- * "false" if the two nodes are equal!
- *
- * @param root
- * @param possible
- * @return if the root is parent of possible, return true, otherwise
- * return false
- */
- private boolean contains(Node root, Node possible) {
- if (DEBUG) {
- System.out.println("=============================================================================================================="); //$NON-NLS-1$
- System.out.println("recursive call w/ root: " + root.getNodeName() + " and possible: " + possible); //$NON-NLS-1$ //$NON-NLS-2$
- System.out.println("--------------------------------------------------------------------------------------------------------------"); //$NON-NLS-1$
- }
-
- // the following checks are important
- // #document node will break the algorithm otherwise
-
- // can't contain the child if it's null
- if (root == null) {
- if (DEBUG) {
- System.out.println("returning false: root is null"); //$NON-NLS-1$
- }
- return false;
- }
- // nothing can be parent of Document node
- if (possible instanceof Document) {
- if (DEBUG) {
- System.out.println("returning false: possible is Document node"); //$NON-NLS-1$
- }
- return false;
- }
- // document contains everything
- if (root instanceof Document) {
- if (DEBUG) {
- System.out.println("returning true: root is Document node"); //$NON-NLS-1$
- }
- return true;
- }
-
- // check parentage
- Node current = possible;
- // loop parents
- while ((current != null) && (current.getNodeType() != Node.DOCUMENT_NODE)) {
- // found it
- if (root.equals(current)) {
- if (DEBUG) {
- System.out.println(" !!! found: " + possible.getNodeName() + " in subelement of: " + root.getNodeName()); //$NON-NLS-1$ //$NON-NLS-2$
- }
- return true;
- }
- current = current.getParentNode();
- }
- // never found it
- return false;
- }
-
- /**
- * Refresh must be on UI thread because it's on a SWT widget.
- *
- * @param node
- */
- private void doRefresh(final Node node, final StructuredViewer[] viewers) {
- final Display display = PlatformUI.getWorkbench().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- if (DEBUG) {
- System.out.println("refresh on: [" + node.getNodeName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- for (int i = 0; i < viewers.length; i++) {
- if (!viewers[i].getControl().isDisposed()) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- viewers[i].refresh(true);
- }
- else {
- viewers[i].refresh(node, true);
- }
- }
- else {
- if (DEBUG) {
- System.out.println(" !!! skipped refreshing disposed viewer: " + viewers[i]); //$NON-NLS-1$
- }
- }
- }
- }
- });
- }
-
- /**
- * Update must be on UI thread because it's on a SWT widget.
- *
- * @param node
- */
- private void doUpdate(final StructuredViewer[] viewers, final Node node, final String[] properties) {
- final Display display = PlatformUI.getWorkbench().getDisplay();
- display.asyncExec(new Runnable() {
- public void run() {
- if (DEBUG) {
- System.out.println("refresh on: [" + node.getNodeName() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- for (int i = 0; i < viewers.length; i++) {
- if (!viewers[i].getControl().isDisposed()) {
- viewers[i].update(node, properties);
- }
- else {
- if (DEBUG) {
- System.out.println(" !!! skipped refreshing disposed viewer: " + viewers[i]); //$NON-NLS-1$
- }
- }
- }
- }
- });
- }
-
- /**
- * This method also synchronized because it accesses the fRefreshes queue
- * and fRefreshViewers list
- *
- * @return an array containing and array of the currently requested Nodes
- * to refresh and the viewers in which to refresh them
- */
- private synchronized Object[] getRefreshRequests() {
- Node[] toRefresh = (Node[]) fRefreshes.toArray(new Node[fRefreshes.size()]);
- fRefreshes.clear();
-
- StructuredViewer[] viewers = (StructuredViewer[]) fRefreshViewers.toArray(new StructuredViewer[fRefreshViewers.size()]);
- fRefreshViewers.clear();
-
- return new Object[]{toRefresh, viewers};
- }
-
- /**
- * This method also synchronized because it accesses the fUpdates queue
- * and fUpdateViewers list
- *
- * @return an array containing and array of the currently requested Nodes
- * to refresh and the viewers in which to refresh them
- */
- private synchronized Object[] getUpdateRequests() {
- Node[] toUpdate = (Node[]) fUpdates.toArray(new Node[fUpdates.size()]);
- fUpdates.clear();
-
- StructuredViewer[] viewers = (StructuredViewer[]) fUpdateViewers.toArray(new StructuredViewer[fUpdateViewers.size()]);
- fUpdateViewers.clear();
-
- String[][] properties = (String[][]) fUpdateProperties.toArray(new String[fUpdateProperties.size()][]);
- fUpdateProperties.clear();
-
- return new Object[]{toUpdate, viewers, properties};
- }
-
- /**
- * Invoke a refresh on the viewer on the given node.
- *
- * @param node
- */
- public void refresh(StructuredViewer viewer, Node node) {
- if (node == null) {
- return;
- }
-
- addRefreshViewer(viewer);
- addRefreshRequest(node);
- schedule(UPDATE_DELAY);
- }
-
- /**
- * Invoke a refresh on the viewer on the given node.
- *
- * @param node
- */
- public void update(StructuredViewer viewer, Node node, String[] properties) {
- if (node == null) {
- return;
- }
-
- addUpdateViewer(viewer);
- addUpdateRequest(node, properties);
- schedule(UPDATE_DELAY);
- }
-
- protected IStatus run(IProgressMonitor monitor) {
- IStatus status = Status.OK_STATUS;
- try {
- performUpdates();
-
- performRefreshes(monitor);
- }
- finally {
- monitor.done();
- }
- return status;
- }
-
- private void performRefreshes(IProgressMonitor monitor) {
- // Retrieve BOTH viewers and Nodes on one block
- Object[] requests = getRefreshRequests();
- Node[] nodes = (Node[]) requests[0];
- StructuredViewer[] viewers = (StructuredViewer[]) requests[1];
-
- for (int i = 0; i < nodes.length; i++) {
- if (monitor.isCanceled()) {
- throw new OperationCanceledException();
- }
- doRefresh(nodes[i], viewers);
- }
- }
-
- private void performUpdates() {
- // Retrieve BOTH viewers and Nodes on one block
- Object[] requests = getUpdateRequests();
- Node[] nodes = (Node[]) requests[0];
- StructuredViewer[] viewers = (StructuredViewer[]) requests[1];
- String[][] properties = (String[][]) requests[2];
-
- for (int i = 0; i < nodes.length; i++) {
- doUpdate(viewers, nodes[i], properties[i]);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
deleted file mode 100644
index f858071966..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/contentoutline/XMLNodeActionManager.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.contentoutline;
-
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
-import org.eclipse.wst.xml.ui.internal.actions.AbstractNodeActionManager;
-import org.w3c.dom.Node;
-
-
-public class XMLNodeActionManager extends AbstractNodeActionManager {
- public XMLNodeActionManager(IStructuredModel model, Viewer viewer) {
- super(model, ModelQueryUtil.getModelQuery(model), viewer);
- }
-
- public void reformat(Node newElement, boolean deep) {
- try {
- // tell the model that we are about to make a big model change
- fModel.aboutToChangeModel();
-
- // format selected node
- IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
- formatProcessor.formatNode(newElement);
- }
- finally {
- // tell the model that we are done with the big model change
- fModel.changedModel();
- }
- }
-
- public void setModel(IStructuredModel newModel) {
- fModel = newModel;
- setModelQuery(ModelQueryUtil.getModelQuery(newModel));
- }
-
- protected void setModelQuery(ModelQuery newModelQuery) {
- modelQuery = newModelQuery;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionAssistantProviderXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionAssistantProviderXML.java
deleted file mode 100644
index 2c11048950..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionAssistantProviderXML.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-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.source.ISourceViewer;
-import org.eclipse.wst.sse.ui.internal.correction.CorrectionAssistantProvider;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-
-/**
- * Correction assistant for XML
- *
- * @deprecated since 2.0 RC0 Use
- * org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
- */
-public class CorrectionAssistantProviderXML extends CorrectionAssistantProvider {
-
- public IContentAssistant getCorrectionAssistant(ISourceViewer sourceViewer) {
- IContentAssistant ca = null;
-
- if (sourceViewer != null) {
- ContentAssistant assistant = new ContentAssistant();
-
- if (sourceViewer != null) {
- IContentAssistProcessor correctionProcessor = new CorrectionProcessorXML(sourceViewer);
- assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_DEFAULT);
- assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_CDATA);
- assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_COMMENT);
- assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_DECLARATION);
- assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.XML_PI);
- assistant.setContentAssistProcessor(correctionProcessor, IXMLPartitions.DTD_SUBSET);
- }
- ca = assistant;
- }
-
- return ca;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java
deleted file mode 100644
index 97e73e73f0..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/CorrectionProcessorXML.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickAssistProcessor;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickFixProcessor;
-import org.eclipse.wst.sse.ui.internal.correction.StructuredCorrectionProcessor;
-
-/**
- * @deprecated since 2.0 RC0 Use
- * org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
- */
-public class CorrectionProcessorXML extends StructuredCorrectionProcessor {
- protected IQuickAssistProcessor fQuickAssistProcessor;
- protected IQuickFixProcessor fQuickFixProcessor;
-
- public CorrectionProcessorXML(ISourceViewer sourceViewer) {
- super(sourceViewer);
- }
-
- protected IQuickAssistProcessor getQuickAssistProcessor() {
- if (fQuickAssistProcessor == null) {
- fQuickAssistProcessor = new QuickAssistProcessorXML();
- }
-
- return fQuickAssistProcessor;
- }
-
- protected IQuickFixProcessor getQuickFixProcessor() {
- if (fQuickFixProcessor == null) {
- fQuickFixProcessor = new QuickFixProcessorXML();
- }
-
- return fQuickFixProcessor;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java
deleted file mode 100644
index 74947edfd4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/InsertRequiredAttrsQuickAssistProposal.java
+++ /dev/null
@@ -1,180 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import java.util.List;
-
-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.ICompletionProposal;
-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.text.edits.InsertEdit;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-public class InsertRequiredAttrsQuickAssistProposal implements ICompletionProposal, ICompletionProposalExtension2 {
- private final List fRequiredAttrs;
-
- /**
- * @param requiredAttrs
- */
- public InsertRequiredAttrsQuickAssistProposal(List requiredAttrs) {
- fRequiredAttrs = requiredAttrs;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
- */
- public void apply(IDocument document) {
- // not implemented?
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- int index = startStructuredDocumentRegion.getEndOffset();
- ITextRegion lastRegion = startStructuredDocumentRegion.getLastRegion();
- if (lastRegion.getType() == DOMRegionContext.XML_TAG_CLOSE) {
- index--;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- }
- else if (lastRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- index = index - 2;
- lastRegion = startStructuredDocumentRegion.getRegionAtCharacterOffset(index - 1);
- }
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- try {
- for (int i = 0; i < fRequiredAttrs.size(); i++) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) fRequiredAttrs.get(i);
- String requiredAttributeName = attrDecl.getAttrName();
- String defaultValue = attrDecl.getDefaultValue();
- if (defaultValue == null) {
- defaultValue = ""; //$NON-NLS-1$
- }
- String nameAndDefaultValue = " "; //$NON-NLS-1$
- if ((i == 0) && (lastRegion.getLength() > lastRegion.getTextLength())) {
- nameAndDefaultValue = ""; //$NON-NLS-1$
- }
- nameAndDefaultValue += requiredAttributeName + "=\"" + defaultValue + "\""; //$NON-NLS-1$//$NON-NLS-2$
- multiTextEdit.addChild(new InsertEdit(index, nameAndDefaultValue));
- // BUG3381: MultiTextEdit applies all child TextEdit's basing
- // on offsets
- // in the document before the first TextEdit, not after each
- // child TextEdit. Therefore, do not need to advance the
- // index.
- // index += nameAndDefaultValue.length();
- }
- multiTextEdit.apply(viewer.getDocument());
- }
- catch (BadLocationException e) {
- // log, for now, unless we find there's reasons why we get some
- // here.
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return XMLUIMessages.InsertRequiredAttrsQuickAssistProposal_1;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- // return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ADD_CORRECTION);
- }
-
- /*
- * (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.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer,
- * boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @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) {
- return false;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java
deleted file mode 100644
index 18fae109eb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/ProblemIDsXML.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-public interface ProblemIDsXML {
- int AttrsInEndTag = 3;
- int AttrValueNotQuoted = 13;
- int EmptyTag = 1;
- int InvalidAttrValue = 11;
- int MissingAttrValue = 4;
- int MissingClosingBracket = 14;
- int MissingEndTag = 2;
- int MissingRequiredAttr = 12;
- int MissingStartTag = 15;
- int NamespaceInPI = 8;
- int NoAttrValue = 5;
- int SpacesBeforePI = 7;
- int SpacesBeforeTagName = 6;
- int Unclassified = 0;
- int UnknownAttr = 10;
- int UnknownElement = 9;
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
deleted file mode 100644
index 486c6c980a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickAssistProcessorXML.java
+++ /dev/null
@@ -1,192 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickAssistProcessor;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * @deprecated since 2.0 RC0 Use
- * org.eclipse.jface.text.quickassist.IQuickAssistProcessor and XMLQuickAssistProcessor
- */
-public class QuickAssistProcessorXML implements IQuickAssistProcessor {
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickAssistProcessor#canAssist(org.eclipse.wst.sse.core.text.IStructuredDocument,
- * int)
- */
- public boolean canAssist(StructuredTextViewer viewer, int offset) {
- return true;
- }
-
- /**
- * @param proposals
- * @param viewer
- * @param offset
- */
- protected void getInsertRequiredAttrs(ArrayList proposals, StructuredTextViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) {
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) {
- IDOMNode cursorNode = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- List requiredAttrs = getRequiredAttrs(cursorNode);
- if (requiredAttrs.size() > 0) {
- NamedNodeMap currentAttrs = node.getAttributes();
- List insertAttrs = new ArrayList();
- if (currentAttrs.getLength() == 0) {
- insertAttrs.addAll(requiredAttrs);
- }
- else {
- for (int i = 0; i < requiredAttrs.size(); i++) {
- String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName();
- boolean found = false;
- for (int j = 0; j < currentAttrs.getLength(); j++) {
- String currentAttrName = currentAttrs.item(j).getNodeName();
- if (requiredAttrName.compareToIgnoreCase(currentAttrName) == 0) {
- found = true;
- break;
- }
- }
- if (!found) {
- insertAttrs.add(requiredAttrs.get(i));
- }
- }
- }
- if (insertAttrs.size() > 0) {
- proposals.add(new InsertRequiredAttrsQuickAssistProposal(insertAttrs));
- }
- }
- }
- }
- }
-
- /**
- * @param proposals
- * @param viewer
- * @param offset
- */
- protected void getLocalRenameQuickAssistProposal(ArrayList proposals, StructuredTextViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- IStructuredDocumentRegion startStructuredDocumentRegion = node == null ? null : node.getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endStructuredDocumentRegion = node == null ? null : node.getEndStructuredDocumentRegion();
-
- ITextRegion region = null;
- int regionTextEndOffset = 0;
- if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) {
- region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region);
- }
- else if ((endStructuredDocumentRegion != null) && endStructuredDocumentRegion.containsOffset(offset)) {
- region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region);
- }
-
- if ((region != null) && ((region.getType() == DOMRegionContext.XML_TAG_NAME) || (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) && (offset <= regionTextEndOffset)) {
- proposals.add(new RenameInFileQuickAssistProposal());
- }
- }
-
- protected ModelQuery getModelQuery(Node node) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return ModelQueryUtil.getModelQuery((Document) node);
- }
- else {
- return ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickAssistProcessor#getProposals(org.eclipse.wst.sse.core.text.IStructuredDocument,
- * int)
- */
- public ICompletionProposal[] getProposals(StructuredTextViewer viewer, int offset) throws CoreException {
- ArrayList proposals = new ArrayList();
-
- getLocalRenameQuickAssistProposal(proposals, viewer, offset);
- getSurroundWithNewElementQuickAssistProposal(proposals, viewer, offset);
- getInsertRequiredAttrs(proposals, viewer, offset);
-
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- protected List getRequiredAttrs(Node node) {
- List result = new ArrayList();
-
- ModelQuery modelQuery = getModelQuery(node);
- if (modelQuery != null) {
- CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
- if (elementDecl != null) {
- CMNamedNodeMap attrMap = elementDecl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element)node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attrMap = allAttributes;
-
- Iterator it = attrMap.iterator();
- CMAttributeDeclaration attr = null;
- while (it.hasNext()) {
- attr = (CMAttributeDeclaration) it.next();
- if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
- result.add(attr);
- }
- }
- }
- }
-
- return result;
- }
-
- /**
- * @param proposals
- * @param viewer
- * @param offset
- */
- protected void getSurroundWithNewElementQuickAssistProposal(ArrayList proposals, StructuredTextViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- if (node != null) {
- proposals.add(new SurroundWithNewElementQuickAssistProposal());
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java
deleted file mode 100644
index 28eaea1de6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/QuickFixProcessorXML.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import java.util.ArrayList;
-
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.jface.text.contentassist.CompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.sse.ui.internal.correction.IQuickFixProcessor;
-import org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-/**
- * @deprecated since 2.0 RC0 Use
- * org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
- */
-public class QuickFixProcessorXML implements IQuickFixProcessor {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickFixProcessor#canFix(int)
- */
- public boolean canFix(Annotation annotation) {
- boolean result = false;
-
- if (annotation instanceof TemporaryAnnotation) {
- TemporaryAnnotation tempAnnotation = (TemporaryAnnotation) annotation;
- int problemID = tempAnnotation.getProblemID();
- switch (problemID) {
- case ProblemIDsXML.EmptyTag :
- case ProblemIDsXML.MissingEndTag :
- case ProblemIDsXML.AttrsInEndTag :
- case ProblemIDsXML.MissingAttrValue :
- case ProblemIDsXML.NoAttrValue :
- case ProblemIDsXML.SpacesBeforeTagName :
- case ProblemIDsXML.SpacesBeforePI :
- case ProblemIDsXML.NamespaceInPI :
- case ProblemIDsXML.UnknownElement :
- case ProblemIDsXML.UnknownAttr :
- case ProblemIDsXML.InvalidAttrValue :
- case ProblemIDsXML.MissingRequiredAttr :
- case ProblemIDsXML.AttrValueNotQuoted :
- case ProblemIDsXML.MissingClosingBracket :
- result = true;
- }
- }
-
- return result;
- }
-
- public Image getImage() {
- // return
- // JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_CHANGE);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_CORRECTION_CHANGE);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.correction.IQuickFixProcessor#getProposals(org.eclipse.wst.sse.ui.internal.reconcile.TemporaryAnnotation)
- */
- public ICompletionProposal[] getProposals(Annotation annotation) throws CoreException {
- ArrayList proposals = new ArrayList();
-
- if (annotation instanceof TemporaryAnnotation) {
- TemporaryAnnotation tempAnnotation = (TemporaryAnnotation) annotation;
- int problemID = tempAnnotation.getProblemID();
- switch (problemID) {
- case ProblemIDsXML.EmptyTag :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_0, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.MissingEndTag :
- String tagName = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
- String tagClose = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1];
- int tagCloseOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[2]).intValue();
- int startTagEndOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[3]).intValue();
- int firstChildStartOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[4]).intValue();
- int endOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[5]).intValue();
- proposals.add(new CompletionProposal(tagClose, tagCloseOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_1, null, "")); //$NON-NLS-1$
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), startTagEndOffset - tempAnnotation.getPosition().getOffset(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_2, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- proposals.add(new CompletionProposal("</" + tagName + ">", firstChildStartOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_3, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("</" + tagName + ">", endOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_4, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.AttrsInEndTag :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_5, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.MissingAttrValue :
- String defaultAttrValue = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
- int insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue();
- proposals.add(new CompletionProposal("\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength() + insertOffset, 0, defaultAttrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.NoAttrValue :
- defaultAttrValue = (String) tempAnnotation.getAdditionalFixInfo();
- proposals.add(new CompletionProposal("=\"" + defaultAttrValue + "\"", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, defaultAttrValue.length() + 3, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.SpacesBeforeTagName :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_8, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.SpacesBeforePI :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_9, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.NamespaceInPI :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_10, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.UnknownElement :
- proposals.add(new RemoveUnknownElementQuickFixProposal(tempAnnotation.getAdditionalFixInfo(), getImage(), XMLUIMessages.QuickFixProcessorXML_11));
- proposals.add(new RenameInFileQuickAssistProposal());
- break;
- case ProblemIDsXML.UnknownAttr :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- proposals.add(new RenameInFileQuickAssistProposal());
- break;
- case ProblemIDsXML.InvalidAttrValue :
- proposals.add(new CompletionProposal("", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_12, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.MissingRequiredAttr :
- String requiredAttr = (String) ((Object[]) tempAnnotation.getAdditionalFixInfo())[0];
- insertOffset = ((Integer) ((Object[]) tempAnnotation.getAdditionalFixInfo())[1]).intValue();
- proposals.add(new CompletionProposal(requiredAttr, tempAnnotation.getPosition().getOffset() + insertOffset, 0, requiredAttr.length(), getImage(), XMLUIMessages.QuickFixProcessorXML_13, null, "")); //$NON-NLS-1$
- break;
- case ProblemIDsXML.AttrValueNotQuoted :
- String attrValue = (String) tempAnnotation.getAdditionalFixInfo();
- proposals.add(new CompletionProposal("\"" + attrValue + "\"", tempAnnotation.getPosition().getOffset(), tempAnnotation.getPosition().getLength(), attrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_14, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.MissingClosingBracket :
- proposals.add(new CompletionProposal(">", tempAnnotation.getPosition().getOffset() + tempAnnotation.getPosition().getLength(), 0, 1, getImage(), XMLUIMessages.QuickFixProcessorXML_15, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
-
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java
deleted file mode 100644
index b87a2c9a78..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RemoveUnknownElementQuickFixProposal.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-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.ICompletionProposal;
-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.text.edits.DeleteEdit;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class RemoveUnknownElementQuickFixProposal implements ICompletionProposal, ICompletionProposalExtension2 {
- private Object fAdditionalFixInfo = null;
- private String fDisplayString;
- private Image fImage;
- private Point fSelection; // initialized by apply()
-
- public RemoveUnknownElementQuickFixProposal(Object additionalFixInfo, Image image, String displayString) {
- fAdditionalFixInfo = additionalFixInfo;
- fImage = image;
- fDisplayString = displayString;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#apply(org.eclipse.jface.text.IDocument)
- */
- public void apply(IDocument document) {
- // not implemented?
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- int startTagOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[0]).intValue();
- int startTagLength = ((Integer) ((Object[]) fAdditionalFixInfo)[1]).intValue();
- int endTagOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[2]).intValue();
- int endTagLength = ((Integer) ((Object[]) fAdditionalFixInfo)[3]).intValue();
-
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- if (endTagOffset != -1) {
- multiTextEdit.addChild(new DeleteEdit(endTagOffset, endTagLength));
- fSelection = new Point(endTagOffset, 0);
- }
- if (startTagOffset != -1) {
- multiTextEdit.addChild(new DeleteEdit(startTagOffset, startTagLength));
- fSelection = new Point(startTagOffset, 0);
- }
-
- try {
- multiTextEdit.apply(viewer.getDocument());
- }
- catch (MalformedTreeException e) {
- // log for now, unless find reasons not to.
- Logger.log(Logger.INFO, e.getMessage());
- }
- catch (BadLocationException e) {
- // log for now, unless find reasons not to.
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- if (fDisplayString == null) {
- fDisplayString = XMLUIMessages.QuickFixProcessorXML_11;
- }
-
- return fDisplayString;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- return fImage;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
- */
- public Point getSelection(IDocument document) {
- return fSelection;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer,
- * boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @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) {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java
deleted file mode 100644
index ac95b3178c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/RenameInFileQuickAssistProposal.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.DocumentEvent;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposalExtension2;
-import org.eclipse.jface.text.contentassist.IContextInformation;
-import org.eclipse.jface.text.link.LinkedModeModel;
-import org.eclipse.jface.text.link.LinkedModeUI;
-import org.eclipse.jface.text.link.LinkedPosition;
-import org.eclipse.jface.text.link.LinkedPositionGroup;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.ui.texteditor.link.EditorLinkedModeUI;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-public class RenameInFileQuickAssistProposal implements ICompletionProposal, ICompletionProposalExtension2 {
- protected IRegion fSelectedRegion; // initialized by apply()
-
- /*
- * (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.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- IDocument document = viewer.getDocument();
- LinkedPositionGroup group = new LinkedPositionGroup();
- try {
- if (viewer instanceof StructuredTextViewer) {
- IDOMNode node = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- ITextRegion region = (startStructuredDocumentRegion == null) ? null : startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- if (region != null) {
- group.addPosition(new LinkedPosition(document, startStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0));
-
- if ((region.getType() == DOMRegionContext.XML_TAG_NAME) && (node.getEndStructuredDocumentRegion() != null)) {
- region = node.getEndStructuredDocumentRegion().getRegions().get(1);
- if (region != null) {
- group.addPosition(new LinkedPosition(document, node.getEndStructuredDocumentRegion().getStartOffset() + region.getStart(), region.getTextLength(), 1));
- }
- }
- }
- else {
- IStructuredDocumentRegion endStructuredDocumentRegion = node.getEndStructuredDocumentRegion();
- region = (endStructuredDocumentRegion == null) ? null : endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- if (region != null) {
- if ((region.getType() == DOMRegionContext.XML_TAG_NAME) && (node.getStartStructuredDocumentRegion() != null)) {
- ITextRegion startTagNameRegion = node.getStartStructuredDocumentRegion().getRegions().get(1);
- if (region != null) {
- group.addPosition(new LinkedPosition(document, node.getStartStructuredDocumentRegion().getStartOffset() + startTagNameRegion.getStart(), startTagNameRegion.getTextLength(), 0));
- group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 1));
- }
- }
- else {
- group.addPosition(new LinkedPosition(document, endStructuredDocumentRegion.getStartOffset() + region.getStart(), region.getTextLength(), 0));
- }
- }
- }
-
- // TODO CompletionProposalPopup#insertProposal() calls
- // IRewriteTarget.beginCompoundChange()
- // which disables redraw in ITextViewer. Workaround for now.
- ((StructuredTextViewer) viewer).setRedraw(true);
- }
-
- LinkedModeModel linkedModeModel = new LinkedModeModel();
- linkedModeModel.addGroup(group);
- linkedModeModel.forceInstall();
-
- LinkedModeUI ui = new EditorLinkedModeUI(linkedModeModel, viewer);
- ui.setExitPosition(viewer, offset, 0, LinkedPositionGroup.NO_STOP);
- ui.enter();
-
- fSelectedRegion = ui.getSelectedRegion();
- }
- catch (BadLocationException e) {
- // log for now, unless find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return XMLUIMessages.RenameInFileQuickAssistProposal_0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getContextInformation()
- */
- public IContextInformation getContextInformation() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return XMLUIMessages.RenameInFileQuickAssistProposal_1;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- // return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_LOCAL_VARIABLE);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getSelection(org.eclipse.jface.text.IDocument)
- */
- public Point getSelection(IDocument document) {
- return new Point(fSelectedRegion.getOffset(), fSelectedRegion.getLength());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#selected(org.eclipse.jface.text.ITextViewer,
- * boolean)
- */
- public void selected(ITextViewer viewer, boolean smartToggle) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#unselected(org.eclipse.jface.text.ITextViewer)
- */
- public void unselected(ITextViewer viewer) {
- }
-
- /*
- * (non-Javadoc)
- *
- * @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) {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java
deleted file mode 100644
index 7baffc845a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/SurroundWithNewElementQuickAssistProposal.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.text.edits.InsertEdit;
-import org.eclipse.text.edits.MalformedTreeException;
-import org.eclipse.text.edits.MultiTextEdit;
-import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.format.FormatProcessorXML;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-import org.w3c.dom.Node;
-
-public class SurroundWithNewElementQuickAssistProposal extends RenameInFileQuickAssistProposal {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposalExtension2#apply(org.eclipse.jface.text.ITextViewer,
- * char, int, int)
- */
- public void apply(ITextViewer viewer, char trigger, int stateMask, int offset) {
- try {
- int startTagOffset = offset;
- int endTagOffset = offset + viewer.getSelectedRange().y;
-
- // surround the node if no selection
- if (startTagOffset == endTagOffset) {
- IDOMNode cursorNode = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, offset);
- // use parent node if text node is empty
- if ((cursorNode.getNodeType() == Node.TEXT_NODE) && (cursorNode.getNodeValue().trim().length() == 0)) {
- cursorNode = (IDOMNode) cursorNode.getParentNode();
- }
-
- startTagOffset = cursorNode.getStartOffset();
- endTagOffset = cursorNode.getEndOffset();
- }
-
- // insert new element
- MultiTextEdit multiTextEdit = new MultiTextEdit();
- // element tag name cannot be DBCS, do not translate "<element>"
- // and "</element>"
- multiTextEdit.addChild(new InsertEdit(startTagOffset, "<element>")); //$NON-NLS-1$
- multiTextEdit.addChild(new InsertEdit(endTagOffset, "</element>")); //$NON-NLS-1$
- multiTextEdit.apply(viewer.getDocument());
-
- // get new element node
- IDOMNode newElementNode = (IDOMNode) ContentAssistUtils.getNodeAt(viewer, startTagOffset);
-
- // format new element
- IStructuredFormatProcessor formatProcessor = new FormatProcessorXML();
- formatProcessor.formatNode(newElementNode);
-
- // rename new element
- super.apply(viewer, trigger, stateMask, newElementNode.getStartOffset() + 1);
- }
- catch (MalformedTreeException e) {
- // log for now, unless find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- catch (BadLocationException e) {
- // log for now, unless find reason not to
- Logger.log(Logger.INFO, e.getMessage());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getAdditionalProposalInfo()
- */
- public String getAdditionalProposalInfo() {
- return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_0;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getDisplayString()
- */
- public String getDisplayString() {
- return XMLUIMessages.SurroundWithNewElementQuickAssistProposal_1;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.contentassist.ICompletionProposal#getImage()
- */
- public Image getImage() {
- // return JavaPluginImages.get(JavaPluginImages.IMG_CORRECTION_LOCAL);
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_ADD_CORRECTION);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java
deleted file mode 100644
index 4649e948af..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/correction/XMLQuickAssistProcessor.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.correction;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
-import org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-public class XMLQuickAssistProcessor implements IQuickAssistProcessor {
-
- public boolean canAssist(IQuickAssistInvocationContext invocationContext) {
- return true;
- }
-
- public boolean canFix(Annotation annotation) {
- return false;
- }
-
- public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
- List proposals = new ArrayList();
-
- getLocalRenameQuickAssistProposal(proposals, invocationContext.getSourceViewer(), invocationContext.getOffset());
- getSurroundWithNewElementQuickAssistProposal(proposals, invocationContext.getSourceViewer(), invocationContext.getOffset());
- getInsertRequiredAttrs(proposals, invocationContext.getSourceViewer(), invocationContext.getOffset());
-
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- public String getErrorMessage() {
- return null;
- }
-
- private void getInsertRequiredAttrs(List proposals, ISourceViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) getNodeAt(viewer, offset);
- if ((node != null) && (node.getNodeType() == Node.ELEMENT_NODE)) {
- IStructuredDocumentRegion startStructuredDocumentRegion = node.getStartStructuredDocumentRegion();
- if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) {
- IDOMNode cursorNode = (IDOMNode) getNodeAt(viewer, offset);
- List requiredAttrs = getRequiredAttrs(cursorNode);
- if (requiredAttrs.size() > 0) {
- NamedNodeMap currentAttrs = node.getAttributes();
- List insertAttrs = new ArrayList();
- if (currentAttrs.getLength() == 0) {
- insertAttrs.addAll(requiredAttrs);
- }
- else {
- for (int i = 0; i < requiredAttrs.size(); i++) {
- String requiredAttrName = ((CMAttributeDeclaration) requiredAttrs.get(i)).getAttrName();
- boolean found = false;
- for (int j = 0; j < currentAttrs.getLength(); j++) {
- String currentAttrName = currentAttrs.item(j).getNodeName();
- if (requiredAttrName.compareToIgnoreCase(currentAttrName) == 0) {
- found = true;
- break;
- }
- }
- if (!found) {
- insertAttrs.add(requiredAttrs.get(i));
- }
- }
- }
- if (insertAttrs.size() > 0) {
- proposals.add(new InsertRequiredAttrsQuickAssistProposal(insertAttrs));
- }
- }
- }
- }
- }
-
- private void getLocalRenameQuickAssistProposal(List proposals, ISourceViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) getNodeAt(viewer, offset);
- IStructuredDocumentRegion startStructuredDocumentRegion = node == null ? null : node.getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endStructuredDocumentRegion = node == null ? null : node.getEndStructuredDocumentRegion();
-
- ITextRegion region = null;
- int regionTextEndOffset = 0;
- if ((startStructuredDocumentRegion != null) && startStructuredDocumentRegion.containsOffset(offset)) {
- region = startStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- regionTextEndOffset = startStructuredDocumentRegion.getTextEndOffset(region);
- }
- else if ((endStructuredDocumentRegion != null) && endStructuredDocumentRegion.containsOffset(offset)) {
- region = endStructuredDocumentRegion.getRegionAtCharacterOffset(offset);
- regionTextEndOffset = endStructuredDocumentRegion.getTextEndOffset(region);
- }
-
- if ((region != null) && ((region.getType() == DOMRegionContext.XML_TAG_NAME) || (region.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) && (offset <= regionTextEndOffset)) {
- proposals.add(new RenameInFileQuickAssistProposal());
- }
- }
-
- private ModelQuery getModelQuery(Node node) {
- if (node.getNodeType() == Node.DOCUMENT_NODE) {
- return ModelQueryUtil.getModelQuery((Document) node);
- }
- else {
- return ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- }
- }
-
- private List getRequiredAttrs(Node node) {
- List result = new ArrayList();
-
- ModelQuery modelQuery = getModelQuery(node);
- if (modelQuery != null) {
- CMElementDeclaration elementDecl = modelQuery.getCMElementDeclaration((Element) node);
- if (elementDecl != null) {
- CMNamedNodeMap attrMap = elementDecl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attrMap = allAttributes;
-
- Iterator it = attrMap.iterator();
- CMAttributeDeclaration attr = null;
- while (it.hasNext()) {
- attr = (CMAttributeDeclaration) it.next();
- if (attr.getUsage() == CMAttributeDeclaration.REQUIRED) {
- result.add(attr);
- }
- }
- }
- }
-
- return result;
- }
-
- private void getSurroundWithNewElementQuickAssistProposal(List proposals, ISourceViewer viewer, int offset) {
- IDOMNode node = (IDOMNode) getNodeAt(viewer, offset);
- if (node != null) {
- proposals.add(new SurroundWithNewElementQuickAssistProposal());
- }
- }
-
- /**
- * 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
- */
- private IndexedRegion getNodeAt(ITextViewer viewer, int documentOffset) {
- // copied from ContentAssistUtils.getNodeAt()
- if (viewer == null)
- return null;
-
- IndexedRegion node = null;
- IModelManager mm = StructuredModelManager.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;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java
deleted file mode 100644
index e95af8078c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditAttributeDialog.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.graphics.Color;
-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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonUIContextIds;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-
-public class EditAttributeDialog extends Dialog implements ModifyListener {
- protected Attr attribute;
- protected String attributeName;
- protected Text attributeNameField;
- protected String attributeValue;
- protected Text attributeValueField;
- protected Label errorMessageLabel;
- protected Button okButton;
- protected Element ownerElement;
-
- public EditAttributeDialog(Shell parentShell, Element ownerElement, Attr attribute) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.ownerElement = ownerElement;
- this.attribute = attribute;
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- attributeName = getModelValue(attributeNameField.getText());
- attributeValue = attributeValueField.getText();
- }
- super.buttonPressed(buttonId);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createContents(Composite parent) {
- Control control = super.createContents(parent);
- attributeNameField.forceFocus();
- attributeNameField.selectAll();
- updateErrorMessage();
- return control;
- }
-
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_ATTRIBUTE_DIALOG);
-
- Composite composite = new Composite(dialogArea, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- composite.setLayout(layout);
-
- //
- // Style convenience constants
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label attributeNameLabel = new Label(composite, SWT.NONE);
- attributeNameLabel.setText(XMLUIMessages._UI_LABEL_NAME_COLON);
-
- attributeNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 300;
- attributeNameField.setLayoutData(gd);
- attributeNameField.setText(getDisplayValue(attribute != null ? attribute.getName() : "")); //$NON-NLS-1$
- attributeNameField.addModifyListener(this);
-
- Label attributeValueLabel = new Label(composite, SWT.NONE);
- attributeValueLabel.setText(XMLUIMessages._UI_LABEL_VALUE_COLON);
-
- String value = attribute != null ? attribute.getValue() : ""; //$NON-NLS-1$
- int style = SWT.SINGLE | SWT.BORDER;
- if (value.indexOf("\n") != -1) { //$NON-NLS-1$
- style = SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL;
- }
-
- attributeValueField = new Text(composite, style);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 300;
- attributeValueField.setLayoutData(gd);
- attributeValueField.setText(getDisplayValue(attribute != null ? attribute.getValue() : "")); //$NON-NLS-1$
-
- // error message
- errorMessageLabel = new Label(composite, SWT.WRAP);
- errorMessageLabel.setText(XMLUIMessages.error_message_goes_here);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 200;
- gd.heightHint = Math.max(30, errorMessageLabel.computeSize(0, 0, false).y * 2);
- gd.horizontalSpan = 2;
- errorMessageLabel.setLayoutData(gd);
- Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0);
- errorMessageLabel.setForeground(color);
-
- return dialogArea;
- }
-
- public String getAttributeName() {
- return attributeName;
- }
-
- public String getAttributeValue() {
- return attributeValue;
- }
-
- protected String getDisplayValue(String string) {
- return string != null ? string : ""; //$NON-NLS-1$
- }
-
- protected String getModelValue(String string) {
- String result = null;
- if ((string != null) && (string.trim().length() > 0)) {
- result = string;
- }
- return result;
- }
-
- public void modifyText(ModifyEvent e) {
- updateErrorMessage();
- }
-
- protected void updateErrorMessage() {
- String errorMessage = null;
- String name = attributeNameField.getText().trim();
- if (name.length() > 0) {
- Attr matchingAttribute = ownerElement.getAttributeNode(name);
- if ((matchingAttribute != null) && (matchingAttribute != attribute)) {
- errorMessage = XMLUIMessages._ERROR_XML_ATTRIBUTE_ALREADY_EXISTS;
- }
- else {
- // TODO get checkName from Model
- // errorMessage = ValidateHelper.checkXMLName(name);
- }
- }
- else {
- errorMessage = ""; //$NON-NLS-1$
- }
-
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- errorMessageLabel.getParent().layout();
- okButton.setEnabled(errorMessage == null);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java
deleted file mode 100644
index 6e071ba91e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditDoctypeDialog.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonUIContextIds;
-import org.w3c.dom.DocumentType;
-
-public class EditDoctypeDialog extends Dialog {
- protected boolean computeSystemId;
- protected String[] doctypeData;
- protected boolean errorChecking;
- protected Label errorMessageLabel;
- protected Button okButton;
- protected Button publicIdBrowseButton;
- protected Text publicIdField;
- protected IPath resourceLocation;
- protected Text rootElementNameField;
- protected Button systemIdBrowseButton;
- protected Text systemIdField;
-
- public EditDoctypeDialog(Shell parentShell, DocumentType doctype) {
- this(parentShell, doctype.getName(), doctype.getPublicId(), doctype.getSystemId());
- }
-
- public EditDoctypeDialog(Shell parentShell, String name, String publicId, String systemId) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- doctypeData = new String[3];
- doctypeData[0] = name;
- doctypeData[1] = publicId;
- doctypeData[2] = systemId;
- }
-
- protected void buttonPressed(int buttonId) {
- doctypeData[0] = getModelValue(rootElementNameField.getText());
- doctypeData[1] = getModelValue(publicIdField.getText());
- doctypeData[2] = getModelValue(systemIdField.getText());
- super.buttonPressed(buttonId);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
-
- protected Control createContents(Composite parent) {
- Control control = super.createContents(parent);
- updateErrorMessage();
- return control;
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogControl = (Composite) super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogControl, XMLCommonUIContextIds.XCUI_DOCTYPE_DIALOG);
-
- Composite composite = new Composite(dialogControl, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- if (e.widget == systemIdField) {
- computeSystemId = false;
- }
- updateErrorMessage();
- }
- };
-
- // row 1
- //
- Label rootElementNameLabel = new Label(composite, SWT.NONE);
- rootElementNameLabel.setText(XMLUIMessages._UI_LABEL_ROOT_ELEMENT_NAME_COLON);
-
- rootElementNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(rootElementNameField, XMLCommonUIContextIds.XCUI_DOCTYPE_ROOT);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 200;
- rootElementNameField.setLayoutData(gd);
- rootElementNameField.setText(getDisplayValue(doctypeData[0]));
- rootElementNameField.addModifyListener(modifyListener);
-
- Label placeHolder = new Label(composite, SWT.NONE);
- placeHolder.setLayoutData(new GridData());
-
- // row 2
- //
- Label publicIdLabel = new Label(composite, SWT.NONE);
- publicIdLabel.setText(XMLUIMessages._UI_LABEL_PUBLIC_ID_COLON);
-
- publicIdField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(publicIdField, XMLCommonUIContextIds.XCUI_DOCTYPE_PUBLIC);
- publicIdField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- publicIdField.setText(getDisplayValue(doctypeData[1]));
-
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- EditEntityHelper helper = new EditEntityHelper();
- if (e.widget == publicIdBrowseButton) {
- helper.performBrowseForPublicId(getShell(), publicIdField, computeSystemId ? systemIdField : null);
- }
- else if (e.widget == systemIdBrowseButton) {
- helper.performBrowseForSystemId(getShell(), systemIdField, resourceLocation);
- }
- }
- };
-
- publicIdBrowseButton = new Button(composite, SWT.NONE);
- publicIdBrowseButton.setText(XMLUIMessages._UI_LABEL_BROWSE);
- publicIdBrowseButton.addSelectionListener(selectionListener);
-
- // row 3
- Label systemIdLabel = new Label(composite, SWT.NONE);
- systemIdLabel.setText(XMLUIMessages._UI_LABEL_SYSTEM_ID_COLON);
-
- systemIdField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(systemIdField, XMLCommonUIContextIds.XCUI_DOCTYPE_SYSTEM);
- systemIdField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- systemIdField.setText(getDisplayValue(doctypeData[2]));
- systemIdField.addModifyListener(modifyListener);
-
-
- systemIdBrowseButton = new Button(composite, SWT.NONE);
- systemIdBrowseButton.setText(XMLUIMessages._UI_LABEL_BROWSE);
- systemIdBrowseButton.addSelectionListener(selectionListener);
-
- // error message
- errorMessageLabel = new Label(dialogControl, SWT.NONE);
- errorMessageLabel.setText(""); //$NON-NLS-1$
- errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0);
- errorMessageLabel.setForeground(color);
-
- Dialog.applyDialogFont(parent);
- return dialogControl;
- }
-
-
- protected Label createMessageArea(Composite composite) {
- Label label = new Label(composite, SWT.NONE);
- // label.setText(message);
- return label;
- }
-
-
- protected String getDisplayValue(String string) {
- return string != null ? string : ""; //$NON-NLS-1$
- }
-
- public boolean getErrorChecking() {
- return errorChecking;
- }
-
-
- protected String getModelValue(String string) {
- String result = null;
- if ((string != null) && (string.trim().length() > 0)) {
- result = string;
- }
- return result;
- }
-
- public String getName() {
- return doctypeData[0];
- }
-
- public String getPublicId() {
- return doctypeData[1];
- }
-
- public String getSystemId() {
- return doctypeData[2];
- }
-
- public void setComputeSystemId(boolean computeSystemId) {
- this.computeSystemId = computeSystemId;
- }
-
- public void setErrorChecking(boolean errorChecking) {
- this.errorChecking = errorChecking;
- }
-
- public void setResourceLocation(IPath path) {
- resourceLocation = path;
- }
-
- public void updateErrorMessage() {
- if (errorChecking) {
- String errorMessage = null;
- if (getModelValue(systemIdField.getText()) == null) {
- errorMessage = XMLUIMessages._UI_WARNING_SYSTEM_ID_MUST_BE_SPECIFIED;
- }
- else if (getModelValue(rootElementNameField.getText()) == null) {
- errorMessage = XMLUIMessages._UI_WARNING_ROOT_ELEMENT_MUST_BE_SPECIFIED;
- }
-
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- okButton.setEnabled(errorMessage == null);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java
deleted file mode 100644
index adad3814f2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditElementDialog.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyEvent;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.graphics.Color;
-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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.core.internal.provisional.NameValidator;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonUIContextIds;
-import org.w3c.dom.Element;
-
-public class EditElementDialog extends Dialog implements ModifyListener {
- protected Element element;
- protected String elementName;
- protected Text elementNameField;
- protected Label errorMessageLabel;
- protected Button okButton;
-
- public EditElementDialog(Shell parentShell, Element element) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.element = element;
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- elementName = getModelValue(elementNameField.getText());
- }
- super.buttonPressed(buttonId);
- }
-
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createContents(Composite parent) {
- Control control = super.createContents(parent);
- elementNameField.forceFocus();
- elementNameField.selectAll();
- updateErrorMessage();
- return control;
- }
-
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_ELEMENT_DIALOG);
-
- Composite composite = new Composite(dialogArea, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label elementNameLabel = new Label(composite, SWT.NONE);
- elementNameLabel.setText(XMLUIMessages._UI_LABEL_ELEMENT_NAME);
-
- elementNameField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 200;
- elementNameField.setLayoutData(gd);
- elementNameField.setText(getDisplayValue(element != null ? element.getNodeName() : "")); //$NON-NLS-1$
- elementNameField.addModifyListener(this);
-
- // error message
- errorMessageLabel = new Label(composite, SWT.NONE);
- errorMessageLabel.setText(XMLUIMessages.error_message_goes_here);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- errorMessageLabel.setLayoutData(gd);
- Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0);
- errorMessageLabel.setForeground(color);
-
- return dialogArea;
- }
-
- protected String getDisplayValue(String string) {
- return string != null ? string : ""; //$NON-NLS-1$
- }
-
- public String getElementName() {
- return elementName;
- }
-
- protected String getModelValue(String string) {
- String result = null;
- if ((string != null) && (string.trim().length() > 0)) {
- result = string;
- }
- return result;
- }
-
- public void modifyText(ModifyEvent e) {
- updateErrorMessage();
- }
-
- protected void updateErrorMessage() {
- String errorMessage = null;
- String name = elementNameField.getText();
- // String name = elementNameField.getText().trim();
- if (name.length() > 0) {
- // TODO use checkName from model level
- // errorMessage = ValidateHelper.checkXMLName(name);
- if (!NameValidator.isValid(name)) {
- errorMessage = XMLUIMessages._UI_INVALID_NAME;
- }
- }
- else {
- errorMessage = ""; //$NON-NLS-1$
- }
-
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- okButton.setEnabled(errorMessage == null);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java
deleted file mode 100644
index 25eb64dc55..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditEntityHelper.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class EditEntityHelper {
-
- public void performBrowseForPublicId(Shell parentShell, Text publicIdField) {
- performBrowseForPublicId(parentShell, publicIdField, null);
- }
-
- public void performBrowseForPublicId(Shell parentShell, Text publicIdField, Text systemIdField) {
- String[] extensions = {"dtd", "txt"}; //$NON-NLS-1$ //$NON-NLS-2$
- SelectXMLCatalogIdDialog dialog = new SelectXMLCatalogIdDialog(parentShell, extensions);
- dialog.create();
- dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_XML_CATALOG_ENTRY);
- dialog.setBlockOnOpen(true);
- dialog.open();
- if (dialog.getReturnCode() == Window.OK) {
- String id = dialog.getId();
- if (id != null) {
- publicIdField.setText(id);
- if ((systemIdField != null) && (dialog.getSystemId() != null)) {
- systemIdField.setText(dialog.getSystemId());
- }
- }
- }
- }
-
- public void performBrowseForSystemId(Shell parentShell, Text systemIdField, IPath resourceLocation) {
- String[] extensions = {"dtd"}; //$NON-NLS-1$
- SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(parentShell, extensions, ICatalogEntry.ENTRY_TYPE_SYSTEM);
- dialog.create();
- dialog.getShell().setText(XMLUIMessages._UI_LABEL_SPECIFY_SYSTEM_ID);
- dialog.setBlockOnOpen(true);
- dialog.open();
- if (dialog.getReturnCode() == Window.OK) {
- String id = dialog.getId();
- IFile file = dialog.getFile();
- if (id != null) {
- systemIdField.setText(id);
- }
- else if (file != null) {
- String uri = null;
- if (resourceLocation != null) {
- uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation);
- }
- else {
- uri = file.getLocation().toOSString();
- }
- systemIdField.setText(uri);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java
deleted file mode 100644
index 844ac60e03..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditNamespaceInfoDialog.java
+++ /dev/null
@@ -1,274 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-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.Shell;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.ContentModelManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonUIContextIds;
-
-public class EditNamespaceInfoDialog extends Dialog {
-
- public static EditNamespaceInfoDialog invokeDialog(Shell shell, String title, NamespaceInfo info, IPath resourceLocation) {
- EditNamespaceInfoDialog dialog = new EditNamespaceInfoDialog(shell, info);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.setResourceLocation(resourceLocation);
- dialog.open();
- return dialog;
- }
-
- protected Button browseButton;
- protected String errorMessage;
-
- protected Label errorMessageLabel;
- protected NamespaceInfo fInfo;
- protected Text locationHintField;
-
- protected Button okButton;
- protected Text prefixField;
- protected IPath resourceLocation;
- protected Text uriField;
-
- public EditNamespaceInfoDialog(Shell parentShell, NamespaceInfo info) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.fInfo = info;
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- fInfo.uri = uriField.getText();
- fInfo.prefix = prefixField.getText();
- fInfo.locationHint = locationHintField.getText();
- }
- super.buttonPressed(buttonId);
- }
-
- protected void computeErrorMessage() {
- errorMessage = null;
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- updateWidgets();
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogsubArea = (Composite) super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogsubArea, XMLCommonUIContextIds.XCUI_NAMESPACE_DIALOG);
-
- Composite composite = new Composite(dialogsubArea, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.marginWidth = 0;
- composite.setLayout(layout);
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 350;
- composite.setLayoutData(gd);
-
- ModifyListener modifyListener = new ModifyListener() {
- public void modifyText(ModifyEvent e) {
- updateWidgets();
- }
- };
-
-
- // row 1
- //
- Label uriLabel = new Label(composite, SWT.NONE);
- uriLabel.setText(XMLUIMessages._UI_LABEL_NAMESPACE_NAME_COLON);
-
- uriField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- uriField.setLayoutData(gd);
- uriField.setText(getDisplayValue(fInfo.uri));
- uriField.addModifyListener(modifyListener);
- uriField.setEnabled(fInfo.getProperty("uri-readOnly") == null); //$NON-NLS-1$
-
- // never read
- Label placeHolder1 = new Label(composite, SWT.NONE);
- placeHolder1.setText(""); //$NON-NLS-1$
-
- // row 2
- //
- Label prefixLabel = new Label(composite, SWT.NONE);
- prefixLabel.setText(XMLUIMessages._UI_LABEL_PREFIX_COLON);
-
- prefixField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- prefixField.setLayoutData(gd);
- prefixField.setText(getDisplayValue(fInfo.prefix));
- prefixField.addModifyListener(modifyListener);
- prefixField.setEnabled(fInfo.getProperty("prefix-readOnly") == null); //$NON-NLS-1$
-
- // never read
- Label placeHolder2 = new Label(composite, SWT.NONE);
- placeHolder2.setText(""); //$NON-NLS-1$
-
- // row 3
- //
- Label locationHintLabel = new Label(composite, SWT.NONE);
- locationHintLabel.setText(XMLUIMessages._UI_LABEL_LOCATION_HINT_COLON);
-
- locationHintField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.grabExcessHorizontalSpace = true;
- locationHintField.setLayoutData(gd);
- locationHintField.setText(getDisplayValue(fInfo.locationHint));
- locationHintField.addModifyListener(modifyListener);
- locationHintField.setEnabled(fInfo.getProperty("locationHint-readOnly") == null); //$NON-NLS-1$
-
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- performBrowse();
- }
- };
-
- browseButton = new Button(composite, SWT.NONE);
- browseButton.setText(XMLUIMessages._UI_LABEL_BROWSE);
- browseButton.addSelectionListener(selectionListener);
- browseButton.setEnabled(locationHintField.getEnabled());
-
- // error message
- errorMessageLabel = new Label(dialogsubArea, SWT.NONE);
- errorMessageLabel.setText(XMLUIMessages.error_message_goes_here);
- errorMessageLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0);
- errorMessageLabel.setForeground(color);
-
- return dialogsubArea;
- }
-
- protected String getDisplayValue(String string) {
- return string != null ? string : ""; //$NON-NLS-1$
- }
-
- protected void performBrowse() {
- String[] extensions = {".xsd"}; //$NON-NLS-1$
- SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(getShell(), extensions);
- dialog.create();
- dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- String grammarURI = null;
- IFile file = dialog.getFile();
- String id = dialog.getId();
- if (file != null) {
- String uri = null;
- if (resourceLocation != null) {
- IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourceLocation);
- if (resource != null) {
- IPath location = resource.getLocation();
- if (location != null) {
- uri = URIHelper.getRelativeURI(file.getLocation(), location);
- }
- }
- else {
- uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation);
- }
- grammarURI = file.getLocation().toOSString();
- }
- else {
- uri = file.getLocation().toOSString();
- grammarURI = uri;
- }
- locationHintField.setText(uri);
- }
- else if (id != null) {
- locationHintField.setText(id);
- URIResolver resolver = URIResolverPlugin.createResolver();
- grammarURI = resolver.resolve(null, id, id);
- }
-
-
- CMDocument document = ContentModelManager.getInstance().createCMDocument(URIHelper.getURIForFilePath(grammarURI), "xsd"); //$NON-NLS-1$
- if(document != null) {
- List namespaceInfoList = (List) document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo"); //$NON-NLS-1$
- if(namespaceInfoList != null) {
- NamespaceInfo info = (NamespaceInfo) namespaceInfoList.get(0);
- if(info != null) {
- if ((uriField.getText().trim().length() == 0) && (info.uri != null)) {
- uriField.setText(info.uri);
- }
- if ((prefixField.getText().trim().length() == 0) && (info.prefix != null)) {
- prefixField.setText(info.prefix);
- }
- }
- }
- }
- }
- }
-
- public void setResourceLocation(IPath path) {
- resourceLocation = path;
- }
-
- protected void updateErrorMessageLabel() {
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- }
-
- protected void updateOKButtonState() {
- if (okButton != null) {
- if ((uriField.getText().trim().length() == 0) && (prefixField.getText().trim().length() == 0) && (locationHintField.getText().trim().length() == 0)) {
- okButton.setEnabled(false);
- }
- else {
- okButton.setEnabled(errorMessage == null);
- }
- }
- }
-
- protected void updateWidgets() {
- computeErrorMessage();
- updateErrorMessageLabel();
- updateOKButtonState();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java
deleted file mode 100644
index 6742855d8c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditProcessingInstructionDialog.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.swt.widgets.Text;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonUIContextIds;
-import org.w3c.dom.ProcessingInstruction;
-
-public class EditProcessingInstructionDialog extends Dialog {
- protected String data;
- protected Text dataField;
- protected String target;
- protected Text targetField;
-
- public EditProcessingInstructionDialog(Shell parentShell, ProcessingInstruction pi) {
- this(parentShell, pi.getTarget(), pi.getData());
- }
-
- public EditProcessingInstructionDialog(Shell parentShell, String target, String data) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.target = target;
- this.data = data;
- }
-
- protected void buttonPressed(int buttonId) {
- target = getModelValue(targetField.getText());
- data = getModelValue(dataField.getText());
- super.buttonPressed(buttonId);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea1 = (Composite) super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea1, XMLCommonUIContextIds.XCUI_PROCESSING_DIALOG);
-
- Composite composite = new Composite(dialogArea1, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- layout.marginWidth = 0;
- composite.setLayout(layout);
- composite.setLayoutData(new GridData(GridData.FILL_BOTH));
-
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 250;
-
- Label targetLabel = new Label(composite, SWT.NONE);
- targetLabel.setText(XMLUIMessages._UI_LABEL_TARGET_COLON);
-
- targetField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- targetField.setLayoutData(gd);
- targetField.setText(getDisplayValue(target));
-
- Label dataLabel = new Label(composite, SWT.NONE);
- dataLabel.setText(XMLUIMessages._UI_LABEL_DATA_COLON);
-
- dataField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- dataField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- dataField.setText(getDisplayValue(data));
-
- return dialogArea1;
- }
-
- protected Label createMessageArea(Composite composite) {
- Label label = new Label(composite, SWT.NONE);
- // label.setText(message);
- return label;
- }
-
- public String getData() {
- return data;
- }
-
- protected String getDisplayValue(String string) {
- return string != null ? string : ""; //$NON-NLS-1$
- }
-
- protected String getModelValue(String string) {
- String result = null;
- if ((string != null) && (string.trim().length() > 0)) {
- result = string;
- }
- return result;
- }
-
-
- public String getTarget() {
- return target;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java
deleted file mode 100644
index d4458097d8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/EditSchemaInfoDialog.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-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.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.nsedit.CommonEditNamespacesDialog;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonUIContextIds;
-
-public class EditSchemaInfoDialog extends Dialog implements UpdateListener {
- // protected NamespaceInfoTable namespaceInfoTable;
- protected Label errorMessageLabel;
- protected List namespaceInfoList;
- protected IPath resourceLocation;
-
- public EditSchemaInfoDialog(Shell parentShell, IPath resourceLocation) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.resourceLocation = resourceLocation;
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_SCHEMA_INFO_DIALOG);
-
- CommonEditNamespacesDialog editNamespacesControl = new CommonEditNamespacesDialog(dialogArea, resourceLocation, XMLUIMessages._UI_NAMESPACE_DECLARATIONS, false, true);
- editNamespacesControl.setNamespaceInfoList(namespaceInfoList);
-
- editNamespacesControl.updateErrorMessage(namespaceInfoList);
-
- return dialogArea;
- }
-
- protected Control getDialogArea(Composite parent) {
- return super.createDialogArea(parent);
- }
-
- public List getNamespaceInfoList() {
- return namespaceInfoList;
- }
-
- public void setNamespaceInfoList(List list) {
- namespaceInfoList = list;
- }
-
- public void updateErrorMessage(List namespaceInfoList) {
- NamespaceInfoErrorHelper helper = new NamespaceInfoErrorHelper();
- String errorMessage = helper.computeErrorMessage(namespaceInfoList, null);
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- }
-
- public void updateOccured(Object object, Object arg) {
- updateErrorMessage((List) arg);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java
deleted file mode 100644
index 540df93305..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoErrorHelper.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolver;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceInfoManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class NamespaceInfoErrorHelper {
-
- protected List errorList;
-
- public NamespaceInfoErrorHelper() {
- }
-
- public String computeErrorMessage(List namespaceInfoList, URIResolver idResolver) {
- String result = null;
- Hashtable prefixTable = new Hashtable();
- Hashtable uriTable = new Hashtable();
- for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext();) {
- NamespaceInfo nsInfo = (NamespaceInfo) iterator.next();
- nsInfo.normalize();
-
- String urikey = nsInfo.uri != null ? nsInfo.uri : ""; //$NON-NLS-1$
- NamespaceInfo nsInfo2 = null;
- if ((nsInfo2 = (NamespaceInfo) uriTable.get(urikey)) != null) {
- if ((nsInfo.uri != null) && nsInfo.uri.equals(nsInfo2.uri)) {
- result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME + "'" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME;
- }
- break;
- }
- else {
- uriTable.put(urikey, nsInfo);
- }
-
- if (nsInfo.uri != null) {
- String key = nsInfo.prefix != null ? nsInfo.prefix : ""; //$NON-NLS-1$
- if (prefixTable.get(key) != null) {
- if (nsInfo.prefix != null) {
- result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX + "'" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- else {
- result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX;
- break;
- }
- }
- else {
- prefixTable.put(key, nsInfo);
- }
-
- if ((nsInfo.locationHint != null) && (idResolver != null)) {
- String grammarURI = idResolver.resolve(null, nsInfo.locationHint, nsInfo.locationHint);
- if (!URIHelper.isReadableURI(grammarURI, false)) {
- result = XMLUIMessages._UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED + " '" + nsInfo.locationHint + "'"; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
- if ((idResolver != null) && (nsInfo.locationHint == null) && !nsInfo.uri.equals(DOMNamespaceInfoManager.XSI_URI)) {
- result = XMLUIMessages._UI_WARNING_LOCATION_HINT_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
- else {
- if (nsInfo.prefix != null) {
- result = XMLUIMessages._UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED + " '" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
- }
- // additional tests
- if (result == null) {
- for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext();) {
- NamespaceInfo nsInfo = (NamespaceInfo) iterator.next();
- nsInfo.normalize();
- if ((nsInfo.uri != null) && nsInfo.isPrefixRequired && (nsInfo.prefix == null)) {
- result = XMLUIMessages._UI_WARNING_PREFIX_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- }
- }
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java
deleted file mode 100644
index 8a438dce85..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/NamespaceInfoTable.java
+++ /dev/null
@@ -1,398 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.ILabelProviderListener;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.TextCellEditor;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.events.SelectionAdapter;
-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.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-public class NamespaceInfoTable extends Composite {
-
- /**
- * NamespaceInfoTableLabelProvider
- */
- protected class NamespaceInfoTableLabelProvider implements ITableLabelProvider, IStructuredContentProvider {
-
- public void addListener(ILabelProviderListener listener) {
- }
-
- public void dispose() {
- }
-
- public Image getColumnImage(Object object, int columnIndex) {
- return null;
- }
-
- public String getColumnText(Object object, int column) {
- NamespaceInfo info = (NamespaceInfo) object;
- String result = null;
- switch (column) {
- case 0 : {
- result = info.uri;
- break;
- }
- case 1 : {
- result = info.prefix;
- break;
- }
- case 2 : {
- result = info.locationHint;
- break;
- }
- }
- result = result != null ? result : ""; //$NON-NLS-1$
- if (result.equals("")) { //$NON-NLS-1$
- switch (column) {
- case 0 : {
- result = XMLUIMessages._UI_NO_NAMESPACE_NAME;
- break;
- }
- case 1 : {
- result = XMLUIMessages._UI_NO_PREFIX;
- break;
- }
- }
- }
- return result;
- }
-
- String getDefaultPrefix() {
- String defaultPrefix = "p"; //$NON-NLS-1$
- if (namespaceInfoList == null) {
- return defaultPrefix;
- }
- Vector v = new Vector();
- for (int i = 0; i < namespaceInfoList.size(); i++) {
- NamespaceInfo nsinfo = (NamespaceInfo) namespaceInfoList.get(i);
- if (nsinfo.prefix != null) {
- v.addElement(nsinfo.prefix);
- }
- }
- if (v.contains(defaultPrefix)) {
- String s = defaultPrefix;
- for (int j = 0; v.contains(s); j++) {
- s = defaultPrefix + Integer.toString(j);
- }
- return s;
- }
- else {
- return defaultPrefix;
- }
- }
-
- public Object[] getElements(Object inputElement) {
- return namespaceInfoList.toArray();
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
-
- public boolean isDeleted(Object element) {
- return false;
- }
-
- public boolean isLabelProperty(Object object, Object property) {
- return false;
- }
-
- public boolean isLabelProperty(Object element, String property) {
- return false;
- }
-
- public void removeListener(ILabelProviderListener listener) {
- }
- }
-
- protected static final String LOCATION_HINT = XMLUIMessages._UI_LABEL_LOCATION_HINT;
- protected static final String NAMESPACE_URI = XMLUIMessages._UI_LABEL_NAMESPACE_NAME;
- protected static final String PREFIX = XMLUIMessages._UI_LABEL_PREFIX;
- protected Button deleteButton;
- protected boolean dummyRowsRemoved = false;
- protected Button editButton;
- protected List namespaceInfoList = new Vector();
- protected Button newButton;
- protected NamespaceInfoTableLabelProvider provider;
- protected IPath resourceLocation;
- protected TableViewer tableViewer;
- protected UpdateListener updateListener;
- protected int visibleRows = -1;
-
- public NamespaceInfoTable(Composite parent) {
- this(parent, -1, -1, -1);
- }
-
- public NamespaceInfoTable(Composite parent, int visibleRows) {
- this(parent, -1, -1, visibleRows);
- }
-
- public NamespaceInfoTable(Composite parent, int widthHint, int heightHint) {
- this(parent, widthHint, heightHint, -1);
- }
-
- public NamespaceInfoTable(Composite parent, int widthHint, int heightHint, int visibleRows) {
- super(parent, SWT.NONE);
- setLayout(createGridLayout());
- setLayoutData(new GridData(GridData.FILL_BOTH));
- Group namespaceInfoGroup = new Group(this, SWT.NONE);
- namespaceInfoGroup.setText(XMLUIMessages._UI_LABEL_XML_SCHEMA_INFORMATION);
- namespaceInfoGroup.setLayout(new GridLayout());
- GridData gd = new GridData(GridData.FILL_BOTH);
- if (widthHint != -1) {
- gd.widthHint = widthHint;
- }
- if (heightHint != -1) {
- gd.heightHint = heightHint;
- }
- namespaceInfoGroup.setLayoutData(gd);
- // WorkbenchHelp.setHelp(namespaceInfoGroup, new
- // ControlContextComputer(namespaceInfoGroup,
- // XMLBuilderContextIds.XMLC_NAMESPACE_GROUP));
- String[] titleArray = {NAMESPACE_URI, PREFIX, LOCATION_HINT};
- tableViewer = new TableViewer(namespaceInfoGroup, SWT.FULL_SELECTION);
- provider = new NamespaceInfoTableLabelProvider();
- tableViewer.setContentProvider(provider);
- tableViewer.setLabelProvider(provider);
- tableViewer.setColumnProperties(titleArray);
- Table table = tableViewer.getTable();
- table.setHeaderVisible(true);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
- int[] widthArray = {50, 20, 30};
- TableLayout layout = new TableLayout();
- for (int i = 0; i < titleArray.length; i++) {
- TableColumn column = new TableColumn(table, i);
- column.setText(titleArray[i]);
- column.setAlignment(SWT.LEFT);
- layout.addColumnData(new ColumnWeightData(widthArray[i], true));
- }
- this.visibleRows = visibleRows;
- for (int i = 0; i < visibleRows; i++) {
- TableItem item = new TableItem(table, SWT.NONE);
- item.setText("#######"); //$NON-NLS-1$
- }
- table.setLayout(layout);
- CellEditor[] cellEditors = new CellEditor[titleArray.length];
- cellEditors[1] = new TextCellEditor(table);
- cellEditors[2] = new TextCellEditor(table);
- tableViewer.setCellEditors(cellEditors);
- MouseAdapter mouseAdapter = new MouseAdapter() {
- public void mouseDoubleClick(MouseEvent e) {
- if (tableViewer.getTable().getItem(new Point(e.x, e.y)) != null) {
- performEdit();
- }
- }
- };
- table.addMouseListener(mouseAdapter);
- createButtons(namespaceInfoGroup);
- ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateButtonEnabledState();
- }
- };
- tableViewer.addSelectionChangedListener(selectionChangedListener);
- }
-
- protected void createButtons(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 2;
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- composite.setLayout(gridLayout);
- Button hiddenButton = new Button(composite, SWT.NONE);
- hiddenButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- hiddenButton.setVisible(false);
- hiddenButton.setEnabled(false);
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == newButton) {
- performNew();
- }
- else if (e.widget == editButton) {
- performEdit();
- }
- else if (e.widget == deleteButton) {
- performDelete();
- }
- }
- };
- // create a composite to hold the three buttons
- Composite buttonComposite = new Composite(composite, SWT.NONE);
- buttonComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- GridLayout buttonGridLayout = new GridLayout();
- buttonGridLayout.numColumns = 3;
- buttonGridLayout.makeColumnsEqualWidth = true;
- buttonComposite.setLayout(buttonGridLayout);
- // add the New button
- //
- newButton = new Button(buttonComposite, SWT.NONE);
- newButton.setText(XMLUIMessages._UI_BUTTON_NEW);
- newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- newButton.addSelectionListener(selectionListener);
- // add the Edit button
- //
- editButton = new Button(buttonComposite, SWT.NONE);
- editButton.setText(XMLUIMessages._UI_BUTTON_EDIT);
- editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- editButton.addSelectionListener(selectionListener);
- // add the Delete button
- //
- deleteButton = new Button(buttonComposite, SWT.NONE);
- deleteButton.setText(XMLUIMessages._UI_BUTTON_DELETE);
- deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- deleteButton.addSelectionListener(selectionListener);
- }
-
- public GridLayout createGridLayout() {
- GridLayout gridLayout = new GridLayout();
- gridLayout.marginWidth = 0;
- gridLayout.horizontalSpacing = 0;
- return gridLayout;
- }
-
- public List getNamespaceInfoList() {
- return namespaceInfoList;
- }
-
- protected NamespaceInfo getTargetNamespaceInfo() {
- return ((namespaceInfoList != null) && (namespaceInfoList.size() > 0)) ? (NamespaceInfo) namespaceInfoList.get(0) : null;
- }
-
- protected EditNamespaceInfoDialog invokeDialog(String title, NamespaceInfo info) {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditNamespaceInfoDialog dialog = new EditNamespaceInfoDialog(shell, info);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.setResourceLocation(resourceLocation);
- dialog.open();
- return dialog;
- }
-
- protected void performDelayedUpdate() {
- Runnable delayedUpdate = new Runnable() {
- public void run() {
- update();
- }
- };
- getDisplay().asyncExec(delayedUpdate);
- if (updateListener != null) {
- updateListener.updateOccured(this, namespaceInfoList);
- }
- }
-
- public void performDelete() {
- ISelection selection = tableViewer.getSelection();
- Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
- if (selectedObject != null) {
- namespaceInfoList.remove(selectedObject);
- performDelayedUpdate();
- }
- }
-
- public void performEdit() {
- ISelection selection = tableViewer.getSelection();
- Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
- if (selectedObject instanceof NamespaceInfo) {
- invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selectedObject);
- performDelayedUpdate();
- }
- }
-
- public void performNew() {
- NamespaceInfo info = new NamespaceInfo();
- EditNamespaceInfoDialog dialog = invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, info);
- if (dialog.getReturnCode() == Window.OK) {
- namespaceInfoList.add(info);
- performDelayedUpdate();
- }
- }
-
- public void setNamespaceInfoList(List namespaceInfoList) {
- this.namespaceInfoList = namespaceInfoList;
- update();
- }
-
- public void setResourceLocation(IPath resourceLocation) {
- this.resourceLocation = resourceLocation;
- }
-
- public void setUpdateListener(UpdateListener updateListener) {
- this.updateListener = updateListener;
- }
-
- public void update() {
- updateHelper(namespaceInfoList);
- }
-
- public void updateButtonEnabledState() {
- ISelection selection = tableViewer.getSelection();
- Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
- NamespaceInfo info = (NamespaceInfo) selectedObject;
- editButton.setEnabled(info != null);
- deleteButton.setEnabled((info != null) && (info.getProperty("unremovable") == null)); //$NON-NLS-1$
- }
-
- public void updateHelper(List namespaceInfoList) {
- if ((visibleRows != -1) && !dummyRowsRemoved) {
- dummyRowsRemoved = true;
- tableViewer.getTable().removeAll();
- }
- ISelection selection = tableViewer.getSelection();
- tableViewer.setInput(namespaceInfoList);
- if (selection.isEmpty()) {
- if (namespaceInfoList.size() > 0) {
- tableViewer.setSelection(new StructuredSelection(namespaceInfoList.get(0)));
- }
- }
- else {
- tableViewer.setSelection(selection);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java
deleted file mode 100644
index d36cf7bc65..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdDialog.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-
-
-public class SelectFileOrXMLCatalogIdDialog extends Dialog {
- protected int catalogEntryType;
- protected String[] extensions;
- protected IFile file;
- protected String id;
- protected Button okButton;
- protected SelectFileOrXMLCatalogIdPanel panel;
-
- public SelectFileOrXMLCatalogIdDialog(Shell parentShell, String[] extensions) {
- this(parentShell, extensions, 0);
- }
-
- public SelectFileOrXMLCatalogIdDialog(Shell parentShell, String[] extensions, int catalogEntryType) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.extensions = extensions;
- this.catalogEntryType = catalogEntryType;
- }
-
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- file = panel.getFile();
- id = panel.getXMLCatalogId();
- }
- super.buttonPressed(buttonId);
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
-
- panel = new SelectFileOrXMLCatalogIdPanel(dialogArea);
- panel.setCatalogEntryType(catalogEntryType);
- panel.setFilterExtensions(extensions);
- panel.setVisibleHelper(true);
- SelectFileOrXMLCatalogIdPanel.Listener listener = new SelectFileOrXMLCatalogIdPanel.Listener() {
- public void completionStateChanged() {
- updateButtonState();
- }
- };
- panel.setListener(listener);
-
- return dialogArea;
- }
-
- public IFile getFile() {
- return file;
- }
-
- public String getId() {
- return id;
- }
-
- protected void updateButtonState() {
- okButton.setEnabled((panel.getFile() != null) || (panel.getXMLCatalogId() != null));
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java
deleted file mode 100644
index 2987b045ca..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectFileOrXMLCatalogIdPanel.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.wst.common.ui.internal.viewers.SelectSingleFileView;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-
-public class SelectFileOrXMLCatalogIdPanel extends Composite implements SelectionListener {
-
- /**
- * TODO: Change the name of this interface; "Listener" is used by SWT.
- */
- public interface Listener {
- void completionStateChanged();
- }
-
- protected class MySelectSingleFileView extends SelectSingleFileView implements SelectSingleFileView.Listener {
- protected Control control;
-
- public MySelectSingleFileView(Composite parent) {
- super(null, true);
- // String[] ext = {".dtd"};
- // addFilterExtensions(ext);
- control = createControl(parent);
- control.setLayoutData(new GridData(GridData.FILL_BOTH));
- MySelectSingleFileView.this.setListener(this);
- }
-
- public Control getControl() {
- return control;
- }
-
- public void setControlComplete(boolean isComplete) {
- updateCompletionStateChange();
- }
-
- public void setVisibleHelper(boolean isVisible) {
- super.setVisibleHelper(isVisible);
- }
- }
-
- protected Listener listener;
- protected PageBook pageBook;
-
- protected Button[] radioButton;
- protected MySelectSingleFileView selectSingleFileView;
- protected SelectXMLCatalogIdPanel selectXMLCatalogIdPanel;
-
- public SelectFileOrXMLCatalogIdPanel(Composite parent) {
- super(parent, SWT.NONE);
-
- // container group
- setLayout(new GridLayout());
- GridData gd = new GridData(GridData.FILL_BOTH);
- gd.heightHint = 400;
- gd.widthHint = 400;
- setLayoutData(gd);
-
- radioButton = new Button[2];
- radioButton[0] = new Button(this, SWT.RADIO);
- radioButton[0].setText(XMLUIMessages._UI_RADIO_BUTTON_SELECT_FROM_WORKSPACE);
- radioButton[0].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- radioButton[0].setSelection(true);
- radioButton[0].addSelectionListener(this);
-
- radioButton[1] = new Button(this, SWT.RADIO);
- radioButton[1].setText(XMLUIMessages._UI_RADIO_BUTTON_SELECT_FROM_CATALOG);
- radioButton[1].setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- radioButton[1].addSelectionListener(this);
-
- pageBook = new PageBook(this, SWT.NONE);
- pageBook.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- selectSingleFileView = new MySelectSingleFileView(pageBook);
-
- ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
- selectXMLCatalogIdPanel = new SelectXMLCatalogIdPanel(pageBook, xmlCatalog);
- selectXMLCatalogIdPanel.getTableViewer().addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateCompletionStateChange();
- }
- });
- Dialog.applyDialogFont(parent);
- pageBook.showPage(selectSingleFileView.getControl());
-
- }
-
- public IFile getFile() {
- IFile result = null;
- if (radioButton[0].getSelection()) {
- result = selectSingleFileView.getFile();
- }
- return result;
- }
-
- public ICatalogEntry getXMLCatalogEntry() {
- ICatalogEntry result = null;
- if (radioButton[1].getSelection()) {
- result = selectXMLCatalogIdPanel.getXMLCatalogEntry();
- }
- return result;
- }
-
- public String getXMLCatalogId() {
- String result = null;
- if (radioButton[1].getSelection()) {
- result = selectXMLCatalogIdPanel.getId();
- }
- return result;
- }
-
- public String getXMLCatalogURI() {
- String result = null;
- if (radioButton[1].getSelection()) {
- result = selectXMLCatalogIdPanel.getURI();
- }
- return result;
- }
-
- public void setCatalogEntryType(int catalogEntryType) {
- selectXMLCatalogIdPanel.setCatalogEntryType(catalogEntryType);
- }
-
- public void setFilterExtensions(String[] filterExtensions) {
- selectSingleFileView.resetFilters();
- selectSingleFileView.addFilterExtensions(filterExtensions);
-
- selectXMLCatalogIdPanel.getTableViewer().setFilterExtensions(filterExtensions);
- }
-
- public void setListener(Listener listener) {
- this.listener = listener;
- }
-
- public void setVisibleHelper(boolean isVisible) {
- selectSingleFileView.setVisibleHelper(isVisible);
- }
-
- public void updateCompletionStateChange() {
- if (listener != null) {
- listener.completionStateChanged();
- }
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == radioButton[0]) {
- pageBook.showPage(selectSingleFileView.getControl());
- }
- else {
- pageBook.showPage(selectXMLCatalogIdPanel);
- }
- updateCompletionStateChange();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java
deleted file mode 100644
index 624c96a89c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdDialog.java
+++ /dev/null
@@ -1,111 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.ui.internal.util.XMLCommonUIContextIds;
-
-
-
-public class SelectXMLCatalogIdDialog extends Dialog {
- protected String[] extensions;
- protected Button okButton;
- protected SelectXMLCatalogIdPanel panel;
- protected String publicId;
- protected String systemId;
-
- public SelectXMLCatalogIdDialog(Shell parentShell, String[] extensions) {
- super(parentShell);
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.extensions = extensions;
- }
-
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- ISelection selection = panel.getTableViewer().getSelection();
- Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
-
- if (selectedObject instanceof ICatalogEntry) {
- ICatalogEntry mappingInfo = (ICatalogEntry) selectedObject;
- publicId = mappingInfo.getKey();
- systemId = computeDefaultSystemId(mappingInfo);
- }
- }
- super.buttonPressed(buttonId);
- }
-
- protected String computeDefaultSystemId(ICatalogEntry mappingInfo) {
- String result = mappingInfo.getAttributeValue(ICatalogEntry.ATTR_WEB_URL);
- if ((result == null) && (mappingInfo.getURI() != null)) {
- int index = mappingInfo.getURI().lastIndexOf("/"); //$NON-NLS-1$
- String lastSegment = index != -1 ? mappingInfo.getURI().substring(index + 1) : mappingInfo.getURI();
- result = lastSegment;
- }
- return result;
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- okButton.setEnabled(false);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(dialogArea, XMLCommonUIContextIds.XCUI_CATALOG_DIALOG);
-
- ICatalog xmlCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
- panel = new SelectXMLCatalogIdPanel(dialogArea, xmlCatalog);
-
- ISelectionChangedListener listener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateButtonState();
- }
- };
- panel.getTableViewer().setFilterExtensions(extensions);
- panel.getTableViewer().addSelectionChangedListener(listener);
- return dialogArea;
- }
-
-
-
- public String getId() {
- return publicId;
- }
-
- public String getSystemId() {
- return systemId;
- }
-
- protected void updateButtonState() {
- ISelection selection = panel.getTableViewer().getSelection();
- okButton.setEnabled(!selection.isEmpty());
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java
deleted file mode 100644
index 01a9e8b399..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/SelectXMLCatalogIdPanel.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import java.util.Collection;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-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.Label;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-
-public class SelectXMLCatalogIdPanel extends Composite {
- protected int catalogEntryType;
- protected boolean doTableSizeHack = false;
-
- protected XMLCatalogTableViewer tableViewer;
- protected ICatalog fXmlCatalog;
-
- public SelectXMLCatalogIdPanel(Composite parent, ICatalog xmlCatalog) {
- super(parent, SWT.NONE);
- this.fXmlCatalog = xmlCatalog;
-
- GridLayout gridLayout = new GridLayout();
- this.setLayout(gridLayout);
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.heightHint = 200;
- gd.widthHint = 700;
- this.setLayoutData(gd);
-
- Label label = new Label(this, SWT.NONE);
- label.setText(XMLUIMessages._UI_LABEL_XML_CATALOG_COLON);
-
- tableViewer = createTableViewer(this);
- tableViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH));
- tableViewer.setInput("dummy"); //$NON-NLS-1$
- }
-
- protected XMLCatalogTableViewer createTableViewer(Composite parent) {
- String headings[] = new String[2];
- headings[0] = XMLUIMessages._UI_LABEL_KEY;
- headings[1] = XMLUIMessages._UI_LABEL_URI;
-
- XMLCatalogTableViewer theTableViewer = new XMLCatalogTableViewer(parent, headings) {
-
- protected void addXMLCatalogEntries(List list, ICatalogEntry[] entries) {
- for (int i = 0; i < entries.length; i++) {
- ICatalogEntry entry = entries[i];
- if (catalogEntryType == 0) {
- list.add(entry);
- }
- else if (catalogEntryType == entry.getEntryType()) {
- list.add(entry);
- }
- }
- }
-
- public Collection getXMLCatalogEntries() {
- List result = null;
-
- if ((fXmlCatalog == null) || doTableSizeHack) {
- // this lets us create a table with an initial height of
- // 10 rows
- // otherwise we get stuck with 0 row heigh table... that's
- // too small
- doTableSizeHack = false;
- result = new Vector();
- for (int i = 0; i < 6; i++) {
- result.add(""); //$NON-NLS-1$
- }
- }
- else {
- result = new Vector();
- INextCatalog[] nextCatalogs = fXmlCatalog.getNextCatalogs();
- for (int i = 0; i < nextCatalogs.length; i++) {
- INextCatalog catalog = nextCatalogs[i];
- ICatalog referencedCatalog = catalog.getReferencedCatalog();
- if (referencedCatalog != null) {
- if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
- ICatalog systemCatalog = referencedCatalog;
- addXMLCatalogEntries(result, systemCatalog.getCatalogEntries());
-
- }
- else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) {
- ICatalog userCatalog = referencedCatalog;
- addXMLCatalogEntries(result, userCatalog.getCatalogEntries());
-
- }
- }
- }
- }
- return result;
- }
- };
- return theTableViewer;
- }
-
-
- public String getId() {
- ICatalogEntry entry = getXMLCatalogEntry();
- return entry != null ? entry.getKey() : null;
- }
-
- public XMLCatalogTableViewer getTableViewer() {
- return tableViewer;
- }
-
- public String getURI() {
- ICatalogEntry entry = getXMLCatalogEntry();
- return entry != null ? entry.getURI() : null;
- }
-
- public ICatalogEntry getXMLCatalogEntry() {
- ICatalogEntry result = null;
- ISelection selection = tableViewer.getSelection();
- Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null;
- if (selectedObject instanceof ICatalogEntry) {
- result = (ICatalogEntry) selectedObject;
- }
- return result;
- }
-
- public void setCatalogEntryType(int catalogEntryType) {
- this.catalogEntryType = catalogEntryType;
- tableViewer.refresh();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/UpdateListener.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/UpdateListener.java
deleted file mode 100644
index 607270ad1f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/UpdateListener.java
+++ /dev/null
@@ -1,20 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-public interface UpdateListener {
-
- public void updateOccured(Object object, Object arg);
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java
deleted file mode 100644
index ada87596e1..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dialogs/XMLCatalogTableViewer.java
+++ /dev/null
@@ -1,201 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.dialogs;
-
-import com.ibm.icu.text.Collator;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Comparator;
-
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerFilter;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-
-public class XMLCatalogTableViewer extends TableViewer {
-
-
- public class CatalogEntryContentProvider implements IStructuredContentProvider {
-
- public void dispose() {
- }
-
- public Object[] getElements(Object element) {
- Object[] array = getXMLCatalogEntries().toArray();
- Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
- int result = 0;
- if ((o1 instanceof ICatalogEntry) && (o2 instanceof ICatalogEntry)) {
- ICatalogEntry mappingInfo1 = (ICatalogEntry) o1;
- ICatalogEntry mappingInfo2 = (ICatalogEntry) o2;
- result = Collator.getInstance().compare(mappingInfo1.getKey(), mappingInfo2.getKey());
- }
- return result;
- }
- };
- Arrays.sort(array, comparator);
- return array;
- }
-
- public void inputChanged(Viewer viewer, Object old, Object newobj) {
- }
-
- public boolean isDeleted(Object object) {
- return false;
- }
- }
-
- public class CatalogEntryLabelProvider extends LabelProvider implements ITableLabelProvider {
-
- public Image getColumnImage(Object object, int columnIndex) {
- Image result = null;
- if (columnIndex == 0) {
- Image base = null;
- if (object instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) object;
- String uri = catalogEntry.getURI();
- if (uri.endsWith("dtd")) { //$NON-NLS-1$
- base = dtdFileImage;
- }
- else if (uri.endsWith("xsd")) { //$NON-NLS-1$
- base = xsdFileImage;
- }
- else {
- base = unknownFileImage;
- }
-
- if (base != null) {
- if (URIHelper.isReadableURI(uri, false)) {
- result = base;
- }
- else {
- // TODO... SSE port
- result = base;// imageFactory.createCompositeImage(base,
- // errorImage,
- // ImageFactory.BOTTOM_LEFT);
- }
- }
- }
- }
- return result;
- }
-
- public String getColumnText(Object object, int columnIndex) {
- String result = null;
- if (object instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) object;
- result = columnIndex == 0 ? catalogEntry.getKey() : catalogEntry.getURI();
- result = URIHelper.removePlatformResourceProtocol(result);
- }
- return result != null ? result : ""; //$NON-NLS-1$
- }
- }
-
-
- class XMLCatalogTableViewerFilter extends ViewerFilter {
- protected String[] extensions;
-
- public XMLCatalogTableViewerFilter(String[] extensions) {
- this.extensions = extensions;
- }
-
- public boolean isFilterProperty(Object element, Object property) {
- return false;
- }
-
- public boolean select(Viewer viewer, Object parent, Object element) {
- boolean result = false;
- if (element instanceof ICatalogEntry) {
- ICatalogEntry catalogEntry = (ICatalogEntry) element;
- for (int i = 0; i < extensions.length; i++) {
- if (catalogEntry.getURI().endsWith(extensions[i])) {
- result = true;
- break;
- }
- }
- }
- return result;
- }
- }
-
- protected static Image dtdFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_DTDFILE);
-
- protected static String ERROR_STATE_KEY = "errorstatekey"; //$NON-NLS-1$
- protected static Image errorImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OVR_ERROR);
-
- protected static Image unknownFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT);
- protected static Image xsdFileImage = XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_XSDFILE);
-
- // protected ImageFactory imageFactory = new ImageFactory();
-
- public XMLCatalogTableViewer(Composite parent, String[] columnProperties) {
- super(parent, SWT.FULL_SELECTION);
-
- Table table = getTable();
- table.setLinesVisible(true);
- table.setHeaderVisible(true);
- table.setLinesVisible(true);
-
- TableLayout layout = new TableLayout();
- for (int i = 0; i < columnProperties.length; i++) {
- TableColumn column = new TableColumn(table, i);
- column.setText(columnProperties[i]);
- column.setAlignment(SWT.LEFT);
- layout.addColumnData(new ColumnWeightData(50, true));
- }
- table.setLayout(layout);
- table.setLinesVisible(false);
-
- setColumnProperties(columnProperties);
-
- setContentProvider(new CatalogEntryContentProvider());
- setLabelProvider(new CatalogEntryLabelProvider());
- }
-
- public Collection getXMLCatalogEntries() {
- return null;
- }
-
-
- public void menuAboutToShow(IMenuManager menuManager) {
- Action action = new Action("hello") { //$NON-NLS-1$
- public void run() {
- System.out.println("run!"); //$NON-NLS-1$
- }
- };
- menuManager.add(action);
- }
-
- public void setFilterExtensions(String[] extensions) {
- resetFilters();
- addFilter(new XMLCatalogTableViewerFilter(extensions));
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
deleted file mode 100644
index ffc9a29c91..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/DragNodeCommand.java
+++ /dev/null
@@ -1,312 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.dnd;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Hashtable;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Vector;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.common.ui.internal.dnd.DefaultDragAndDropCommand;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-public class DragNodeCommand extends DefaultDragAndDropCommand {
- private List fSelections;
- private TreeViewer fTreeViewer;
-
- public DragNodeCommand(Object target, float location, int operations, int operation, Collection sources, TreeViewer treeViewer) {
- super(target, location, operations, operation, sources);
- fTreeViewer = treeViewer;
- fSelections = new ArrayList();
- }
-
- private void beginModelChange(Node node, boolean batchUpdate) {
- IStructuredModel structuredModel = getStructuredModel(node);
- if (structuredModel != null) {
- String undoDesc = new String();
- if (getOperation() == DND.DROP_MOVE) {
- undoDesc = XMLUIMessages.DragNodeCommand_0;
- }
- else if (getOperation() == DND.DROP_COPY) {
- undoDesc = XMLUIMessages.DragNodeCommand_1;
- }
-
- structuredModel.beginRecording(this, undoDesc);
- if (batchUpdate) {
- // structuredModel.aboutToChangeModel();
- }
- }
- }
-
- public boolean canExecute() {
- return executeHelper(true);
- }
-
- private boolean doModify(Node source, Node parentNode, Node refChild, boolean testOnly) {
- boolean result = false;
- if (source.getNodeType() == Node.ATTRIBUTE_NODE) {
- Attr sourceAttribute = (Attr) source;
- Element sourceAttributeOwnerElement = sourceAttribute.getOwnerElement();
- if ((parentNode.getNodeType() == Node.ELEMENT_NODE) && (sourceAttributeOwnerElement != parentNode)) {
- result = true;
- if (!testOnly) {
- try {
- if (getOperation() == DND.DROP_MOVE) {
- Element targetElement = (Element) parentNode;
- sourceAttributeOwnerElement.removeAttributeNode(sourceAttribute);
- targetElement.getAttributes().setNamedItem(sourceAttribute);
- fSelections.add(sourceAttribute);
- }
- else if (getOperation() == DND.DROP_COPY) {
- Attr cloneAttribute = (Attr) sourceAttribute.cloneNode(false);
- Element targetElement = (Element) parentNode;
- targetElement.getAttributes().setNamedItem(cloneAttribute);
- fSelections.add(cloneAttribute);
- }
- }
- catch (Exception e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- }
- }
- else {
- if (((parentNode.getNodeType() == Node.ELEMENT_NODE) || (parentNode.getNodeType() == Node.DOCUMENT_NODE)) && !(refChild instanceof Attr)) {
- result = true;
-
- if (!testOnly) {
- try {
- if (isAncestor(source, parentNode)) {
- // System.out.println("can not perform this drag drop
- // operation.... todo... pop up dialog");
- }
- else {
- // defect 221055 this test is required or else the
- // node will
- // be removed from the tree and the insert will fail
- if (source != refChild) {
- if (getOperation() == DND.DROP_MOVE) {
- Node oldParent = source.getParentNode();
- Node oldSibling = source.getNextSibling();
- oldParent.removeChild(source);
- try {
- parentNode.insertBefore(source, refChild);
- } catch (DOMException e) {
- // bug151692 - if unable to move node to new location, reinsert back to old location
- oldParent.insertBefore(source, oldSibling);
- }
- fSelections.add(source);
- }
- else if (getOperation() == DND.DROP_COPY) {
- Node nodeClone = source.cloneNode(true);
- parentNode.insertBefore(nodeClone, refChild);
- fSelections.add(nodeClone);
- }
- }
- }
- }
- catch (Exception e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- }
- }
- return result;
- }
-
- private void endModelChange(Node node, boolean batchUpdate) {
- IStructuredModel structuredModel = getStructuredModel(node);
- if (structuredModel != null) {
- structuredModel.endRecording(this);
- if (batchUpdate) {
- // structuredModel.changedModel();
- }
- }
- }
-
- public void execute() {
- executeHelper(false);
-
- // Make our selection if the treeViewer != null
- if (fTreeViewer != null) {
- StructuredSelection structuredSelection = new StructuredSelection(fSelections);
- fTreeViewer.setSelection(structuredSelection);
- }
- }
-
- private boolean executeHelper(boolean testOnly) {
- boolean result = true;
- if (target instanceof Node) {
- Node targetNode = (Node) target;
- if (!testOnly && fTreeViewer != null && !validateEdit(getStructuredModel(targetNode), fTreeViewer.getControl().getShell()))
- return false;
-
- Node parentNode = getParentForDropPosition(targetNode);
- Node refChild = getRefChild(targetNode);
-
- Vector sourcesList = new Vector();
- sourcesList.addAll(sources);
-
- removeMemberDescendants(sourcesList);
- boolean performBatchUpdate = sourcesList.size() > 5;
-
- if (!testOnly) {
- beginModelChange(targetNode, performBatchUpdate);
- }
- for (Iterator i = sourcesList.iterator(); i.hasNext();) {
- Object source = i.next();
- if (source instanceof Node) {
- if (!((refChild == null) && (targetNode instanceof Attr))) {
- result = doModify((Node) source, parentNode, refChild, testOnly);
- }
- else {
- result = false;
- }
- if (!result) {
- break;
- }
- }
- }
- if (!testOnly) {
- endModelChange(targetNode, performBatchUpdate);
- }
- }
- else {
- result = false;
- }
- return result;
- }
-
- /**
- * Checks that the resource backing the model is writeable utilizing <code>validateEdit</code>
- * on a given <tt>IWorkspace</tt>.
- *
- * @param model the model to be checked
- * @param context the shell context for which <code>validateEdit</code> will be run
- * @return boolean result of checking <code>validateEdit</code>. If the resource is unwriteable, <code>status.isOK()</code>
- * will return true; otherwise, false.
- */
- private boolean validateEdit(IStructuredModel model, Shell context) {
- if (model != null && model.getBaseLocation() != null) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(model.getBaseLocation()));
- return !file.isAccessible() || ResourcesPlugin.getWorkspace().validateEdit(new IFile[] {file}, context).isOK();
- }
- return false; //$NON-NLS-1$
- }
-
- public int getFeedback() {
- int result = DND.FEEDBACK_SELECT;
- if (location > 0.75) {
- result = DND.FEEDBACK_INSERT_AFTER;
- }
- else if (location < 0.25) {
- result = DND.FEEDBACK_INSERT_BEFORE;
- }
- return result;
- }
-
- private Node getParentForDropPosition(Node node) {
- Node result = null;
-
- int feedback = getFeedback();
- if (feedback == DND.FEEDBACK_SELECT) {
- result = node;
- }
- else {
- result = getParentOrOwner(node);
- }
- return result;
- }
-
-
- private Node getParentOrOwner(Node node) {
- return (node.getNodeType() == Node.ATTRIBUTE_NODE) ? ((Attr) node).getOwnerElement() : node.getParentNode();
- }
-
-
- private Node getRefChild(Node node) {
- Node result = null;
-
- int feedback = getFeedback();
-
- if (feedback == DND.FEEDBACK_INSERT_BEFORE) {
- result = node;
- }
- else if (feedback == DND.FEEDBACK_INSERT_AFTER) {
- result = node.getNextSibling();
- }
- return result;
- }
-
- private IStructuredModel getStructuredModel(Node node) {
- IStructuredModel result = null;
- if (node instanceof IDOMNode) {
- result = ((IDOMNode) node).getModel();
- }
- return result;
- }
-
- // returns true if a is an ancestore of b
- //
- private boolean isAncestor(Node a, Node b) {
- boolean result = false;
- for (Node parent = b; parent != null; parent = parent.getParentNode()) {
- if (parent == a) {
- result = true;
- break;
- }
- }
- return result;
- }
-
-
- /**
- * This method removes members of the list that have ancestors that are
- * also members of the list.
- */
- private void removeMemberDescendants(List list) {
- Hashtable table = new Hashtable();
- for (Iterator i = list.iterator(); i.hasNext();) {
- Object node = i.next();
- table.put(node, node);
- }
-
- for (int i = list.size() - 1; i >= 0; i--) {
- Object node = list.get(i);
- if (node instanceof Node){
- for (Node parent = getParentOrOwner((Node)node); parent != null; parent = getParentOrOwner(parent)) {
- if (table.get(parent) != null) {
- list.remove(i);
- break;
- }
- }
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java
deleted file mode 100644
index 48097a81eb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/dnd/XMLDragAndDropManager.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.dnd;
-
-import java.util.Collection;
-
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.wst.common.ui.internal.dnd.DragAndDropCommand;
-import org.eclipse.wst.common.ui.internal.dnd.DragAndDropManager;
-import org.eclipse.wst.common.ui.internal.dnd.ObjectTransfer;
-import org.eclipse.wst.common.ui.internal.dnd.ViewerDragAdapter;
-import org.eclipse.wst.common.ui.internal.dnd.ViewerDropAdapter;
-import org.w3c.dom.Node;
-
-public class XMLDragAndDropManager implements DragAndDropManager {
- private TreeViewer fViewer;
-
- public static void addDragAndDropSupport(TreeViewer viewer) {
- int dndOperations = DND.DROP_COPY | DND.DROP_MOVE | DND.DROP_LINK;
- Transfer[] transfers = new Transfer[]{ObjectTransfer.getInstance()};
- viewer.addDragSupport(dndOperations, transfers, new ViewerDragAdapter(viewer));
- viewer.addDropSupport(dndOperations, transfers, new ViewerDropAdapter(viewer, new XMLDragAndDropManager(viewer)));
- }
-
- public XMLDragAndDropManager() {
- super();
- }
-
- public XMLDragAndDropManager(TreeViewer viewer) {
- fViewer = viewer;
- }
-
- public DragAndDropCommand createCommand(Object target, float location, int operations, int operation, Collection source) {
- DragAndDropCommand result = null;
- if (target instanceof Node) {
- result = new DragNodeCommand(target, location, operations, operation, source, fViewer);
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java
deleted file mode 100644
index b23097ecf2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/doubleclick/XMLDoubleClickStrategy.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.doubleclick;
-
-import org.eclipse.jface.text.DefaultTextDoubleClickStrategy;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.w3c.dom.Node;
-
-
-public class XMLDoubleClickStrategy extends DefaultTextDoubleClickStrategy {
- protected static final char DOUBLE_QUOTE = '\"';
- protected static final char SINGLE_QUOTE = '\'';
- protected static final char SPACE = ' ';
- protected int fCaretPosition = -1;
- protected int fDoubleClickCount = 0;
- protected Node fNode = null;
- protected IStructuredDocumentRegion fStructuredDocumentRegion = null;
- protected String fStructuredDocumentRegionText = ""; //$NON-NLS-1$
- protected IStructuredModel fStructuredModel = null;
- protected StructuredTextViewer fStructuredTextViewer;
- protected ITextRegion fTextRegion = null;
-
- public void doubleClicked(ITextViewer textViewer) {
- if (textViewer instanceof StructuredTextViewer) {
- fStructuredTextViewer = (StructuredTextViewer) textViewer;
- try {
- fStructuredModel = StructuredModelManager.getModelManager().getExistingModelForRead(fStructuredTextViewer.getDocument());
-
- if (fStructuredModel != null) {
- int caretPosition = textViewer.getSelectedRange().x;
- if (caretPosition < 0) {
- return;
- }
-
- fNode = (Node) fStructuredModel.getIndexedRegion(caretPosition);
- if (fNode == null) {
- return;
- }
-
- updateDoubleClickCount(caretPosition);
- updateStructuredDocumentRegion();
- updateTextRegion();
-
- if (fNode.getNodeType() == Node.TEXT_NODE) {
- processTextDoubleClicked();
- }
- else {
- processElementDoubleClicked();
- }
- }
- }
- finally {
- if (fStructuredModel != null) {
- fStructuredModel.releaseFromRead();
- }
- }
- }
- }
-
- protected Point getWord(String string, int cursor) {
- if (string == null) {
- return null;
- }
-
- int wordStart = 0;
- int wordEnd = string.length();
-
- wordStart = string.lastIndexOf(SPACE, cursor - 1);
- int temp = string.lastIndexOf(SINGLE_QUOTE, cursor - 1);
- wordStart = Math.max(wordStart, temp);
- temp = string.lastIndexOf(DOUBLE_QUOTE, cursor - 1);
- wordStart = Math.max(wordStart, temp);
- if (wordStart == -1) {
- wordStart = cursor;
- }
- else {
- wordStart++;
- }
-
- wordEnd = string.indexOf(SPACE, cursor);
- if (wordEnd == -1) {
- wordEnd = string.length();
- }
- temp = string.indexOf(SINGLE_QUOTE, cursor);
- if (temp == -1) {
- temp = string.length();
- }
- wordEnd = Math.min(wordEnd, temp);
- temp = string.indexOf(DOUBLE_QUOTE, cursor);
- if (temp == -1) {
- temp = string.length();
- }
- wordEnd = Math.min(wordEnd, temp);
- if (wordEnd == string.length()) {
- wordEnd = cursor;
- }
-
- if ((wordStart == wordEnd) && !isQuoted(string)) {
- wordStart = 0;
- wordEnd = string.length();
- }
-
- return new Point(wordStart, wordEnd);
- }
-
- protected 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) && (lastChar == SINGLE_QUOTE)) || ((firstChar == DOUBLE_QUOTE) && (lastChar == DOUBLE_QUOTE)));
- }
-
- protected void processElementAttrEqualsDoubleClicked2Times() {
- int prevRegionOffset = fStructuredDocumentRegion.getStartOffset(fTextRegion) - 1;
- ITextRegion prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset);
- int nextRegionOffset = fStructuredDocumentRegion.getEndOffset(fTextRegion);
- ITextRegion nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset);
-
- if ((prevRegion != null) && (prevRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) && (nextRegion != null) && (nextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(prevRegion), nextRegion.getTextEnd() - prevRegion.getStart());
- }
- }
-
- protected void processElementAttrNameDoubleClicked2Times() {
- int nextRegionOffset = fStructuredDocumentRegion.getEndOffset(fTextRegion);
- ITextRegion nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset);
-
- if (nextRegion != null) {
- nextRegionOffset = fStructuredDocumentRegion.getEndOffset(nextRegion);
- nextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(nextRegionOffset);
- if ((nextRegion != null) && (nextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), nextRegion.getTextEnd() - fTextRegion.getStart());
- }
- else {
- // attribute has no value
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- }
-
- protected void processElementAttrValueDoubleClicked() {
- String regionText = fStructuredDocumentRegion.getText(fTextRegion);
-
- if (fDoubleClickCount == 1) {
- Point word = getWord(regionText, fCaretPosition - fStructuredDocumentRegion.getStartOffset(fTextRegion));
- if (word.x == word.y) { // no word found; select whole region
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), regionText.length());
- fDoubleClickCount++;
- }
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion) + word.x, word.y - word.x);
- }
- }
- else if (fDoubleClickCount == 2) {
- if (isQuoted(regionText)) {
- // ==> // Point word = getWord(regionText, fCaretPosition -
- // fStructuredDocumentRegion.getStartOffset(fTextRegion));
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), regionText.length());
- }
- else {
- processElementAttrValueDoubleClicked2Times();
- }
- }
- else if (fDoubleClickCount == 3) {
- if (isQuoted(regionText)) {
- processElementAttrValueDoubleClicked2Times();
- }
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- else { // fDoubleClickCount == 4
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
-
- protected void processElementAttrValueDoubleClicked2Times() {
- int prevRegionOffset = fStructuredDocumentRegion.getStartOffset(fTextRegion) - 1;
- ITextRegion prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset);
-
- if (prevRegion != null) {
- prevRegionOffset = fStructuredDocumentRegion.getStartOffset(prevRegion) - 1;
- prevRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(prevRegionOffset);
- if ((prevRegion != null) && (prevRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME)) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(prevRegion), fTextRegion.getTextEnd() - prevRegion.getStart());
- }
- }
- }
-
- protected void processElementDoubleClicked() {
- if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- processElementAttrValueDoubleClicked(); // special handling for
- }
- else {
- if (fDoubleClickCount == 1) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart() + fTextRegion.getStart(), fTextRegion.getTextLength());
- }
- else if (fDoubleClickCount == 2) {
- if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- processElementAttrNameDoubleClicked2Times();
- }
- else if (fTextRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- processElementAttrEqualsDoubleClicked2Times();
- }
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- else { // fDoubleClickCount == 3
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- }
-
- protected void processTextDoubleClicked() {
- if (fDoubleClickCount == 1) {
- super.doubleClicked(fStructuredTextViewer);
-
- Point selectedRange = fStructuredTextViewer.getSelectedRange();
- if ((selectedRange.x == fStructuredDocumentRegion.getStartOffset(fTextRegion)) && (selectedRange.y == fTextRegion.getTextLength())) {
- // only one word in region, skip one level of double click
- // selection
- fDoubleClickCount++;
- }
- }
- else if (fDoubleClickCount == 2) {
- if (fTextRegion.getType() == DOMRegionContext.UNDEFINED) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- else {
- if (isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion))) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion) + 1, fTextRegion.getTextLength() - 2);
- }
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength());
- }
- }
- }
- else {
- if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegion.getFullText(fTextRegion))) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStartOffset(fTextRegion), fTextRegion.getTextLength());
- }
- else {
- if ((fDoubleClickCount == 3) && isQuoted(fStructuredDocumentRegionText)) {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart() + 1, fStructuredDocumentRegion.getLength() - 2);
- }
- else {
- fStructuredTextViewer.setSelectedRange(fStructuredDocumentRegion.getStart(), fStructuredDocumentRegion.getLength());
- fDoubleClickCount = 0;
- }
- }
- }
- }
-
- public void setModel(IStructuredModel structuredModel) {
- fStructuredModel = structuredModel;
- }
-
- protected void updateDoubleClickCount(int caretPosition) {
- if (fCaretPosition == caretPosition) {
- if (fStructuredDocumentRegion != null) {
- fDoubleClickCount++;
- }
- else {
- fDoubleClickCount = 1;
- }
- }
- else {
- fCaretPosition = caretPosition;
- fDoubleClickCount = 1;
- }
- }
-
- protected void updateStructuredDocumentRegion() {
- fStructuredDocumentRegion = fStructuredModel.getStructuredDocument().getRegionAtCharacterOffset(fCaretPosition);
- if (fStructuredDocumentRegion != null) {
- fStructuredDocumentRegionText = fStructuredDocumentRegion.getText();
- }
- else {
- fStructuredDocumentRegionText = ""; //$NON-NLS-1$
- }
- }
-
- protected void updateTextRegion() {
- if (fStructuredDocumentRegion != null) {
- fTextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(fCaretPosition);
- // if fTextRegion is null, it means we are at just past the last
- // fStructuredDocumentRegion,
- // at the very end of the document, so we'll use the last text
- // region in the document
- if (fTextRegion == null) {
- fTextRegion = fStructuredDocumentRegion.getRegionAtCharacterOffset(fCaretPosition - 1);
- }
- }
- else {
- fTextRegion = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java
deleted file mode 100644
index 112fe2c2d1..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/CMImageUtil.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.editor;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.SWTException;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.ImageData;
-import org.eclipse.wst.sse.core.internal.util.JarUtilities;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * @author nsd
- */
-public class CMImageUtil {
-
- public static String SMALL_ICON_URL = "small-icon"; //$NON-NLS-1$
-
- public static CMNode getDeclaration(Node node) {
- CMNode decl = null;
- ModelQuery mq = null;
- switch (node.getNodeType()) {
- case Node.ATTRIBUTE_NODE : {
- mq = ModelQueryUtil.getModelQuery(((Attr) node).getOwnerDocument());
- decl = mq.getCMAttributeDeclaration((Attr) node);
- }
- break;
- case Node.ELEMENT_NODE : {
- mq = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- decl = mq.getCMElementDeclaration((Element) node);
- }
- break;
- }
- return decl;
- }
-
- public static Image getImage(CMNode cmnode) {
- if (cmnode == null) {
- return null;
- }
- Image image = null;
- ImageDescriptor descriptor = getImageDescriptor(cmnode);
- if (descriptor != null) {
- image = descriptor.createImage(false);
- }
- return image;
- }
-
- public static ImageDescriptor getImageDescriptor(CMNode cmnode) {
- if (cmnode == null) {
- return null;
- }
- // cache CM-specified images with the XML UI plugin
- String imageURLString = (String) cmnode.getProperty(SMALL_ICON_URL);
- ImageDescriptor descriptor = null;
- if ((imageURLString != null) && (imageURLString.length() > 0)) {
- descriptor = XMLUIPlugin.getInstance().getImageRegistry().getDescriptor(imageURLString);
- if (descriptor == null) {
- try {
- URL imageURL = new URL(imageURLString);
- InputStream inputStream = JarUtilities.getInputStream(imageURL);
- try {
- ImageData data = new ImageData(inputStream);
- descriptor = ImageDescriptor.createFromImageData(data);
- XMLUIPlugin.getInstance().getImageRegistry().put(imageURLString, descriptor);
- }
- catch (SWTException e) {
- /*
- * There was a problem loading image from stream
- * (corrupt, missing, etc.)
- */
- if (inputStream != null)
- inputStream.close();
- }
- }
- catch (MalformedURLException e) {
- descriptor = null;
- }
- catch (IOException e) {
- descriptor = null;
- }
- }
- }
- return descriptor;
- }
-
- /**
- *
- */
- private CMImageUtil() {
- super();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/DOMSelectionConvertorFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/DOMSelectionConvertorFactory.java
deleted file mode 100644
index 0f0988b6f7..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/DOMSelectionConvertorFactory.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.editor;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.editor.SelectionConvertor;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.NamedNodeMap;
-
-/**
- * @author nitin
- *
- */
-public class DOMSelectionConvertorFactory implements IAdapterFactory {
-
- private static final Class[] ADAPTER_LIST = new Class[]{SelectionConvertor.class};
-
- private static class XMLSelectionConvertor extends SelectionConvertor {
- /* (non-Javadoc)
- * @see org.eclipse.wst.sse.ui.internal.editor.SelectionConvertor#getElements(org.eclipse.wst.sse.core.internal.provisional.IStructuredModel, int, int)
- */
- public Object[] getElements(IStructuredModel model, int start, int end) {
- Object[] objects = super.getElements(model, start, end);
- // narrow single selected Elements into Attrs if possible
- if (objects.length == 1) {
- if (objects[0] instanceof IDOMNode) {
- IDOMNode node = (IDOMNode) objects[0];
- NamedNodeMap attributes = node.getAttributes();
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- IDOMAttr attribute = (IDOMAttr) attributes.item(i);
- if (attribute.contains(start) && attribute.contains(end)) {
- objects[0] = attribute;
- break;
- }
- }
- }
- }
- }
- return objects;
- }
- }
-
- private static final Object selectionConvertor = new XMLSelectionConvertor();
-
- /**
- *
- */
- public DOMSelectionConvertorFactory() {
- }
-
- /*
- * (non-Javadoc)
- *
- * @see
- * org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object,
- * java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- if (adaptableObject instanceof IDOMModel && SelectionConvertor.class.equals(adapterType))
- return selectionConvertor;
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList() {
- return ADAPTER_LIST;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java
deleted file mode 100644
index f7542e3cd6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/IHelpContextIds.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.editor;
-
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * Help context ids for the XML Source Editor.
- * <p>
- * This interface contains constants only; it is not intended to be
- * implemented.
- * </p>
- *
- */
-public interface IHelpContextIds {
- // org.eclipse.wst.xml.ui.
- public static final String PREFIX = XMLUIPlugin.ID + "."; //$NON-NLS-1$
-
- // figured out on the fly
- // // XML Source page editor
- // public static final String XML_SOURCEVIEW_HELPID =
- // ContentTypeIdForXML.ContentTypeID_XML +"_source_HelpId"; //$NON-NLS-1$
-
- // XML Files Preference page
- public static final String XML_PREFWEBX_FILES_HELPID = PREFIX + "webx0060"; //$NON-NLS-1$
- // XML Source Preference page
- public static final String XML_PREFWEBX_SOURCE_HELPID = PREFIX + "webx0061"; //$NON-NLS-1$
- // XML Styles Preference page
- public static final String XML_PREFWEBX_STYLES_HELPID = PREFIX + "webx0062"; //$NON-NLS-1$
- // XML Templates Preference page
- public static final String XML_PREFWEBX_TEMPLATES_HELPID = PREFIX + "webx0063"; //$NON-NLS-1$
- // XML Validator Preference page
- public static final String XML_PREFWEBX_VALIDATOR_HELPID = PREFIX + "webx0064"; //$NON-NLS-1$
-
- // XML Cleanup dialog
- public static final String CLEANUP_XML_HELPID = PREFIX + "xmlm1200"; //$NON-NLS-1$
-
- // XML New File Wizard - Template Page
- public static final String XML_NEWWIZARD_TEMPLATE_HELPID = PREFIX + "xmlw0010"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java
deleted file mode 100644
index 73b67360e8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImageHelper.java
+++ /dev/null
@@ -1,159 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.editor;
-
-import java.util.HashMap;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.resource.ImageRegistry;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-
-/**
- * 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 XMLEditorPluginImageHelper {
- private static XMLEditorPluginImageHelper instance = null;
-
- /**
- * Gets the instance.
- *
- * @return Returns a XMLEditorPluginImageHelper
- */
- public synchronized static XMLEditorPluginImageHelper getInstance() {
- if (instance == null) {
- instance = new XMLEditorPluginImageHelper();
- }
- return instance;
- }
-
- // save a descriptor for each image
- private HashMap fImageDescRegistry = null;
- private final String PLUGINID = XMLUIPlugin.ID;
-
- /**
- * 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();
- // dont add the missing image descriptor image to the image
- // registry
- if (!desc.equals(ImageDescriptor.getMissingImageDescriptor())) {
- 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;
- }
-
- /**
- * 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 XMLUIPlugin.getDefault().getImageRegistry();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java
deleted file mode 100644
index 52c379affc..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/editor/XMLEditorPluginImages.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.editor;
-
-/**
- * Bundle of most images used by the XML Source Editor plug-in.
- */
-public class XMLEditorPluginImages {
-
- public static final String IMG_DTOOL_CONSTRAINOFF = "icons/full/dtool16/constrainoff.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_CONSTRAINON = "icons/full/dtool16/constrainon.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_RLDGRMR = "icons/full/dtool16/rldgrmr.gif"; //$NON-NLS-1$
- public static final String IMG_DTOOL_VALIDATE = "icons/full/dtool16/validate.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_CONSTRAINOFF = "icons/full/etool16/constrainoff.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_CONSTRAINON = "icons/full/etool16/constrainon.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_RLDGRMR = "icons/full/etool16/rldgrmr.gif"; //$NON-NLS-1$
- public static final String IMG_ETOOL_VALIDATE = "icons/full/etool16/validate.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ADD_CORRECTION = "icons/full/obj16/add_correction.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ATT_REQ_OBJ = "icons/full/obj16/att_req_obj.gif"; //$NON-NLS-1$
-
- public static final String IMG_OBJ_ATTRIBUTE = "icons/full/obj16/attribute_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_CDATASECTION = "icons/full/obj16/cdatasection.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_COMMENT = "icons/full/obj16/comment_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_CORRECTION_CHANGE = "icons/full/obj16/correction_change.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_DOCTYPE = "icons/full/obj16/doctype.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_DTDFILE = "icons/full/obj16/dtdfile.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ELEMENT = "icons/full/obj16/element_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ENTITY = "icons/full/obj16/entity.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ENTITY_REFERENCE = "icons/full/obj16/entity_reference.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_ENUM = "icons/full/obj16/enum.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_LOCAL_VARIABLE = "icons/full/obj16/localvariable_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_NOTATION = "icons/full/obj16/notation.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_PROCESSINGINSTRUCTION = "icons/full/obj16/proinst_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_SORT = "icons/full/obj16/sort.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TAG_GENERIC = "icons/full/obj16/tag-generic.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TAG_GENERIC_DEEMPHASIZED = "icons/full/obj16/tag_generic_deemphasized_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TAG_GENERIC_EMPHASIZED = "icons/full/obj16/tag_generic_emphasized_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TAG_MACRO = "icons/full/obj16/tag-macro.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_TXTEXT = "icons/full/obj16/text.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_WARNING_OBJ = "icons/full/obj16/warning_obj.gif"; //$NON-NLS-1$
- public static final String IMG_OBJ_XSDFILE = "icons/full/obj16/XSDFile.gif"; //$NON-NLS-1$
-
- public static final String IMG_OVR_ERROR = "icons/full/ovr16/error_ovr.gif"; //$NON-NLS-1$
- public static final String IMG_OVR_STALE_ERROR = "icons/full/ovr16/stale_error_ovr.gif"; //$NON-NLS-1$
- public static final String IMG_OVR_WARN = "icons/full/ovr16/warn_ovr.gif"; //$NON-NLS-1$
-
- public static final String IMG_WIZBAN_GENERATEXML = "icons/full/wizban/generatexml_wiz.png"; //$NON-NLS-1$
-
- public static final String IMG_OBJ_DEFAULT = "icons/full/obj16/default.gif"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AbstractSiblingNavigationHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AbstractSiblingNavigationHandler.java
deleted file mode 100644
index 4e0565bbf2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AbstractSiblingNavigationHandler.java
+++ /dev/null
@@ -1,92 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-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.handlers.HandlerUtil;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- * Provides navigation to next/previous DOM sibling Nodes
- */
-abstract public class AbstractSiblingNavigationHandler extends AbstractHandler {
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
- if (textEditor != null) {
-
- ISelection selection = textEditor.getSelectionProvider().getSelection();
- if (!selection.isEmpty() && selection instanceof IStructuredSelection) {
- Object o = ((IStructuredSelection) selection).getFirstElement();
- if (o instanceof Node) {
- Node sibling = null;
-
- if (((Node) o).getNodeType() == Node.ATTRIBUTE_NODE) {
- o = ((Attr) o).getOwnerElement();
- }
- if (moveForward()) {
- sibling = ((Node) o).getNextSibling();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getNextSibling();
- }
- if (sibling == null) {
- sibling = ((Node) o).getParentNode().getFirstChild();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getNextSibling();
- }
- }
- }
- else {
- sibling = ((Node) o).getPreviousSibling();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getPreviousSibling();
- }
- if (sibling == null) {
- sibling = ((Node) o).getParentNode().getLastChild();
- while (sibling != null && sibling.getNodeType() == Node.TEXT_NODE && sibling.getNodeValue().trim().length() == 0) {
- sibling = sibling.getPreviousSibling();
- }
- }
- }
-
- // The only child is a Text Node, go to the parent Node
- if (((Node) o).getNodeType() == Node.TEXT_NODE && o.equals(sibling)) {
- sibling = ((Node) o).getParentNode();
- }
-
-
- if (sibling != null) {
- textEditor.getSelectionProvider().setSelection(new StructuredSelection(sibling));
- }
- }
- }
- }
- return null;
- }
-
- abstract protected boolean moveForward();
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java
deleted file mode 100644
index 475f37a1f8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/AddBlockCommentHandler.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.xml.core.internal.document.CommentImpl;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class AddBlockCommentHandler extends CommentHandler implements IHandler {
-
- public AddBlockCommentHandler() {
- super();
- }
-
- void processAction(ITextEditor textEditor, IDocument document, ITextSelection textSelection) {
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
- if (model != null) {
- try {
- IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset());
- IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength());
-
- if (selectionStartIndexedRegion == null) {
- return;
- }
- if ((selectionEndIndexedRegion == null) && (textSelection.getLength() > 0)) {
- selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength() - 1);
- }
- if (selectionEndIndexedRegion == null) {
- return;
- }
-
- int openCommentOffset = selectionStartIndexedRegion.getStartOffset();
- int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() + OPEN_COMMENT.length();
-
- if ((textSelection.getLength() == 0) && (selectionStartIndexedRegion instanceof CommentImpl)) {
- return;
- }
-
- model.beginRecording(this, XMLUIMessages.AddBlockComment_tooltip);
- model.aboutToChangeModel();
-
- try {
- document.replace(openCommentOffset, 0, OPEN_COMMENT);
- document.replace(closeCommentOffset, 0, CLOSE_COMMENT);
- super.removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length());
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- finally {
- model.changedModel();
- model.endRecording(this);
- }
- }
- finally {
- model.releaseFromEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java
deleted file mode 100644
index 0d46a0e6d9..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CleanupdocumentHandler.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation - bug 212330 -
- * Based off CleanupActionXMLDelegate
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-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.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.cleanup.IStructuredCleanupProcessor;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.SSEUIMessages;
-import org.eclipse.wst.xml.core.internal.cleanup.CleanupProcessorXML;
-import org.eclipse.wst.xml.ui.internal.actions.CleanupDialogXML;
-
-public class CleanupdocumentHandler extends AbstractHandler implements IHandler {
- private IStructuredCleanupProcessor fCleanupProcessor;
-
- public void dispose() {
- // nulling out just in case
- fCleanupProcessor = null;
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
- if (textEditor != null) {
- final ITextEditor finalTextEditor = textEditor;
- Dialog cleanupDialog = new CleanupDialogXML(editor.getSite().getShell());
- if (cleanupDialog.open() == Window.OK) {
- // setup runnable
- Runnable runnable = new Runnable() {
- public void run() {
- IStructuredCleanupProcessor cleanupProcessor = getCleanupProcessor();
- if (cleanupProcessor != null) {
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForEdit(finalTextEditor.getDocumentProvider().getDocument(finalTextEditor.getEditorInput()));
- if (model != null) {
- cleanupProcessor.cleanupModel(model);
- }
- }
- finally {
- if (model != null) {
- model.releaseFromEdit();
- }
- }
- }
- }
- };
-
- // TODO: make independent of 'model'.
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getExistingModelForEdit(textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput()));
- if (model != null) {
- // begin recording
- ITextSelection selection = (ITextSelection) textEditor.getSelectionProvider().getSelection();
- model.beginRecording(this, SSEUIMessages.Cleanup_Document_UI_, SSEUIMessages.Cleanup_Document_UI_, selection.getOffset(), selection.getLength());
-
- // tell the model that we are about to make a big
- // model change
- model.aboutToChangeModel();
-
- // run
- BusyIndicator.showWhile(textEditor.getEditorSite().getWorkbenchWindow().getShell().getDisplay(), runnable);
- }
- }
- finally {
- if (model != null) {
- // tell the model that we are done with the big
- // model
- // change
- model.changedModel();
-
- // end recording
- ITextSelection selection = (ITextSelection) textEditor.getSelectionProvider().getSelection();
- model.endRecording(this, selection.getOffset(), selection.getLength());
- model.releaseFromEdit();
- }
- }
- }
- }
-
- return null;
- }
-
- IStructuredCleanupProcessor getCleanupProcessor() {
- if (fCleanupProcessor == null) {
- fCleanupProcessor = new CleanupProcessorXML();
- }
-
- return fCleanupProcessor;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java
deleted file mode 100644
index 60c644be2e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CollapseAllHandler.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-
-public class CollapseAllHandler extends ExpandCollapseAllHandler implements IHandler {
-
- /**
- *
- */
- public CollapseAllHandler() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
-
- viewer = getTableTreeViewerForEditorPart(editorPart);
-
- if (viewer != null) {
- // temporarily set the visibility to false
- // this has a HUGE performance benefit
- boolean isVisible = viewer.getControl().getVisible();
- viewer.getControl().setVisible(false);
- viewer.collapseAll();
-
- // restore the previous visibility state
- //
- viewer.getControl().setVisible(isVisible);
- }
-
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CommentHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CommentHandler.java
deleted file mode 100644
index 6188db2ca6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/CommentHandler.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.xml.ui.internal.Logger;
-
-public class CommentHandler extends AbstractHandler implements IHandler {
- static final String CLOSE_COMMENT = "-->"; //$NON-NLS-1$
- static final String OPEN_COMMENT = "<!--"; //$NON-NLS-1$
-
- public CommentHandler() {
- super();
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
- if (textEditor != null) {
- IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- if (document != null) {
- // get current text selection
- ITextSelection textSelection = getCurrentSelection(textEditor);
- if (textSelection.isEmpty()) {
- return null;
- }
-
- processAction(textEditor, document, textSelection);
- }
- }
-
- return null;
- }
-
- protected ITextSelection getCurrentSelection(ITextEditor textEditor) {
- ISelectionProvider provider = textEditor.getSelectionProvider();
- if (provider != null) {
- ISelection selection = provider.getSelection();
- if (selection instanceof ITextSelection) {
- return (ITextSelection) selection;
- }
- }
- return TextSelection.emptySelection();
- }
-
- void processAction(ITextEditor textEditor, IDocument document, ITextSelection textSelection) {
- // Implementations to over ride.
- }
-
- protected void removeOpenCloseComments(IDocument document, int offset, int length) {
- try {
- int adjusted_length = length;
-
- // remove open comments
- String string = document.get(offset, length);
- int index = string.lastIndexOf(OPEN_COMMENT);
- while (index != -1) {
- document.replace(offset + index, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- index = string.lastIndexOf(OPEN_COMMENT, index - 1);
- adjusted_length -= OPEN_COMMENT.length();
- }
-
- // remove close comments
- string = document.get(offset, adjusted_length);
- index = string.lastIndexOf(CLOSE_COMMENT);
- while (index != -1) {
- document.replace(offset + index, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- index = string.lastIndexOf(CLOSE_COMMENT, index - 1);
- }
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandAllHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandAllHandler.java
deleted file mode 100644
index 9091399bbc..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandAllHandler.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeViewer;
-
-public class ExpandAllHandler extends ExpandCollapseAllHandler {
-
- protected XMLTableTreeViewer viewer = null;
-
- /**
- *
- */
- public ExpandAllHandler() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
-
- IEditorPart editorPart = HandlerUtil.getActiveEditor(event);
-
- viewer = getTableTreeViewerForEditorPart(editorPart);
-
- if (viewer != null) {
- // temporarily set the visibility to false
- // this has a HUGE performance benefit
- boolean isVisible = viewer.getControl().getVisible();
- viewer.getControl().setVisible(false);
- viewer.expandAll();
-
- // restore the previous visibility state
- //
- viewer.getControl().setVisible(isVisible);
- }
-
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java
deleted file mode 100644
index 52d40f4d5d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ExpandCollapseAllHandler.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import java.util.Map;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.commands.IElementUpdater;
-import org.eclipse.ui.menus.UIElement;
-import org.eclipse.wst.xml.ui.internal.tabletree.IDesignViewer;
-import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeViewer;
-
-public class ExpandCollapseAllHandler extends AbstractHandler implements IElementUpdater {
-
- protected XMLTableTreeViewer viewer = null;
-
- /**
- * Command handler for handling Expand and Collapse for Tree Viewer
- */
- public ExpandCollapseAllHandler() {
- super();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- // Implementors to put their code here.
-
- return null;
- }
-
- protected XMLTableTreeViewer getTableTreeViewerForEditorPart(IEditorPart targetEditor) {
- XMLTableTreeViewer result = null;
- Object object = targetEditor.getAdapter(IDesignViewer.class);
- if (object instanceof XMLTableTreeViewer) {
- result = (XMLTableTreeViewer) object;
- }
- return result;
- }
-
- public void updateElement(UIElement element, Map parameters) {
- // TODO Auto-generated method stub
-
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/NextSiblingNavigationHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/NextSiblingNavigationHandler.java
deleted file mode 100644
index c25951cc89..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/NextSiblingNavigationHandler.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-public class NextSiblingNavigationHandler extends AbstractSiblingNavigationHandler {
-
- protected boolean moveForward() {
- return true;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/PreviousSiblingNavigationHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/PreviousSiblingNavigationHandler.java
deleted file mode 100644
index 3442a8b523..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/PreviousSiblingNavigationHandler.java
+++ /dev/null
@@ -1,19 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-public class PreviousSiblingNavigationHandler extends AbstractSiblingNavigationHandler {
-
- protected boolean moveForward() {
- return false;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java
deleted file mode 100644
index c371a18e21..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ReloadDependenciesHandler.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.CMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelqueryimpl.InferredGrammarBuildingCMDocumentLoader;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Document;
-
-public class ReloadDependenciesHandler extends AbstractHandler implements IHandler {
- protected IStructuredModel model;
-
- /**
- *
- */
- public ReloadDependenciesHandler() {
- // TODO Auto-generated constructor stub
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.commands.AbstractHandler#execute(org.eclipse.core.commands.ExecutionEvent)
- */
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
- if (textEditor != null) {
- IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model != null) {
- ModelQuery modelQuery = null;
- try {
- modelQuery = ModelQueryUtil.getModelQuery(model);
- }
- finally {
- model.releaseFromRead();
- }
- Document domDocument = ((IDOMModel) model).getDocument();
- if ((modelQuery != null) && (modelQuery.getCMDocumentManager() != null)) {
- modelQuery.getCMDocumentManager().getCMDocumentCache().clear();
- // TODO... need to figure out how to access the
- // DOMObserver via ModelQuery
- // ...why?
- CMDocumentLoader loader = new InferredGrammarBuildingCMDocumentLoader(domDocument, modelQuery);
- loader.loadCMDocuments();
- }
- }
- }
- return null;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java
deleted file mode 100644
index b4080bf944..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/RemoveBlockCommentHandler.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.xml.core.internal.document.CommentImpl;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * @author dcarver
- *
- */
-public class RemoveBlockCommentHandler extends CommentHandler implements IHandler {
-
- public RemoveBlockCommentHandler() {
- super();
- }
-
- void processAction(ITextEditor textEditor, IDocument document, ITextSelection textSelection) {
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
- if (model != null) {
- try {
- IndexedRegion selectionStartIndexedRegion = model.getIndexedRegion(textSelection.getOffset());
- IndexedRegion selectionEndIndexedRegion = model.getIndexedRegion(textSelection.getOffset() + textSelection.getLength());
-
- if ((selectionStartIndexedRegion == null) || (selectionEndIndexedRegion == null)) {
- return;
- }
-
- int openCommentOffset = selectionStartIndexedRegion.getStartOffset();
- int closeCommentOffset = selectionEndIndexedRegion.getEndOffset() - OPEN_COMMENT.length() - CLOSE_COMMENT.length();
-
- model.beginRecording(this, XMLUIMessages.RemoveBlockComment_tooltip);
- model.aboutToChangeModel();
-
- try {
- if (textSelection.getLength() == 0) {
- if (selectionStartIndexedRegion instanceof CommentImpl) {
- document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- }
- }
- else {
- if (selectionStartIndexedRegion instanceof CommentImpl) {
- document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- }
-
- if (selectionEndIndexedRegion instanceof CommentImpl) {
- document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- }
- }
- removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length());
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- finally {
- model.changedModel();
- model.endRecording(this);
- }
- }
- finally {
- model.releaseFromEdit();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectEnclosingXMLHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectEnclosingXMLHandler.java
deleted file mode 100644
index f043b6e1b6..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectEnclosingXMLHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.handlers.AbstractStructuredSelectHandler;
-import org.w3c.dom.Node;
-
-public class StructuredSelectEnclosingXMLHandler extends AbstractStructuredSelectHandler {
- protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
- IndexedRegion indexedRegion = null;
-
- indexedRegion = getIndexedRegion(document, textSelection.getOffset());
-
- return indexedRegion;
- }
-
- protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node cursorNode = (Node) indexedRegion;
-
- // 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) {
- indexedRegion = (IndexedRegion) cursorNode;
- }
- }
-
- Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
-
- if ((cursorNodeRegion.getOffset() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength())) {
- Node newNode = cursorNode.getParentNode();
-
- if (newNode instanceof IndexedRegion) {
- IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
- newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
- }
- }
- else {
- newRegion = cursorNodeRegion;
- }
- }
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectNextXMLHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectNextXMLHandler.java
deleted file mode 100644
index 366789fc29..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectNextXMLHandler.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.handlers.AbstractStructuredSelectHandler;
-import org.w3c.dom.Node;
-
-public class StructuredSelectNextXMLHandler extends AbstractStructuredSelectHandler {
-
- protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
- int offset = textSelection.getOffset() + textSelection.getLength() - 1;
- if (offset < 0) {
- offset = 0;
- }
-
- IndexedRegion indexedRegion = null;
-
- indexedRegion = getIndexedRegion(document, offset);
-
- return indexedRegion;
- }
-
- protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node cursorNode = (Node) indexedRegion;
-
- // 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) {
- indexedRegion = (IndexedRegion) cursorNode;
- }
- }
-
- Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
- int currentOffset = textSelection.getOffset();
- int currentEndOffset = currentOffset + textSelection.getLength();
- if ((cursorNodeRegion.getOffset() >= currentOffset) && (cursorNodeRegion.getOffset() <= currentEndOffset) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentOffset) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentEndOffset)) {
- newRegion = getNewSelectionRegion2(indexedRegion, textSelection);
- }
- else {
- newRegion = cursorNodeRegion;
- }
- }
- return newRegion;
- }
-
- /**
- * This method was separated out from getNewSelectionRegion2 because the
- * code in here is allowed to be called recursively.
- *
- * @param indexedRegion
- * @param textSelection
- * @return new region to select or null if none
- */
- private Region getNewSelectionRegion2(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node node = (Node) indexedRegion;
- 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(textSelection.getOffset(), newIndexedRegion.getEndOffset() - textSelection.getOffset());
-
- if (newNode.getNodeType() == Node.TEXT_NODE) {
- newRegion = getNewSelectionRegion2(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength()));
- }
- }
- }
- }
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectPreviousXMLHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectPreviousXMLHandler.java
deleted file mode 100644
index ab57447cee..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/StructuredSelectPreviousXMLHandler.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.handlers.AbstractStructuredSelectHandler;
-import org.w3c.dom.Node;
-
-public class StructuredSelectPreviousXMLHandler extends AbstractStructuredSelectHandler {
-
- protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
- IndexedRegion indexedRegion = null;
-
- indexedRegion = getIndexedRegion(document, textSelection.getOffset());
-
- return indexedRegion;
- }
-
- protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node cursorNode = (Node) indexedRegion;
-
- // 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) {
- indexedRegion = (IndexedRegion) cursorNode;
- }
- }
-
- Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
-
- if ((cursorNodeRegion.getOffset() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength())) {
- Node newNode = cursorNode.getPreviousSibling();
- if (newNode == null) {
- newNode = cursorNode.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(), textSelection.getOffset() + textSelection.getLength() - newIndexedRegion.getStartOffset());
-
- if (newNode.getNodeType() == Node.TEXT_NODE) {
- newRegion = getNewSelectionRegion(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength()));
- }
- }
- }
-
- }
- else {
- newRegion = cursorNodeRegion;
- }
- }
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleCommentHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleCommentHandler.java
deleted file mode 100644
index 174f680bbb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleCommentHandler.java
+++ /dev/null
@@ -1,193 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Position;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.jface.viewers.ISelectionProvider;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class ToggleCommentHandler extends CommentHandler implements IHandler {
- public ToggleCommentHandler() {
- super();
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
- if (textEditor != null) {
- IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- if (document != null) {
- // get current text selection
- ITextSelection textSelection = getCurrentSelection(textEditor);
- if (textSelection.isEmpty()) {
- return null;
- }
-
- processAction(textEditor, document, textSelection);
- }
- }
- return null;
- }
-
- void processAction(ITextEditor textEditor, IDocument document, ITextSelection textSelection) {
- // get text selection lines info
- int selectionStartLine = textSelection.getStartLine();
- int selectionEndLine = textSelection.getEndLine();
- try {
- int selectionEndLineOffset = document.getLineOffset(selectionEndLine);
- int selectionEndOffset = textSelection.getOffset() + textSelection.getLength();
-
- // adjust selection end line
- if ((selectionEndLine > selectionStartLine) && (selectionEndLineOffset == selectionEndOffset)) {
- selectionEndLine--;
- }
-
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
-
- // save the selection position since it will be changing
- Position selectionPosition = null;
- boolean updateStartOffset = false;
- try {
- selectionPosition = new Position(textSelection.getOffset(), textSelection.getLength());
- document.addPosition(selectionPosition);
-
- // extra check if commenting from beginning of line
- int selectionStartLineOffset = document.getLineOffset(selectionStartLine);
- if ((textSelection.getLength() > 0) && (selectionStartLineOffset == textSelection.getOffset()) && !isCommentLine(document, selectionStartLine)) {
- updateStartOffset = true;
- }
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
-
- processAction(document, selectionStartLine, selectionEndLine);
-
- updateCurrentSelection(textEditor, selectionPosition, document, updateStartOffset);
- }
-
- private void processAction(IDocument document, int selectionStartLine, int selectionEndLine) {
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForEdit(document);
- if (model != null) {
- try {
- model.beginRecording(this, XMLUIMessages.ToggleComment_tooltip);
- model.aboutToChangeModel();
-
- for (int i = selectionStartLine; i <= selectionEndLine; i++) {
- try {
- if (document.getLineLength(i) > 0) {
- if (isCommentLine(document, i)) {
- int lineOffset = document.getLineOffset(i);
- IRegion region = document.getLineInformation(i);
- String string = document.get(region.getOffset(), region.getLength());
- int openCommentOffset = lineOffset + string.indexOf(OPEN_COMMENT);
- int closeCommentOffset = lineOffset + string.indexOf(CLOSE_COMMENT) - OPEN_COMMENT.length();
- uncomment(document, openCommentOffset, closeCommentOffset);
- }
- else {
- int openCommentOffset = document.getLineOffset(i);
- int lineDelimiterLength = document.getLineDelimiter(i) == null ? 0 : document.getLineDelimiter(i).length();
- int closeCommentOffset = openCommentOffset + document.getLineLength(i) - lineDelimiterLength + OPEN_COMMENT.length();
- comment(document, openCommentOffset, closeCommentOffset);
- }
- }
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- }
- finally {
- model.changedModel();
- model.endRecording(this);
- model.releaseFromEdit();
- }
- }
- }
-
- private boolean isCommentLine(IDocument document, int line) {
- boolean isComment = false;
-
- try {
- IRegion region = document.getLineInformation(line);
- String string = document.get(region.getOffset(), region.getLength()).trim();
- isComment = (string.length() >= OPEN_COMMENT.length() + CLOSE_COMMENT.length()) && string.startsWith(OPEN_COMMENT) && string.endsWith(CLOSE_COMMENT);
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- return isComment;
- }
-
- private void comment(IDocument document, int openCommentOffset, int closeCommentOffset) {
- try {
- document.replace(openCommentOffset, 0, OPEN_COMMENT);
- document.replace(closeCommentOffset, 0, CLOSE_COMMENT);
- removeOpenCloseComments(document, openCommentOffset + OPEN_COMMENT.length(), closeCommentOffset - openCommentOffset - CLOSE_COMMENT.length());
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
-
- private void uncomment(IDocument document, int openCommentOffset, int closeCommentOffset) {
- try {
- document.replace(openCommentOffset, OPEN_COMMENT.length(), ""); //$NON-NLS-1$
- document.replace(closeCommentOffset, CLOSE_COMMENT.length(), ""); //$NON-NLS-1$
- }
- catch (BadLocationException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
-
- private void updateCurrentSelection(ITextEditor textEditor, Position selectionPosition, IDocument document, boolean updateStartOffset) {
- // update the selection if text selection changed
- if (selectionPosition != null) {
- ITextSelection selection = null;
- if (updateStartOffset) {
- selection = new TextSelection(document, selectionPosition.getOffset() - OPEN_COMMENT.length(), selectionPosition.getLength() + OPEN_COMMENT.length());
- }
- else {
- selection = new TextSelection(document, selectionPosition.getOffset(), selectionPosition.getLength());
- }
- ISelectionProvider provider = textEditor.getSelectionProvider();
- if (provider != null) {
- provider.setSelection(selection);
- }
- document.removePosition(selectionPosition);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java
deleted file mode 100644
index c36673fcd4..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/ToggleEditModeHandler.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation, bug 212330
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.commands.IElementUpdater;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.menus.UIElement;
-import org.eclipse.ui.services.IServiceScopes;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.tabletree.XMLEditorMessages;
-import org.eclipse.wst.xml.ui.internal.util.SharedXMLEditorPluginImageHelper;
-
-public class ToggleEditModeHandler extends AbstractHandler implements IElementUpdater {
- protected ImageDescriptor onImage = SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_CONSTRAINON);
- protected ImageDescriptor offImage = SharedXMLEditorPluginImageHelper.getImageDescriptor(SharedXMLEditorPluginImageHelper.IMG_ETOOL_CONSTRAINOFF);
-
- public ToggleEditModeHandler() {
- super();
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
- if (textEditor != null) {
- IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model != null) {
- ModelQuery modelQuery;
- try {
- modelQuery = ModelQueryUtil.getModelQuery(model);
- }
- finally {
- model.releaseFromRead();
- }
- if (modelQuery != null) {
- int newState = getNextState(modelQuery.getEditMode());
- modelQuery.setEditMode(newState);
-
- // Force a Refresh on this command so that the image can
- // be
- // updated.
- ICommandService commandService = (ICommandService) HandlerUtil.getActiveWorkbenchWindow(event).getService(ICommandService.class);
- Map filter = new HashMap();
- filter.put(IServiceScopes.WINDOW_SCOPE, HandlerUtil.getActiveWorkbenchWindow(event));
- commandService.refreshElements(event.getCommand().getId(), filter);
- }
- }
- }
-
- return null;
- }
-
- public int getNextState(int editMode) {
- int result = -1;
- if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) {
- result = ModelQuery.EDIT_MODE_UNCONSTRAINED;
- }
- else {
- result = ModelQuery.EDIT_MODE_CONSTRAINED_STRICT;
- }
- return result;
- }
-
-
- // Handlers that need to interact with the ui that the command came from
- // need to use implement this method.
- public void updateElement(UIElement element, Map parameters) {
- IEditorPart editor = XMLUIPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
- ITextEditor textEditor = null;
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else if (editor != null) {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
- if (textEditor != null) {
- IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- IStructuredModel model = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (model != null) {
- ModelQuery modelQuery;
- try {
- modelQuery = ModelQueryUtil.getModelQuery(model);
- }
- finally {
- model.releaseFromRead();
- }
- if (modelQuery != null) {
- setAppearanceForEditMode(modelQuery.getEditMode(), element);
- }
- }
- }
- }
-
- public void setAppearanceForEditMode(int editMode, UIElement element) {
- if (editMode == ModelQuery.EDIT_MODE_CONSTRAINED_STRICT) {
- element.setTooltip(XMLEditorMessages.XMLTableTreeActionBarContributor_3);
- element.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_3);
- element.setIcon(onImage);
- }
- else {
- element.setTooltip(XMLEditorMessages.XMLTableTreeActionBarContributor_5);
- element.setText(XMLEditorMessages.XMLTableTreeActionBarContributor_5);
- element.setIcon(offImage);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java
deleted file mode 100644
index 3e388dcddb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/handlers/XMLFindOccurencesHandler.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2010 Standards for Technology in Automotive Retail and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - initial API and implementation - bug 212330 -
- * Based off CleanupActionXMLDelegate
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.handlers;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.commands.AbstractHandler;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.core.commands.ExecutionException;
-import org.eclipse.core.commands.IHandler;
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.BadLocationException;
-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.ui.IEditorPart;
-import org.eclipse.ui.IFileEditorInput;
-import org.eclipse.ui.handlers.HandlerUtil;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.sse.ui.internal.ExtendedConfigurationBuilder;
-import org.eclipse.wst.sse.ui.internal.SSEUIMessages;
-import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor;
-import org.eclipse.wst.sse.ui.internal.util.PlatformStatusLineUtil;
-import org.eclipse.wst.xml.ui.internal.search.XMLFindOccurrencesProcessor;
-
-public class XMLFindOccurencesHandler extends AbstractHandler implements IHandler {
- private List fProcessors;
-
- public void dispose() {
- }
-
- public Object execute(ExecutionEvent event) throws ExecutionException {
- IEditorPart editor = HandlerUtil.getActiveEditor(event);
- ITextEditor textEditor = null;
- boolean okay = false;
-
- if (editor instanceof ITextEditor)
- textEditor = (ITextEditor) editor;
- else {
- Object o = editor.getAdapter(ITextEditor.class);
- if (o != null)
- textEditor = (ITextEditor) o;
- }
-
- if (textEditor != null) {
- IDocument document = textEditor.getDocumentProvider().getDocument(textEditor.getEditorInput());
- if (document != null) {
- ITextSelection textSelection = getTextSelection(textEditor);
- FindOccurrencesProcessor findOccurrenceProcessor = getProcessorForCurrentSelection(document, textSelection);
- if (findOccurrenceProcessor != null) {
- if (textEditor.getEditorInput() instanceof IFileEditorInput) {
- IFile file = ((IFileEditorInput) textEditor.getEditorInput()).getFile();
- okay = findOccurrenceProcessor.findOccurrences(document, textSelection, file);
- }
- }
- }
- }
- if (okay) {
- // clear status message
- PlatformStatusLineUtil.clearStatusLine();
- }
- else {
- String errorMessage = SSEUIMessages.FindOccurrencesActionProvider_0; //$NON-NLS-1$
- PlatformStatusLineUtil.displayErrorMessage(errorMessage);
- PlatformStatusLineUtil.addOneTimeClearListener();
- }
-
- return null;
- }
-
- /**
- * Get the appropriate find occurrences processor
- *
- * @param document -
- * assumes not null
- * @param textSelection
- * @return FindOccurrencesProcessor
- */
- private FindOccurrencesProcessor getProcessorForCurrentSelection(IDocument document, ITextSelection textSelection) {
- // check if we have an action that's enabled on the current partition
- ITypedRegion tr = getPartition(document, textSelection);
- String partition = tr != null ? tr.getType() : ""; //$NON-NLS-1$
-
- Iterator it = getProcessors().iterator();
- FindOccurrencesProcessor processor = null;
- while (it.hasNext()) {
- processor = (FindOccurrencesProcessor) it.next();
- // we just choose the first action that can handle the partition
- if (processor.enabledForParitition(partition))
- return processor;
- }
-
- List extendedFindOccurrencesProcessors = ExtendedConfigurationBuilder.getInstance().getConfigurations(FindOccurrencesProcessor.class.getName(), partition);
- for (int i = 0; i < extendedFindOccurrencesProcessors.size(); i++) {
- Object o = extendedFindOccurrencesProcessors.get(i);
- if (o instanceof FindOccurrencesProcessor) {
- /*
- * We just choose the first registered processor that
- * explicitly says it can handle the partition
- */
- processor = (FindOccurrencesProcessor) o;
- if (processor.enabledForParitition(partition))
- return processor;
- }
- }
- return null;
- }
-
- private ITypedRegion getPartition(IDocument document, ITextSelection textSelection) {
- ITypedRegion region = null;
- if (textSelection != null) {
- try {
- region = document.getPartition(textSelection.getOffset());
- }
- catch (BadLocationException e) {
- region = null;
- }
- }
- return region;
- }
-
- private ITextSelection getTextSelection(ITextEditor textEditor) {
- ITextSelection textSelection = null;
- ISelection selection = textEditor.getSelectionProvider().getSelection();
- if (selection instanceof ITextSelection && !selection.isEmpty()) {
- textSelection = (ITextSelection) selection;
- }
- return textSelection;
- }
-
- protected List getProcessors() {
- if (fProcessors == null) {
- fProcessors = new ArrayList();
- XMLFindOccurrencesProcessor htmlProcessor = new XMLFindOccurrencesProcessor();
- fProcessors.add(htmlProcessor);
- }
- return fProcessors;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/CatalogEntryHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/CatalogEntryHyperlink.java
deleted file mode 100644
index 7ef29868a2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/CatalogEntryHyperlink.java
+++ /dev/null
@@ -1,116 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import java.io.File;
-import java.net.MalformedURLException;
-import java.net.URL;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-class CatalogEntryHyperlink implements IHyperlink {
-
- private IRegion fHyperlinkRegion = null;
- private ICatalogEntry fEntry = null;
-
- /**
- * @param hyperlinkRegion
- * @param entry
- */
- CatalogEntryHyperlink(IRegion hyperlinkRegion, ICatalogEntry entry) {
- super();
- fHyperlinkRegion = hyperlinkRegion;
- fEntry = entry;
- }
-
- /**
- * @return
- */
- private IHyperlink getHyperlink() {
- if (fEntry.getURI().startsWith("file:")) { //$NON-NLS-1$
- return new ExternalFileHyperlink(fHyperlinkRegion, new File(fEntry.getURI().substring(5)));
- }
- else if (fEntry.getURI().startsWith("platform:/resource/")) { //$NON-NLS-1$
- IPath path = new Path(fEntry.getURI().substring(20));
- if (path.segmentCount() > 1)
- return new WorkspaceFileHyperlink(fHyperlinkRegion, ResourcesPlugin.getWorkspace().getRoot().getFile(path));
- }
- else {
- /*
- * the URL detector will already work on the literal text, so
- * offer to open the contents in an editor
- */
- try {
- if (fEntry.getURI().startsWith("jar:file:"))
- return new URLStorageHyperlink(fHyperlinkRegion, new URL(fEntry.getURI())) {
- public String getHyperlinkText() {
- return NLS.bind(XMLUIMessages.Open, fEntry.getKey());
- }
- };
- }
- catch (MalformedURLException e) {
- // not valid?
- }
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkRegion()
- */
- public IRegion getHyperlinkRegion() {
- return fHyperlinkRegion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- IHyperlink link = getHyperlink();
- if (link != null)
- return link.getHyperlinkText();
- return NLS.bind(XMLUIMessages.Open, fEntry.getKey());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- IHyperlink link = getHyperlink();
- if (link != null)
- return link.getTypeLabel();
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
- */
- public void open() {
- IHyperlink link = getHyperlink();
- if (link != null)
- link.open();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java
deleted file mode 100644
index 86e85d05a2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileEditorInput.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-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.IPathEditorInput;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.editors.text.ILocationProvider;
-import org.eclipse.ui.model.IWorkbenchAdapter;
-
-/**
- * EditorInput for external files. Copied from
- * org.eclipse.ui.internal.editors.text.JavaFileEditorInput
- */
-class ExternalFileEditorInput implements IEditorInput, ILocationProvider {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- /**
- * The workbench adapter which simply provides the label.
- */
- private class WorkbenchAdapter implements IWorkbenchAdapter {
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getChildren(java.lang.Object)
- */
- public Object[] getChildren(Object o) {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getImageDescriptor(java.lang.Object)
- */
- public ImageDescriptor getImageDescriptor(Object object) {
- return null;
- }
-
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getLabel(java.lang.Object)
- */
- public String getLabel(Object o) {
- return ((ExternalFileEditorInput) o).getName();
- }
-
- /*
- * @see org.eclipse.ui.model.IWorkbenchAdapter#getParent(java.lang.Object)
- */
- public Object getParent(Object o) {
- return null;
- }
- }
-
- private File fFile;
- private WorkbenchAdapter fWorkbenchAdapter = new WorkbenchAdapter();
-
- public ExternalFileEditorInput(File file) {
- super();
- fFile = file;
- fWorkbenchAdapter = new WorkbenchAdapter();
- }
-
- /*
- * @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;
- }
- if (IWorkbenchAdapter.class.equals(adapter)) {
- return fWorkbenchAdapter;
- }
- 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 Path.fromOSString(input.fFile.getAbsolutePath());
- }
- return null;
- }
-
- /*
- * @see org.eclipse.ui.IPathEditorInput#getPath()
- * @since 3.1
- */
- public IPath getPath() {
- return Path.fromOSString(fFile.getAbsolutePath());
- }
-
- /*
- * @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);
- }
-
- if (o instanceof IPathEditorInput) {
- IPathEditorInput input = (IPathEditorInput) o;
- return getPath().equals(input.getPath());
- }
-
- return false;
- }
-
- /*
- * @see java.lang.Object#hashCode()
- */
- public int hashCode() {
- return fFile.hashCode();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java
deleted file mode 100644
index 6761969c3c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/ExternalFileHyperlink.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import java.io.File;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Hyperlink for external files.
- */
-class ExternalFileHyperlink implements IHyperlink {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- private IRegion fHyperlinkRegion;
- private File fHyperlinkFile;
-
- public ExternalFileHyperlink(IRegion region, File file) {
- fHyperlinkFile = file;
- fHyperlinkRegion = region;
- }
-
- public IRegion getHyperlinkRegion() {
- return fHyperlinkRegion;
- }
-
- public String getTypeLabel() {
- return null;
- }
-
- public String getHyperlinkText() {
- String path = fHyperlinkFile.getPath();
- if (path.length() > 60) {
- path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
- }
- return NLS.bind(XMLUIMessages.Open, path);
- }
-
- public void open() {
- if (fHyperlinkFile != null) {
- IEditorInput input = new ExternalFileEditorInput(fHyperlinkFile);
- IEditorDescriptor descriptor;
- try {
- descriptor = IDE.getEditorDescriptor(input.getName(), true);
- if (descriptor != null) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IDE.openEditor(page, input, descriptor.getId(), true);
- }
- }
- catch (PartInitException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/URLStorageHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/URLStorageHyperlink.java
deleted file mode 100644
index bc4b03f92c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/URLStorageHyperlink.java
+++ /dev/null
@@ -1,180 +0,0 @@
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import org.eclipse.core.resources.IStorage;
-import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.jface.text.hyperlink.URLHyperlink;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.IEditorDescriptor;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IPersistableElement;
-import org.eclipse.ui.IStorageEditorInput;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.wst.sse.core.internal.util.JarUtilities;
-import org.eclipse.wst.xml.core.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * Hyperlink for URLs (opens in read-only mode)
- */
-class URLStorageHyperlink implements IHyperlink {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- static class StorageEditorInput implements IStorageEditorInput {
- IStorage fStorage = null;
-
- StorageEditorInput(IStorage storage) {
- fStorage = storage;
- }
-
- public IStorage getStorage() throws CoreException {
- return fStorage;
- }
-
- public boolean exists() {
- return fStorage != null;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof StorageEditorInput) {
- return fStorage.equals(((StorageEditorInput) obj).fStorage);
- }
- return super.equals(obj);
- }
-
- public ImageDescriptor getImageDescriptor() {
- return null;
- }
-
- public String getName() {
- return fStorage.getName();
- }
-
- public IPersistableElement getPersistable() {
- return null;
- }
-
- public String getToolTipText() {
- return fStorage.getFullPath() != null ? fStorage.getFullPath().toString() : fStorage.getName();
- }
-
- public Object getAdapter(Class adapter) {
- return null;
- }
- }
-
- static class URLStorage implements IStorage {
- URL fURL = null;
-
- URLStorage(URL url) {
- fURL = url;
- }
-
- public boolean equals(Object obj) {
- if (obj instanceof URLStorage) {
- return fURL.equals(((URLStorage) obj).fURL);
- }
- return super.equals(obj);
- }
-
- public InputStream getContents() throws CoreException {
- InputStream stream = null;
- try {
- if (fURL.toString().startsWith("jar:file"))
- stream = JarUtilities.getInputStream(fURL);
- else
- stream = fURL.openStream();
- }
- catch (Exception e) {
- throw new CoreException(new Status(IStatus.ERROR, XMLUIPlugin.getDefault().getBundle().getSymbolicName(), IStatus.ERROR, fURL.toString(), e));
- }
- return stream;
- }
-
- public IPath getFullPath() {
- return new Path(fURL.toString());
- }
-
- public String getName() {
- return new Path(fURL.getFile()).lastSegment();
- }
-
- public boolean isReadOnly() {
- return true;
- }
-
- public Object getAdapter(Class adapter) {
- return null;
- }
-
- }
-
- private IRegion fRegion;
- private URL fURL;
-
- public URLStorageHyperlink(IRegion region, URL url) {
- fRegion = region;
- fURL = url;
- }
-
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- return NLS.bind(XMLUIMessages.Open, fURL.toString());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#open()
- */
- public void open() {
- if (fURL != null) {
- IEditorInput input = new StorageEditorInput(new URLStorage(fURL));
- IEditorDescriptor descriptor;
- try {
- descriptor = IDE.getEditorDescriptor(input.getName());
- if (descriptor != null) {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IDE.openEditor(page, input, descriptor.getId(), true);
- }
- }
- catch (PartInitException e) {
- Logger.log(Logger.WARNING_DEBUG, e.getMessage(), e);
- new URLHyperlink(fRegion, fURL.toString()).open();
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java
deleted file mode 100644
index 0319952b04..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/WorkspaceFileHyperlink.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.ui.IWorkbenchPage;
-import org.eclipse.ui.PartInitException;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.ide.IDE;
-import org.eclipse.ui.texteditor.ITextEditor;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Hyperlink for files within the workspace. (As long as there is an IFile,
- * this can be used) Opens the default editor for the file.
- */
-class WorkspaceFileHyperlink implements IHyperlink {
- // copies of this class exist in:
- // org.eclipse.wst.xml.ui.internal.hyperlink
- // org.eclipse.wst.html.ui.internal.hyperlink
- // org.eclipse.jst.jsp.ui.internal.hyperlink
-
- private IRegion fRegion;
- private IFile fFile;
- private IRegion fHighlightRange;
-
- public WorkspaceFileHyperlink(IRegion region, IFile file) {
- fRegion = region;
- fFile = file;
- }
-
- public WorkspaceFileHyperlink(IRegion region, IFile file, IRegion range) {
- fRegion = region;
- fFile = file;
- fHighlightRange = range;
- }
-
- public IRegion getHyperlinkRegion() {
- return fRegion;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getTypeLabel()
- */
- public String getTypeLabel() {
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.hyperlink.IHyperlink#getHyperlinkText()
- */
- public String getHyperlinkText() {
- String path = fFile.getFullPath().toString();
- if (path.length() > 60) {
- path = path.substring(0, 25) + "..." + path.substring(path.length() - 25, path.length());
- }
- return NLS.bind(XMLUIMessages.Open, path);
- }
-
- public void open() {
- if ((fFile != null) && fFile.exists()) {
- try {
- IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
- IEditorPart editor = IDE.openEditor(page, fFile, true);
- // highlight range in editor if possible
- if ((fHighlightRange != null) && (editor instanceof ITextEditor)) {
- ((ITextEditor) editor).setHighlightRange(fHighlightRange.getOffset(), fHighlightRange.getLength(), true);
- }
- }
- catch (PartInitException pie) {
- Logger.log(Logger.WARNING_DEBUG, pie.getMessage(), pie);
- }
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
deleted file mode 100644
index 09abdc3985..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/hyperlink/XMLHyperlinkDetector.java
+++ /dev/null
@@ -1,569 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.hyperlink;
-
-import java.io.File;
-import java.net.URI;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.hyperlink.AbstractHyperlinkDetector;
-import org.eclipse.jface.text.hyperlink.IHyperlink;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DocumentType;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-import com.ibm.icu.util.StringTokenizer;
-
-/**
- * Detects hyperlinks in XML tags. Includes detection in DOCTYPE and attribute
- * values. Resolves references to schemas, dtds, etc using the Common URI
- * Resolver.
- *
- */
-public class XMLHyperlinkDetector extends AbstractHyperlinkDetector {
- private final String NO_NAMESPACE_SCHEMA_LOCATION = "noNamespaceSchemaLocation"; //$NON-NLS-1$
- private final String SCHEMA_LOCATION = "schemaLocation"; //$NON-NLS-1$
- private final String XMLNS = "xmlns"; //$NON-NLS-1$
- private final String XSI_NAMESPACE_URI = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
-
- /**
- * Create the appropriate hyperlink
- *
- * @param uriString
- * @param hyperlinkRegion
- * @return IHyperlink
- */
- private IHyperlink createHyperlink(String uriString, IRegion hyperlinkRegion, IDocument document, Node node) {
- IHyperlink link = null;
-
- ICatalogEntry entry = getCatalogEntry(uriString);
- if (entry != null) {
- link = new CatalogEntryHyperlink(hyperlinkRegion, entry);
- }
- else {
- // try to locate the file in the workspace
- File systemFile = getFileFromUriString(uriString);
- if (systemFile != null) {
- String systemPath = systemFile.getPath();
- IFile file = getFile(systemPath);
- if (file != null) {
- // this is a WorkspaceFileHyperlink since file exists in
- // workspace
- link = new WorkspaceFileHyperlink(hyperlinkRegion, file);
- }
- else {
- // this is an ExternalFileHyperlink since file does not
- // exist in workspace
- link = new ExternalFileHyperlink(hyperlinkRegion, systemFile);
- }
- }
- }
- return link;
- }
-
- public IHyperlink[] detectHyperlinks(ITextViewer textViewer, IRegion region, boolean canShowMultipleHyperlinks) {
- // for now, only capable of creating 1 hyperlink
- List hyperlinks = new ArrayList(0);
-
- if ((region != null) && (textViewer != null)) {
- IDocument document = textViewer.getDocument();
- Node currentNode = getCurrentNode(document, region.getOffset());
- if (currentNode != null) {
- String uriString = null;
- if (currentNode.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
- // doctype nodes
- uriString = getURIString(currentNode, document);
- }
- else if (currentNode.getNodeType() == Node.ELEMENT_NODE) {
- // element nodes
- Attr currentAttr = getCurrentAttrNode(currentNode, region.getOffset());
- if (currentAttr != null) {
- // try to find link for current attribute
- // resolve attribute value
- uriString = getURIString(currentAttr, document);
- // verify validity of uri string
- if ((uriString == null) || !isValidURI(uriString)) {
- // reset current attribute
- currentAttr = null;
- }
- }
- if (currentAttr == null) {
- // try to find a linkable attribute within element
- currentAttr = getLinkableAttr((Element) currentNode);
- if (currentAttr != null) {
- uriString = getURIString(currentAttr, document);
- }
- }
- currentNode = currentAttr;
- }
- // try to create hyperlink from information gathered
- if ((uriString != null) && (currentNode != null) && isValidURI(uriString)) {
- IRegion hyperlinkRegion = getHyperlinkRegion(currentNode);
- IHyperlink hyperlink = createHyperlink(uriString, hyperlinkRegion, document, currentNode);
- if (hyperlink != null) {
- hyperlinks.add(hyperlink);
- }
- }
- }
- }
- if (hyperlinks.size() == 0) {
- return null;
- }
- return (IHyperlink[]) hyperlinks.toArray(new IHyperlink[0]);
- }
-
- /**
- * Get the base location from the current model (local file system)
- */
- private String getBaseLocation(IDocument document) {
- String result = null;
-
- // get the base location from the current model
- IStructuredModel sModel = null;
- try {
- sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (sModel != null) {
- result = sModel.getBaseLocation();
-
- IPath path = new Path(result);
- if (path.segmentCount() > 1) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- if (file.exists()) {
- String baseLocation = null;
- if (file.getLocation() != null) {
- baseLocation = file.getLocation().toString();
- }
- if (baseLocation == null && file.getLocationURI() != null) {
- baseLocation = file.getLocationURI().toString();
- }
- if (baseLocation == null) {
- baseLocation = file.getFullPath().toString();
- }
- result = baseLocation;
- }
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
- return result;
- }
-
- /**
- * Get the CMElementDeclaration for an element
- *
- * @param element
- * @return CMElementDeclaration
- */
- private CMElementDeclaration getCMElementDeclaration(Element element) {
- CMElementDeclaration ed = null;
-
- ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if (mq != null) {
- ed = mq.getCMElementDeclaration(element);
- }
- return ed;
- }
-
- /**
- * Returns the attribute node within node at offset
- *
- * @param node
- * @param offset
- * @return Attr
- */
- private Attr getCurrentAttrNode(Node node, int offset) {
- if ((node instanceof IndexedRegion) && ((IndexedRegion) node).contains(offset) && (node.hasAttributes())) {
- NamedNodeMap attrs = node.getAttributes();
- // go through each attribute in node and if attribute contains
- // offset, return that attribute
- for (int i = 0; i < attrs.getLength(); ++i) {
- // assumption that if parent node is of type IndexedRegion,
- // then its attributes will also be of type IndexedRegion
- IndexedRegion attRegion = (IndexedRegion) attrs.item(i);
- if (attRegion.contains(offset)) {
- return (Attr) attrs.item(i);
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the node the cursor is currently on in the document. null if no
- * node is selected
- *
- * @param offset
- * @return Node either element, doctype, text, or null
- */
- private Node getCurrentNode(IDocument document, int offset) {
- // get the current node at the offset (returns either: element,
- // doctype, text)
- IndexedRegion inode = null;
- IStructuredModel sModel = null;
- try {
- sModel = StructuredModelManager.getModelManager().getExistingModelForRead(document);
- if (sModel != null) {
- inode = sModel.getIndexedRegion(offset);
- if (inode == null) {
- inode = sModel.getIndexedRegion(offset - 1);
- }
- }
- }
- finally {
- if (sModel != null) {
- sModel.releaseFromRead();
- }
- }
-
- if (inode instanceof Node) {
- return (Node) inode;
- }
- return null;
- }
-
- /**
- * 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
- */
- private IFile getFile(String fileString) {
- IFile file = null;
-
- if (fileString != null) {
- Path filePath = new Path(fileString);
- if (filePath.segmentCount() > 1 && ResourcesPlugin.getWorkspace().getRoot().getFile(filePath).exists()) {
- return ResourcesPlugin.getWorkspace().getRoot().getFile(filePath);
- }
- IFile[] files = ResourcesPlugin.getWorkspace().getRoot().findFilesForLocation(filePath);
- for (int i = 0; (i < files.length) && (file == null); i++) {
- if (files[i].exists()) {
- file = files[i];
- }
- }
- }
-
- return file;
- }
-
- /**
- * Create a file from the given uri string
- *
- * @param uriString -
- * assumes uriString is not http://
- * @return File created from uriString if possible, null otherwise
- */
- private File getFileFromUriString(String uriString) {
- File file = null;
- try {
- // first just try to create a file directly from uriString as
- // default in case create file from uri does not work
- file = new File(uriString);
-
- // try to create file from uri
- URI uri = new URI(uriString);
- file = new File(uri);
- }
- catch (Exception e) {
- // if exception is thrown while trying to create File just ignore
- // and file will be null
- }
- return file;
- }
-
- private IRegion getHyperlinkRegion(Node node) {
- IRegion hyperRegion = null;
-
- if (node != null) {
- short nodeType = node.getNodeType();
- if (nodeType == Node.DOCUMENT_TYPE_NODE) {
- // handle doc type node
- IDOMNode docNode = (IDOMNode) node;
- hyperRegion = new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());
- }
- else if (nodeType == Node.ATTRIBUTE_NODE) {
- // handle attribute nodes
- IDOMAttr att = (IDOMAttr) node;
- // do not include quotes in attribute value region
- int regOffset = att.getValueRegionStartOffset();
- ITextRegion valueRegion = att.getValueRegion();
- if (valueRegion != null) {
- int regLength = valueRegion.getTextLength();
- String attValue = att.getValueRegionText();
- if (StringUtils.isQuoted(attValue)) {
- ++regOffset;
- regLength = regLength - 2;
- }
- hyperRegion = new Region(regOffset, regLength);
- }
- }
- }
- return hyperRegion;
- }
-
- /**
- * Attempts to find an attribute within element that is openable.
- *
- * @param element -
- * cannot be null
- * @return Attr attribute that can be used for open on, null if no
- * attribute could be found
- */
- private Attr getLinkableAttr(Element element) {
- CMElementDeclaration ed = getCMElementDeclaration(element);
- // get the list of attributes for this node
- NamedNodeMap attrs = element.getAttributes();
- for (int i = 0; i < attrs.getLength(); ++i) {
- // check if this attribute is "openOn-able"
- Attr att = (Attr) attrs.item(i);
- if (isLinkableAttr(att, ed)) {
- return att;
- }
- }
- return null;
- }
-
- /**
- * Find the location hint for the given namespaceURI if it exists
- *
- * @param elementNode -
- * cannot be null
- * @param namespaceURI -
- * cannot be null
- * @return location hint (systemId) if it was found, null otherwise
- */
- private String getLocationHint(Element elementNode, String namespaceURI) {
- Attr schemaLocNode = elementNode.getAttributeNodeNS(XSI_NAMESPACE_URI, SCHEMA_LOCATION);
- if (schemaLocNode != null) {
- StringTokenizer st = new StringTokenizer(schemaLocNode.getValue());
- while (st.hasMoreTokens()) {
- String publicId = st.hasMoreTokens() ? st.nextToken() : null;
- String systemId = st.hasMoreTokens() ? st.nextToken() : null;
- // found location hint
- if (namespaceURI.equalsIgnoreCase(publicId)) {
- return systemId;
- }
- }
- }
- return null;
- }
-
- /**
- * Returns the URI string
- *
- * @param node -
- * assumes not null
- */
- private String getURIString(Node node, IDocument document) {
- String resolvedURI = null;
- // need the base location, publicId, and systemId for URIResolver
- String baseLoc = null;
- String publicId = null;
- String systemId = null;
-
- short nodeType = node.getNodeType();
- // handle doc type node
- if (nodeType == Node.DOCUMENT_TYPE_NODE) {
- baseLoc = getBaseLocation(document);
- publicId = ((DocumentType) node).getPublicId();
- systemId = ((DocumentType) node).getSystemId();
- }
- else if (nodeType == Node.ATTRIBUTE_NODE) {
- // handle attribute node
- Attr attrNode = (Attr) node;
- String attrName = attrNode.getName();
- String attrValue = attrNode.getValue();
- attrValue = StringUtils.strip(attrValue);
- if ((attrValue != null) && (attrValue.length() > 0)) {
- baseLoc = getBaseLocation(document);
-
- // handle schemaLocation attribute
- String prefix = DOMNamespaceHelper.getPrefix(attrName);
- String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
- if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
- publicId = attrValue;
- systemId = getLocationHint(attrNode.getOwnerElement(), publicId);
- if (systemId == null) {
- systemId = attrValue;
- }
- }
- else if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attrNode))) && (SCHEMA_LOCATION.equals(unprefixedName))) {
- // for now just use the first pair
- // need to look into being more precise
- StringTokenizer st = new StringTokenizer(attrValue);
- publicId = st.hasMoreTokens() ? st.nextToken() : null;
- systemId = st.hasMoreTokens() ? st.nextToken() : null;
- // else check if xmlns publicId = value
- }
- else {
- systemId = attrValue;
- }
- }
- }
-
- resolvedURI = resolveURI(baseLoc, publicId, systemId);
- return resolvedURI;
- }
-
- /**
- * Checks to see if the given attribute is openable. Attribute is openable
- * if it is a namespace declaration attribute or if the attribute value is
- * of type URI.
- *
- * @param attr
- * cannot be null
- * @param cmElement
- * CMElementDeclaration associated with the attribute (can be
- * null)
- * @return true if this attribute is "openOn-able" false otherwise
- */
- private boolean isLinkableAttr(Attr attr, CMElementDeclaration cmElement) {
- String attrName = attr.getName();
- String prefix = DOMNamespaceHelper.getPrefix(attrName);
- String unprefixedName = DOMNamespaceHelper.getUnprefixedName(attrName);
- // determine if attribute is namespace declaration
- if ((XMLNS.equals(prefix)) || (XMLNS.equals(unprefixedName))) {
- return true;
- }
-
- // determine if attribute contains schema location
- if ((XSI_NAMESPACE_URI.equals(DOMNamespaceHelper.getNamespaceURI(attr))) && ((SCHEMA_LOCATION.equals(unprefixedName)) || (NO_NAMESPACE_SCHEMA_LOCATION.equals(unprefixedName)))) {
- return true;
- }
-
- // determine if attribute value is of type URI
- if (cmElement != null) {
- CMNamedNodeMap attrDecls = cmElement.getAttributes();
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrDecls);
- List nodes = ModelQueryUtil.getModelQuery(attr.getOwnerDocument()).getAvailableContent(attr.getOwnerElement(), cmElement, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attrDecls = allAttributes;
-
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attrDecls.getNamedItem(attrName);
- if ((attrDecl != null) && (attrDecl.getAttrType() != null) && (CMDataType.URI.equals(attrDecl.getAttrType().getDataTypeName()))) {
- return true;
- }
- }
- return false;
- }
-
- /**
- * Checks whether the given uriString is really pointing to a file
- *
- * @param uriString
- * @return boolean
- */
- private boolean isValidURI(String uriString) {
- boolean isValid = false;
-
- if (getCatalogEntry(uriString) != null) {
- isValid = true;
- }
- else {
- File file = getFileFromUriString(uriString);
- if (file != null) {
- isValid = file.isFile();
- }
- if(!isValid) {
- }
-
- }
- return isValid;
- }
-
- /**
- * @param uriString
- * @return
- */
- private ICatalogEntry getCatalogEntry(String uriString) {
- ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
- if (defaultCatalog != null) {
- // Process default catalog
- ICatalogEntry[] entries = defaultCatalog.getCatalogEntries();
- for (int entry = 0; entry < entries.length; entry++) {
- if (uriString.equals(entries[entry].getKey())||uriString.equals(entries[entry].getURI())) {
- return entries[entry];
- }
- }
-
- // Process declared OASIS nextCatalogs catalog
- INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
- for (int nextCatalog = 0; nextCatalog < nextCatalogs.length; nextCatalog++) {
- ICatalog catalog = nextCatalogs[nextCatalog].getReferencedCatalog();
- ICatalogEntry[] entries2 = catalog.getCatalogEntries();
- for (int entry = 0; entry < entries2.length; entry++) {
- if (uriString.equals(entries2[entry].getKey())||uriString.equals(entries2[entry].getURI()))
- return entries2[entry];
- }
- }
- }
- return null;
- }
-
- /**
- * Resolves the given URI information
- *
- * @param baseLocation
- * @param publicId
- * @param systemId
- * @return String resolved uri.
- */
- private String resolveURI(String baseLocation, String publicId, String systemId) {
- // dont resolve if there's nothing to resolve
- if ((baseLocation == null) && (publicId == null) && (systemId == null)) {
- return null;
- }
- return URIResolverPlugin.createResolver().resolve(baseLocation, publicId, systemId);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java
deleted file mode 100644
index 2782c4778c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesControl.java
+++ /dev/null
@@ -1,281 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.nsedit;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.part.PageBook;
-import org.eclipse.wst.common.uriresolver.internal.provisional.URIResolverPlugin;
-import org.eclipse.wst.common.uriresolver.internal.util.URIHelper;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.dialogs.SelectFileOrXMLCatalogIdDialog;
-
-public class CommonAddNamespacesControl extends Composite implements SelectionListener {
-
- class EditNamespaceControl extends Composite {
- protected Button browseButton;
- Text locationHintField;
- Text prefixField;
- Text uriField;
-
- // protected NamespaceInfo info;
-
- public EditNamespaceControl(Composite parent) {
- super(parent, SWT.NONE); // BORDER);
- setLayout(new GridLayout());
- setLayoutData(new GridData(GridData.FILL_BOTH));
-
- Label label = new Label(this, SWT.NONE);
- label.setText(XMLUIMessages._UI_ENTER_REQ_PREFIX_AND_NAMESPACE);
-
- Composite composite = new Composite(this, SWT.NONE);
- GridLayout layout = new GridLayout();
- layout.numColumns = 3;
- layout.marginWidth = 0;
- layout.verticalSpacing = 1;
- composite.setLayout(layout);
-
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.widthHint = 350;
- composite.setLayoutData(gd);
-
- // row 1
- //
- Label prefixLabel = new Label(composite, SWT.NONE);
- prefixLabel.setText(XMLUIMessages._UI_LABEL_PREFIX_COLON);
-
- prefixField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- prefixField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // prefixField.setText(getDisplayValue(info.prefix));
- // prefixField.addModifyListener(modifyListener);
- // prefixField.setEnabled(info.getProperty("prefix-readOnly") ==
- // null);
- new Label(composite, SWT.NONE);
-
- // row 2
- //
- Label uriLabel = new Label(composite, SWT.NONE);
- uriLabel.setText(XMLUIMessages._UI_LABEL_NAMESPACE_NAME_COLON);
-
- uriField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- uriField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // uriField.setText(getDisplayValue(info.uri));
- // uriField.addModifyListener(modifyListener);
- // uriField.setEnabled(info.getProperty("uri-readOnly") == null);
-
- new Label(composite, SWT.NONE);
-
- // row 3
- //
- Label locationHintLabel = new Label(composite, SWT.NONE);
- locationHintLabel.setText(XMLUIMessages._UI_LABEL_LOCATION_HINT_COLON);
-
- locationHintField = new Text(composite, SWT.SINGLE | SWT.BORDER);
- locationHintField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // locationHintField.setText(getDisplayValue(info.locationHint));
- // locationHintField.addModifyListener(modifyListener);
- // locationHintField.setEnabled(info.getProperty("locationHint-readOnly")
- // == null);
-
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- performBrowse();
- }
- };
-
- browseButton = new Button(composite, SWT.NONE);
- browseButton.setText(XMLUIMessages._UI_LABEL_BROWSE);
- browseButton.addSelectionListener(selectionListener);
- browseButton.setEnabled(locationHintField.getEnabled());
- }
-
- protected void performBrowse() {
- String[] extensions = {".xsd"}; //$NON-NLS-1$
- SelectFileOrXMLCatalogIdDialog dialog = new SelectFileOrXMLCatalogIdDialog(getShell(), extensions);
- dialog.create();
- dialog.getShell().setText(XMLUIMessages._UI_LABEL_SELECT_FILE);
- dialog.setBlockOnOpen(true);
- dialog.open();
-
- if (dialog.getReturnCode() == Window.OK) {
- // String grammarURI = null;
- IFile file = dialog.getFile();
- String id = dialog.getId();
- if (file != null) {
- String uri = null;
- if (resourceLocation != null) {
- IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(resourceLocation);
- if (resource != null) {
- IPath location = resource.getLocation();
- if (location != null) {
- uri = URIHelper.getRelativeURI(file.getLocation(), location);
- }
- }
- else {
- uri = URIHelper.getRelativeURI(file.getLocation(), resourceLocation);
- }
- // grammarURI = file.getLocation().toOSString();
- }
- else {
- uri = file.getLocation().toOSString();
- // grammarURI = uri;
- }
- locationHintField.setText(uri);
- }
- else if (id != null) {
- locationHintField.setText(id);
- // URIResolver resolver =
- URIResolverPlugin.createResolver();
- // grammarURI = resolver.resolve(null, id, id);
- }
-
- try {
- // TODO CMDocument document =
- // CMDocumentBuilderRegistry.getInstance().buildCMDocument(grammarURI);
- // List namespaceInfoList =
- // (List)document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo");
- // NamespaceInfo info =
- // (NamespaceInfo)namespaceInfoList.get(0);
- // if (uriField.getText().trim().length() == 0 && info.uri
- // != null)
- // {
- // uriField.setText(info.uri);
- // }
- // if (prefixField.getText().trim().length() == 0 &&
- // info.prefix != null)
- // {
- // prefixField.setText(info.prefix);
- // }
- }
- catch (Exception e) {
- }
- }
- }
- }
-
- protected Button deleteButton;
- protected Button editButton;
- protected EditNamespaceControl editNamespaceControl;
- protected int heightHint = 250;
- protected List namespaceInfoList = new ArrayList();
- protected Button newButton;
- protected PageBook pageBook;
- protected Button radio1;
- protected Button radio2;
- protected IPath resourceLocation;
- protected Composite tableSection;
- protected CommonNamespaceInfoTable tableViewer;
- protected int widthHint = 500;
-
-
- public CommonAddNamespacesControl(Composite parent, int style, IPath resourceLocation) {
- super(parent, style);
- this.resourceLocation = resourceLocation;
- GridData gd = new GridData(GridData.FILL_BOTH);
- if (widthHint != -1) {
- gd.widthHint = widthHint;
- }
- if (heightHint != -1) {
- gd.heightHint = heightHint;
- }
- setLayoutData(gd);
- setLayout(new GridLayout());
-
- radio1 = new Button(this, SWT.RADIO);
- radio1.setText(XMLUIMessages._UI_SELECT_REGISTERED_NAMESPACES);
- radio1.addSelectionListener(this);
-
- radio2 = new Button(this, SWT.RADIO);
- radio2.setText(XMLUIMessages._UI_SPECIFY_NEW_NAMESPACE);
- radio2.addSelectionListener(this);
-
- Label separator = new Label(this, SWT.SEPARATOR | SWT.HORIZONTAL);
- separator.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- // Group namespaceInfoGroup = new Group(this, SWT.NONE);
- // namespaceInfoGroup.setText("Namespace Declarations");
- // //XMLCommonUIPlugin.getInstance().getString("_UI_LABEL_XML_SCHEMA_INFORMATION"));
- // namespaceInfoGroup.setLayout(new GridLayout(2, false));
- // namespaceInfoGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
- pageBook = new PageBook(this, SWT.NONE);
- pageBook.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- tableSection = new Composite(pageBook, SWT.NONE);
- tableSection.setLayout(new GridLayout());
- Label label = new Label(tableSection, SWT.NONE);
- label.setText(XMLUIMessages._UI_SELECT_NAMESPACE_TO_ADD);
-
- tableViewer = new CommonNamespaceInfoTable(tableSection, SWT.CHECK, 6);
- editNamespaceControl = new EditNamespaceControl(pageBook);
- pageBook.showPage(tableSection);
-
- tableViewer.setInput(namespaceInfoList);
- }
-
-
-
- public List getNamespaceInfoList() {
- List list = new ArrayList();
- if (radio1.getSelection()) {
- TableItem[] items = tableViewer.getTable().getItems();
- for (int i = 0; i < items.length; i++) {
- TableItem item = items[i];
- if (item.getChecked()) {
- list.add(item.getData());
- }
- }
- }
- else {
- NamespaceInfo info = new NamespaceInfo();
- info.prefix = editNamespaceControl.prefixField.getText();
- info.uri = editNamespaceControl.uriField.getText();
- info.locationHint = editNamespaceControl.locationHintField.getText();
- list.add(info);
- }
- return list;
- }
-
- public void setNamespaceInfoList(List list) {
- namespaceInfoList = list;
- tableViewer.setInput(namespaceInfoList);
- }
-
- public void widgetDefaultSelected(SelectionEvent e) {
- }
-
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == radio1) {
- pageBook.showPage(tableSection);
- }
- else if (e.widget == radio2) {
- pageBook.showPage(editNamespaceControl);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java
deleted file mode 100644
index 269113fea8..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonAddNamespacesDialog.java
+++ /dev/null
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.nsedit;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.dialogs.IDialogConstants;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalog;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.ICatalogEntry;
-import org.eclipse.wst.xml.core.internal.catalog.provisional.INextCatalog;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-
-
-
-public class CommonAddNamespacesDialog extends Dialog {
- protected CommonAddNamespacesControl addNamespacesControl;
- protected List existingNamespaces;
- protected List namespaceInfoList;
- protected Button okButton;
- protected HashMap preferredPrefixTable = new HashMap();
- protected IPath resourceLocation;
- protected String title;
-
- public CommonAddNamespacesDialog(Shell parentShell, String title, IPath resourceLocation, List existingNamespaces) {
- super(parentShell);
- this.resourceLocation = resourceLocation;
- setShellStyle(getShellStyle() | SWT.RESIZE);
- this.title = title;
- this.existingNamespaces = existingNamespaces;
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/", "wsdl"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/soap/", "soap"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/http/", "http"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/wsdl/mime/", "mime"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/soap/encoding/", "soapenc"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://schemas.xmlsoap.org/soap/envelope/", "soapenv"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://www.w3.org/2001/XMLSchema-instance", "xsi"); //$NON-NLS-1$ //$NON-NLS-2$
- preferredPrefixTable.put("http://www.w3.org/2001/XMLSchema", "xsd"); //$NON-NLS-1$ //$NON-NLS-2$
- }
-
- protected void addBuiltInNamespaces(List list) {
- String xsiNamespace = "http://www.w3.org/2001/XMLSchema-instance"; //$NON-NLS-1$
- String xsdNamespace = "http://www.w3.org/2001/XMLSchema"; //$NON-NLS-1$
- if (!isAlreadyDeclared(xsiNamespace)) {
- list.add(new NamespaceInfo("http://www.w3.org/2001/XMLSchema-instance", "xsi", null)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- if (!isAlreadyDeclared(xsdNamespace)) {
- list.add(new NamespaceInfo("http://www.w3.org/2001/XMLSchema", "xsd", null)); //$NON-NLS-1$ //$NON-NLS-2$
- }
- }
-
- protected void addCatalogMapToList(ICatalog catalog, List list) {
- ICatalogEntry[] entries = catalog.getCatalogEntries();
- for (int i = 0; i < entries.length; i++) {
- ICatalogEntry entry = entries[i];
- if ((entry.getEntryType() == ICatalogEntry.ENTRY_TYPE_PUBLIC) && entry.getURI().endsWith(".xsd")) { //$NON-NLS-1$
- if (!isAlreadyDeclared(entry.getKey())) {
- NamespaceInfo namespaceInfo = new NamespaceInfo(entry.getKey(), "xx", null); //$NON-NLS-1$
- list.add(namespaceInfo);
- }
- }
- }
- }
-
- protected void buttonPressed(int buttonId) {
- if (buttonId == IDialogConstants.OK_ID) {
- namespaceInfoList = addNamespacesControl.getNamespaceInfoList();
- }
- super.buttonPressed(buttonId);
- }
-
- public void computeAddablePrefixes(List addableList, List exisitingList) {
- HashMap map = new HashMap();
- for (Iterator i = exisitingList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- if (info.prefix != null) {
- map.put(info.prefix, info);
- }
- }
- for (Iterator i = addableList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- if (info.uri != null) {
- String prefix = (String) preferredPrefixTable.get(info.uri);
- info.prefix = getUniquePrefix(map, prefix, info.uri);
- map.put(info.prefix, info);
- }
- }
- }
-
- public int createAndOpen() {
- create();
- getShell().setText(title);
- Rectangle r = getShell().getBounds();
- getShell().setBounds(r.x + 80, r.y + 80, r.width, r.height);
- setBlockOnOpen(true);
- return open();
- }
-
- protected void createButtonsForButtonBar(Composite parent) {
- okButton = createButton(parent, IDialogConstants.OK_ID, IDialogConstants.OK_LABEL, true);
- createButton(parent, IDialogConstants.CANCEL_ID, IDialogConstants.CANCEL_LABEL, false);
- }
-
- protected Control createContents(Composite parent) {
- Control control = super.createContents(parent);
- return control;
- }
-
-
-
- protected Control createDialogArea(Composite parent) {
- Composite dialogArea = (Composite) super.createDialogArea(parent);
- addNamespacesControl = new CommonAddNamespacesControl(dialogArea, SWT.NONE, resourceLocation);
- List list = new ArrayList();
-
- addBuiltInNamespaces(list);
- ICatalog defaultCatalog = XMLCorePlugin.getDefault().getDefaultXMLCatalog();
- INextCatalog[] nextCatalogs = defaultCatalog.getNextCatalogs();
- for (int i = 0; i < nextCatalogs.length; i++) {
- INextCatalog catalog = nextCatalogs[i];
- ICatalog referencedCatalog = catalog.getReferencedCatalog();
- if (referencedCatalog != null) {
- if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) {
- ICatalog userCatalog = referencedCatalog;
- addCatalogMapToList(userCatalog, list);
-
- }
- else if (XMLCorePlugin.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) {
- ICatalog systemCatalog = referencedCatalog;
- addCatalogMapToList(systemCatalog, list);
- }
- }
- }
-
- computeAddablePrefixes(list, existingNamespaces);
-
- addNamespacesControl.setNamespaceInfoList(list);
- return dialogArea;
- }
-
- public List getNamespaceInfoList() {
- return namespaceInfoList;
- }
-
- protected String getPreferredPrefix(String namespaceURI) {
- return (String) preferredPrefixTable.get(namespaceURI);
- }
-
- private String getUniquePrefix(HashMap prefixMap, String prefix, String uri) {
- if (prefix == null) {
- int lastIndex = uri.lastIndexOf('/');
- if (lastIndex == uri.length() - 1) {
- uri = uri.substring(0, lastIndex);
- lastIndex = uri.lastIndexOf('/');
- }
- prefix = uri.substring(lastIndex + 1);
- if ((prefix.length() > 20) || (prefix.indexOf(':') != -1)) {
- prefix = null;
- }
- }
- if (prefix == null) {
- prefix = "p"; //$NON-NLS-1$
- }
- if (prefixMap.get(prefix) != null) {
- String base = prefix;
- for (int count = 0; prefixMap.get(prefix) != null; count++) {
- prefix = base + count;
- }
- }
- return prefix;
- }
-
- protected boolean isAlreadyDeclared(String namespaceURI) {
- boolean result = false;
- for (Iterator i = existingNamespaces.iterator(); i.hasNext();) {
- NamespaceInfo namespaceInfo = (NamespaceInfo) i.next();
- if (namespaceURI.equals(namespaceInfo.uri)) {
- result = true;
- break;
- }
- }
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java
deleted file mode 100644
index 3a358cd03f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesDialog.java
+++ /dev/null
@@ -1,327 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.nsedit;
-
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.graphics.Color;
-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.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.dialogs.EditNamespaceInfoDialog;
-import org.eclipse.wst.xml.ui.internal.dialogs.NamespaceInfoErrorHelper;
-
-public class CommonEditNamespacesDialog {
- protected Composite commonComposite;
- protected Button deleteButton;
- protected Button editButton;
-
- protected Label errorMessageLabel;
- protected int heightHint = 250;
- protected List namespaceInfoList = new ArrayList();
-
- protected Button newButton;
- protected IPath resourceLocation;
-
- private boolean showLocationText = false;
- protected String tableLabel = ""; //$NON-NLS-1$
- protected CommonNamespaceInfoTable tableViewer;
-
- protected Composite topComposite;
- protected boolean useGroup;
- protected int widthHint = 500;
-
- public CommonEditNamespacesDialog(Composite parent, IPath resourceLocation, String stringTableLabel) {
- this(parent, resourceLocation, stringTableLabel, false, false);
- }
-
- public CommonEditNamespacesDialog(Composite parent, IPath resourceLocation, String stringTableLabel, boolean useGroup, boolean showLocText) {
- this.resourceLocation = resourceLocation;
- tableLabel = stringTableLabel;
- this.useGroup = useGroup;
- showLocationText = showLocText;
-
- GridData gd = new GridData(GridData.FILL_BOTH);
- if (widthHint != -1) {
- gd.widthHint = widthHint;
- }
- if (heightHint != -1) {
- gd.heightHint = heightHint;
- }
-
- // Set GridData and GridLayout for the parent Composite
- parent.setLayoutData(gd);
- parent.setLayout(new GridLayout());
-
- // Create the top Composite
- topComposite = new Composite(parent, SWT.NONE);
- GridData topData = new GridData(GridData.FILL_HORIZONTAL);
- topData.heightHint = 0;
- topComposite.setLayoutData(topData);
- topComposite.setLayout(new GridLayout());
-
- // Create the 'common'/middle Composite
- if (useGroup) {
- commonComposite = new Group(parent, SWT.NONE);
- }
- else {
- commonComposite = new Composite(parent, SWT.NONE);
- }
- commonComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
- commonComposite.setLayout(new GridLayout(3, false));
-
- // Add the error Message Label
- errorMessageLabel = new Label(parent, SWT.NONE);
- errorMessageLabel.setLayoutData(createHorizontalFill());
- Color color = new Color(errorMessageLabel.getDisplay(), 200, 0, 0);
- errorMessageLabel.setForeground(color);
-
- createControlArea();
- }
-
-
- protected void createButtons(Composite parent) {
- Composite composite = new Composite(parent, SWT.NONE);
- composite.setLayoutData(new GridData(GridData.FILL_VERTICAL));
- GridLayout gridLayout = new GridLayout();
- gridLayout.numColumns = 1;
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- composite.setLayout(gridLayout);
-
- SelectionListener selectionListener = new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (e.widget == newButton) {
- performNew();
- }
- else if (e.widget == editButton) {
- performEdit();
- }
- else if (e.widget == deleteButton) {
- performDelete();
- }
- }
- };
-
- // create a composite to hold the three buttons
- Composite buttonComposite = new Composite(composite, SWT.NONE);
- buttonComposite.setLayoutData(createHorizontalFill());
- GridLayout buttonGridLayout = new GridLayout();
- // buttonGridLayout.numColumns = 3;
- // buttonGridLayout.makeColumnsEqualWidth = true;
- buttonComposite.setLayout(buttonGridLayout);
-
- // add the New button
- //
- newButton = new Button(buttonComposite, SWT.NONE);
- // newButton.setText(" " +
- // XMLCommonUIPlugin.getInstance().getString("_UI_BUTTON_NEW") + " ");
- newButton.setText(" " + XMLUIMessages.CommonEditNamespacesDialog_0 + " "); //$NON-NLS-1$ //$NON-NLS-2$
- newButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // ViewUtility.createHorizontalFill());
- newButton.addSelectionListener(selectionListener);
-
- // add the Edit button
- //
- // gd = new GridData();
- // gd.horizontalAlignment = gd.FILL;
- // gd.grabExcessHorizontalSpace = true;
-
- editButton = new Button(buttonComposite, SWT.NONE);
- editButton.setText(XMLUIMessages._UI_BUTTON_EDIT);
- editButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // ViewUtility.createHorizontalFill());
- editButton.addSelectionListener(selectionListener);
-
- // add the Delete button
- //
- // gd = new GridData();
- // gd.horizontalAlignment = gd.FILL;
- // gd.grabExcessHorizontalSpace = true;
-
- deleteButton = new Button(buttonComposite, SWT.NONE);
- deleteButton.setText(XMLUIMessages._UI_BUTTON_DELETE);
- deleteButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); // ViewUtility.createHorizontalFill());
- deleteButton.addSelectionListener(selectionListener);
- }
-
- private void createControlArea() {
- if (useGroup) {
- ((Group) commonComposite).setText(tableLabel);
- }
- else {
- Label label = new Label(commonComposite, SWT.NONE);
- label.setText(tableLabel);
- label.setLayoutData(createGridData(false, 3));
- }
-
- tableViewer = new CommonNamespaceInfoTable(commonComposite, 6, showLocationText);
- tableViewer.getControl().setLayoutData(createGridData(true, 2));
- createButtons(commonComposite);
-
- tableViewer.setInput(namespaceInfoList);
- updateButtonEnabledState();
- ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- updateButtonEnabledState();
- }
- };
- tableViewer.addSelectionChangedListener(selectionChangedListener);
- }
-
- protected GridData createGridData(boolean both, int span) {
- GridData gd = new GridData(both ? GridData.FILL_BOTH : GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = 2;
- return gd;
- }
-
- private GridData createHorizontalFill() {
- GridData gd = new GridData();
- gd.horizontalAlignment = GridData.FILL;
- gd.grabExcessHorizontalSpace = true;
- return gd;
- }
-
-
-
- public NamespaceInfo getNamespaceInfo(String namespace) {
- NamespaceInfo result = null;
- for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) {
- NamespaceInfo info = (NamespaceInfo) i.next();
- if ((info.uri != null) && info.uri.equals(namespace)) {
- result = info;
- break;
- }
- }
- return result;
- }
-
- protected Object getSelection(ISelection selection) {
- if (selection == null) {
- return null;
- } // end of if ()
-
- Object result = null;
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection es = (IStructuredSelection) selection;
- Iterator i = es.iterator();
- if (i.hasNext()) {
- result = i.next();
- }
- }
- return result;
- }
-
- /*
- * Use the returned Composite to add content above the 'common contents'.
- * Note: The GridData for the returned Composite has a heightHint = 0.
- * This means when using the returned Composite, the GridData must be
- * reset, else the Composite and it's contents will not appear.
- */
- protected Composite getTopComposite() {
- return topComposite;
- }
-
- protected EditNamespaceInfoDialog invokeDialog(String title, NamespaceInfo info) {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- EditNamespaceInfoDialog dialog = new EditNamespaceInfoDialog(shell, info);
- dialog.create();
- dialog.getShell().setText(title);
- dialog.setBlockOnOpen(true);
- dialog.setResourceLocation(resourceLocation);
- dialog.open();
- return dialog;
- }
-
- protected void performDelayedUpdate() {
- tableViewer.refresh();
- /*
- * Runnable delayedUpdate = new Runnable() { public void run() {
- * tableViewer.refresh(); } };
- * Display.getCurrent().asyncExec(delayedUpdate);
- */
- // if (updateListener != null)
- // {
- // updateListener.updateOccured(this, namespaceInfoList);
- // }
- }
-
- public void performDelete() {
- ISelection selection = tableViewer.getSelection();
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSelection = (IStructuredSelection) selection;
- namespaceInfoList.removeAll(structuredSelection.toList());
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
- }
- }
-
- public void performEdit() {
- Object selection = getSelection(tableViewer.getSelection());
- if (selection != null) {
- invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, (NamespaceInfo) selection);
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
- }
- }
-
- public void performNew() {
- Shell shell = XMLUIPlugin.getInstance().getWorkbench().getActiveWorkbenchWindow().getShell();
- CommonAddNamespacesDialog dialog = new CommonAddNamespacesDialog(shell, XMLUIMessages._UI_ADD_NAMESPACE_DECLARATIONS, resourceLocation, namespaceInfoList);
- dialog.createAndOpen();
- if (dialog.getReturnCode() == Window.OK) {
- namespaceInfoList.addAll(dialog.getNamespaceInfoList());
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
- }
- }
-
- public void setNamespaceInfoList(List list) {
- namespaceInfoList = list;
- tableViewer.setInput(namespaceInfoList);
- }
-
- public void updateButtonEnabledState() {
- Object selection = getSelection(tableViewer.getSelection());
- NamespaceInfo info = (NamespaceInfo) selection;
- editButton.setEnabled(info != null);
- deleteButton.setEnabled((info != null) && (info.getProperty("unremovable") == null)); //$NON-NLS-1$
- }
-
- public void updateErrorMessage(List namespaceInfoList) {
- NamespaceInfoErrorHelper helper = new NamespaceInfoErrorHelper();
- String errorMessage = helper.computeErrorMessage(namespaceInfoList, null);
- errorMessageLabel.setText(errorMessage != null ? errorMessage : ""); //$NON-NLS-1$
- }
-
- public void setResourcePath(IPath path) {
- resourceLocation = path;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java
deleted file mode 100644
index 1f6d85ae0a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonEditNamespacesTargetFieldDialog.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.nsedit;
-
-import org.eclipse.core.runtime.IPath;
-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.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/*
- * This class is an extension of CommonEditNamespacesDialog. This class adds
- * the target namespaces dialog field.
- */
-public class CommonEditNamespacesTargetFieldDialog extends CommonEditNamespacesDialog {
-
- class TargetNamespaceModifyListener implements ModifyListener {
- public void modifyText(ModifyEvent e) {
- String oldTargetNamespace = targetNamespace;
- targetNamespace = targetNamespaceField.getText();
- updateTargetNamespaceAndNamespaceInfo(oldTargetNamespace, targetNamespace);
- }
- }
-
- protected String targetNamespace;
- protected Text targetNamespaceField;
-
- public CommonEditNamespacesTargetFieldDialog(Composite parent, IPath resourceLocation1) {
- super(parent, resourceLocation1, XMLUIMessages._UI_NAMESPACE_DECLARATIONS);
-
- Composite targetComp = getTopComposite();
- targetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
-
- GridData gd = new GridData(GridData.FILL_BOTH);
- Label targetNamespaceLabel = new Label(targetComp, SWT.NONE);
- targetNamespaceLabel.setLayoutData(gd);
- targetNamespaceLabel.setText(XMLUIMessages._UI_TARGET_NAMESPACE);
-
- targetNamespaceField = new Text(targetComp, SWT.BORDER);
- targetNamespaceField.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- targetNamespaceField.addModifyListener(new TargetNamespaceModifyListener());
-
- // createControlArea();
- }
-
- public String getTargetNamespace() {
- return targetNamespace;
- }
-
- public void performEdit() {
- Object selection = getSelection(tableViewer.getSelection());
- if (selection != null) {
- boolean editTargetNamespace = false;
- NamespaceInfo nsInfo = (NamespaceInfo) selection;
- if (getTargetNamespace().equals(nsInfo.uri)) {
- editTargetNamespace = true;
- }
-
- invokeDialog(XMLUIMessages._UI_LABEL_NEW_NAMESPACE_INFORMATION, nsInfo);
- updateErrorMessage(namespaceInfoList);
- performDelayedUpdate();
-
- if (editTargetNamespace) {
- targetNamespaceField.setText(nsInfo.uri);
- }
- }
- }
-
- public void setTargetNamespace(String theTargetNamespace) {
- targetNamespace = theTargetNamespace != null ? theTargetNamespace : ""; //$NON-NLS-1$
- targetNamespaceField.setText(targetNamespace);
- // updateTargetNamespaceAndNamespaceInfo(targetNamespace);
- }
-
- void updateTargetNamespaceAndNamespaceInfo(String oldTargetNamespace, String newTargetNamespace) {
- NamespaceInfo info = getNamespaceInfo(newTargetNamespace);
- if (info == null) {
- info = getNamespaceInfo(oldTargetNamespace);
- if (info == null) {
- info = new NamespaceInfo(newTargetNamespace, "tns", null); //$NON-NLS-1$
- namespaceInfoList.add(info);
- }
- else {
- info.uri = targetNamespace;
- }
- }
- tableViewer.refresh();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java
deleted file mode 100644
index 44162e45ff..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/nsedit/CommonNamespaceInfoTable.java
+++ /dev/null
@@ -1,346 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.nsedit;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITableLabelProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.MouseAdapter;
-import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Table;
-import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class CommonNamespaceInfoTable extends TableViewer {
-
- /**
- * NamespaceInfoTableLabelProvider
- */
- protected class Provider extends LabelProvider implements ITableLabelProvider, IStructuredContentProvider {
- Viewer viewer;
-
- public Image getColumnImage(Object object, int columnIndex) {
- Image result = null;
- int columnCode = getColumnCode(columnIndex);
- if (columnCode == COLUMN_LOCATION_HINT) {
- NamespaceInfo info = (NamespaceInfo) object;
- if ((info.locationHint == null) || info.locationHint.trim().equals("")) { //$NON-NLS-1$
- // Comment this out until we solve the alignment/(space
- // for image being allocated
- // to prefix column) ......
- // result =
- // XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_WARNING_OBJ);
- }
- }
-
- return result;
- }
-
- public String getColumnText(Object object, int column) {
- NamespaceInfo info = (NamespaceInfo) object;
- String result = null;
- int columnCode = getColumnCode(column);
- switch (columnCode) {
- case COLUMN_PREFIX : {
- result = info.prefix;
- break;
- }
- case COLUMN_NAMESPACE_URI : {
- result = info.uri;
- break;
- }
- case COLUMN_CHECKBOX : {
- result = ""; // info.locationHint; //$NON-NLS-1$
- break;
- }
- case COLUMN_LOCATION_HINT : {
- result = info.locationHint;
- break;
- }
- }
- result = result != null ? result : ""; //$NON-NLS-1$
- if (result.equals("")) { //$NON-NLS-1$
- switch (columnCode) {
- case COLUMN_PREFIX : {
- result = XMLUIMessages._UI_NO_PREFIX;
- break;
- }
- case COLUMN_NAMESPACE_URI : {
- result = XMLUIMessages._UI_NO_NAMESPACE_NAME;
- break;
- }
- }
- }
- return result;
- }
-
- public Object[] getElements(Object inputElement) {
- List list = (List) viewer.getInput();
- return list != null ? list.toArray() : null;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- this.viewer = viewer;
- }
- }
-
- class TableItemChecker extends MouseAdapter {
- public void mouseDown(MouseEvent e) {
- TableItem item = getTable().getItem(new Point(e.x, e.y));
- if (item != null) {
- Object obj = item.getData();
- if (obj != null) {
- NamespaceInfo info = (NamespaceInfo) obj;
- TableColumn col = getTable().getColumn(0);
- if (e.x < col.getWidth()) // if the point falls within
- // the
- // Select column then perform
- // check/uncheck
- {
- String currentState = (String) info.getProperty("checked"); //$NON-NLS-1$
- System.out.println("currentState" + currentState); //$NON-NLS-1$
- if ((currentState == null) || currentState.equals("false")) //$NON-NLS-1$
- {
- info.setProperty("checked", "true"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- else {
- info.setProperty("checked", "false"); //$NON-NLS-1$ //$NON-NLS-2$
- }
- refresh();
- }
- }
- }
- }
- }
-
- protected static final int COLUMN_CHECKBOX = 1;
- protected static final int COLUMN_LOCATION_HINT = 4;
- protected static final int COLUMN_NAMESPACE_URI = 2;
- protected static final int COLUMN_PREFIX = 3;
-
- protected static final String LABEL_CHECKBOX = ""; //$NON-NLS-1$
- protected static final String LABEL_LOCATION_HINT = XMLUIMessages._UI_LABEL_LOCATION_HINT;
- protected static final String LABEL_NAMESPACE_URI = XMLUIMessages._UI_LABEL_NAMESPACE_NAME;
- protected static final String LABEL_PREFIX = XMLUIMessages._UI_LABEL_PREFIX;
- protected List checkedList = new ArrayList();
-
- // protected List namespaceInfoList = new ArrayList();
- protected int[] columnIndexMap;
- protected boolean showCheckBoxes = true;
- private boolean showLocationText = false;
-
- private Table table;
- protected int visibleRows = -1;
-
- public CommonNamespaceInfoTable(Composite parent, int visibleRows) {
- this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows, false);
- }
-
- // protected CellEditor getCellEditor(int column)
- // {
- // return (column == COLUMN_CHECKBOX) ? checkBoxCellEditor :
- // textCellEditor;
- // }
-
- public CommonNamespaceInfoTable(Composite parent, int visibleRows, boolean showLocationText) {
- this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER, visibleRows, showLocationText);
- }
-
- public CommonNamespaceInfoTable(Composite parent, int style, int visibleRows) {
- this(parent, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER | style, visibleRows, false);
- }
-
- public CommonNamespaceInfoTable(Composite parent, int style, int visibleRows, boolean showLocationText) {
- super(new Table(parent, style));
- getTable().setLinesVisible(true);
- this.showCheckBoxes = (style & SWT.CHECK) != 0;
- columnIndexMap = createColumnIndexMap();
- this.showLocationText = showLocationText;
-
- Provider provider = new Provider();
- setContentProvider(provider);
- setLabelProvider(provider);
-
- String[] columnPropertiesArray = createColumnPropertiesArray();
- setColumnProperties(columnPropertiesArray);
-
- table = getTable();
- table.setHeaderVisible(true);
- table.setLayoutData(new GridData(GridData.FILL_BOTH));
-
- TableLayout layout = new TableLayout();
-
- for (int i = 0; i < columnPropertiesArray.length; i++) {
- TableColumn column = new TableColumn(table, i);
- if ((columnPropertiesArray[i]).equals(LABEL_LOCATION_HINT)) {
- if (showLocationText) {
- column.setText(columnPropertiesArray[i]);
- }
- else {
- // Comment this out until we solve the alignment/(space
- // for image being allocated
- // to prefix column) ......
- // column.setImage(XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_TXTEXT));
- }
- }
- else {
- column.setText(columnPropertiesArray[i]);
- }
- column.setAlignment(SWT.LEFT);
- layout.addColumnData(new ColumnWeightData(getColumnWidth(i), true));
- }
- table.setLayout(layout);
-
- this.visibleRows = visibleRows;
- // for (int i = 0; i < visibleRows; i++)
- // {
- // TableItem item = new TableItem(table, SWT.NONE);
- // item.setText("#######");
- // }
- // checkBoxCellEditor = new NamespaceInfoCheckboxCellEditor(table);
- // textCellEditor = new TextCellEditor(table);
-
- /*
- * CellEditor[] cellEditors = new
- * CellEditor[columnPropertiesArray.length]; for (int i = 0; i <
- * columnPropertiesArray.length; i++) { cellEditors[i] =
- * getCellEditor(i); } setCellEditors(cellEditors);
- */
- // if (showCheckBoxes)
- // {
- // getTable().addMouseListener(new TableItemChecker());
- // }
- }
-
- // protected CellEditor checkBoxCellEditor;
- // protected CellEditor textCellEditor;
-
- protected int[] createColumnIndexMap() {
- int[] result = new int[showCheckBoxes ? 4 : 3];
- int i = 0;
- if (showCheckBoxes) {
- result[i++] = COLUMN_CHECKBOX;
- }
- result[i++] = COLUMN_PREFIX;
- result[i++] = COLUMN_NAMESPACE_URI;
- if (!showCheckBoxes) {
- result[i++] = COLUMN_LOCATION_HINT;
- }
- return result;
- }
-
- protected String[] createColumnPropertiesArray() {
- String[] result = new String[3];
- int i = 0;
- if (showCheckBoxes) {
- result[i++] = LABEL_CHECKBOX;
- }
- result[i++] = LABEL_PREFIX;
- result[i++] = LABEL_NAMESPACE_URI;
- if (!showCheckBoxes) {
- result[i++] = LABEL_LOCATION_HINT;
- }
- return result;
- }
-
- protected int getColumnCode(int column) {
- int result = 0;
- if (column < columnIndexMap.length) {
- result = columnIndexMap[column];
- }
- return result;
- }
-
- protected int getColumnWidth(int column) {
- int result = 0;
- switch (getColumnCode(column)) {
- case COLUMN_PREFIX : {
- result = 5;
- break;
- }
- case COLUMN_NAMESPACE_URI : {
- // Size columns differently when location hint text label is
- // displayed
- if (showLocationText) {
- result = 10;
- }
- else {
- result = 20;
- }
- break;
- }
- case COLUMN_CHECKBOX : {
- result = 1; // info.locationHint;
- break;
- }
- case COLUMN_LOCATION_HINT : {
- // Size columns differently when location hint text label is
- // displayed
- if (showLocationText) {
- result = 10;
- }
- else {
- result = 2;
- }
- break;
- }
- }
- return result;
- }
- /*
- * protected class NamespaceInfoCellModifier implements ICellModifier {
- * public NamespaceInfoCellModifier() { }
- *
- * public boolean canModify(Object element, String property) { if
- * (property.equals(LABEL_CHECKBOX)) { return true; } else if
- * (property.equals(LABEL_PREFIX)) { return true; } return false; }
- *
- * public Object getValue(Object element, String property) { int column =
- * 0; if (property.equals(LABEL_CHECKBOX)) { column = 0; } else if
- * (property.equals(LABEL_PREFIX)) { column = 1; } else if
- * (property.equals(LABEL_NAMESPACE_URI)) { column = 2; }
- *
- * //if (element instanceof TableElement) //{ // return
- * provider.getColumnText(element, column); //} //else //{ // return null; // }
- * return "hello"; }
- *
- * public void modify(Object element, String property, Object value) { } }
- *
- * protected class NamespaceInfoCheckboxCellEditor extends
- * CheckboxCellEditor implements MouseListener { public
- * NamespaceInfoCheckboxCellEditor(Composite parent) { super(parent); }
- *
- * protected void doSetValue(Object value) { }
- *
- * public void activate() { super.activate(); deactivate();
- * Display.getCurrent().getFocusControl().redraw(); }
- *
- * public void mouseDown(MouseEvent e) { if (getTable().getItem(new
- * Point(e.x, e.y)) != null) { } } public void mouseDoubleClick(MouseEvent
- * e) { } public void mouseUp(MouseEvent e) { } }
- */
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/perspective/XMLPerspectiveFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/perspective/XMLPerspectiveFactory.java
deleted file mode 100644
index 840a0c84a3..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/perspective/XMLPerspectiveFactory.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2009 Standards for Technology in Automotive Retail
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * David Carver - bug 213883 - initial api
- * IBM Corporation - bug 271619 - Move and rename XML perspective definition
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.perspective;
-
-import org.eclipse.ui.IPageLayout;
-import org.eclipse.ui.IPerspectiveFactory;
-
-
-/**
- * @author dcarver
- *
- */
-public class XMLPerspectiveFactory implements IPerspectiveFactory {
-
-// private static final String SEARCH_VIEW_ID = "org.eclipse.search.ui.views.SearchView"; //$NON-NLS-1$
-// private static final String XPATH_VIEW_ID = "org.eclipse.wst.xml.views.XPathView"; //$NON-NLS-1$
-// private static final String SNIPPETS_VIEW_ID = "org.eclipse.wst.common.snippets.internal.ui.SnippetsView"; //$NON-NLS-1$
-// private static final String TEXTEDITOR_TEMPLATES_VIEW_ID = "org.eclipse.ui.texteditor.TemplatesView"; //$NON-NLS-1$
-// private static final String ID_CONSOLE_VIEW = "org.eclipse.ui.console.ConsoleView"; //$NON-NLS-1$
-
- /**
- * Creates the initial layout. This is what the layout is reset to when
- * the Reset Perspective is selected. It takes as input a IPageLayout
- * object.
- *
- * @param layout
- */
- public void createInitialLayout(IPageLayout layout) {
- // Get the Editor Area
-// String editorArea = layout.getEditorArea();
-
- // Turn on the Editor Area
- layout.setEditorAreaVisible(true);
- layout.setFixed(false);
-
- // Create the areas of the layout with their initial views
-// IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, (float) 0.23, editorArea); //$NON-NLS-1$
-// left.addView(IPageLayout.ID_PROJECT_EXPLORER);
-//
-// IFolderLayout bottomLeft = layout.createFolder("bottom-left", IPageLayout.BOTTOM, (float) 0.50, "left"); //$NON-NLS-1$ //$NON-NLS-2$
-// bottomLeft.addView(XPATH_VIEW_ID); //$NON-NLS-1$
-//
-// IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, (float) 0.70, editorArea); //$NON-NLS-1$
-// right.addView(IPageLayout.ID_OUTLINE);
-//
-// IFolderLayout bottomRight = layout.createFolder("bottom-right", IPageLayout.BOTTOM, (float) 0.60, "right"); //$NON-NLS-1$//$NON-NLS-2$
-// bottomRight.addView(TEXTEDITOR_TEMPLATES_VIEW_ID);
-//
-// IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, (float) 0.75, editorArea); //$NON-NLS-1$
-// bottom.addView(IPageLayout.ID_PROBLEM_VIEW);
-// bottom.addView(IPageLayout.ID_PROP_SHEET);
-// bottom.addView(ID_CONSOLE_VIEW);
-// bottom.addView(SNIPPETS_VIEW_ID);
-//
-// bottom.addPlaceholder(SEARCH_VIEW_ID);
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EmptyFilePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EmptyFilePreferencePage.java
deleted file mode 100644
index 9870632ea9..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EmptyFilePreferencePage.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.jface.preference.PreferencePage;
-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.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-public class EmptyFilePreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private Composite createComposite(Composite parent, int numColumns) {
- noDefaultAndApplyButton();
-
- 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 Control createContents(Composite parent) {
- Composite composite = createScrolledComposite(parent);
-
- String description = XMLUIMessages.EmptyFilePreferencePage_0;
- Text text = new Text(composite, SWT.READ_ONLY);
- // some themes on GTK have different background colors for Text and Labels
- text.setBackground(composite.getBackground());
- text.setText(description);
-
- setSize(composite);
- return composite;
- }
-
- private Composite createScrolledComposite(Composite parent) {
- // create scrollbars for this parent 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);
-
- // not calling setSize for composite will result in a blank composite,
- // 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;
- }
-
- public void init(IWorkbench workbench) {
- }
-
- private void setSize(Composite composite) {
- if (composite != null) {
- // Note: The font is set here in anticipation that the class inheriting
- // this base class may add widgets to the dialog. setSize
- // is assumed to be called just before we go live.
- applyDialogFont(composite);
- 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);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java
deleted file mode 100644
index 16fa130476..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/EncodingSettings.java
+++ /dev/null
@@ -1,360 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import java.util.Vector;
-
-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.layout.GridLayout;
-import org.eclipse.swt.widgets.Combo;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.wst.sse.core.internal.encoding.CommonCharsetNames;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * EncodingSettings is a composite that can be used to display the set of
- * encoding values that are available to the user. The list of encoding values
- * is based off the SupportedJavaEncoding class. As the user selects an
- * encoding from the combo box, the readonly field below it changes to show
- * the IANA tag for that particular encoding description. The labels for the
- * widgets are configurable and the initial value to display to the user can
- * be set using the setIANATag(). The currently selected entry's IANA tag can
- * be retrieved with getIANATag(). Entries displayed to the user can be added
- * and removed.
- */
-public class EncodingSettings extends Composite {
-
- private class ComboListener implements ModifyListener {
- public void modifyText(ModifyEvent e) {
- int i = encodingCombo.getSelectionIndex();
- if ((i >= 0) && (i < ianaVector.size())) {
- ianaText.setText((String) (ianaVector.elementAt(encodingCombo.getSelectionIndex())));
- }
- }
- }
-
- private static String ENCODING_LABEL = XMLUIMessages.EncodingSettings_1;
-
- private static String IANA_LABEL = XMLUIMessages.EncodingSettings_0;
-
- private ModifyListener comboListener = new ComboListener();
- protected Combo encodingCombo;
- protected Label encodingLabel, ianaLabel;
- protected Text ianaText;
- protected Vector ianaVector;
-
- /**
- * Method EncodingSettings.
- *
- * @param parent
- */
- public EncodingSettings(Composite parent) {
- super(parent, SWT.NONE);
- init(IANA_LABEL, ENCODING_LABEL);
- }
-
- /**
- * Method EncodingSettings.
- *
- * @param parent
- * @param encodingLabel -
- * text label to use beside the locale sensitive description of
- * the currently selected encoding
- */
- public EncodingSettings(Composite parent, String encodingLabel) {
- super(parent, SWT.NONE);
- init(IANA_LABEL, encodingLabel);
- }
-
- /**
- * Method EncodingSettings.
- *
- * @param parent
- * @param ianaLabel =
- * text label to use beside the display only IANA field
- * @param encodingLabel -
- * text label to use beside the locale sensitive description of
- * the currently selected encoding
- */
- public EncodingSettings(Composite parent, String ianaLabel, String encodingLabel) {
- super(parent, SWT.NONE);
- init(ianaLabel, encodingLabel);
- }
-
- /**
- * Method addEntry. Add an entry to the end of the Encoding Combobox
- *
- * @param description -
- * encoding description to display
- * @param ianaTag -
- * IANA tag for the description
- */
- public void addEntry(String description, String ianaTag) {
- encodingCombo.add(description);
- ianaVector.add(ianaTag);
- }
-
- /**
- * Method addEntry. Add an entry to the Encoding Combobox at index index
- *
- * @param description -
- * encoding description to display
- * @param ianaTag -
- * IANA tag for the description
- * @param index -
- * index into the combo to add to
- */
- public void addEntry(String description, String ianaTag, int index) {
- if (index == ianaVector.size()) {
- // just add to the end
- addEntry(description, ianaTag);
- return;
- }
-
- if ((0 <= index) && (index < ianaVector.size())) {
- encodingCombo.add(description, index);
- ianaVector.add(index, ianaTag);
- }
- }
-
- protected Combo createComboBox(Composite parent, boolean isReadOnly) {
- int style = isReadOnly == true ? SWT.READ_ONLY : SWT.DROP_DOWN;
-
- Combo combo = new Combo(parent, style);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- combo.setLayoutData(data);
- return combo;
- }
-
- /**
- * Helper method for creating labels.
- */
- protected 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;
- }
-
- protected Text createTextField(Composite parent, int width) {
- Text text = new Text(parent, SWT.SINGLE | SWT.READ_ONLY);
-
- GridData data = new GridData();
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- data.widthHint = width;
- text.setLayoutData(data);
-
- text.setBackground(text.getDisplay().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND));
- return text;
- }
-
- /**
- * @see org.eclipse.swt.widgets.Widget#dispose()
- */
- public void dispose() {
- encodingCombo.removeModifyListener(comboListener);
- super.dispose();
- }
-
- private void fillCombo() {
- try {
- String[] ianaTags = CommonCharsetNames.getCommonCharsetNames();
- int totalNum = ianaTags.length;
- for (int i = 0; i < totalNum; i++) {
- String iana = ianaTags[i];
- String enc = CommonCharsetNames.getDisplayString(iana);
-
- if (enc != null) {
- encodingCombo.add(enc);
- }
- else {
- Logger.log(Logger.WARNING, "CommonCharsetNames.getDisplayString(" + iana + ") returned null"); //$NON-NLS-1$ //$NON-NLS-2$
- encodingCombo.add(iana);
- }
- ianaVector.add(iana);
- }
- }
- catch (Exception e) {
- // e.printStackTrace();
- // MessageDialog.openError(getShell(), "Resource exception",
- // "Unable to obtain encoding strings. Check resource file");
- // XMLEncodingPlugin.getPlugin().getMsgLogger().write(e.toString());
- // XMLEncodingPlugin.getPlugin().getMsgLogger().writeCurrentThread();
- Logger.log(Logger.ERROR, "Exception", e); //$NON-NLS-1$
- }
- }
-
- /**
- * <code>getEncoding</code> Get the descriptive encoding name that was
- * selected.
- *
- * @return a <code>String</code> value
- */
- public String getEncoding() {
- return encodingCombo.getText();
- }
-
- /**
- * Method getEncodingCombo. Returns the combo used to display the encoding
- * descriptions.
- *
- * @return Combo
- */
- public Combo getEncodingCombo() {
- return encodingCombo;
- }
-
- /**
- * <code>getIANATag</code> Get the IANA tag equivalent of the selected
- * descriptive encoding name
- *
- * @return a <code>String</code> value
- */
- public String getIANATag() {
- int i = encodingCombo.getSelectionIndex();
- if (i >= 0) {
- return (String) (ianaVector.elementAt(i));
- }
- return ""; //$NON-NLS-1$
- }
-
- protected void init(String ianaLabelStr, String encodingLabelStr) {
- GridLayout layout = new GridLayout();
- layout.numColumns = 2;
- setLayout(layout);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- setLayoutData(data);
-
- encodingLabel = createLabel(this, encodingLabelStr);
- encodingCombo = createComboBox(this, true);
- ianaLabel = createLabel(this, ianaLabelStr);
- ianaText = createTextField(this, 20);
- ianaVector = new Vector();
-
- fillCombo();
- resetToDefaultEncoding();
- encodingCombo.addModifyListener(comboListener);
- }
-
- /**
- * <code>isEncodingInList</code> Checks whether the encoding name is in
- * the combo
- *
- * @param enc
- * a <code>string</code> value. The encoding name.
- * @return a <code>boolean</code> value. TRUE if encoding is in list.
- * FALSE if encoding is not in list.
- */
- public boolean isEncodingInList(String enc) {
- int i = encodingCombo.indexOf(enc);
- if (i >= 0) {
- return true;
- }
- return false;
- }
-
- /**
- * <code>isIANATagInList</code> Checks whether the IANA tag is in the
- * combo
- *
- * @param ianaTag
- * a <code>string</code> value. The IANA tag.
- * @return a <code>boolean</code> value. TRUE if tag is in list. FALSE
- * if tag is not in list.
- */
- public boolean isIANATagInList(String ianaTag) {
- int i = ianaVector.indexOf(ianaTag);
- if (i >= 0) {
- return true;
- }
- return false;
- }
-
- /**
- * Method removeEntry. Removes both the description and the IANA tag at
- * the specified index
- *
- * @param index
- */
- public void removeEntry(int index) {
- if ((0 <= index) && (index < ianaVector.size())) {
- encodingCombo.remove(index);
- ianaVector.remove(index);
- }
- }
-
- /**
- * Method resetToDefaultEncoding. Reset the control to the default
- * encoding. Currently UTF-8
- */
- public void resetToDefaultEncoding() {
- String defaultIANATag = "UTF-8"; //$NON-NLS-1$
- ianaText.setText(defaultIANATag);
- setIANATag(defaultIANATag);
- }
-
- /**
- * Method setEnabled. Enable/disable the EncodingSettings composite.
- *
- * @param enabled
- */
- public void setEnabled(boolean enabled) {
- encodingCombo.setEnabled(enabled);
- encodingLabel.setEnabled(enabled);
- ianaLabel.setEnabled(enabled);
- ianaText.setEnabled(enabled);
- }
-
- /**
- * <code>setEncoding</code> Set the selection in the combo to the
- * descriptive encoding name.
- *
- * @param enc
- * a <code>string</code> value. Note this is not the IANA
- * tag.
- */
- public void setEncoding(String enc) {
- encodingCombo.setText(enc);
- encodingCombo.select(encodingCombo.indexOf(enc));
- }
-
- /**
- * <code>setIANATag</code> Set the IANA tag for the combo
- *
- * @param ianaTag
- * a <code>string</code> value. The IANA tag.
- */
- public void setIANATag(String ianaTag) {
- int i = ianaVector.indexOf(ianaTag);
- if (i >= 0) {
- encodingCombo.select(i);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java
deleted file mode 100644
index e7930edb9e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/WorkbenchDefaultEncodingSettings.java
+++ /dev/null
@@ -1,141 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.SelectionAdapter;
-import org.eclipse.swt.events.SelectionEvent;
-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.wst.sse.core.internal.encoding.CommonCharsetNames;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * WorkbenchDefaultEncodingSettings is an extension of EncodingSettings. This
- * composite contains EncodingSettings for users to select the encoding they
- * desire as well as a checkbox for users to select to use the default
- * workbench encoding instead.
- *
- * @see org.eclipse.wst.xml.ui.internal.preferences.EncodingSettings
- */
-public class WorkbenchDefaultEncodingSettings extends Composite {
-
- private final static int INDENT = 15;
- private static final String WORKBENCH_DEFAULT = ""; //$NON-NLS-1$
- private EncodingSettings fEncodingSettings;
- private String fNonDefaultIANA = null;
- private Button fUseDefaultButton;
-
- public WorkbenchDefaultEncodingSettings(Composite parent) {
- super(parent, SWT.NONE);
- createControls();
- }
-
- private void createControls() {
- GridLayout layout = new GridLayout();
- layout.numColumns = 1;
- layout.marginWidth = 0;
- setLayout(layout);
- GridData data = new GridData();
- data.verticalAlignment = GridData.FILL;
- data.horizontalAlignment = GridData.FILL;
- data.grabExcessHorizontalSpace = true;
- setLayoutData(data);
-
- Composite defaultEncodingComposite = new Composite(this, SWT.NONE);
- layout = new GridLayout();
- layout.marginWidth = 0;
- layout.marginHeight = 0;
- data = new GridData(GridData.FILL_BOTH);
- defaultEncodingComposite.setLayout(layout);
- defaultEncodingComposite.setLayoutData(data);
-
- fUseDefaultButton = new Button(defaultEncodingComposite, SWT.CHECK);
- fUseDefaultButton.setText(XMLUIMessages.WorkbenchDefaultEncodingSettings_0);
-
- fUseDefaultButton.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- handleUseDefaultButtonSelected();
- }
- });
-
- fEncodingSettings = new EncodingSettings(this);
- ((GridLayout) fEncodingSettings.getLayout()).marginWidth = 0;
- ((GridData) fEncodingSettings.getLayoutData()).horizontalIndent = INDENT;
-
- }
-
- private Combo getEncodingCombo() {
- return fEncodingSettings.getEncodingCombo();
- }
-
- /**
- * <code>getIANATag</code> Get the IANA tag equivalent of the selected
- * descriptive encoding name. Returns empty string if using workbench
- * encoding.
- *
- * @return a <code>String</code> value
- */
- public String getIANATag() {
- if (!isDefault()) {
- return fEncodingSettings.getIANATag();
- }
- return WORKBENCH_DEFAULT;
- }
-
- private String getWorkbenchEncoding() {
- return ResourcesPlugin.getEncoding();
- }
-
- void handleUseDefaultButtonSelected() {
- if (fUseDefaultButton.getSelection()) {
- fNonDefaultIANA = fEncodingSettings.getIANATag();
- String workbenchValue = getWorkbenchEncoding();
- workbenchValue = CommonCharsetNames.getIanaPreferredCharsetName(workbenchValue);
- fEncodingSettings.setIANATag(workbenchValue);
- }
- else if (fNonDefaultIANA != null) {
- fEncodingSettings.setIANATag(fNonDefaultIANA);
- }
- getEncodingCombo().setEnabled(!fUseDefaultButton.getSelection());
- fEncodingSettings.setEnabled(!fUseDefaultButton.getSelection());
- }
-
- private boolean isDefault() {
- return fUseDefaultButton.getSelection();
- }
-
- /**
- * <code>setEncoding</code> Set the selection in the combo to the
- * descriptive encoding name. Selects use workbench encoding if ianaTag is
- * null or empty string.
- *
- */
- public void setIANATag(String ianaTag) {
- if ((ianaTag == null) || ianaTag.equals(WORKBENCH_DEFAULT)) {
- fUseDefaultButton.setSelection(true);
- handleUseDefaultButtonSelected();
- }
- else {
- fUseDefaultButton.setSelection(false);
- handleUseDefaultButtonSelected();
- if (!isDefault()) {
- fEncodingSettings.setIANATag(ianaTag);
- }
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java
deleted file mode 100644
index 4f29d750f1..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLColorPage.java
+++ /dev/null
@@ -1,288 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- * Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.Iterator;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore.OverlayKey;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractColorPage;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.StyledTextColorPicker;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
-
-/**
- * @deprecated
- */
-public class XMLColorPage extends AbstractColorPage {
-
- protected Control createContents(Composite parent) {
- Composite pageComponent = createComposite(parent, 1);
- ((GridData) pageComponent.getLayoutData()).horizontalAlignment = GridData.HORIZONTAL_ALIGN_FILL;
-
- super.createContents(pageComponent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
- return pageComponent;
- }
-
- /**
- * Set up all the style preference keys in the overlay store
- */
- protected OverlayKey[] createOverlayStoreKeys() {
- ArrayList overlayKeys = new ArrayList();
-
- ArrayList styleList = new ArrayList();
- initStyleList(styleList);
- Iterator i = styleList.iterator();
- while (i.hasNext()) {
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, (String) i.next()));
- }
-
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- protected IPreferenceStore doGetPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- public String getSampleText() {
- return XMLUIMessages.Sample_XML_doc; // = "<?xml
- // version=\"1.0\"?>\n<?customProcessingInstruction\n\tXML
- // processor
- // specific\n\tcontent
- // ?>\n<!DOCTYPE
- // colors\n\tPUBLIC
- // \"//IBM/XML/COLORS/\"
- // \"colors.dtd\">\n<colors>\n\t<!--
- // begin color definitions
- // -->\n\t<color
- // name=\"plaintext\"
- // foreground=\"#000000\"\n\t\tbackground=\"#D4D0C8\"/>\n\t<color
- // name=\"bold\"
- // foreground=\"#000000\"\n\t\tbackground=\"#B3ACA0\">\n\t<![CDATA[<123456789>]]>\n\tNormal
- // text content.\n\t<color
- // name=\"inverse\"
- // foreground=\"#F0F0F0\"\n\t\tbackground=\"#D4D0C8\"/>\n\n</colors>\n";
- }
-
- protected void initCommonContextStyleMap(Dictionary contextStyleMap) {
-
- contextStyleMap.put(DOMRegionContext.XML_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT);
- contextStyleMap.put(DOMRegionContext.XML_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_TAG_OPEN, IStyleConstantsXML.TAG_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_END_TAG_OPEN, IStyleConstantsXML.TAG_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_TAG_NAME, IStyleConstantsXML.TAG_NAME);
- contextStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- contextStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- contextStyleMap.put(DOMRegionContext.XML_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_EMPTY_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_DECLARATION_OPEN, IStyleConstantsXML.DECL_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_ELEMENT_DECLARATION, IStyleConstantsXML.DECL_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_CLOSE, IStyleConstantsXML.DECL_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_CHAR_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE);
- contextStyleMap.put(DOMRegionContext.XML_ENTITY_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE);
- contextStyleMap.put(DOMRegionContext.XML_PE_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE);
-
- contextStyleMap.put(DOMRegionContext.XML_CONTENT, IStyleConstantsXML.XML_CONTENT);
- }
-
- protected void initCommonDescriptions(Dictionary descriptions) {
-
- // create descriptions for hilighting types
- descriptions.put(IStyleConstantsXML.COMMENT_BORDER, XMLUIMessages.Comment_Delimiters_UI_); // =
- // "Comment
- // Delimiters"
- descriptions.put(IStyleConstantsXML.COMMENT_TEXT, XMLUIMessages.Comment_Content_UI_); // =
- // "Comment
- // Content"
- descriptions.put(IStyleConstantsXML.TAG_BORDER, XMLUIMessages.Tag_Delimiters_UI_); // =
- // "Tag
- // Delimiters"
- descriptions.put(IStyleConstantsXML.TAG_NAME, XMLUIMessages.Tag_Names_UI_); // =
- // "Tag
- // Names"
- descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, XMLUIMessages.Attribute_Names_UI_); // =
- // "Attribute
- // Names"
- descriptions.put(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, XMLUIMessages.Attribute_Values_UI_); // =
- // "Attribute
- // Values"
- descriptions.put(IStyleConstantsXML.DECL_BORDER, XMLUIMessages.Declaration_Delimiters_UI_); // =
- // "Declaration
- // Delimiters"
- descriptions.put(IStyleConstantsXML.XML_CONTENT, XMLUIMessages.Content_UI_); // =
- // "Content"
- descriptions.put(IStyleConstantsXML.ENTITY_REFERENCE, XMLUIMessages.Entity_Reference_UI_); //$NON-NLS-1$ = "Entity References"
- }
-
- protected void initCommonStyleList(ArrayList list) {
-
- // list.add(IStyleConstantsXML.CDATA_BORDER);
- // list.add(IStyleConstantsXML.CDATA_TEXT);
- // list.add(IStyleConstantsXML.PI_BORDER);
- // list.add(IStyleConstantsXML.PI_CONTENT);
-
- list.add(IStyleConstantsXML.TAG_BORDER);
- list.add(IStyleConstantsXML.TAG_NAME);
- list.add(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- list.add(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- list.add(IStyleConstantsXML.COMMENT_BORDER);
- list.add(IStyleConstantsXML.COMMENT_TEXT);
- list.add(IStyleConstantsXML.DECL_BORDER);
- list.add(IStyleConstantsXML.XML_CONTENT);
- list.add(IStyleConstantsXML.ENTITY_REFERENCE);
- }
-
- protected void initContextStyleMap(Dictionary contextStyleMap) {
-
- initCommonContextStyleMap(contextStyleMap);
- initDocTypeContextStyleMap(contextStyleMap);
- contextStyleMap.put(DOMRegionContext.XML_CDATA_OPEN, IStyleConstantsXML.CDATA_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_CDATA_TEXT, IStyleConstantsXML.CDATA_TEXT);
- contextStyleMap.put(DOMRegionContext.XML_CDATA_CLOSE, IStyleConstantsXML.CDATA_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_PI_OPEN, IStyleConstantsXML.PI_BORDER);
- contextStyleMap.put(DOMRegionContext.XML_PI_CONTENT, IStyleConstantsXML.PI_CONTENT);
- contextStyleMap.put(DOMRegionContext.XML_PI_CLOSE, IStyleConstantsXML.PI_BORDER);
-
- }
-
- protected void initDescriptions(Dictionary descriptions) {
-
- initCommonDescriptions(descriptions);
- initDocTypeDescriptions(descriptions);
- descriptions.put(IStyleConstantsXML.CDATA_BORDER, XMLUIMessages.CDATA_Delimiters_UI_); // =
- // "CDATA
- // Delimiters"
- descriptions.put(IStyleConstantsXML.CDATA_TEXT, XMLUIMessages.CDATA_Content_UI_); // =
- // "CDATA
- // Content"
- descriptions.put(IStyleConstantsXML.PI_BORDER, XMLUIMessages.Processing_Instruction_Del_UI_); // =
- // "Processing
- // Instruction
- // Delimiters"
- descriptions.put(IStyleConstantsXML.PI_CONTENT, XMLUIMessages.Processing_Instruction_Con_UI__UI_); // =
- // "Processing
- // Instruction
- // Content"
- }
-
- protected void initDocTypeContextStyleMap(Dictionary contextStyleMap) {
-
- contextStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_NAME, IStyleConstantsXML.DOCTYPE_NAME);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION, IStyleConstantsXML.TAG_NAME);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER);
-
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_NAME, IStyleConstantsXML.DOCTYPE_NAME);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- contextStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- }
-
- protected void initDocTypeDescriptions(Dictionary descriptions) {
-
- // create descriptions for hilighting types for DOCTYPE related items
- descriptions.put(IStyleConstantsXML.DOCTYPE_NAME, XMLUIMessages.DOCTYPE_Name_UI_); // =
- // "DOCTYPE
- // Name"
- descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, XMLUIMessages.DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_); // =
- // "DOCTYPE
- // SYSTEM/PUBLIC
- // Keyword"
- descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, XMLUIMessages.DOCTYPE_Public_Reference_UI_); // =
- // "DOCTYPE
- // Public
- // Reference"
- descriptions.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, XMLUIMessages.DOCTYPE_System_Reference_UI_); // =
- // "DOCTYPE
- // System
- // Reference"
- }
-
- protected void initDocTypeStyleList(ArrayList list) {
-
- list.add(IStyleConstantsXML.DOCTYPE_NAME);
- list.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- list.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- list.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- }
-
- protected void initStyleList(ArrayList list) {
- initCommonStyleList(list);
- initDocTypeStyleList(list);
- list.add(IStyleConstantsXML.CDATA_BORDER);
- list.add(IStyleConstantsXML.CDATA_TEXT);
- list.add(IStyleConstantsXML.PI_BORDER);
- list.add(IStyleConstantsXML.PI_CONTENT);
- }
-
- public boolean performOk() {
- // required since the superclass *removes* existing preferences before
- // saving its own
- super.performOk();
-
- SSEUIPlugin.getDefault().savePluginPreferences();
- return true;
- }
-
- protected void setupPicker(StyledTextColorPicker picker) {
- IModelManager mmanager = StructuredModelManager.getModelManager();
- picker.setParser(mmanager.createStructuredDocumentFor(ContentTypeIdForXML.ContentTypeID_XML).getParser());
-
- Dictionary descriptions = new Hashtable();
- initDescriptions(descriptions);
-
- Dictionary contextStyleMap = new Hashtable();
- initContextStyleMap(contextStyleMap);
-
- ArrayList styleList = new ArrayList();
- initStyleList(styleList);
-
- picker.setContextStyleMap(contextStyleMap);
- picker.setDescriptions(descriptions);
- picker.setStyleList(styleList);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.preferences.ui.AbstractColorPage#savePreferences()
- */
- protected void savePreferences() {
- XMLUIPlugin.getDefault().savePluginPreferences();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLCompletionProposalCategoriesConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLCompletionProposalCategoriesConfiguration.java
deleted file mode 100644
index 92a7ccc0ce..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLCompletionProposalCategoriesConfiguration.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.sse.ui.preferences.AbstractCompletionProposalCategoriesConfiguration;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * <p>The readable and writable completion proposal categories configuration
- * for the XML content type</p>
- */
-public class XMLCompletionProposalCategoriesConfiguration extends AbstractCompletionProposalCategoriesConfiguration {
-
- /** the ID of the preference page where users can change the preferences */
- private static final String PREFERENCES_PAGE_ID = "org.eclipse.wst.sse.ui.preferences.xml.contentassist"; //$NON-NLS-1$
-
- /**
- * <p>Creates the configuration</p>
- */
- public XMLCompletionProposalCategoriesConfiguration() {
- //nothing to do.
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.preferences.AbstractCompletionProposalCategoriesConfiguration#getPreferenceStore()
- */
- protected IPreferenceStore getPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.preferences.ICompletionProposalCategoriesConfigurationWriter#hasAssociatedPropertiesPage()
- */
- public boolean hasAssociatedPropertiesPage() {
- return true;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.preferences.ICompletionProposalCategoriesConfigurationWriter#getPropertiesPageID()
- */
- public String getPropertiesPageID() {
- return PREFERENCES_PAGE_ID;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.preferences.AbstractCompletionProposalCategoriesConfiguration#getShouldNotDisplayOnDefaultPagePrefKey()
- */
- protected String getShouldNotDisplayOnDefaultPagePrefKey() {
- return XMLUIPreferenceNames.CONTENT_ASSIST_DO_NOT_DISPLAY_ON_DEFAULT_PAGE;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.preferences.AbstractCompletionProposalCategoriesConfiguration#getShouldNotDisplayOnOwnPagePrefKey()
- */
- protected String getShouldNotDisplayOnOwnPagePrefKey() {
- return XMLUIPreferenceNames.CONTENT_ASSIST_DO_NOT_DISPLAY_ON_OWN_PAGE;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.preferences.AbstractCompletionProposalCategoriesConfiguration#getPageSortOrderPrefKey()
- */
- protected String getPageSortOrderPrefKey() {
- return XMLUIPreferenceNames.CONTENT_ASSIST_OWN_PAGE_SORT_ORDER;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.preferences.AbstractCompletionProposalCategoriesConfiguration#getDefaultPageSortOrderPrefKey()
- */
- protected String getDefaultPageSortOrderPrefKey() {
- return XMLUIPreferenceNames.CONTENT_ASSIST_DEFAULT_PAGE_SORT_ORDER;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLContentAssistPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLContentAssistPreferencePage.java
deleted file mode 100644
index 3e9ec2736e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLContentAssistPreferencePage.java
+++ /dev/null
@@ -1,256 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import java.util.Vector;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.GridData;
-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.IWorkbenchPreferencePage;
-import org.eclipse.wst.sse.ui.internal.Logger;
-import org.eclipse.wst.sse.ui.internal.contentassist.CompletionProposoalCatigoriesConfigurationRegistry;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
-import org.eclipse.wst.sse.ui.preferences.CodeAssistCyclingConfigurationBlock;
-import org.eclipse.wst.sse.ui.preferences.ICompletionProposalCategoriesConfigurationWriter;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * <p>Defines the preference page for allowing the user to change the content
- * assist preferences</p>
- */
-public class XMLContentAssistPreferencePage extends AbstractPreferencePage implements
- IWorkbenchPreferencePage {
-
- private static final String XML_CONTENT_TYPE_ID = "org.eclipse.core.runtime.xml"; //$NON-NLS-1$
-
- // Auto Activation
- private Button fAutoPropose;
- private Label fAutoProposeLabel;
- private Text fAutoProposeText;
- private Combo fSuggestionStrategyCombo;
- private Vector fSuggestionStrategies = null;
-
- /** configuration block for changing preference having to do with the content assist categories */
- private CodeAssistCyclingConfigurationBlock fConfigurationBlock;
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite parent) {
- final Composite composite = super.createComposite(parent, 1);
-
- createContentsForAutoActivationGroup(composite);
- createContentsForCyclingGroup(composite);
-
- setSize(composite);
- loadPreferences();
-
- return composite;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage#performDefaults()
- */
- protected void performDefaults() {
- performDefaultsForAutoActivationGroup();
- performDefaultsForCyclingGroup();
-
- validateValues();
- enableValues();
-
- super.performDefaults();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage#initializeValues()
- */
- protected void initializeValues() {
- initializeValuesForAutoActivationGroup();
- initializeValuesForCyclingGroup();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage#storeValues()
- */
- protected void storeValues() {
- storeValuesForAutoActivationGroup();
- storeValuesForCyclingGroup();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage#enableValues()
- */
- protected void enableValues() {
- if (fAutoPropose != null) {
- if (fAutoPropose.getSelection()) {
- fAutoProposeLabel.setEnabled(true);
- fAutoProposeText.setEnabled(true);
- }
- else {
- fAutoProposeLabel.setEnabled(false);
- fAutoProposeText.setEnabled(false);
- }
- }
- }
-
- /**
- * @see org.eclipse.jface.preference.PreferencePage#doGetPreferenceStore()
- */
- protected IPreferenceStore doGetPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- /**
- * <p>Create contents for the auto activation preference group</p>
- * @param parent {@link Composite} parent of the group
- */
- private void createContentsForAutoActivationGroup(Composite parent) {
- Group contentAssistGroup = createGroup(parent, 2);
- contentAssistGroup.setText(XMLUIMessages.XMLContentAssistPreferencePage_Auto_Activation_UI_);
-
- fAutoPropose = createCheckBox(contentAssistGroup, XMLUIMessages.Automatically_make_suggest_UI_);
- ((GridData) fAutoPropose.getLayoutData()).horizontalSpan = 2;
- fAutoPropose.addSelectionListener(this);
-
- fAutoProposeLabel = createLabel(contentAssistGroup, XMLUIMessages.Prompt_when_these_characte_UI_);
- fAutoProposeText = createTextField(contentAssistGroup);
-
- createLabel(contentAssistGroup, XMLUIMessages.Suggestion_Strategy);
- fSuggestionStrategyCombo = new Combo(contentAssistGroup, SWT.READ_ONLY);
- fSuggestionStrategies = new Vector();
- fSuggestionStrategyCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
- fSuggestionStrategyCombo.add(XMLUIMessages.Suggestion_Strategy_Lax);
- fSuggestionStrategies.add(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_LAX);
- fSuggestionStrategyCombo.add(XMLUIMessages.Suggestion_Strategy_Strict);
- fSuggestionStrategies.add(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT);
- }
-
- /**
- * <p>Create the contents for the content assist cycling preference group</p>
- * @param parent {@link Composite} parent of the group
- */
- private void createContentsForCyclingGroup(Composite parent) {
- ICompletionProposalCategoriesConfigurationWriter configurationWriter = CompletionProposoalCatigoriesConfigurationRegistry.getDefault().getWritableConfiguration(XML_CONTENT_TYPE_ID);
-
- if(configurationWriter != null) {
- fConfigurationBlock = new CodeAssistCyclingConfigurationBlock(XML_CONTENT_TYPE_ID, configurationWriter);
- fConfigurationBlock.createContents(parent, XMLUIMessages.XMLContentAssistPreferencePage_Cycling_UI_);
- } else {
- Logger.log(Logger.ERROR, "There should be an ICompletionProposalCategoriesConfigurationWriter" + //$NON-NLS-1$
- " specified for the XML content type, but can't fine it, thus can't create user" + //$NON-NLS-1$
- " preference block for editing proposal categories preferences."); //$NON-NLS-1$
- }
- }
-
- /**
- * <p>Store the values for the auto activation group</p>
- */
- private void storeValuesForAutoActivationGroup() {
- getPreferenceStore().setValue(XMLUIPreferenceNames.AUTO_PROPOSE, fAutoPropose.getSelection());
- getPreferenceStore().setValue(XMLUIPreferenceNames.AUTO_PROPOSE_CODE, fAutoProposeText.getText());
- getPreferenceStore().setValue(XMLUIPreferenceNames.SUGGESTION_STRATEGY, getCurrentAutoActivationSuggestionStrategy());
- }
-
- /**
- * <p>Store the values for the cycling group</p>
- */
- private void storeValuesForCyclingGroup() {
- if (fConfigurationBlock != null) {
- fConfigurationBlock.storeValues();
- }
- }
-
- /**
- * <p>Initialize the values for the auto activation group</p>
- */
- private void initializeValuesForAutoActivationGroup() {
- fAutoPropose.setSelection(getPreferenceStore().getBoolean(XMLUIPreferenceNames.AUTO_PROPOSE));
- fAutoProposeText.setText(getPreferenceStore().getString(XMLUIPreferenceNames.AUTO_PROPOSE_CODE));
- String suggestionStrategy = getPreferenceStore().getString(XMLUIPreferenceNames.SUGGESTION_STRATEGY);
- if (suggestionStrategy.length() > 0) {
- setCurrentAutoActivationSuggestionStrategy(suggestionStrategy);
- }
- else {
- setCurrentAutoActivationSuggestionStrategy(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_LAX);
- }
- }
-
- /**
- * <p>Initialize the values for the cycling group</p>
- */
- private void initializeValuesForCyclingGroup() {
- if(fConfigurationBlock != null) {
- fConfigurationBlock.initializeValues();
- }
- }
-
- /**
- * <p>Load the defaults for the auto activation group</p>
- */
- private void performDefaultsForAutoActivationGroup() {
- fAutoPropose.setSelection(getPreferenceStore().getDefaultBoolean(XMLUIPreferenceNames.AUTO_PROPOSE));
- fAutoProposeText.setText(getPreferenceStore().getDefaultString(XMLUIPreferenceNames.AUTO_PROPOSE_CODE));
- String suggestionStrategy = getPreferenceStore().getDefaultString(XMLUIPreferenceNames.SUGGESTION_STRATEGY);
- if (suggestionStrategy.length() > 0) {
- setCurrentAutoActivationSuggestionStrategy(suggestionStrategy);
- }
- else {
- setCurrentAutoActivationSuggestionStrategy(XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_LAX);
- }
- }
-
- /**
- * <p>Load the defaults of the cycling group</p>
- */
- private void performDefaultsForCyclingGroup() {
- if(fConfigurationBlock != null) {
- fConfigurationBlock.performDefaults();
- }
- }
-
- /**
- * Return the currently selected suggestion strategy preference
- *
- * @return a suggestion strategy constant from XMLUIPreferenceNames
- */
- private String getCurrentAutoActivationSuggestionStrategy() {
- int i = fSuggestionStrategyCombo.getSelectionIndex();
- if (i >= 0) {
- return (String) (fSuggestionStrategies.elementAt(i));
- }
- return ""; //$NON-NLS-1$
- }
-
- /**
- * Set a suggestion strategy in suggestion strategy combo box
- *
- * @param strategy
- */
- private void setCurrentAutoActivationSuggestionStrategy(String strategy) {
- // Clear the current selection.
- fSuggestionStrategyCombo.clearSelection();
- fSuggestionStrategyCombo.deselectAll();
-
- int i = fSuggestionStrategies.indexOf(strategy);
- if (i >= 0) {
- fSuggestionStrategyCombo.select(i);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java
deleted file mode 100644
index 8a19fcac83..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLFilesPreferencePage.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Iterator;
-import java.util.List;
-
-import org.eclipse.core.runtime.Platform;
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.core.runtime.content.IContentType;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.swt.layout.GridData;
-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.ui.PlatformUI;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-public class XMLFilesPreferencePage extends AbstractPreferencePage {
- protected EncodingSettings fEncodingSettings = null;
-
- private Combo fDefaultSuffix;
- private List fValidExtensions;
-
- protected Control createContents(Composite parent) {
- Composite composite = (Composite) super.createContents(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_FILES_HELPID);
- createContentsForCreatingGroup(composite);
-
- setSize(composite);
- loadPreferences();
-
- return composite;
- }
-
- protected void createContentsForCreatingGroup(Composite parent) {
- Group creatingGroup = createGroup(parent, 2);
- creatingGroup.setText(XMLUIMessages.Creating_files);
-
- // Default extension for New file Wizard
- createLabel(creatingGroup, XMLUIMessages.XMLFilesPreferencePage_ExtensionLabel);
- fDefaultSuffix = createDropDownBox(creatingGroup);
- String[] validExtensions = (String[]) getValidExtensions().toArray(new String[0]);
- Arrays.sort(validExtensions);
- fDefaultSuffix.setItems(validExtensions);
- fDefaultSuffix.addSelectionListener(this);
-
- Label label = createLabel(creatingGroup, XMLUIMessages.Encoding_desc);
- ((GridData) label.getLayoutData()).horizontalSpan = 2;
- fEncodingSettings = new EncodingSettings(creatingGroup, XMLUIMessages.Encoding);
- ((GridData) fEncodingSettings.getLayoutData()).horizontalSpan = 2;
- }
-
- public void dispose() {
- fDefaultSuffix.removeModifyListener(this);
- super.dispose();
- }
-
- protected void doSavePreferenceStore() {
- XMLCorePlugin.getDefault().savePluginPreferences(); // model
- }
-
- /**
- * Get content type associated with this new file wizard
- *
- * @return IContentType
- */
- protected IContentType getContentType() {
- return Platform.getContentTypeManager().getContentType(ContentTypeIdForXML.ContentTypeID_XML);
- }
-
- /**
- * Get list of valid extensions
- *
- * @return List
- */
- private List getValidExtensions() {
- if (fValidExtensions == null) {
- IContentType type = getContentType();
- fValidExtensions = new ArrayList(Arrays.asList(type.getFileSpecs(IContentType.FILE_EXTENSION_SPEC)));
- }
- return fValidExtensions;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.preferences.ui.AbstractPreferencePage#getModelPreferences()
- */
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void initializeValues() {
- initializeValuesForCreatingGroup();
- }
-
- protected void initializeValuesForCreatingGroup() {
- String suffix = getModelPreferences().getString(XMLCorePreferenceNames.DEFAULT_EXTENSION);
- fDefaultSuffix.setText(suffix);
-
- String encoding = getModelPreferences().getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
-
- fEncodingSettings.setIANATag(encoding);
- }
-
- protected void performDefaults() {
- performDefaultsForCreatingGroup();
-
- super.performDefaults();
- }
-
- protected void performDefaultsForCreatingGroup() {
- String suffix = getModelPreferences().getDefaultString(XMLCorePreferenceNames.DEFAULT_EXTENSION);
- fDefaultSuffix.setText(suffix);
-
- String encoding = getModelPreferences().getDefaultString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
-
- fEncodingSettings.setIANATag(encoding);
- // fEncodingSettings.resetToDefaultEncoding();
- }
-
- public boolean performOk() {
- boolean result = super.performOk();
-
- doSavePreferenceStore();
-
- return result;
- }
-
- protected void storeValues() {
- storeValuesForCreatingGroup();
- }
-
- protected void storeValuesForCreatingGroup() {
- String suffix = fDefaultSuffix.getText();
- getModelPreferences().setValue(XMLCorePreferenceNames.DEFAULT_EXTENSION, suffix);
-
- getModelPreferences().setValue(CommonEncodingPreferenceNames.OUTPUT_CODESET, fEncodingSettings.getIANATag());
- }
-
- protected void validateValues() {
- boolean isValid = false;
- Iterator i = getValidExtensions().iterator();
- while (i.hasNext() && !isValid) {
- String extension = (String) i.next();
- isValid = extension.equalsIgnoreCase(fDefaultSuffix.getText());
- }
-
- if (!isValid) {
- setErrorMessage(NLS.bind(XMLUIMessages.XMLFilesPreferencePage_ExtensionError, getValidExtensions().toString()));
- setValid(false);
- }
- else {
- setErrorMessage(null);
- setValid(true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
deleted file mode 100644
index 65456897e2..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSourcePreferencePage.java
+++ /dev/null
@@ -1,306 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.jface.layout.GridDataFactory;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.ModifyListener;
-import org.eclipse.swt.events.SelectionListener;
-import org.eclipse.swt.layout.GridData;
-import org.eclipse.swt.layout.GridLayout;
-import org.eclipse.swt.widgets.Button;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Group;
-import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Spinner;
-import org.eclipse.swt.widgets.Text;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PreferenceLinkArea;
-import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-public class XMLSourcePreferencePage extends AbstractPreferencePage implements ModifyListener, SelectionListener, IWorkbenchPreferencePage {
- private final int MIN_INDENTATION_SIZE = 0;
- private final int MAX_INDENTATION_SIZE = 16;
-
- // Formatting
- protected Label fLineWidthLabel;
- protected Text fLineWidthText;
- protected Button fSplitMultiAttrs;
- private Button fIndentUsingTabs;
- private Button fIndentUsingSpaces;
- private Spinner fIndentationSize;
- private Button fPreservePCDATAContent;
- private Button fAlignEndBracket;
- private Button fFormatComments;
- private Button fFormatCommentsJoinLines;
- // BUG195264 - Support for removing/adding a space before empty close tags
- private Button fSpaceBeforeEmptyCloseTag;
- protected Button fClearAllBlankLines;
-
- // grammar constraints
- protected Button fUseInferredGrammar;
-
- protected Control createContents(Composite parent) {
- final Composite composite = super.createComposite(parent, 1);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_SOURCE_HELPID);
-
- new PreferenceLinkArea(composite, SWT.WRAP | SWT.MULTI, "org.eclipse.wst.sse.ui.preferences.editor", XMLUIMessages._UI_STRUCTURED_TEXT_EDITOR_PREFS_LINK,//$NON-NLS-1$
- (IWorkbenchPreferenceContainer) getContainer(), null).getControl().setLayoutData(GridDataFactory.fillDefaults().hint(150, SWT.DEFAULT).create());
- new Label(composite, SWT.NONE).setLayoutData(GridDataFactory.swtDefaults().create());
-
- createContentsForFormattingGroup(composite);
- createContentsForGrammarConstraintsGroup(composite);
- setSize(composite);
- loadPreferences();
-
- return composite;
- }
-
- protected void createContentsForFormattingGroup(Composite parent) {
- Group formattingGroup = createGroup(parent, 2);
- formattingGroup.setText(XMLUIMessages.Formatting_UI_);
-
- fLineWidthLabel = createLabel(formattingGroup, XMLUIMessages.Line_width__UI_);
- fLineWidthText = new Text(formattingGroup, SWT.SINGLE | SWT.BORDER);
- GridData gData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.BEGINNING);
- gData.widthHint = 25;
- fLineWidthText.setLayoutData(gData);
- fLineWidthText.addModifyListener(this);
-
- fSplitMultiAttrs = createCheckBox(formattingGroup, XMLUIMessages.Split_multiple_attributes);
- ((GridData) fSplitMultiAttrs.getLayoutData()).horizontalSpan = 2;
- fAlignEndBracket = createCheckBox(formattingGroup, XMLUIMessages.Align_final_bracket);
- ((GridData) fAlignEndBracket.getLayoutData()).horizontalSpan = 2;
- fPreservePCDATAContent = createCheckBox(formattingGroup, XMLUIMessages.Preserve_PCDATA_Content);
- ((GridData) fPreservePCDATAContent.getLayoutData()).horizontalSpan = 2;
- fClearAllBlankLines = createCheckBox(formattingGroup, XMLUIMessages.Clear_all_blank_lines_UI_);
- ((GridData) fClearAllBlankLines.getLayoutData()).horizontalSpan = 2;
- // formatting comments
- fFormatComments = createCheckBox(formattingGroup, XMLUIMessages.Format_comments);
- ((GridData) fFormatComments.getLayoutData()).horizontalSpan = 2;
- fFormatComments.addSelectionListener(this);
- fFormatCommentsJoinLines = createCheckBox(formattingGroup, XMLUIMessages.Format_comments_join_lines);
- ((GridData) fFormatCommentsJoinLines.getLayoutData()).horizontalSpan = 2;
- ((GridData) fFormatCommentsJoinLines.getLayoutData()).horizontalIndent = 20;
- // end formatting comments
- fSpaceBeforeEmptyCloseTag = createCheckBox(formattingGroup, XMLUIMessages.Space_before_empty_close_tag);
- ((GridData) fSpaceBeforeEmptyCloseTag.getLayoutData()).horizontalSpan = 2;
-
- // [269224] - Place the indent controls in their own composite for proper tab ordering
- Composite indentComposite = createComposite(formattingGroup, 1);
- ((GridData) indentComposite.getLayoutData()).horizontalSpan = 2;
- ((GridLayout) indentComposite.getLayout()).marginWidth = 0;
- ((GridLayout) indentComposite.getLayout()).marginHeight = 0;
-
- fIndentUsingTabs = createRadioButton(indentComposite, XMLUIMessages.Indent_using_tabs);
- ((GridData) fIndentUsingTabs.getLayoutData()).horizontalSpan = 1;
-
- fIndentUsingSpaces = createRadioButton(indentComposite, XMLUIMessages.Indent_using_spaces);
- ((GridData) fIndentUsingSpaces.getLayoutData()).horizontalSpan = 1;
-
- createLabel(formattingGroup, XMLUIMessages.Indentation_size);
- fIndentationSize = new Spinner(formattingGroup, SWT.READ_ONLY | SWT.BORDER);
- GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
- fIndentationSize.setLayoutData(gd);
- fIndentationSize.setToolTipText(XMLUIMessages.Indentation_size_tip);
- fIndentationSize.setMinimum(MIN_INDENTATION_SIZE);
- fIndentationSize.setMaximum(MAX_INDENTATION_SIZE);
- fIndentationSize.setIncrement(1);
- fIndentationSize.setPageIncrement(4);
- fIndentationSize.addModifyListener(this);
- }
-
- protected void createContentsForGrammarConstraintsGroup(Composite parent) {
- Group grammarConstraintsGroup = createGroup(parent, 1);
- grammarConstraintsGroup.setText(XMLUIMessages.Grammar_Constraints);
- grammarConstraintsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL));
-
- fUseInferredGrammar = createCheckBox(grammarConstraintsGroup, XMLUIMessages.Use_inferred_grammar_in_absence_of);
- }
-
- protected IPreferenceStore doGetPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- protected void doSavePreferenceStore() {
- XMLUIPlugin.getDefault().savePluginPreferences(); // editor
- XMLCorePlugin.getDefault().savePluginPreferences(); // model
- }
-
- protected void enableValues() {
- if (fFormatComments != null && fFormatCommentsJoinLines != null) {
- fFormatCommentsJoinLines.setEnabled(fFormatComments.getSelection());
- }
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void initializeValues() {
- initializeValuesForFormattingGroup();
- initializeValuesForGrammarConstraintsGroup();
- }
-
- protected void initializeValuesForFormattingGroup() {
- // Formatting
- fLineWidthText.setText(getModelPreferences().getString(XMLCorePreferenceNames.LINE_WIDTH));
- fSplitMultiAttrs.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
- fAlignEndBracket.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
- fClearAllBlankLines.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
- fPreservePCDATAContent.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
- fSpaceBeforeEmptyCloseTag.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.SPACE_BEFORE_EMPTY_CLOSE_TAG));
- fFormatComments.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_TEXT));
- fFormatCommentsJoinLines.setSelection(getModelPreferences().getBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_JOIN_LINES));
-
- if (XMLCorePreferenceNames.TAB.equals(getModelPreferences().getString(XMLCorePreferenceNames.INDENTATION_CHAR))) {
- fIndentUsingTabs.setSelection(true);
- fIndentUsingSpaces.setSelection(false);
- }
- else {
- fIndentUsingSpaces.setSelection(true);
- fIndentUsingTabs.setSelection(false);
- }
-
- fIndentationSize.setSelection(getModelPreferences().getInt(XMLCorePreferenceNames.INDENTATION_SIZE));
- }
-
- protected void initializeValuesForGrammarConstraintsGroup() {
- fUseInferredGrammar.setSelection(getPreferenceStore().getBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR));
- }
-
- protected void performDefaults() {
- performDefaultsForFormattingGroup();
- performDefaultsForGrammarConstraintsGroup();
-
- validateValues();
- enableValues();
-
- super.performDefaults();
- }
-
- protected void performDefaultsForFormattingGroup() {
- // Formatting
- fLineWidthText.setText(getModelPreferences().getDefaultString(XMLCorePreferenceNames.LINE_WIDTH));
- fSplitMultiAttrs.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS));
- fAlignEndBracket.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.ALIGN_END_BRACKET));
- fClearAllBlankLines.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES));
- fPreservePCDATAContent.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.PRESERVE_CDATACONTENT));
- // BUG195264 - Support for removing/adding a space before empty close tags
- fSpaceBeforeEmptyCloseTag.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.SPACE_BEFORE_EMPTY_CLOSE_TAG));
- fFormatComments.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_TEXT));
- fFormatCommentsJoinLines.setSelection(getModelPreferences().getDefaultBoolean(XMLCorePreferenceNames.FORMAT_COMMENT_JOIN_LINES));
-
- if (XMLCorePreferenceNames.TAB.equals(getModelPreferences().getDefaultString(XMLCorePreferenceNames.INDENTATION_CHAR))) {
- fIndentUsingTabs.setSelection(true);
- fIndentUsingSpaces.setSelection(false);
- }
- else {
- fIndentUsingSpaces.setSelection(true);
- fIndentUsingTabs.setSelection(false);
- }
- fIndentationSize.setSelection(getModelPreferences().getDefaultInt(XMLCorePreferenceNames.INDENTATION_SIZE));
- }
-
- protected void performDefaultsForGrammarConstraintsGroup() {
- fUseInferredGrammar.setSelection(getPreferenceStore().getDefaultBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR));
- }
-
- public boolean performOk() {
- boolean result = super.performOk();
-
- doSavePreferenceStore();
-
- return result;
- }
-
- protected void storeValues() {
- storeValuesForFormattingGroup();
- storeValuesForGrammarConstraintsGroup();
- }
-
- protected void storeValuesForFormattingGroup() {
- // Formatting
- getModelPreferences().setValue(XMLCorePreferenceNames.LINE_WIDTH, fLineWidthText.getText());
- getModelPreferences().setValue(XMLCorePreferenceNames.SPLIT_MULTI_ATTRS, fSplitMultiAttrs.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.ALIGN_END_BRACKET, fAlignEndBracket.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.CLEAR_ALL_BLANK_LINES, fClearAllBlankLines.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.PRESERVE_CDATACONTENT, fPreservePCDATAContent.getSelection());
- // BUG195264 - Support for removing/adding a space before empty close tags
- getModelPreferences().setValue(XMLCorePreferenceNames.SPACE_BEFORE_EMPTY_CLOSE_TAG, fSpaceBeforeEmptyCloseTag.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.FORMAT_COMMENT_TEXT, fFormatComments.getSelection());
- getModelPreferences().setValue(XMLCorePreferenceNames.FORMAT_COMMENT_JOIN_LINES, fFormatCommentsJoinLines.getSelection());
-
- if (fIndentUsingTabs.getSelection()) {
- getModelPreferences().setValue(XMLCorePreferenceNames.INDENTATION_CHAR, XMLCorePreferenceNames.TAB);
- }
- else {
- getModelPreferences().setValue(XMLCorePreferenceNames.INDENTATION_CHAR, XMLCorePreferenceNames.SPACE);
- }
- getModelPreferences().setValue(XMLCorePreferenceNames.INDENTATION_SIZE, fIndentationSize.getSelection());
- }
-
- protected void storeValuesForGrammarConstraintsGroup() {
- getPreferenceStore().setValue(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR, fUseInferredGrammar.getSelection());
- }
-
- protected void validateValues() {
- boolean isError = false;
- String widthText = null;
-
- if (fLineWidthText != null) {
- try {
- widthText = fLineWidthText.getText();
- int formattingLineWidth = Integer.parseInt(widthText);
- if ((formattingLineWidth < WIDTH_VALIDATION_LOWER_LIMIT) || (formattingLineWidth > WIDTH_VALIDATION_UPPER_LIMIT)) {
- throw new NumberFormatException();
- }
- }
- catch (NumberFormatException nfexc) {
- setInvalidInputMessage(widthText);
- setValid(false);
- isError = true;
- }
- }
-
- int indentSize = 0;
- if (fIndentationSize != null) {
- try {
- indentSize = fIndentationSize.getSelection();
- if ((indentSize < MIN_INDENTATION_SIZE) || (indentSize > MAX_INDENTATION_SIZE)) {
- throw new NumberFormatException();
- }
- }
- catch (NumberFormatException nfexc) {
- setInvalidInputMessage(Integer.toString(indentSize));
- setValid(false);
- isError = true;
- }
- }
-
- if (!isError) {
- setErrorMessage(null);
- setValid(true);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSyntaxColoringPage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSyntaxColoringPage.java
deleted file mode 100644
index 245f0abf15..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLSyntaxColoringPage.java
+++ /dev/null
@@ -1,873 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-import org.eclipse.jface.preference.ColorSelector;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.preference.PreferencePage;
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.jface.viewers.ISelectionChangedListener;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.ITreeContentProvider;
-import org.eclipse.jface.viewers.LabelProvider;
-import org.eclipse.jface.viewers.ListViewer;
-import org.eclipse.jface.viewers.SelectionChangedEvent;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.StructuredViewer;
-import org.eclipse.jface.viewers.Viewer;
-import org.eclipse.jface.viewers.ViewerComparator;
-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.custom.SashForm;
-import org.eclipse.swt.custom.StyleRange;
-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.SelectionAdapter;
-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.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.Link;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.IWorkbenchPreferencePage;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.dialogs.PreferencesUtil;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.SSEUIMessages;
-import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore;
-import org.eclipse.wst.sse.ui.internal.preferences.OverlayPreferenceStore.OverlayKey;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;
-import org.eclipse.wst.sse.ui.internal.util.EditorUtility;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
-
-import com.ibm.icu.text.Collator;
-
-/**
- * A preference page to configure our XML syntax color. It resembles the JDT
- * and CDT pages far more than our original color page while retaining the
- * extra "click-to-find" functionality.
- */
-public final class XMLSyntaxColoringPage extends PreferencePage implements IWorkbenchPreferencePage {
-
- private Button fBold;
- private Label fForegroundLabel;
- private Label fBackgroundLabel;
- private Button fClearStyle;
- private Map fContextToStyleMap;
- private Color fDefaultForeground = null;
- private Color fDefaultBackground = null;
- private IStructuredDocument fDocument;
- private ColorSelector fForegroundColorEditor;
- private ColorSelector fBackgroundColorEditor;
- private Button fItalic;
- private OverlayPreferenceStore fOverlayStore;
- private Button fStrike;
- private Collection fStylePreferenceKeys;
- private StructuredViewer fStylesViewer = null;
- private Map fStyleToDescriptionMap;
- private StyledText fText;
- private Button fUnderline;
-
- // activate controls based on the given local color type
- private void activate(String namedStyle) {
- Color foreground = fDefaultForeground;
- Color background = fDefaultBackground;
- if (namedStyle == null) {
- fClearStyle.setEnabled(false);
- fBold.setEnabled(false);
- fItalic.setEnabled(false);
- fStrike.setEnabled(false);
- fUnderline.setEnabled(false);
- fForegroundLabel.setEnabled(false);
- fBackgroundLabel.setEnabled(false);
- fForegroundColorEditor.setEnabled(false);
- fBackgroundColorEditor.setEnabled(false);
- fBold.setSelection(false);
- fItalic.setSelection(false);
- fStrike.setSelection(false);
- fUnderline.setSelection(false);
- }
- else {
- TextAttribute attribute = getAttributeFor(namedStyle);
- fClearStyle.setEnabled(true);
- fBold.setEnabled(true);
- fItalic.setEnabled(true);
- fStrike.setEnabled(true);
- fUnderline.setEnabled(true);
- fForegroundLabel.setEnabled(true);
- fBackgroundLabel.setEnabled(true);
- fForegroundColorEditor.setEnabled(true);
- fBackgroundColorEditor.setEnabled(true);
- fBold.setSelection((attribute.getStyle() & SWT.BOLD) != 0);
- fItalic.setSelection((attribute.getStyle() & SWT.ITALIC) != 0);
- fStrike.setSelection((attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0);
- fUnderline.setSelection((attribute.getStyle() & TextAttribute.UNDERLINE) != 0);
- if (attribute.getForeground() != null) {
- foreground = attribute.getForeground();
- }
- if (attribute.getBackground() != null) {
- background = attribute.getBackground();
- }
- }
-
- fForegroundColorEditor.setColorValue(foreground.getRGB());
- fBackgroundColorEditor.setColorValue(background.getRGB());
- }
-
- /**
- * Color the text in the sample area according to the current preferences
- */
- void applyStyles() {
- if (fText == null || fText.isDisposed())
- return;
- IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion();
- while (documentRegion != null) {
- ITextRegionList regions = documentRegion.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) fContextToStyleMap.get(currentRegion.getType());
- if (namedStyle == null)
- continue;
- TextAttribute attribute = getAttributeFor(namedStyle);
- if (attribute == null)
- continue;
- StyleRange style = new StyleRange(documentRegion.getStartOffset(currentRegion), currentRegion.getTextLength(), attribute.getForeground(), attribute.getBackground(), attribute.getStyle());
- style.strikeout = (attribute.getStyle() & TextAttribute.STRIKETHROUGH) != 0;
- style.underline = (attribute.getStyle() & TextAttribute.UNDERLINE) != 0;
- fText.setStyleRange(style);
- }
- documentRegion = documentRegion.getNext();
- }
- }
-
- Button createCheckbox(Composite parent, String label) {
- Button button = new Button(parent, SWT.CHECK);
- button.setText(label);
- button.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
- return button;
- }
-
- /**
- * 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.makeColumnsEqualWidth = false;
- layout.marginHeight = 0;
- layout.marginWidth = 0;
- composite.setLayout(layout);
-
- // GridData
- GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
- composite.setLayoutData(data);
- return composite;
- }
-
- protected Control createContents(final Composite parent) {
- initializeDialogUnits(parent);
-
- fDefaultForeground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_FOREGROUND);
- fDefaultBackground = parent.getDisplay().getSystemColor(SWT.COLOR_LIST_BACKGROUND);
- Composite pageComponent = createComposite(parent, 2);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
-
- Link link = new Link(pageComponent, SWT.WRAP);
- link.setText(SSEUIMessages.SyntaxColoring_Link);
- link.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null);
- }
- });
-
- GridData linkData= new GridData(SWT.FILL, SWT.BEGINNING, true, false, 2, 1);
- linkData.widthHint= 150; // only expand further if anyone else requires it
- link.setLayoutData(linkData);
-
- new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
- new Label(pageComponent, SWT.NONE).setLayoutData(new GridData());
-
- SashForm editor = new SashForm(pageComponent, SWT.VERTICAL);
- GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true);
- gridData2.horizontalSpan = 2;
- editor.setLayoutData(gridData2);
- SashForm top = new SashForm(editor, SWT.HORIZONTAL);
- Composite styleEditor = createComposite(top, 1);
- ((GridLayout) styleEditor.getLayout()).marginRight = 5;
- ((GridLayout) styleEditor.getLayout()).marginLeft = 0;
- createLabel(styleEditor, XMLUIMessages.SyntaxColoringPage_0);
- fStylesViewer = createStylesViewer(styleEditor);
- GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
- gridData.horizontalIndent = 0;
- Iterator iterator = fStyleToDescriptionMap.values().iterator();
- while (iterator.hasNext()) {
- gridData.widthHint = Math.max(gridData.widthHint, convertWidthInCharsToPixels(iterator.next().toString().length()));
- }
- gridData.heightHint = convertHeightInCharsToPixels(5);
- fStylesViewer.getControl().setLayoutData(gridData);
-
- Composite editingComposite = createComposite(top, 1);
- ((GridLayout) styleEditor.getLayout()).marginLeft = 5;
- createLabel(editingComposite, ""); //$NON-NLS-1$
- Button enabler = createCheckbox(editingComposite, XMLUIMessages.SyntaxColoringPage_2);
- enabler.setEnabled(false);
- enabler.setSelection(true);
- Composite editControls = createComposite(editingComposite, 2);
- ((GridLayout) editControls.getLayout()).marginLeft = 20;
-
- fForegroundLabel = createLabel(editControls, SSEUIMessages.Foreground_UI_);
- ((GridData) fForegroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
- fForegroundLabel.setEnabled(false);
-
- fForegroundColorEditor = new ColorSelector(editControls);
- Button fForegroundColor = fForegroundColorEditor.getButton();
- GridData gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
- fForegroundColor.setLayoutData(gd);
- fForegroundColorEditor.setEnabled(false);
-
- fBackgroundLabel = createLabel(editControls, SSEUIMessages.Background_UI_);
- ((GridData) fBackgroundLabel.getLayoutData()).verticalAlignment = SWT.CENTER;
- fBackgroundLabel.setEnabled(false);
-
- fBackgroundColorEditor = new ColorSelector(editControls);
- Button fBackgroundColor = fBackgroundColorEditor.getButton();
- gd = new GridData(SWT.BEGINNING, SWT.FILL, false, false);
- fBackgroundColor.setLayoutData(gd);
- fBackgroundColorEditor.setEnabled(false);
-
- fBold = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_3);
- fBold.setEnabled(false);
- ((GridData) fBold.getLayoutData()).horizontalSpan = 2;
- fItalic = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_4);
- fItalic.setEnabled(false);
- ((GridData) fItalic.getLayoutData()).horizontalSpan = 2;
- fStrike = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_5);
- fStrike.setEnabled(false);
- ((GridData) fStrike.getLayoutData()).horizontalSpan = 2;
- fUnderline = createCheckbox(editControls, XMLUIMessages.SyntaxColoringPage_6);
- fUnderline.setEnabled(false);
- ((GridData) fUnderline.getLayoutData()).horizontalSpan = 2;
- fClearStyle = new Button(editingComposite, SWT.PUSH);
- fClearStyle.setText(SSEUIMessages.Restore_Default_UI_); //$NON-NLS-1$ = "Restore Default"
- fClearStyle.setLayoutData(new GridData(SWT.BEGINNING));
- ((GridData) fClearStyle.getLayoutData()).horizontalIndent = 20;
- fClearStyle.setEnabled(false);
-
- Composite sampleArea = createComposite(editor, 1);
-
- ((GridLayout) sampleArea.getLayout()).marginLeft = 5;
- ((GridLayout) sampleArea.getLayout()).marginTop = 5;
- createLabel(sampleArea, SSEUIMessages.Sample_text__UI_); //$NON-NLS-1$ = "&Sample text:"
- SourceViewer viewer = new SourceViewer(sampleArea, null, SWT.BORDER | SWT.LEFT_TO_RIGHT | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.READ_ONLY);
- fText = viewer.getTextWidget();
- GridData gridData3 = new GridData(SWT.FILL, SWT.FILL, true, true);
- gridData3.widthHint = convertWidthInCharsToPixels(20);
- gridData3.heightHint = convertHeightInCharsToPixels(5);
- gridData3.horizontalSpan = 2;
- fText.setLayoutData(gridData3);
- fText.setEditable(false);
- fText.setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$
- fText.addKeyListener(getTextKeyListener());
- fText.addSelectionListener(getTextSelectionListener());
- fText.addMouseListener(getTextMouseListener());
- fText.addTraverseListener(getTraverseListener());
- setAccessible(fText, SSEUIMessages.Sample_text__UI_);
- fDocument = StructuredModelManager.getModelManager().createStructuredDocumentFor(ContentTypeIdForXML.ContentTypeID_XML);
- fDocument.set(getExampleText());
- viewer.setDocument(fDocument);
-
- top.setWeights(new int[]{1, 1});
- editor.setWeights(new int[]{1, 1});
- PlatformUI.getWorkbench().getHelpSystem().setHelp(pageComponent, IHelpContextIds.XML_PREFWEBX_STYLES_HELPID);
-
- fStylesViewer.setInput(getStylePreferenceKeys());
-
- applyStyles();
-
- fStylesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
- public void selectionChanged(SelectionChangedEvent event) {
- if (!event.getSelection().isEmpty()) {
- Object o = ((IStructuredSelection) event.getSelection()).getFirstElement();
- String namedStyle = o.toString();
- activate(namedStyle);
- if (namedStyle == null)
- return;
- }
- }
- });
-
- fForegroundColorEditor.addListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
- Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
- String namedStyle = o.toString();
- String prefString = getOverlayStore().getString(namedStyle);
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[0];
- // open color dialog to get new color
- String newValue = ColorHelper.toRGBString(fForegroundColorEditor.getColorValue());
-
- if (!newValue.equals(oldValue)) {
- stylePrefs[0] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getOverlayStore().setValue(namedStyle, newPrefString);
- applyStyles();
- fText.redraw();
- }
- }
- }
- }
- });
-
- fBackgroundColorEditor.addListener(new IPropertyChangeListener() {
- public void propertyChange(PropertyChangeEvent event) {
- if (event.getProperty().equals(ColorSelector.PROP_COLORCHANGE)) {
- Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
- String namedStyle = o.toString();
- String prefString = getOverlayStore().getString(namedStyle);
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[1];
- // open color dialog to get new color
- String newValue = ColorHelper.toRGBString(fBackgroundColorEditor.getColorValue());
-
- if (!newValue.equals(oldValue)) {
- stylePrefs[1] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getOverlayStore().setValue(namedStyle, newPrefString);
- applyStyles();
- fText.redraw();
- activate(namedStyle);
- }
- }
- }
- }
- });
-
- fBold.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- // get current (newly old) style
- Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
- String namedStyle = o.toString();
- String prefString = getOverlayStore().getString(namedStyle);
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[2];
- String newValue = String.valueOf(fBold.getSelection());
- if (!newValue.equals(oldValue)) {
- stylePrefs[2] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getOverlayStore().setValue(namedStyle, newPrefString);
- applyStyles();
- fText.redraw();
- }
- }
- }
- });
-
- fItalic.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- // get current (newly old) style
- Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
- String namedStyle = o.toString();
- String prefString = getOverlayStore().getString(namedStyle);
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[3];
- String newValue = String.valueOf(fItalic.getSelection());
- if (!newValue.equals(oldValue)) {
- stylePrefs[3] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getOverlayStore().setValue(namedStyle, newPrefString);
- applyStyles();
- fText.redraw();
- }
- }
- }
- });
-
- fStrike.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- // get current (newly old) style
- Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
- String namedStyle = o.toString();
- String prefString = getOverlayStore().getString(namedStyle);
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[4];
- String newValue = String.valueOf(fStrike.getSelection());
- if (!newValue.equals(oldValue)) {
- stylePrefs[4] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getOverlayStore().setValue(namedStyle, newPrefString);
- applyStyles();
- fText.redraw();
- }
- }
- }
- });
-
- fUnderline.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- super.widgetSelected(e);
- // get current (newly old) style
- Object o = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement();
- String namedStyle = o.toString();
- String prefString = getOverlayStore().getString(namedStyle);
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- String oldValue = stylePrefs[5];
- String newValue = String.valueOf(fUnderline.getSelection());
- if (!newValue.equals(oldValue)) {
- stylePrefs[5] = newValue;
- String newPrefString = ColorHelper.packStylePreferences(stylePrefs);
- getOverlayStore().setValue(namedStyle, newPrefString);
- applyStyles();
- fText.redraw();
- }
- }
- }
- });
-
- fClearStyle.addSelectionListener(new SelectionAdapter() {
- public void widgetSelected(SelectionEvent e) {
- if (fStylesViewer.getSelection().isEmpty())
- return;
- String namedStyle = ((IStructuredSelection) fStylesViewer.getSelection()).getFirstElement().toString();
- getOverlayStore().setToDefault(namedStyle);
- applyStyles();
- fText.redraw();
- activate(namedStyle);
- }
- });
-
- return pageComponent;
- }
-
- private Label createLabel(Composite parent, String text) {
- Label label = new Label(parent, SWT.WRAP);
- label.setText(text);
- GridData data = new GridData(SWT.FILL, SWT.FILL, false, false);
- label.setLayoutData(data);
- label.setBackground(parent.getBackground());
- return label;
- }
-
- // protected Label createDescriptionLabel(Composite parent) {
- // return null;
- // }
-
- /**
- * Set up all the style preference keys in the overlay store
- */
- private OverlayKey[] createOverlayStoreKeys() {
- List overlayKeys = new ArrayList();
-
- Iterator i = getStylePreferenceKeys().iterator();
- while (i.hasNext()) {
- overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, (String) i.next()));
- }
-
- OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()];
- overlayKeys.toArray(keys);
- return keys;
- }
-
- /**
- * Creates the List viewer where we see the various syntax element display
- * names--would it ever be a Tree like JDT's?
- *
- * @param parent
- * @return
- */
- private StructuredViewer createStylesViewer(Composite parent) {
- StructuredViewer stylesViewer = new ListViewer(parent, SWT.SINGLE | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER);
- stylesViewer.setComparator(new ViewerComparator(Collator.getInstance()));
- stylesViewer.setLabelProvider(new LabelProvider() {
- public String getText(Object element) {
- Object description = fStyleToDescriptionMap.get(element);
- if (description != null)
- return description.toString();
- return super.getText(element);
- }
- });
- stylesViewer.setContentProvider(new ITreeContentProvider() {
- public void dispose() {
- }
-
- public Object[] getChildren(Object parentElement) {
- return getStylePreferenceKeys().toArray();
- }
-
- public Object[] getElements(Object inputElement) {
- return getChildren(inputElement);
- }
-
- public Object getParent(Object element) {
- return getStylePreferenceKeys();
- }
-
- public boolean hasChildren(Object element) {
- return false;
- }
-
- public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
- }
- });
- return stylesViewer;
- }
-
- public void dispose() {
- if (fOverlayStore != null) {
- fOverlayStore.stop();
- }
- super.dispose();
- }
-
- protected IPreferenceStore doGetPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- private TextAttribute getAttributeFor(String namedStyle) {
- TextAttribute ta = new TextAttribute(fDefaultForeground, fDefaultBackground, SWT.NORMAL);
-
- if (namedStyle != null && fOverlayStore != null) {
- // note: "namedStyle" *is* the preference key
- String prefString = getOverlayStore().getString(namedStyle);
- String[] stylePrefs = ColorHelper.unpackStylePreferences(prefString);
- if (stylePrefs != null) {
- RGB foreground = ColorHelper.toRGB(stylePrefs[0]);
- RGB background = ColorHelper.toRGB(stylePrefs[1]);
-
- int fontModifier = SWT.NORMAL;
-
- if (stylePrefs.length > 2) {
- boolean on = Boolean.valueOf(stylePrefs[2]).booleanValue();
- if (on)
- fontModifier = fontModifier | SWT.BOLD;
- }
- if (stylePrefs.length > 3) {
- boolean on = Boolean.valueOf(stylePrefs[3]).booleanValue();
- if (on)
- fontModifier = fontModifier | SWT.ITALIC;
- }
- if (stylePrefs.length > 4) {
- boolean on = Boolean.valueOf(stylePrefs[4]).booleanValue();
- if (on)
- fontModifier = fontModifier | TextAttribute.STRIKETHROUGH;
- }
- if (stylePrefs.length > 5) {
- boolean on = Boolean.valueOf(stylePrefs[5]).booleanValue();
- if (on)
- fontModifier = fontModifier | TextAttribute.UNDERLINE;
- }
-
- ta = new TextAttribute((foreground != null) ? EditorUtility.getColor(foreground) : null, (background != null) ? EditorUtility.getColor(background) : null, fontModifier);
- }
- }
- return ta;
- }
-
- private String getExampleText() {
- return XMLUIMessages.Sample_XML_doc;
- }
-
- private String getNamedStyleAtOffset(int offset) {
- // ensure the offset is clean
- if (offset >= fDocument.getLength())
- return getNamedStyleAtOffset(fDocument.getLength() - 1);
- else if (offset < 0)
- return getNamedStyleAtOffset(0);
- IStructuredDocumentRegion documentRegion = fDocument.getFirstStructuredDocumentRegion();
- while (documentRegion != null && !documentRegion.containsOffset(offset)) {
- documentRegion = documentRegion.getNext();
- }
- if (documentRegion != null) {
- // find the ITextRegion's Context at this offset
- ITextRegion interest = documentRegion.getRegionAtCharacterOffset(offset);
- if (interest == null)
- return null;
- if (offset > documentRegion.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) fContextToStyleMap.get(regionContext);
- if (namedStyle != null) {
- return namedStyle;
- }
- }
- return null;
- }
-
- private OverlayPreferenceStore getOverlayStore() {
- return fOverlayStore;
- }
-
- private Collection getStylePreferenceKeys() {
- if (fStylePreferenceKeys == null) {
- List styles = new ArrayList();
- styles.add(IStyleConstantsXML.DOCTYPE_NAME);
- styles.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- styles.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- styles.add(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- styles.add(IStyleConstantsXML.CDATA_BORDER);
- styles.add(IStyleConstantsXML.CDATA_TEXT);
- styles.add(IStyleConstantsXML.PI_BORDER);
- styles.add(IStyleConstantsXML.PI_CONTENT);
- styles.add(IStyleConstantsXML.TAG_BORDER);
- styles.add(IStyleConstantsXML.TAG_NAME);
- styles.add(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- styles.add(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- styles.add(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- styles.add(IStyleConstantsXML.COMMENT_BORDER);
- styles.add(IStyleConstantsXML.COMMENT_TEXT);
- styles.add(IStyleConstantsXML.DECL_BORDER);
- styles.add(IStyleConstantsXML.XML_CONTENT);
- styles.add(IStyleConstantsXML.ENTITY_REFERENCE);
- fStylePreferenceKeys = styles;
- }
- return fStylePreferenceKeys;
- }
-
- 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 widgetSelected(SelectionEvent e) {
- selectColorAtOffset(e.x);
- if (e.widget instanceof StyledText) {
- ((StyledText) e.widget).setSelection(e.x);
- }
- }
- };
- }
-
- 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;
- }
- }
- };
- }
-
- public void init(IWorkbench workbench) {
- setDescription(SSEUIMessages.SyntaxColoring_Description);
-
- fStyleToDescriptionMap = new HashMap();
- fContextToStyleMap = new HashMap();
-
- initStyleToDescriptionMap();
- initRegionContextToStyleMap();
-
- fOverlayStore = new OverlayPreferenceStore(getPreferenceStore(), createOverlayStoreKeys());
- fOverlayStore.load();
- fOverlayStore.start();
- }
-
- private void initRegionContextToStyleMap() {
- fContextToStyleMap.put(DOMRegionContext.XML_COMMENT_OPEN, IStyleConstantsXML.COMMENT_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_COMMENT_TEXT, IStyleConstantsXML.COMMENT_TEXT);
- fContextToStyleMap.put(DOMRegionContext.XML_COMMENT_CLOSE, IStyleConstantsXML.COMMENT_BORDER);
-
- fContextToStyleMap.put(DOMRegionContext.XML_TAG_OPEN, IStyleConstantsXML.TAG_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_END_TAG_OPEN, IStyleConstantsXML.TAG_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_TAG_NAME, IStyleConstantsXML.TAG_NAME);
- fContextToStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- fContextToStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS, IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- fContextToStyleMap.put(DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE, IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- fContextToStyleMap.put(DOMRegionContext.XML_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_EMPTY_TAG_CLOSE, IStyleConstantsXML.TAG_BORDER);
-
- fContextToStyleMap.put(DOMRegionContext.XML_DECLARATION_OPEN, IStyleConstantsXML.DECL_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_ELEMENT_DECLARATION, IStyleConstantsXML.DECL_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_CLOSE, IStyleConstantsXML.DECL_BORDER);
-
- fContextToStyleMap.put(DOMRegionContext.XML_CONTENT, IStyleConstantsXML.XML_CONTENT);
- fContextToStyleMap.put(DOMRegionContext.XML_CDATA_OPEN, IStyleConstantsXML.CDATA_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_CDATA_TEXT, IStyleConstantsXML.CDATA_TEXT);
- fContextToStyleMap.put(DOMRegionContext.XML_CDATA_CLOSE, IStyleConstantsXML.CDATA_BORDER);
-
- fContextToStyleMap.put(DOMRegionContext.XML_PI_OPEN, IStyleConstantsXML.PI_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_PI_CONTENT, IStyleConstantsXML.PI_CONTENT);
- fContextToStyleMap.put(DOMRegionContext.XML_PI_CLOSE, IStyleConstantsXML.PI_BORDER);
- fContextToStyleMap.put(DOMRegionContext.XML_ELEMENT_DECL_NAME, IStyleConstantsXML.DOCTYPE_NAME);
- fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION, IStyleConstantsXML.TAG_NAME);
- fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_DECLARATION_CLOSE, IStyleConstantsXML.DECL_BORDER);
-
- fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_NAME, IStyleConstantsXML.DOCTYPE_NAME);
- fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- fContextToStyleMap.put(DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
-
- fContextToStyleMap.put(DOMRegionContext.XML_CHAR_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE);
- fContextToStyleMap.put(DOMRegionContext.XML_ENTITY_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE);
- fContextToStyleMap.put(DOMRegionContext.XML_PE_REFERENCE, IStyleConstantsXML.ENTITY_REFERENCE);
- }
-
- private void initStyleToDescriptionMap() {
- fStyleToDescriptionMap.put(IStyleConstantsXML.CDATA_BORDER, XMLUIMessages.CDATA_Delimiters_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.CDATA_TEXT, XMLUIMessages.CDATA_Content_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.PI_BORDER, XMLUIMessages.Processing_Instruction_Del_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.PI_CONTENT, XMLUIMessages.Processing_Instruction_Con_UI__UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.COMMENT_BORDER, XMLUIMessages.Comment_Delimiters_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.COMMENT_TEXT, XMLUIMessages.Comment_Content_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_BORDER, XMLUIMessages.Tag_Delimiters_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_NAME, XMLUIMessages.Tag_Names_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, XMLUIMessages.Attribute_Names_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS, XMLUIMessages.Attribute_Equals_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, XMLUIMessages.Attribute_Values_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.DECL_BORDER, XMLUIMessages.Declaration_Delimiters_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.XML_CONTENT, XMLUIMessages.Content_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_NAME, XMLUIMessages.DOCTYPE_Name_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, XMLUIMessages.DOCTYPE_SYSTEM_PUBLIC_Keyw_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, XMLUIMessages.DOCTYPE_Public_Reference_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, XMLUIMessages.DOCTYPE_System_Reference_UI_);
- fStyleToDescriptionMap.put(IStyleConstantsXML.ENTITY_REFERENCE, XMLUIMessages.Entity_Reference_UI_);
- }
-
- protected void performDefaults() {
- super.performDefaults();
- getOverlayStore().loadDefaults();
- applyStyles();
- fStylesViewer.setSelection(StructuredSelection.EMPTY);
- activate(null);
- fText.redraw();
- }
-
- public boolean performOk() {
- getOverlayStore().propagate();
-
- XMLUIPlugin.getDefault().savePluginPreferences();
- SSEUIPlugin.getDefault().savePluginPreferences();
- return true;
- }
-
- private void selectColorAtOffset(int offset) {
- String namedStyle = getNamedStyleAtOffset(offset);
- if (namedStyle != null) {
- fStylesViewer.setSelection(new StructuredSelection(namedStyle));
- fStylesViewer.reveal(namedStyle);
- }
- else {
- fStylesViewer.setSelection(StructuredSelection.EMPTY);
- }
- activate(namedStyle);
- }
-
- /**
- * 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;
- }
- });
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java
deleted file mode 100644
index 810b5997e3..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTemplatePreferencePage.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.jface.resource.JFaceResources;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.contentassist.ContentAssistant;
-import org.eclipse.jface.text.contentassist.IContentAssistant;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.text.source.SourceViewer;
-import org.eclipse.jface.text.source.SourceViewerConfiguration;
-import org.eclipse.jface.text.templates.ContextTypeRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.jface.window.Window;
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.texteditor.templates.TemplatePreferencePage;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.StructuredTextViewerConfiguration;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.eclipse.wst.xml.core.internal.provisional.contenttype.ContentTypeIdForXML;
-import org.eclipse.wst.xml.ui.StructuredTextViewerConfigurationXML;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-
-/**
- * Preference page for XML templates
- */
-public class XMLTemplatePreferencePage extends TemplatePreferencePage {
-
- class XMLEditTemplateDialog extends EditTemplateDialog {
- public XMLEditTemplateDialog(Shell parent, Template template, boolean edit, boolean isNameModifiable, ContextTypeRegistry registry) {
- super(parent, template, edit, isNameModifiable, registry);
- }
-
- protected SourceViewer createViewer(Composite parent) {
- SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {
- StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationXML();
-
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return baseConfiguration.getConfiguredContentTypes(sourceViewer);
- }
-
- public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
- return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
- }
-
- public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
- ContentAssistant assistant = new ContentAssistant();
- assistant.enableAutoActivation(true);
- assistant.enableAutoInsert(true);
- assistant.setContentAssistProcessor(getTemplateProcessor(), IDocument.DEFAULT_CONTENT_TYPE);
- return assistant;
- }
- };
- return doCreateViewer(parent, sourceViewerConfiguration);
- }
- }
-
- public XMLTemplatePreferencePage() {
- XMLUIPlugin xmlEditorPlugin = XMLUIPlugin.getDefault();
-
- setPreferenceStore(xmlEditorPlugin.getPreferenceStore());
- setTemplateStore(xmlEditorPlugin.getTemplateStore());
- setContextTypeRegistry(xmlEditorPlugin.getTemplateContextRegistry());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.PreferencePage#createContents(org.eclipse.swt.widgets.Composite)
- */
- protected Control createContents(Composite ancestor) {
- Control c = super.createContents(ancestor);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(c, IHelpContextIds.XML_PREFWEBX_TEMPLATES_HELPID);
- return c;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#createViewer(org.eclipse.swt.widgets.Composite)
- */
- protected SourceViewer createViewer(Composite parent) {
- SourceViewerConfiguration sourceViewerConfiguration = new StructuredTextViewerConfiguration() {
- StructuredTextViewerConfiguration baseConfiguration = new StructuredTextViewerConfigurationXML();
-
- public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
- return baseConfiguration.getConfiguredContentTypes(sourceViewer);
- }
-
- public LineStyleProvider[] getLineStyleProviders(ISourceViewer sourceViewer, String partitionType) {
- return baseConfiguration.getLineStyleProviders(sourceViewer, partitionType);
- }
- };
- return doCreateViewer(parent, sourceViewerConfiguration);
- }
-
- SourceViewer doCreateViewer(Composite parent, SourceViewerConfiguration viewerConfiguration) {
- SourceViewer viewer = null;
- String contentTypeID = ContentTypeIdForXML.ContentTypeID_XML;
- viewer = new StructuredTextViewer(parent, null, null, false, SWT.BORDER | SWT.V_SCROLL | SWT.H_SCROLL);
- ((StructuredTextViewer) viewer).getTextWidget().setFont(JFaceResources.getFont("org.eclipse.wst.sse.ui.textfont")); //$NON-NLS-1$
- IStructuredModel scratchModel = StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(contentTypeID);
- IDocument document = scratchModel.getStructuredDocument();
- viewer.configure(viewerConfiguration);
- viewer.setDocument(document);
- return viewer;
- }
-
- /**
- * Creates the edit dialog. Subclasses may override this method to provide
- * a custom dialog.
- *
- * @param template
- * the template being edited
- * @param edit
- * whether the dialog should be editable
- * @param isNameModifiable
- * whether the template name may be modified
- * @return the created or modified template, or <code>null</code> if the
- * edition failed
- * @since 3.1
- */
- protected Template editTemplate(Template template, boolean edit, boolean isNameModifiable) {
- EditTemplateDialog dialog = new XMLEditTemplateDialog(getShell(), template, edit, isNameModifiable, getContextTypeRegistry());
- if (dialog.open() == Window.OK) {
- return dialog.getTemplate();
- }
- return null;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.templates.TemplatePreferencePage#isShowFormatterSetting()
- */
- protected boolean isShowFormatterSetting() {
- // template formatting has not been implemented
- return false;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.preference.IPreferencePage#performOk()
- */
- public boolean performOk() {
- boolean ok = super.performOk();
- XMLUIPlugin.getDefault().savePluginPreferences();
- return ok;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTypingPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTypingPreferencePage.java
deleted file mode 100644
index 8487ab2cb3..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLTypingPreferencePage.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2008, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-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.Group;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-public class XMLTypingPreferencePage extends AbstractPreferencePage {
-
- private Button fCloseComment;
- private Button fCloseEndTag;
- private Button fRemoveEndTag;
- private Button fCloseElement;
- private Button fCloseStrings;
- private Button fCloseBrackets;
-
- protected Control createContents(Composite parent) {
- Composite composite = super.createComposite(parent, 1);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_FILES_HELPID);
-
- createStartTagGroup(composite);
- createEndTagGroup(composite);
- createAutoComplete(composite);
- createAutoRemove(composite);
-
- setSize(composite);
- loadPreferences();
-
- return composite;
- }
-
- private void createStartTagGroup(Composite parent) {
- Group group = createGroup(parent, 2);
-
- group.setText(XMLUIMessages.XMLTyping_Start_Tag);
-
- fCloseElement = createCheckBox(group, XMLUIMessages.XMLTyping_Complete_Elements);
- ((GridData) fCloseElement.getLayoutData()).horizontalSpan = 2;
- }
-
- private void createEndTagGroup(Composite parent) {
- Group group = createGroup(parent, 2);
-
- group.setText(XMLUIMessages.XMLTyping_End_Tag);
-
- fCloseEndTag = createCheckBox(group, XMLUIMessages.XMLTyping_Complete_End_Tags);
- ((GridData) fCloseEndTag.getLayoutData()).horizontalSpan = 2;
- }
-
- private void createAutoComplete(Composite parent) {
- Group group = createGroup(parent, 2);
-
- group.setText(XMLUIMessages.XMLTyping_Auto_Complete);
-
- fCloseComment = createCheckBox(group, XMLUIMessages.XMLTyping_Complete_Comments);
- ((GridData) fCloseComment.getLayoutData()).horizontalSpan = 2;
-
- fCloseStrings = createCheckBox(group, XMLUIMessages.XMLTyping_Close_Strings);
- ((GridData) fCloseStrings.getLayoutData()).horizontalSpan = 2;
-
- fCloseBrackets = createCheckBox(group, XMLUIMessages.XMLTyping_Close_Brackets);
- ((GridData) fCloseBrackets.getLayoutData()).horizontalSpan = 2;
- }
-
- private void createAutoRemove(Composite parent) {
- Group group = createGroup(parent, 2);
-
- group.setText(XMLUIMessages.XMLTyping_Auto_Remove);
-
- fRemoveEndTag = createCheckBox(group, XMLUIMessages.XMLTyping_Remove_End_Tags);
- ((GridData) fRemoveEndTag.getLayoutData()).horizontalSpan = 2;
- }
-
- public boolean performOk() {
- boolean result = super.performOk();
-
- XMLUIPlugin.getDefault().savePluginPreferences();
-
- return result;
- }
-
- protected void initializeValues() {
- initCheckbox(fCloseComment, XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS);
- initCheckbox(fCloseEndTag, XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS);
- initCheckbox(fCloseElement, XMLUIPreferenceNames.TYPING_COMPLETE_ELEMENTS);
- initCheckbox(fRemoveEndTag, XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS);
- initCheckbox(fCloseStrings, XMLUIPreferenceNames.TYPING_CLOSE_STRINGS);
- initCheckbox(fCloseBrackets, XMLUIPreferenceNames.TYPING_CLOSE_BRACKETS);
- }
-
- protected void performDefaults() {
- defaultCheckbox(fCloseComment, XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS);
- defaultCheckbox(fCloseEndTag, XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS);
- defaultCheckbox(fCloseElement, XMLUIPreferenceNames.TYPING_COMPLETE_ELEMENTS);
- defaultCheckbox(fRemoveEndTag, XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS);
- defaultCheckbox(fCloseStrings, XMLUIPreferenceNames.TYPING_CLOSE_STRINGS);
- defaultCheckbox(fCloseBrackets, XMLUIPreferenceNames.TYPING_CLOSE_BRACKETS);
- }
-
- protected void storeValues() {
- getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS, (fCloseComment != null) ? fCloseComment.getSelection() : false);
- getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS, (fCloseEndTag != null) ? fCloseEndTag.getSelection() : false);
- getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_COMPLETE_ELEMENTS, (fCloseElement != null) ? fCloseElement.getSelection() : false);
- getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS, (fRemoveEndTag != null) ? fRemoveEndTag.getSelection() : false);
- getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_CLOSE_STRINGS, (fCloseStrings != null) ? fCloseStrings.getSelection() : false);
- getPreferenceStore().setValue(XMLUIPreferenceNames.TYPING_CLOSE_BRACKETS, (fCloseBrackets != null) ? fCloseBrackets.getSelection() : false);
- }
-
- protected IPreferenceStore doGetPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java
deleted file mode 100644
index 5d9d9a47cf..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceInitializer.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.resource.ColorRegistry;
-import org.eclipse.jface.text.templates.Template;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.ColorHelper;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.style.IStyleConstantsXML;
-
-/**
- * Sets default values for XML UI preferences
- */
-public class XMLUIPreferenceInitializer extends AbstractPreferenceInitializer {
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
- */
- public void initializeDefaultPreferences() {
- IPreferenceStore store = XMLUIPlugin.getDefault().getPreferenceStore();
- ColorRegistry registry = PlatformUI.getWorkbench().getThemeManager().getCurrentTheme().getColorRegistry();
-
- store.setDefault(XMLUIPreferenceNames.AUTO_PROPOSE, true);
- store.setDefault(XMLUIPreferenceNames.AUTO_PROPOSE_CODE, "<=:"); //$NON-NLS-1$
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=140946
- store.setDefault(XMLUIPreferenceNames.SUGGESTION_STRATEGY, XMLUIPreferenceNames.SUGGESTION_STRATEGY_VALUE_STRICT);
- store.setDefault(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR, true);
-
- // XML Style Preferences
- String NOBACKGROUNDBOLD = " | null | false"; //$NON-NLS-1$
- String JUSTITALIC = " | null | false | true"; //$NON-NLS-1$
- String styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.TAG_ATTRIBUTE_NAME, 127, 0, 127) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_NAME, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, 42, 0, 255) + JUSTITALIC;
- store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE, styleValue);
-
- styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
- store.setDefault(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS, styleValue); // specified
- // value is black; leaving as widget default
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.COMMENT_BORDER, 63, 95, 191) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.COMMENT_BORDER, styleValue);
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.COMMENT_TEXT, 63, 95, 191) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.COMMENT_TEXT, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.DECL_BORDER, 0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DECL_BORDER, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.DOCTYPE_NAME, 0, 0, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DOCTYPE_NAME, styleValue);
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, 0, 0, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, 128, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, 63, 127, 95) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF, styleValue);
-
- styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
- store.setDefault(IStyleConstantsXML.XML_CONTENT, styleValue); // specified
- // value is black; leaving as widget default
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.TAG_BORDER, 0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.TAG_BORDER, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.TAG_NAME, 63, 127, 127) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.TAG_NAME, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.PI_BORDER, 0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.PI_BORDER, styleValue);
-
- styleValue = "null" + NOBACKGROUNDBOLD; //$NON-NLS-1$
- store.setDefault(IStyleConstantsXML.PI_CONTENT, styleValue); // specified
- // value is black; leaving as widget default
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.CDATA_BORDER, 0, 128, 128) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.CDATA_BORDER, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.CDATA_TEXT, 0, 0, 0) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.CDATA_TEXT, styleValue);
-
- styleValue = ColorHelper.findRGBString(registry, IStyleConstantsXML.ENTITY_REFERENCE, 42, 0, 255) + NOBACKGROUNDBOLD;
- store.setDefault(IStyleConstantsXML.ENTITY_REFERENCE, styleValue);
-
- // set default new xml file template to use in new file wizard
- /*
- * Need to find template name that goes with default template id (name
- * may change for differnt language)
- */
- String templateName = ""; //$NON-NLS-1$
- Template template = XMLUIPlugin.getDefault().getTemplateStore().findTemplateById("org.eclipse.wst.xml.ui.internal.templates.xmldeclaration"); //$NON-NLS-1$
- if (template != null)
- templateName = template.getName();
- store.setDefault(XMLUIPreferenceNames.NEW_FILE_TEMPLATE_NAME, templateName);
-
- // Defaults for the Typing preference page
- store.setDefault(XMLUIPreferenceNames.TYPING_COMPLETE_COMMENTS, true);
- store.setDefault(XMLUIPreferenceNames.TYPING_COMPLETE_END_TAGS, true);
- store.setDefault(XMLUIPreferenceNames.TYPING_COMPLETE_ELEMENTS, true);
- store.setDefault(XMLUIPreferenceNames.TYPING_REMOVE_END_TAGS, true);
- store.setDefault(XMLUIPreferenceNames.TYPING_CLOSE_STRINGS, true);
- store.setDefault(XMLUIPreferenceNames.TYPING_CLOSE_BRACKETS, true);
-
- // Defaults for Content Assist preference page
- store.setDefault(XMLUIPreferenceNames.CONTENT_ASSIST_DO_NOT_DISPLAY_ON_DEFAULT_PAGE, "");
- store.setDefault(XMLUIPreferenceNames.CONTENT_ASSIST_DO_NOT_DISPLAY_ON_OWN_PAGE, "");
- store.setDefault(XMLUIPreferenceNames.CONTENT_ASSIST_DEFAULT_PAGE_SORT_ORDER,
- "org.eclipse.wst.xml.ui.proposalCategory.xmlTags\0" +
- "org.eclipse.wst.xml.ui.proposalCategory.xmlTemplates");
- store.setDefault(XMLUIPreferenceNames.CONTENT_ASSIST_OWN_PAGE_SORT_ORDER,
- "org.eclipse.wst.xml.ui.proposalCategory.xmlTemplates\0"+
- "org.eclipse.wst.xml.ui.proposalCategory.xmlTags");
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java
deleted file mode 100644
index 93a87323ec..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLUIPreferenceNames.java
+++ /dev/null
@@ -1,200 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-/**
- * Preference keys for XML UI
- */
-public class XMLUIPreferenceNames {
-
- public final static String SUGGESTION_STRATEGY_VALUE_LAX = "Lax"; //$NON-NLS-1$
- public final static String SUGGESTION_STRATEGY_VALUE_STRICT = "Strict"; //$NON-NLS-1$
- /**
- * A named preference that controls if code assist gets auto activated.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String AUTO_PROPOSE = getAutoProposeKey();
-
- private static String getAutoProposeKey() {
- return "autoPropose";//$NON-NLS-1$
- }
-
- /**
- * A named preference that holds the characters that auto activate code
- * assist.
- * <p>
- * Value is of type <code>String</code>. All characters that trigger
- * auto code assist.
- * </p>
- */
- public static final String AUTO_PROPOSE_CODE = getAutoProposeCodeKey();
-
- private static String getAutoProposeCodeKey() {
- return "autoProposeCode";//$NON-NLS-1$
- }
-
- /**
- * The key to store customized templates.
- * <p>
- * Value is of type <code>String</code>.
- * </p>
- */
- public static final String TEMPLATES_KEY = getTemplatesKey();
-
- private static String getTemplatesKey() {
- return "org.eclipse.wst.sse.ui.custom_templates"; //$NON-NLS-1$
- }
-
- /**
- * A named preference that controls whether or grammar should be inferred
- * or not.
- * <p>
- * Value is of type <code>Boolean</code>.
- * </p>
- */
- public static final String USE_INFERRED_GRAMMAR = getUseInferredGrammarKey();
-
- public static class OUTLINE_BEHAVIOR {
- public static final String ELEMENT_NODE = "outline-behavior.element-node"; //$NON-NLS-1$
- public static final String ATTRIBUTE_NODE = "outline-behavior.attribute-node"; //$NON-NLS-1$
- public static final String TEXT_NODE = "outline-behavior.text-node"; //$NON-NLS-1$
- public static final String CDATA_SECTION_NODE = "outline-behavior.cdata-section-node"; //$NON-NLS-1$
- public static final String ENTITY_REFERENCE_NODE = "outline-behavior.entity-reference-node"; //$NON-NLS-1$
- public static final String ENTITY_NODE = "outline-behavior.entity-node"; //$NON-NLS-1$
- public static final String PROCESSING_INSTRUCTION_NODE = "outline-behavior.instruction-node"; //$NON-NLS-1$
- public static final String COMMENT_NODE = "outline-behavior.comment-node"; //$NON-NLS-1$
- public static final String DOCUMENT_NODE = "outline-behavior.document-node"; //$NON-NLS-1$
- public static final String DOCUMENT_TYPE_NODE = "outline-behavior.document-type-node"; //$NON-NLS-1$
- public static final String DOCUMENT_FRAGMENT_NODE = "outline-behavior.document-fragment-node"; //$NON-NLS-1$
- public static final String NOTATION_NODE = "outline-behavior.notation-node"; //$NON-NLS-1$
- }
-
- private static String getUseInferredGrammarKey() {
- return "useInferredGrammar"; //$NON-NLS-1$
- }
-
- /**
- * A named preference that holds the characters that auto activate code
- * assist.
- * <p>
- * Value is of type <code>String</code>. All characters that trigger
- * auto code assist.
- * </p>
- */
- public static final String SUGGESTION_STRATEGY = getSuggestionStrategeyKey();
-
- private static String getSuggestionStrategeyKey() {
- return "suggestionStrategy";//$NON-NLS-1$
- }
-
- /**
- * The key to store the last template name used in new DTD file wizard.
- * Template name is stored instead of template id because user-created
- * templates do not have template ids.
- * <p>
- * Value is of type <code>String</code>.
- * </p>
- */
- public static final String NEW_FILE_TEMPLATE_NAME = "newFileTemplateName"; //$NON-NLS-1$
-
- /**
- * The key to store the option for auto-completing comments while
- * typing.
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String TYPING_COMPLETE_COMMENTS = "completeComments"; //$NON-NLS-1$
-
- /**
- * The key to store the option for auto-completing end-tags after entering
- * <code>&lt;/</code>
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String TYPING_COMPLETE_END_TAGS = "completeEndTags"; //$NON-NLS-1$
-
- /**
- * The key to store the option for auto-completing the element after entering
- * <code>&gt;</code>
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String TYPING_COMPLETE_ELEMENTS = "completeElements"; //$NON-NLS-1$
-
- /**
- * The key to store the option for removing an end-tag if the start tag is
- * converted to an empty-tag.
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String TYPING_REMOVE_END_TAGS = "removeEndTags"; //$NON-NLS-1$
-
- /**
- * The key to store the option for auto-completing strings (" and ') while
- * typing.
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String TYPING_CLOSE_STRINGS = "closeStrings"; //$NON-NLS-1$
-
- /**
- * The key to store the option for auto-completing brackets ([ and () while
- * typing.
- * <p>
- * Value is of type <code>boolean</code>.
- * </p>
- */
- public static final String TYPING_CLOSE_BRACKETS = "closeBrackets"; //$NON-NLS-1$
-
- /**
- * <p>preference key used for saving which categories should not display on the default page</p>
- *
- * <p>Value is of type {@link String} consisting of
- * <tt>org.eclipse.wst.sse.ui.completionProposal/proposalCategory/@id</tt>s separated by the null
- * character (<tt>\0</tt>), ordered is ignored</p>
- */
- public static final String CONTENT_ASSIST_DO_NOT_DISPLAY_ON_DEFAULT_PAGE = "xml_content_assist_display_on_default_page"; //$NON-NLS-1$
-
- /**
- * <p>preference key used for saving which categories should not display on their own page</p>
- *
- * <p>Value is of type {@link String} consisting of
- * <tt>org.eclipse.wst.sse.ui.completionProposal/proposalCategory/@id</tt>s separated by the null
- * character (<tt>\0</tt>), order is ignored</p>
- */
- public static final String CONTENT_ASSIST_DO_NOT_DISPLAY_ON_OWN_PAGE = "xml_content_assist_display_on_own_page"; //$NON-NLS-1$
-
- /**
- * <p>preference key for saving the sort order of the categories when displaying them on their own page</p>
- *
- * <p>Value is of type {@link String} consisting of
- * <tt>org.eclipse.wst.sse.ui.completionProposal/proposalCategory/@id</tt>s separated by the null
- * character (<tt>\0</tt>) in the desired sort order.</p>
- */
- public static final String CONTENT_ASSIST_OWN_PAGE_SORT_ORDER= "xml_content_assist_own_page_sort_order"; //$NON-NLS-1$
-
- /**
- * <p>preference key for saving the sort order of the categories when displaying them on the default page</p>
- *
- * <p>Value is of type {@link String} consisting of
- * <tt>org.eclipse.wst.sse.ui.completionProposal/proposalCategory/@id</tt>s separated by the null
- * character (<tt>\0</tt>) in the desired sort order.</p>
- */
- public static final String CONTENT_ASSIST_DEFAULT_PAGE_SORT_ORDER= "xml_content_assist_default_page_sort_order"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java
deleted file mode 100644
index 674937599f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/preferences/XMLValidatorPreferencePage.java
+++ /dev/null
@@ -1,172 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- * David Carver - STAR - [205989] - [validation] validate XML after XInclude resolution
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.preferences;
-
-
-import org.eclipse.core.runtime.Preferences;
-import org.eclipse.swt.SWT;
-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.ui.PlatformUI;
-import org.eclipse.wst.sse.ui.internal.preferences.ui.AbstractPreferencePage;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.core.internal.preferences.XMLCorePreferenceNames;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.editor.IHelpContextIds;
-
-
-public class XMLValidatorPreferencePage extends AbstractPreferencePage {
- private Combo fIndicateNoGrammar;
-
- private Button fHonourAllSchemaLocations;
-
- private Button fUseXinclude;
-
- private static final String[] SEVERITIES = {XMLUIMessages.Indicate_no_grammar_specified_severities_error, XMLUIMessages.Indicate_no_grammar_specified_severities_warning, XMLUIMessages.Indicate_no_grammar_specified_severities_ignore};
-
- protected Control createContents(Composite parent) {
- Composite composite = (Composite)super.createContents(parent);
- PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.XML_PREFWEBX_VALIDATOR_HELPID);
- createContentsForValidatingGroup(composite);
-
- setSize(composite);
- loadPreferences();
-
- return composite;
- }
-
- protected void createContentsForValidatingGroup(Composite parent) {
- Group validatingGroup = createGroup(parent, 2);
- ((GridLayout)validatingGroup.getLayout()).makeColumnsEqualWidth = false;
- validatingGroup.setText(XMLUIMessages.Validating_files);
-
- if (fIndicateNoGrammar == null) {
- createLabel(validatingGroup, XMLUIMessages.Indicate_no_grammar_specified);
- fIndicateNoGrammar = createCombo(validatingGroup, SEVERITIES);
- }
- if (fUseXinclude == null) {
- fUseXinclude = createCheckBox(validatingGroup, XMLUIMessages.Use_XInclude);
- ((GridData)fUseXinclude.getLayoutData()).horizontalSpan = 2;
- }
- if (fHonourAllSchemaLocations == null) {
- fHonourAllSchemaLocations = createCheckBox(validatingGroup, XMLUIMessages.Honour_all_schema_locations);
- ((GridData)fHonourAllSchemaLocations.getLayoutData()).horizontalSpan = 2;
- }
- }
-
- /**
- * @param parent
- * @return
- */
- private Combo createCombo(Composite parent, String[] items) {
- Combo combo = new Combo(parent, SWT.DROP_DOWN | SWT.READ_ONLY);
- combo.setItems(items);
-
- //GridData
- GridData data = new GridData(SWT.FILL, SWT.CENTER, true, true);
- combo.setLayoutData(data);
-
- return combo;
- }
-
- protected void initializeValues() {
- initializeValuesForValidatingGroup();
- }
-
- protected void initializeValuesForValidatingGroup() {
- Preferences modelPreferences = getModelPreferences();
- int indicateNoGrammarButtonSelected = modelPreferences.getInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR);
- boolean useXIncludeButtonSelected = modelPreferences.getBoolean(XMLCorePreferenceNames.USE_XINCLUDE);
-
- if (fIndicateNoGrammar != null) {
- fIndicateNoGrammar.select(2 - indicateNoGrammarButtonSelected);
- fIndicateNoGrammar.setText(SEVERITIES[2 - indicateNoGrammarButtonSelected]);
- }
- if (fUseXinclude != null) {
- fUseXinclude.setSelection(useXIncludeButtonSelected);
- }
-
- boolean honourAllSelected = modelPreferences.getBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS);
- if (fHonourAllSchemaLocations != null) {
- fHonourAllSchemaLocations.setSelection(honourAllSelected);
- }
- }
-
- protected void performDefaultsForValidatingGroup() {
- Preferences modelPreferences = getModelPreferences();
- int indicateNoGrammarButtonSelected = modelPreferences.getDefaultInt(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR);
- boolean useXIncludeButtonSelected = modelPreferences.getDefaultBoolean(XMLCorePreferenceNames.USE_XINCLUDE);
-
- if (fIndicateNoGrammar != null) {
- fIndicateNoGrammar.setSelection(new Point(indicateNoGrammarButtonSelected, 2 - indicateNoGrammarButtonSelected));
- fIndicateNoGrammar.setText(SEVERITIES[indicateNoGrammarButtonSelected]);
- }
- if (fUseXinclude != null) {
- fUseXinclude.setSelection(useXIncludeButtonSelected);
- }
-
- boolean honourAllButtonSelected = modelPreferences.getDefaultBoolean(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS);
- if (fHonourAllSchemaLocations != null) {
- fHonourAllSchemaLocations.setSelection(honourAllButtonSelected);
- }
- }
-
- protected void storeValuesForValidatingGroup()
- {
- Preferences modelPreferences = getModelPreferences();
- if (fIndicateNoGrammar != null) {
- int warnNoGrammarButtonSelected = 2 - fIndicateNoGrammar.getSelectionIndex();
- modelPreferences.setValue(XMLCorePreferenceNames.INDICATE_NO_GRAMMAR, warnNoGrammarButtonSelected);
- }
- if (fUseXinclude != null) {
- boolean useXIncludeButtonSelected = fUseXinclude.getSelection();
- modelPreferences.setValue(XMLCorePreferenceNames.USE_XINCLUDE, useXIncludeButtonSelected);
- }
- if (fHonourAllSchemaLocations != null) {
- boolean honourAllButtonSelected = fHonourAllSchemaLocations.getSelection();
- modelPreferences.setValue(XMLCorePreferenceNames.HONOUR_ALL_SCHEMA_LOCATIONS, honourAllButtonSelected);
- }
- }
-
- protected void storeValues() {
- storeValuesForValidatingGroup();
- }
-
- protected void performDefaults() {
- performDefaultsForValidatingGroup();
- super.performDefaults();
- }
-
- protected Preferences getModelPreferences() {
- return XMLCorePlugin.getDefault().getPluginPreferences();
- }
-
- protected void doSavePreferenceStore() {
- XMLCorePlugin.getDefault().savePluginPreferences(); // model
- }
-
- public boolean performOk() {
- boolean result = super.performOk();
-
- doSavePreferenceStore();
-
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLCommentFoldingPosition.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLCommentFoldingPosition.java
deleted file mode 100644
index d9740e9055..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLCommentFoldingPosition.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.projection;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredCommentFoldingPosition;
-
-/**
- *
- */
-public class XMLCommentFoldingPosition extends AbstractStructuredCommentFoldingPosition {
-
- /**
- * The region covering an XML comment
- */
- private IStructuredDocumentRegion fRegion;
-
- /**
- * Create a folding position to cover a XML comment region
- *
- * @param region
- */
- public XMLCommentFoldingPosition(IStructuredDocumentRegion region) {
- //can't use region.getLength here because doesn't work in DTD docs for some reason
- super(region.getStartOffset(), region.getEndOffset() - region.getStartOffset());
- this.fRegion = region;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredCommentFoldingPosition#getEndOffset()
- */
- protected int getEndOffset() {
- return fRegion.getEndOffset();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredCommentFoldingPosition#getStartOffset()
- */
- protected int getStartOffset() {
- return fRegion.getStartOffset();
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLElementFoldingPosition.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLElementFoldingPosition.java
deleted file mode 100644
index 233e301133..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLElementFoldingPosition.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.projection;
-
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredFoldingPosition;
-
-/**
- * Folds an XML element
- */
-public class XMLElementFoldingPosition extends AbstractStructuredFoldingPosition {
-
- /**
- * The region representing the start of the folding region
- */
- private IStructuredDocumentRegion fStartRegion;
-
- /**
- * The region representing the end of the folding region, or <code>null</code>
- * if the entire folding region is represented by <code>fStartRegion</code>
- */
- private IStructuredDocumentRegion fEndRegion;
-
- /**
- * <p>Used to represent a folding position that covers a single
- * {@link IStructuredDocumentRegion}.</p>
- *
- * @param region the region that covers the entire position of the folding region
- */
- public XMLElementFoldingPosition(IStructuredDocumentRegion region) {
- super(region.getStartOffset(), region.getEndOffset()-region.getStartOffset());
- this.fStartRegion = region;
- this.fEndRegion = null;
- }
-
- /**
- * <p>Used to represent a folding position that covers more then one
- * {@link IStructuredDocumentRegion}.</p>
- *
- * @param startRegion the first region covered by this position
- * @param endRegion the last region covered by this position
- */
- public XMLElementFoldingPosition(IStructuredDocumentRegion startRegion, IStructuredDocumentRegion endRegion) {
- super(startRegion.getStartOffset(), endRegion.getEndOffset()-startRegion.getStartOffset());
- this.fStartRegion = startRegion;
- this.fEndRegion = endRegion;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredFoldingPosition#getStartOffset()
- */
- protected int getStartOffset() {
- return fStartRegion.getStartOffset();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredFoldingPosition#getEndOffset()
- */
- protected int getEndOffset() {
- int endOffset;
- if(fEndRegion != null) {
- endOffset = fEndRegion.getEndOffset();
- } else {
- endOffset = fStartRegion.getEndOffset();
- }
- return endOffset;
- }
-} \ No newline at end of file
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLFoldingStrategy.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLFoldingStrategy.java
deleted file mode 100644
index 227f9d8e18..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/projection/XMLFoldingStrategy.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.projection;
-
-import org.eclipse.jface.text.Position;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredFoldingStrategy;
-import org.eclipse.wst.xml.core.internal.document.CommentImpl;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-
-
-/**
- * A folding strategy for XML type structured documents.
- * See AbstractStructuredFoldingStrategy for more details.
- */
-public class XMLFoldingStrategy extends AbstractStructuredFoldingStrategy {
-
- /**
- * Create an instance of the folding strategy.
- * Be sure to set the viewer and document after creation.
- */
- public XMLFoldingStrategy() {
- super();
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.projection.AbstractFoldingStrategy#calcNewFoldPosition(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)
- */
- protected Position calcNewFoldPosition(IndexedRegion indexedRegion) {
- Position retPos = null;
-
- //only want to fold regions of the valid type and with a valid range
- if(indexedRegion.getStartOffset() >= 0 && indexedRegion.getLength() >= 0) {
- IDOMNode node = (IDOMNode)indexedRegion;
- IStructuredDocumentRegion startRegion = node.getStartStructuredDocumentRegion();
- IStructuredDocumentRegion endRegion = node.getEndStructuredDocumentRegion();
-
- //if the node has an endRegion (end tag) then folding region is
- // between the start and end tag
- //else if the region is a comment
- //else if the region is only an open tag or an open/close tag then don't fold it
- if(startRegion != null && endRegion != null) {
- retPos = new XMLElementFoldingPosition(startRegion, endRegion);
- } else if(startRegion != null && indexedRegion instanceof CommentImpl) {
- retPos = new XMLCommentFoldingPosition(startRegion);
- }
- }
-
- return retPos;
- }
-
- /**
- * @see org.eclipse.wst.sse.ui.internal.projection.AbstractFoldingStrategy#indexedRegionValidType(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)
- */
- protected boolean indexedRegionValidType(IndexedRegion indexedRegion) {
- return (indexedRegion instanceof IDOMNode) && !(indexedRegion instanceof IDOMText);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java
deleted file mode 100644
index a4bd9f6fcb..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/EnumeratedStringPropertyDescriptor.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.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;
-
- 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.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java
deleted file mode 100644
index a6536be42a..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/StringComboBoxCellEditor.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.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.internal.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.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java
deleted file mode 100644
index d9c2ed4528..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/properties/XMLPropertySource.java
+++ /dev/null
@@ -1,833 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.properties;
-
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
-import java.util.Stack;
-
-import org.eclipse.swt.widgets.Display;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySheetEntry;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySource2;
-import org.eclipse.ui.views.properties.TextPropertyDescriptor;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.views.properties.IPropertySourceExtension;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.document.DocumentTypeAdapter;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Attr;
-import org.w3c.dom.DOMException;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * An IPropertySource implementation for a JFace viewer used to display
- * properties of DOM nodes.
- */
-public class XMLPropertySource implements IPropertySource, IPropertySourceExtension, IPropertySource2 {
- protected final static String CATEGORY_ATTRIBUTES = XMLUIMessages.XMLPropertySourceAdapter_0;
-
- /**
- * Controls whether optional attributes are marked as for "experts"
- */
- private static final boolean fSetExpertFilter = false;
-
- /**
- * Controls whether to derive categories from CMDataTypes; disabled by
- * default until display strings can be planned
- */
- private boolean fShouldDeriveCategories = false;
-
- private final static boolean fSortEnumeratedValues = true;
-
- /**
- * Note: we want the default fCaseSensitive to be true, but, to avoid
- * meaningless double initialization, we leave default here, and set in
- * constructor only.
- */
- private boolean fCaseSensitive;
- private IPropertyDescriptor[] fDescriptors = null;
- private Node fNode = null;
-
- private Stack fValuesBeingSet = new Stack();
-
- public XMLPropertySource(INodeNotifier target) {
- super();
- fNode = initNode(target);
- fCaseSensitive = initCaseSensitive(fNode);
- }
-
- public XMLPropertySource(Node target, boolean useCategories) {
- super();
- initNode(target);
- fNode = target;
- fCaseSensitive = initCaseSensitive(fNode);
- fShouldDeriveCategories = useCategories;
- }
-
- /** Separate method just to isolate error processing */
- private static INodeNotifier initNode(Node target) {
- if (target instanceof INodeNotifier) {
- return (INodeNotifier) target;
- }
- throw new IllegalArgumentException("XMLPropertySource is only for INodeNotifiers"); //$NON-NLS-1$
- }
-
- /** Separate method just to isolate error processing */
- private static Node initNode(INodeNotifier target) {
- if (target instanceof Node) {
- return (Node) target;
- }
- throw new IllegalArgumentException("XMLPropertySource is only for W3C DOM Nodes"); //$NON-NLS-1$
- }
-
- private boolean initCaseSensitive(Node node) {
- // almost all tags are case sensitive, except that old HTML
- boolean caseSensitive = true;
- if (node instanceof IDOMNode) {
- DocumentTypeAdapter adapter = getDocTypeFromDOMNode(node);
- if (adapter != null) {
- caseSensitive = (adapter.getTagNameCase() == DocumentTypeAdapter.STRICT_CASE);
- }
- }
- return caseSensitive;
- }
-
- /**
- * by "internal spec" the DOCTYPE adapter is only available from Document
- * Node
- *
- * @return {@link DocumentTypeAdapter}
- */
- private DocumentTypeAdapter getDocTypeFromDOMNode(Node node) {
- DocumentTypeAdapter adapter = null;
- Document ownerDocument = node.getOwnerDocument();
- if (ownerDocument == null) {
- // if ownerDocument is null, then fNode must be the Document Node
- // [old, old comment]
- // hmmmm, guess not. See
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=130233
- // guess this is used for many INodeNotifiers, not just XML.
- // (and DTD's use IDOMNode? ... that doesn't sound quite right
- // ... but, maybe a separate issue).
- if (node instanceof Document) {
- ownerDocument = (Document) node;
- }
- }
- if (ownerDocument != null) {
- adapter = (DocumentTypeAdapter) ((INodeNotifier) ownerDocument).getAdapterFor(DocumentTypeAdapter.class);
- }
-
- return adapter;
- }
-
- private String[] _getValidFixedStrings(CMAttributeDeclaration attrDecl, CMDataType helper) {
- String attributeName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- List values = new ArrayList(1);
- String impliedValue = helper.getImpliedValue();
- if (impliedValue != null) {
- values.add(impliedValue);
- }
- boolean checkIfCurrentValueIsIncluded = ((fNode.getAttributes() != null) && (fNode.getAttributes().getNamedItem(attributeName) != null) && (fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null));
- if (checkIfCurrentValueIsIncluded) {
- String currentValue = null;
- currentValue = fNode.getAttributes().getNamedItem(attributeName).getNodeValue();
- if (!currentValue.equals(impliedValue)) {
- values.add(currentValue);
- }
- }
- String[] validStrings = new String[values.size()];
- validStrings = (String[]) values.toArray(validStrings);
- return validStrings;
- }
-
- private String[] _getValidStrings(CMAttributeDeclaration attrDecl, CMDataType valuesHelper) {
- String attributeName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- List values = new ArrayList(1);
- boolean currentValueKnown = false;
- boolean checkIfCurrentValueIsKnown = ((fNode.getAttributes() != null) && (fNode.getAttributes().getNamedItem(attributeName) != null) && (fNode.getAttributes().getNamedItem(attributeName).getNodeValue() != null));
- String currentValue = null;
- if (checkIfCurrentValueIsKnown) {
- currentValue = fNode.getAttributes().getNamedItem(attributeName).getNodeValue();
- }
-
- if ((valuesHelper.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED) && (valuesHelper.getImpliedValue() != null)) {
- // FIXED value
- currentValueKnown = (currentValue != null) && valuesHelper.getImpliedValue().equals(currentValue);
- values.add(valuesHelper.getImpliedValue());
- }
- else {
- // ENUMERATED values
- String[] valueStrings = null;
- // valueStrings = valuesHelper.getEnumeratedValues();
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument());
- if ((modelQuery != null) && (fNode.getNodeType() == Node.ELEMENT_NODE)) {
- valueStrings = modelQuery.getPossibleDataTypeValues((Element) fNode, attrDecl);
- }
- else {
- valueStrings = attrDecl.getAttrType().getEnumeratedValues();
- }
- if (valueStrings != null) {
- for (int i = 0; i < valueStrings.length; i++) {
- if (checkIfCurrentValueIsKnown && valueStrings[i].equals(currentValue)) {
- currentValueKnown = true;
- }
- values.add(valueStrings[i]);
- }
- }
- }
- if ((valuesHelper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (valuesHelper.getImpliedValue() != null)) {
- if (!values.contains(valuesHelper.getImpliedValue())) {
- values.add(valuesHelper.getImpliedValue());
- }
- }
-
- if (checkIfCurrentValueIsKnown && !currentValueKnown && (currentValue != null) && (currentValue.length() > 0)) {
- values.add(currentValue);
- }
- String[] validStrings = new String[values.size()];
- validStrings = (String[]) values.toArray(validStrings);
- return validStrings;
- }
-
- private IPropertyDescriptor createDefaultPropertyDescriptor(String attributeName) {
- return createDefaultPropertyDescriptor(attributeName, false);
- }
-
- private IPropertyDescriptor createDefaultPropertyDescriptor(String attributeName, boolean hideOnFilter) {
- // The descriptor class used here is also used in
- // updatePropertyDescriptors()
- TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attributeName, attributeName);
- descriptor.setCategory(getCategory(null, null));
- descriptor.setDescription(attributeName);
- if (hideOnFilter && fSetExpertFilter) {
- descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT});
- }
- return descriptor;
- }
-
- /**
- * Creates a property descriptor for an attribute with ENUMERATED values -
- * if the value does not exist, an editable combo box is returned - if the
- * value exists but is not one in the enumerated list of value, a combo
- * box featuring the current and correct values is returned - if the value
- * exists and it is a valid value, a combo box featuring the correct
- * values with the current one visible is returned
- */
- private IPropertyDescriptor createEnumeratedPropertyDescriptor(CMAttributeDeclaration attrDecl, CMDataType valuesHelper, Attr attr) {
- // the displayName MUST be set
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrName, attrName, _getValidStrings(attrDecl, valuesHelper));
- descriptor.setCategory(getCategory(attrDecl, attr));
- descriptor.setDescription(attrName);
- if ((attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED) && fSetExpertFilter) {
- descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT});
- }
- return descriptor;
- }
-
- /**
- * Creates a property descriptor for an attribute with a FIXED value - if
- * the value does not exist, an editable combo box is returned - if the
- * value exists but is not the fixed/default value, a combo box featuring
- * the current and correct value is returned - if the value exists and it
- * is the fixed/default value, no cell editor is provided "locking" the
- * value in
- */
- private IPropertyDescriptor createFixedPropertyDescriptor(CMAttributeDeclaration attrDecl, CMDataType helper, Attr attr) {
- // the displayName MUST be set
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- EnumeratedStringPropertyDescriptor descriptor = new EnumeratedStringPropertyDescriptor(attrName, attrName, _getValidFixedStrings(attrDecl, helper));
- descriptor.setCategory(getCategory(attrDecl, attr));
- descriptor.setDescription(DOMNamespaceHelper.computeName(attrDecl, fNode, null));
- return descriptor;
- }
-
- protected IPropertyDescriptor createPropertyDescriptor(CMAttributeDeclaration attrDecl, Attr attr) {
- IPropertyDescriptor descriptor = null;
- CMDataType attrType = attrDecl.getAttrType();
-
- if (attrType != null) {
- // handle declarations that provide FIXED/ENUMERATED values
- if ((attrType.getEnumeratedValues() != null) && (attrType.getEnumeratedValues().length > 0)) {
- descriptor = createEnumeratedPropertyDescriptor(attrDecl, attrType, attr);
- }
- else if (((attrDecl.getUsage() == CMAttributeDeclaration.FIXED) || (attrType.getImpliedValueKind() == CMDataType.IMPLIED_VALUE_FIXED)) && (attrType.getImpliedValue() != null)) {
- descriptor = createFixedPropertyDescriptor(attrDecl, attrType, attr);
- }
- else {
- // plain text
- descriptor = createTextPropertyDescriptor(attrDecl, attr);
- }
- }
- else {
- // no extra information given
- descriptor = createTextPropertyDescriptor(attrDecl, attr);
- }
- return descriptor;
- }
-
- /**
- * Returns the current collection of property descriptors.
- *
- * @return all valid descriptors.
- */
- private IPropertyDescriptor[] createPropertyDescriptors() {
- CMNamedNodeMap attrMap = null;
- CMElementDeclaration ed = getDeclaration();
- if (ed != null) {
- attrMap = ed.getAttributes();
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
- List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attrMap = allAttributes;
- }
-
- List descriptorList = new ArrayList();
- List names = new ArrayList();
- IPropertyDescriptor descriptor;
-
- CMAttributeDeclaration attrDecl = null;
-
- // add descriptors for existing attributes
- NamedNodeMap attributes = fNode.getAttributes();
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attr = (Attr) attributes.item(i);
- // if metainfo is present for this attribute, use the
- // CMAttributeDeclaration to derive a descriptor
- if (attrMap != null) {
- String attrName = attr.getName();
- if (fCaseSensitive) {
- attrDecl = (CMAttributeDeclaration) attrMap.getNamedItem(attrName);
- }
- else {
- attrDecl = null;
- for (int j = 0; j < attrMap.getLength(); j++) {
- if (!fCaseSensitive && attrMap.item(j).getNodeName().equalsIgnoreCase(attrName)) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(j);
- break;
- }
- }
- }
- }
- // be consistent: if there's metainfo, use *that* as the
- // descriptor ID
- descriptor = null;
- if (attrDecl != null) {
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- if (!names.contains(attrName)) {
- descriptor = createPropertyDescriptor(attrDecl, attr);
- if (descriptor != null)
- names.add(attrName);
- }
- }
- else {
- if (!names.contains(attr.getName())) {
- descriptor = createDefaultPropertyDescriptor(attr.getName());
- if (descriptor != null)
- names.add(attr.getName());
- }
- }
- if (descriptor != null) {
- descriptorList.add(descriptor);
- }
- }
- }
-
- // add descriptors from the metainfo that are not yet listed
- if (attrMap != null) {
- for (int i = 0; i < attrMap.getLength(); i++) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(i);
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- if (!names.contains(attrName)) {
- IPropertyDescriptor holdDescriptor = createPropertyDescriptor(attrDecl, null);
- if (holdDescriptor != null) {
- names.add(attrName);
- descriptorList.add(holdDescriptor);
- }
- }
- }
- }
-
- // add MQE-based descriptors
- if (ed != null && fNode.getNodeType() == Node.ELEMENT_NODE) {
- List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int i = 0; i < nodes.size(); i++) {
- CMNode node = (CMNode) nodes.get(i);
- if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- attrDecl = (CMAttributeDeclaration) node;
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- if (!names.contains(attrName)) {
- IPropertyDescriptor holdDescriptor = createPropertyDescriptor(attrDecl, null);
- if (holdDescriptor != null) {
- names.add(attrName);
- descriptorList.add(holdDescriptor);
- }
- }
- }
- }
- }
-
-
- IPropertyDescriptor[] descriptors = new IPropertyDescriptor[descriptorList.size()];
- for (int i = 0; i < descriptors.length; i++) {
- descriptors[i] = (IPropertyDescriptor) descriptorList.get(i);
- }
- return descriptors;
- }
-
- private IPropertyDescriptor createTextPropertyDescriptor(CMAttributeDeclaration attrDecl, Attr attr) {
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- TextPropertyDescriptor descriptor = new TextPropertyDescriptor(attrName, attrName);
- descriptor.setCategory(getCategory(attrDecl, attr));
- descriptor.setDescription(attrName);
- if ((attrDecl.getUsage() != CMAttributeDeclaration.REQUIRED) && fSetExpertFilter) {
- descriptor.setFilterFlags(new String[]{IPropertySheetEntry.FILTER_ID_EXPERT});
- }
- return descriptor;
- }
-
- private String getCategory(CMAttributeDeclaration attrDecl, Attr attr) {
- if (attr != null) {
- String namespaceURI = attr.getNamespaceURI();
- if (namespaceURI == null)
- namespaceURI = attr.getOwnerElement().getNamespaceURI();
- if (namespaceURI != null)
- return namespaceURI;
- }
- if (attrDecl != null) {
- if (attrDecl.supports("category")) { //$NON-NLS-1$
- return (String) attrDecl.getProperty("category"); //$NON-NLS-1$
- }
- if (fShouldDeriveCategories && (attrDecl.getAttrType() != null) && (attrDecl.getAttrType().getDataTypeName() != null) && (attrDecl.getAttrType().getDataTypeName().length() > 0)) {
- return attrDecl.getAttrType().getDataTypeName();
- }
- }
- return CATEGORY_ATTRIBUTES;
- }
-
- private CMElementDeclaration getDeclaration() {
- if ((fNode == null) || (fNode.getNodeType() != Node.ELEMENT_NODE)) {
- return null;
- }
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument());
- if (modelQuery != null) {
- return modelQuery.getCMElementDeclaration((Element) fNode);
- }
- return null;
- }
-
- private Display getDisplay() {
-
- return PlatformUI.getWorkbench().getDisplay();
- }
-
- /**
- * Returns a value for this Node that can be editted in a property sheet.
- *
- * @return a value that can be editted
- */
- public Object getEditableValue() {
- return null;
- }
-
- /**
- * Returns the current collection of property descriptors.
- *
- * @return all valid descriptors.
- */
- public final IPropertyDescriptor[] getPropertyDescriptors() {
- if ((fDescriptors == null) || (fDescriptors.length == 0)) {
- fDescriptors = createPropertyDescriptors();
- }
- else {
- updatePropertyDescriptors();
- }
- return fDescriptors;
- }
-
- /**
- * Returns the current value for the named property.
- *
- */
- public Object getPropertyValue(Object nameObject) {
- String name = nameObject.toString();
- String returnedValue = null;
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrMap != null) {
- Node attribute = attrMap.getNamedItem(name);
- if (attribute != null) {
- if (attribute instanceof IDOMNode) {
- returnedValue = ((IDOMNode) attribute).getValueSource();
- }
- else {
- returnedValue = attribute.getNodeValue();
- }
- }
- }
- if (returnedValue == null) {
- returnedValue = ""; //$NON-NLS-1$
- }
- return returnedValue;
- }
-
- private String[] getValidValues(CMAttributeDeclaration attrDecl) {
- if (attrDecl == null) {
- return new String[0];
- }
-
- String[] validValues = null;
- CMDataType attrType = attrDecl.getAttrType();
- if (attrType != null) {
- validValues = _getValidStrings(attrDecl, attrType);
- if (fSortEnumeratedValues) {
- Arrays.sort(validValues);
- }
- }
- if (validValues == null) {
- validValues = new String[0];
- }
- return validValues;
- }
-
- public boolean isPropertyRemovable(Object id) {
- return true;
- }
-
- public boolean isPropertyResettable(Object id) {
- return fNode != null && fNode.getNodeType() == Node.ELEMENT_NODE;
- }
-
- /**
- * Returns whether the property value has changed from the default.
- *
- * @return <code>true</code> if the value of the specified property has
- * changed from its original default value; <code>false</code>
- * otherwise.
- */
- public boolean isPropertySet(Object propertyObject) {
- String property = propertyObject.toString();
-
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrMap != null) {
- return attrMap.getNamedItem(property) != null;
- }
- return false;
- }
-
- /**
- * Remove the given attribute from the Node
- *
- * @param propertyObject
- */
- public void removeProperty(Object propertyObject) {
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrMap != null) {
- Node attribute = attrMap.getNamedItem(propertyObject.toString());
- if (attribute != null) {
- try {
- attrMap.removeNamedItem(propertyObject.toString());
- }
- catch (DOMException e) {
- if (e.code != DOMException.INVALID_MODIFICATION_ERR) {
- Logger.logException(e);
- }
- }
- }
- }
- }
-
- /**
- * Resets the specified property's value to its default value.
- */
- public void resetPropertyValue(Object propertyObject) {
- String property = propertyObject.toString();
- CMNamedNodeMap attrDecls = null;
-
- CMElementDeclaration ed = getDeclaration();
- if (ed != null) {
- attrDecls = ed.getAttributes();
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrDecls);
- List nodes = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument()).getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attrDecls = allAttributes;
- }
-
- NamedNodeMap attrMap = fNode.getAttributes();
- if (attrDecls != null) {
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attrDecls.getNamedItem(property);
- String defValue = null;
- if (attrDecl != null) {
- if (attrDecl.getAttrType() != null) {
- CMDataType helper = attrDecl.getAttrType();
- if ((helper.getImpliedValueKind() != CMDataType.IMPLIED_VALUE_NONE) && (helper.getImpliedValue() != null)) {
- defValue = helper.getImpliedValue();
- }
- }
- }
- if ((defValue != null) && (defValue.length() > 0)) {
- ((Attr) attrMap.getNamedItem(property)).setValue(defValue);
- }
- else {
- // remember, this method is for reset, not remove
- ((Attr) attrMap.getNamedItem(property)).setValue(""); //$NON-NLS-1$
- }
- }
- else {
- // remember, this method is for reset, not remove
- ((Attr) attrMap.getNamedItem(property)).setValue(""); //$NON-NLS-1$
- }
- }
-
- /**
- * Sets the named property to the given value.
- *
- */
- public void setPropertyValue(Object nameObject, Object value) {
- // Avoid cycling - can happen if a closing cell editor causes a
- // refresh
- // on the PropertySheet page and the setInput again asks the editor to
- // close; besides, why apply the same value twice?
- if (!fValuesBeingSet.isEmpty() && (fValuesBeingSet.peek() == nameObject)) {
- return;
- }
- fValuesBeingSet.push(nameObject);
- String name = nameObject.toString();
- String valueString = ""; //$NON-NLS-1$
- if (value != null) {
- valueString = value.toString();
- }
- NamedNodeMap attrMap = fNode.getAttributes();
- try {
- if (attrMap != null) {
- Attr attr = (Attr) attrMap.getNamedItem(name);
- if (attr != null) {
- // EXISTING VALUE
- // potential out of control loop if updating the value
- // triggers a viewer update, forcing the
- // active cell editor to save its value and causing the
- // loop to continue
- if ((attr.getValue() == null) || !attr.getValue().equals(valueString)) {
- if (attr instanceof IDOMNode) {
- ((IDOMNode) attr).setValueSource(valueString);
- }
- else {
- attr.setValue(valueString);
- }
- }
- }
- else {
- // NEW(?) value
- Attr newAttr = fNode.getOwnerDocument().createAttribute(name);
- if (newAttr instanceof IDOMNode) {
- ((IDOMNode) newAttr).setValueSource(valueString);
- }
- else {
- newAttr.setValue(valueString);
- }
- attrMap.setNamedItem(newAttr);
- }
- }
- else {
- if (fNode instanceof Element) {
- ((Element) fNode).setAttribute(name, valueString);
- }
- }
- }
- catch (DOMException e) {
- Display d = getDisplay();
- if (d != null) {
- d.beep();
- }
- }
- fValuesBeingSet.pop();
- }
-
- protected void updatePropertyDescriptors() {
- if ((fDescriptors == null) || (fDescriptors.length == 0)) {
- // Nothing to update
- return;
- }
-
- // List of all names encountered in the tag and defined by the element
- List declaredNames = new ArrayList();
- // New descriptor list that will become fDescriptors after all
- // processing is done
- List descriptors = new ArrayList();
- // Names of the descriptors in the above List
- List descriptorNames = new ArrayList();
-
- // Update any descriptors derived from the metainfo
- CMElementDeclaration ed = getDeclaration();
- CMNamedNodeMap attrMap = null;
- if (ed != null) {
- attrMap = ed.getAttributes();
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attrMap);
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(fNode.getOwnerDocument());
- if(modelQuery != null) {
- List nodes = modelQuery.getAvailableContent((Element) fNode, ed, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- }
- attrMap = allAttributes;
- }
- // Update exiting descriptors; not added to the final list here
- if (attrMap != null) {
- // Update existing descriptor types based on metainfo
- CMAttributeDeclaration attrDecl = null;
- for (int i = 0; i < attrMap.getLength(); i++) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(i);
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- if (!declaredNames.contains(attrName)) {
- declaredNames.add(attrName);
- }
- for (int j = 0; j < fDescriptors.length; j++) {
- boolean sameName = (fCaseSensitive && fDescriptors[j].getId().equals(attrDecl.getNodeName())) || (!fCaseSensitive && attrDecl.getNodeName().equals(fDescriptors[j].getId().toString()));
- if (sameName) {
- String[] validValues = getValidValues(attrDecl);
- // Update the descriptor for this
- // CMAttributeDeclaration (only enumerated values get
- // updated for now)
- if (fDescriptors[j] instanceof EnumeratedStringPropertyDescriptor) {
- ((EnumeratedStringPropertyDescriptor) fDescriptors[j]).updateValues(validValues);
- }
- // Replace with better descriptor
- else if ((validValues != null) && (validValues.length > 0)) {
- fDescriptors[j] = createPropertyDescriptor(attrDecl, null);
- }
- }
- }
- }
- }
- else {
- // Update existing descriptors based on not having any metainfo
- for (int j = 0; j < fDescriptors.length; j++) {
- // Replace with basic descriptor
- if (!(fDescriptors[j] instanceof TextPropertyDescriptor)) {
- fDescriptors[j] = createDefaultPropertyDescriptor((String) fDescriptors[j].getId());
- }
- }
- }
-
- NamedNodeMap attributes = fNode.getAttributes();
-
- // Remove descriptors for attributes that aren't present AND aren't
- // known through metainfo,
- // do this by only reusing existing descriptors for attributes that
- // are present or declared
- for (int i = 0; i < fDescriptors.length; i++) {
- if (fDescriptors[i] != null) {
- String descriptorName = fDescriptors[i].getId().toString();
- if ((declaredNames.contains(descriptorName) || (attributes.getNamedItem(descriptorName) != null)) && !descriptorNames.contains(descriptorName)) {
- descriptorNames.add(descriptorName);
- descriptors.add(fDescriptors[i]);
- }
- }
- }
-
- // Add descriptors for declared attributes that don't already have one
- if (attrMap != null) {
- // Update existing descriptor types based on metainfo
- CMAttributeDeclaration attrDecl = null;
- for (int i = 0; i < attrMap.getLength(); i++) {
- attrDecl = (CMAttributeDeclaration) attrMap.item(i);
- String attrName = DOMNamespaceHelper.computeName(attrDecl, fNode, null);
- if (fCaseSensitive) {
- if (!descriptorNames.contains(attrName)) {
- IPropertyDescriptor descriptor = createPropertyDescriptor(attrDecl, null);
- if (descriptor != null) {
- descriptorNames.add(attrName);
- descriptors.add(descriptor);
- }
- }
- }
- else {
- boolean exists = false;
- for (int j = 0; j < descriptorNames.size(); j++) {
- exists = (descriptorNames.get(j).toString().equalsIgnoreCase(attrName)) || exists;
- }
- if (!exists) {
- descriptorNames.add(attrName);
- IPropertyDescriptor descriptor = createPropertyDescriptor(attrDecl, null);
- if (descriptor != null) {
- descriptorNames.add(attrName);
- descriptors.add(descriptor);
- }
- }
- }
- }
- }
-
- // Add descriptors for existing attributes that don't already have one
- if (attributes != null) {
- for (int i = 0; i < attributes.getLength(); i++) {
- Attr attr = (Attr) attributes.item(i);
- String attrName = attr.getName();
- if (fCaseSensitive) {
- if (!descriptorNames.contains(attrName)) {
- descriptorNames.add(attrName);
- descriptors.add(createDefaultPropertyDescriptor(attrName));
- }
- }
- else {
- boolean exists = false;
- for (int j = 0; j < descriptorNames.size(); j++) {
- exists = (descriptorNames.get(j).toString().equalsIgnoreCase(attrName)) || exists;
- }
- if (!exists) {
- descriptorNames.add(attrName);
- descriptors.add(createDefaultPropertyDescriptor(attrName));
- }
- }
- }
- }
-
- // Update fDescriptors
- IPropertyDescriptor[] newDescriptors = new IPropertyDescriptor[descriptors.size()];
- for (int i = 0; i < newDescriptors.length; i++) {
- newDescriptors[i] = (IPropertyDescriptor) descriptors.get(i);
- }
- fDescriptors = newDescriptors;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/IDOMSourceEditingTextTools.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/IDOMSourceEditingTextTools.java
deleted file mode 100644
index a018b08f09..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/IDOMSourceEditingTextTools.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.provisional;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.NodeLocation;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-public interface IDOMSourceEditingTextTools extends ISourceEditingTextTools {
- /**
- * Returns a W3C DOM document
- *
- * @return Document object or <code>null</code> if corresponding
- * document does not exist
- */
- Document getDOMDocument();
-
- /**
- * Returns the W3C DOM Node at the given offset
- *
- * @param offset
- * the offset within the IDocument
- * @return a Node at that location, if one is present
- *
- * @throws BadLocationException
- * for invalid offsets
- */
- Node getNode(int offset) throws BadLocationException;
-
- /**
- * Returns a NodeLocation object describing the position information of
- * the Node's start and end tags.
- *
- * @param node
- * @return The NodeLocation for this Node, null for unsupported Node
- * instances.
- */
- NodeLocation getNodeLocation(Node node);
-
- /**
- * Returns the current server-side page language for the Document of the
- * given Node.
- *
- * @return The server-side page language for this nodem null for Nodes
- * within unsupported Documents.
- */
- String getPageLanguage(Node node);
-
- /**
- * Returns start offset of given Node.
- *
- * @param node
- * w3c <code>Node</code> object to check
- * @return the start offset or -1 for unsupported Nodes
- */
- int getStartOffset(Node node);
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java
deleted file mode 100644
index 63a337edd1..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/provisional/XMLSourceEditingTextTools.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.provisional;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.ui.IEditorPart;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.ui.StructuredTextEditor;
-import org.eclipse.wst.sse.ui.internal.StructuredTextViewer;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools;
-import org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.NodeLocation;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.w3c.dom.Document;
-import org.w3c.dom.Node;
-
-/**
- * Implements ISourceEditingTextTools interface
- */
-public class XMLSourceEditingTextTools implements IDOMSourceEditingTextTools, INodeAdapter {
-
- protected class NodeLocationImpl implements NodeLocation {
- private IDOMNode node;
-
- public NodeLocationImpl(IDOMNode xmlnode) {
- super();
- node = xmlnode;
- }
-
- public int getEndTagEndOffset() {
- if (node.getEndStructuredDocumentRegion() != null) {
- return node.getEndStructuredDocumentRegion().getEndOffset();
- }
- return -1;
- }
-
- public int getEndTagStartOffset() {
- if (node.getEndStructuredDocumentRegion() != null) {
- return node.getEndStructuredDocumentRegion().getStartOffset();
- }
- return -1;
- }
-
- public int getStartTagEndOffset() {
- if (node.getStartStructuredDocumentRegion() != null) {
- return node.getStartStructuredDocumentRegion().getEndOffset();
- }
- return -1;
- }
-
- public int getStartTagStartOffset() {
- if (node.getStartStructuredDocumentRegion() != null) {
- return node.getStartStructuredDocumentRegion().getStartOffset();
- }
- return -1;
- }
- }
-
- StructuredTextEditor fTextEditor = null;
-
- public int getCaretOffset() {
- StructuredTextViewer stv = fTextEditor.getTextViewer();
- if ((stv != null) && (stv.getTextWidget() != null) && !stv.getTextWidget().isDisposed()) {
- return stv.widgetOffset2ModelOffset(stv.getTextWidget().getCaretOffset());
- }
- return 0;
- }
-
- public IDocument getDocument() {
- return fTextEditor.getDocumentProvider().getDocument(fTextEditor.getEditorInput());
- }
-
- public Document getDOMDocument() {
- return (Document) fTextEditor.getModel().getAdapter(Document.class);
- }
-
- /*
- * If similar function is needed, composite it around the text editor's
- * instance. Removed also because it returns an alread-released model
- *
- * public Document getDOMDocument(IMarker marker) { if (marker == null)
- * return null;
- *
- * IResource res = marker.getResource(); if (res == null || !(res
- * instanceof IFile)) return null;
- *
- * IModelManager mm = StructuredModelManager.getModelManager();
- * IStructuredModel model = null; try { model =
- * mm.getExistingModelForRead((IFile) res); if (model == null || !(model
- * instanceof IDOMModel)) return null;
- *
- * return ((IDOMModel) model).getDocument(); } finally { if (model !=
- * null) model.releaseFromRead(); } }
- */
-
- public IEditorPart getEditorPart() {
- return fTextEditor.getEditorPart();
- }
-
- public Node getNode(int offset) throws BadLocationException {
- Node node = null;
- if ((0 <= offset) && (offset <= getDocument().getLength())) {
- node = (Node) fTextEditor.getModel().getIndexedRegion(offset);
- }
- else {
- throw new BadLocationException();
- }
- return node;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.extensions.SourceEditingTextTools#getNodeLocation(org.w3c.dom.Node)
- */
- public NodeLocation getNodeLocation(Node node) {
- if ((node.getNodeType() == Node.ELEMENT_NODE) && (node instanceof IDOMNode)) {
- return new NodeLocationImpl((IDOMNode) node);
- }
- return null;
- }
-
- public String getPageLanguage(Node node) {
- return ""; //$NON-NLS-1$
- }
-
- public ITextSelection getSelection() {
- return (ITextSelection) fTextEditor.getSelectionProvider().getSelection();
- }
-
- /**
- * IExtendedMarkupEditor method
- */
- // public List getSelectedNodes() {
- // ViewerSelectionManager vsm = getViewerSelectionManager();
- // return (vsm != null) ? vsm.getSelectedNodes() : null;
- // }
- public int getStartOffset(Node node) {
- if ((node == null) || !(node instanceof IDOMText)) {
- return -1;
- }
-
- IStructuredDocumentRegion fnode = ((IDOMText) node).getFirstStructuredDocumentRegion();
- return fnode.getStartOffset();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.core.INodeAdapter#isAdapterForType(java.lang.Object)
- */
- public boolean isAdapterForType(Object type) {
- return ISourceEditingTextTools.class.equals(type);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.core.core.INodeAdapter#notifyChanged(org.eclipse.wst.sse.core.core.INodeNotifier,
- * int, java.lang.Object, java.lang.Object, java.lang.Object, int)
- */
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- }
-
- public void setTextEditor(StructuredTextEditor editor) {
- fTextEditor = editor;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java
deleted file mode 100644
index 3794a1782e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/registry/AdapterFactoryProviderForXML.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.registry;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler;
-import org.eclipse.wst.sse.core.internal.model.FactoryRegistry;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.util.Assert;
-import org.eclipse.wst.sse.ui.internal.contentoutline.IJFaceNodeAdapter;
-import org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelhandler.ModelHandlerForXML;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.DOMObserver;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeAdapterFactory;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-
-/**
- *
- */
-public class AdapterFactoryProviderForXML implements AdapterFactoryProvider {
-
- /*
- * @see AdapterFactoryProvider#addAdapterFactories(IStructuredModel)
- */
- public void addAdapterFactories(IStructuredModel structuredModel) {
-
- // add the normal content based factories to model's registry
- addContentBasedFactories(structuredModel);
- }
-
- protected void addContentBasedFactories(IStructuredModel structuredModel) {
- FactoryRegistry factoryRegistry = structuredModel.getFactoryRegistry();
- Assert.isNotNull(factoryRegistry, "Program Error: client caller must ensure model has factory registry"); //$NON-NLS-1$
- INodeAdapterFactory factory = null;
-
- factory = factoryRegistry.getFactoryFor(IJFaceNodeAdapter.class);
- if (factory == null) {
- factory = new JFaceNodeAdapterFactory();
- factoryRegistry.addFactory(factory);
- }
-
- // cs... added for inferred grammar support
- //
- if (structuredModel != null) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(structuredModel);
- if (modelQuery != null) {
- CMDocumentManager documentManager = modelQuery.getCMDocumentManager();
- if (documentManager != null) {
- IPreferenceStore store = XMLUIPlugin.getDefault().getPreferenceStore();
- boolean useInferredGrammar = (store != null) ? store.getBoolean(XMLUIPreferenceNames.USE_INFERRED_GRAMMAR) : true;
-
- documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_ASYNC_LOAD, true);
- documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD, false);
- documentManager.setPropertyEnabled(CMDocumentManager.PROPERTY_USE_CACHED_RESOLVED_URI, true);
- DOMObserver domObserver = new DOMObserver(structuredModel);
- domObserver.setGrammarInferenceEnabled(useInferredGrammar);
- domObserver.init();
- }
- }
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.internal.provisional.registry.AdapterFactoryProvider#isFor(org.eclipse.wst.sse.core.internal.ltk.modelhandler.IDocumentTypeHandler)
- */
- public boolean isFor(IDocumentTypeHandler contentTypeDescription) {
- return (contentTypeDescription instanceof ModelHandlerForXML);
- }
-
- public void reinitializeFactories(IStructuredModel structuredModel) {
- // nothing to do, since no embedded type
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java
deleted file mode 100644
index 84f2ec934e..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesActionDelegate.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.search;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesActionDelegate;
-
-/**
- * Sets up FindOccurrencesActionDelegate for xml find occurrences processors
- */
-public class XMLFindOccurrencesActionDelegate extends FindOccurrencesActionDelegate {
- private List fProcessors;
-
- protected List getProcessors() {
- if (fProcessors == null) {
- fProcessors = new ArrayList();
- XMLFindOccurrencesProcessor htmlProcessor = new XMLFindOccurrencesProcessor();
- fProcessors.add(htmlProcessor);
- }
- return fProcessors;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java
deleted file mode 100644
index 6b12fec560..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/search/XMLFindOccurrencesProcessor.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.search;
-
-import org.eclipse.wst.sse.ui.internal.search.FindOccurrencesProcessor;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.core.text.IXMLPartitions;
-
-/**
- * Configures a FindOccurrencesProcessor with XML partitions and regions
- */
-public class XMLFindOccurrencesProcessor extends FindOccurrencesProcessor {
-
- protected String[] getPartitionTypes() {
- return new String[]{IXMLPartitions.XML_DEFAULT};
- }
-
- protected String[] getRegionTypes() {
- return new String[]{DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_NAME, DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE};
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java
deleted file mode 100644
index 258be52d4f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectEnclosingXMLActionDelegate.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.selection;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.selection.StructuredSelectActionDelegate;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Node;
-
-public class StructuredSelectEnclosingXMLActionDelegate extends StructuredSelectActionDelegate {
-
- protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
- IndexedRegion indexedRegion = null;
-
- indexedRegion = getIndexedRegion(document, textSelection.getOffset());
-
- return indexedRegion;
- }
-
- protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node cursorNode = (Node) indexedRegion;
-
- // 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) {
- indexedRegion = (IndexedRegion) cursorNode;
- }
- }
-
- Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
-
- if ((cursorNodeRegion.getOffset() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength())) {
- Node newNode = cursorNode.getParentNode();
-
- if (newNode instanceof IndexedRegion) {
- IndexedRegion newIndexedRegion = (IndexedRegion) newNode;
- newRegion = new Region(newIndexedRegion.getStartOffset(), newIndexedRegion.getEndOffset() - newIndexedRegion.getStartOffset());
- }
- }
- else {
- newRegion = cursorNodeRegion;
- }
- }
- return newRegion;
- }
-
- public void init(IAction action) {
- if (action != null) {
- action.setText(XMLUIMessages.StructureSelectEnclosing_label);
- action.setToolTipText(XMLUIMessages.StructureSelectEnclosing_tooltip);
- action.setDescription(XMLUIMessages.StructureSelectEnclosing_description);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java
deleted file mode 100644
index f5088c3122..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectNextXMLActionDelegate.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.selection;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.selection.StructuredSelectActionDelegate;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Node;
-
-public class StructuredSelectNextXMLActionDelegate extends StructuredSelectActionDelegate {
-
- protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
- int offset = textSelection.getOffset() + textSelection.getLength() - 1;
- if (offset < 0) {
- offset = 0;
- }
-
- IndexedRegion indexedRegion = null;
-
- indexedRegion = getIndexedRegion(document, offset);
-
- return indexedRegion;
- }
-
- protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node cursorNode = (Node) indexedRegion;
-
- // 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) {
- indexedRegion = (IndexedRegion) cursorNode;
- }
- }
-
- Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
- int currentOffset = textSelection.getOffset();
- int currentEndOffset = currentOffset + textSelection.getLength();
- if ((cursorNodeRegion.getOffset() >= currentOffset) && (cursorNodeRegion.getOffset() <= currentEndOffset) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= currentOffset) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= currentEndOffset)) {
- newRegion = getNewSelectionRegion2(indexedRegion, textSelection);
- }
- else {
- newRegion = cursorNodeRegion;
- }
- }
- return newRegion;
- }
-
- public void init(IAction action) {
- if (action != null) {
- action.setText(XMLUIMessages.StructureSelectNext_label);
- action.setToolTipText(XMLUIMessages.StructureSelectNext_tooltip);
- action.setDescription(XMLUIMessages.StructureSelectNext_description);
- }
- }
-
- /**
- * This method was separated out from getNewSelectionRegion2 because the
- * code in here is allowed to be called recursively.
- *
- * @param indexedRegion
- * @param textSelection
- * @return new region to select or null if none
- */
- private Region getNewSelectionRegion2(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node node = (Node) indexedRegion;
- 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(textSelection.getOffset(), newIndexedRegion.getEndOffset() - textSelection.getOffset());
-
- if (newNode.getNodeType() == Node.TEXT_NODE) {
- newRegion = getNewSelectionRegion2(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength()));
- }
- }
- }
- }
- return newRegion;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java
deleted file mode 100644
index 8939c32b4d..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/selection/StructuredSelectPreviousXMLActionDelegate.java
+++ /dev/null
@@ -1,88 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.selection;
-
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.ITextSelection;
-import org.eclipse.jface.text.Region;
-import org.eclipse.jface.text.TextSelection;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.selection.StructuredSelectActionDelegate;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.w3c.dom.Node;
-
-public class StructuredSelectPreviousXMLActionDelegate extends StructuredSelectActionDelegate {
-
- protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) {
- IndexedRegion indexedRegion = null;
-
- indexedRegion = getIndexedRegion(document, textSelection.getOffset());
-
- return indexedRegion;
- }
-
- protected Region getNewSelectionRegion(IndexedRegion indexedRegion, ITextSelection textSelection) {
- Region newRegion = null;
- if (indexedRegion instanceof Node) {
- Node cursorNode = (Node) indexedRegion;
-
- // 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) {
- indexedRegion = (IndexedRegion) cursorNode;
- }
- }
-
- Region cursorNodeRegion = new Region(indexedRegion.getStartOffset(), indexedRegion.getEndOffset() - indexedRegion.getStartOffset());
-
- if ((cursorNodeRegion.getOffset() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() <= textSelection.getOffset() + textSelection.getLength()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() >= textSelection.getOffset()) && (cursorNodeRegion.getOffset() + cursorNodeRegion.getLength() <= textSelection.getOffset() + textSelection.getLength())) {
- Node newNode = cursorNode.getPreviousSibling();
- if (newNode == null) {
- newNode = cursorNode.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(), textSelection.getOffset() + textSelection.getLength() - newIndexedRegion.getStartOffset());
-
- if (newNode.getNodeType() == Node.TEXT_NODE) {
- newRegion = getNewSelectionRegion(newIndexedRegion, new TextSelection(newRegion.getOffset(), newRegion.getLength()));
- }
- }
- }
-
- }
- else {
- newRegion = cursorNodeRegion;
- }
- }
- return newRegion;
- }
-
- public void init(IAction action) {
- if (action != null) {
- action.setText(XMLUIMessages.StructureSelectPrevious_label);
- action.setToolTipText(XMLUIMessages.StructureSelectPrevious_tooltip);
- action.setDescription(XMLUIMessages.StructureSelectPrevious_description);
- }
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/spelling/SpellcheckDelegateAdapterFactory.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/spelling/SpellcheckDelegateAdapterFactory.java
deleted file mode 100644
index a6fae546c3..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/spelling/SpellcheckDelegateAdapterFactory.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.spelling;
-
-import org.eclipse.core.runtime.IAdapterFactory;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.ui.internal.spelling.ISpellcheckDelegate;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.w3c.dom.Comment;
-
-/**
- * An <code>IAdapterFactory</code> to adapt an <code>IDOMModel</code> to a
- * <code>ISpellcheckDelegate</code>.
- */
-public class SpellcheckDelegateAdapterFactory implements IAdapterFactory {
- /**
- * This list of classes this factory adapts to.
- */
- private static final Class[] ADAPTER_LIST = new Class[]{ISpellcheckDelegate.class};
-
- /**
- * The <code>ISpellcheckDelegate</code> this factory adapts to
- */
- private static final ISpellcheckDelegate DELEGATE = new XMLSpellcheckDelegate();
-
- /**
- * Implementation of <code>ISpellcheckDelegate</code> for XML type documents.
- */
- private static class XMLSpellcheckDelegate implements ISpellcheckDelegate {
-
- /**
- * If the region in the given <code>model</code> at the given <code>offset</code> is a
- * <code>Comment</code> region then it should be spell checked, otherwise it should not.
- *
- * @see org.eclipse.wst.sse.ui.internal.spelling.ISpellcheckDelegate#shouldSpellcheck(org.eclipse.wst.sse.core.internal.provisional.IndexedRegion)
- */
- public boolean shouldSpellcheck(int offset, IStructuredModel model) {
- boolean shouldSpellcheck = true;
-
- IndexedRegion region = model.getIndexedRegion(offset);
- if(region != null) {
- shouldSpellcheck = (region instanceof Comment);
- }
-
- return shouldSpellcheck;
- }
-
- }
-
- /**
- * Adapts <code>IDOMModel</code> to <code>ISpellcheckDelegate</code>.
- *
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class)
- */
- public Object getAdapter(Object adaptableObject, Class adapterType) {
- ISpellcheckDelegate decision = null;
-
- if (adaptableObject instanceof IDOMModel && ISpellcheckDelegate.class.equals(adapterType)) {
- decision = DELEGATE;
- }
-
- return decision;
- }
-
- /**
- * This adapter only adapts to <code>ISpellcheckDelegate</code>
- *
- * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList()
- */
- public Class[] getAdapterList() {
- return ADAPTER_LIST;
- }
-
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java
deleted file mode 100644
index 79055b6c95..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/IStyleConstantsXML.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- * Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.style;
-
-/**
- * Contains the symbolic name of styles used by LineStyleProvider,
- * ColorManager, and any others who may be interested
- */
-public interface IStyleConstantsXML {
- public static final String BACKGROUND = "background"; //$NON-NLS-1$
- public static final String CDATA_BORDER = "cdataBorder";//$NON-NLS-1$
- public static final String CDATA_TEXT = "cdataText";//$NON-NLS-1$
- public static final String COMMENT_BORDER = "commentBorder";//$NON-NLS-1$
- public static final String COMMENT_TEXT = "commentText";//$NON-NLS-1$
- public static final String DECL_BORDER = "declBoder";//$NON-NLS-1$
- public static final String DOCTYPE_EXTERNAL_ID = "doctypeExternalId";//$NON-NLS-1$
- public static final String DOCTYPE_EXTERNAL_ID_PUBREF = "doctypeExternalPubref";//$NON-NLS-1$
- public static final String DOCTYPE_EXTERNAL_ID_SYSREF = "doctypeExtrenalSysref";//$NON-NLS-1$
- public static final String DOCTYPE_NAME = "doctypeName";//$NON-NLS-1$
-
- public static final String FOREGROUND = "foreground"; //$NON-NLS-1$
- public static final String PI_BORDER = "piBorder";//$NON-NLS-1$
- public static final String PI_CONTENT = "piContent";//$NON-NLS-1$
-
- public static final String TAG_ATTRIBUTE_EQUALS = "tagAttributeEquals"; //$NON-NLS-1$
- public static final String TAG_ATTRIBUTE_NAME = "tagAttributeName";//$NON-NLS-1$
- public static final String TAG_ATTRIBUTE_VALUE = "tagAttributeValue";//$NON-NLS-1$
- public static final String TAG_BORDER = "tagBorder";//$NON-NLS-1$
- public static final String TAG_NAME = "tagName";//$NON-NLS-1$
- public static final String XML_CONTENT = "xmlContent";//$NON-NLS-1$
- public static final String ENTITY_REFERENCE = "entityReference";//$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java
deleted file mode 100644
index 938c793a27..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/style/LineStyleProviderForXML.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- * Benjamin Muskalla, b.muskalla@gmx.net - [158660] character entities should have their own syntax highlighting preference
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.style;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.TextAttribute;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.internal.provisional.style.AbstractLineStyleProvider;
-import org.eclipse.wst.sse.ui.internal.provisional.style.LineStyleProvider;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-public class LineStyleProviderForXML extends AbstractLineStyleProvider implements LineStyleProvider {
- public LineStyleProviderForXML() {
- super();
- }
-
- protected TextAttribute getAttributeFor(ITextRegion region) {
- /**
- * a method to centralize all the "format rules" for regions
- * specifically associated for how to "open" the region.
- */
- // not sure why this is coming through null, but just to catch it
- if (region == null) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT);
- }
-
- String type = region.getType();
- if ((type == DOMRegionContext.XML_CONTENT) || (type == DOMRegionContext.XML_DOCTYPE_INTERNAL_SUBSET)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.XML_CONTENT);
- }
- if ((type == DOMRegionContext.XML_TAG_OPEN) || (type == DOMRegionContext.XML_END_TAG_OPEN) || (type == DOMRegionContext.XML_TAG_CLOSE) || (type == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_BORDER);
- }
- if ((type == DOMRegionContext.XML_CDATA_OPEN) || (type == DOMRegionContext.XML_CDATA_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_BORDER);
- }
- if (type == DOMRegionContext.XML_CDATA_TEXT) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT);
- }
- if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- }
- if (type == DOMRegionContext.XML_DOCTYPE_DECLARATION) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_NAME);
- }
- if (type == DOMRegionContext.XML_TAG_NAME) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_NAME);
- }
- if ((type == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- }
- if (type == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- }
- if ((type == DOMRegionContext.XML_COMMENT_OPEN) || (type == DOMRegionContext.XML_COMMENT_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.COMMENT_BORDER);
- }
- if (type == DOMRegionContext.XML_COMMENT_TEXT) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.COMMENT_TEXT);
- }
- if (type == DOMRegionContext.XML_DOCTYPE_NAME) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_NAME);
- }
- if ((type == DOMRegionContext.XML_CHAR_REFERENCE) || (type == DOMRegionContext.XML_ENTITY_REFERENCE) || (type == DOMRegionContext.XML_PE_REFERENCE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.ENTITY_REFERENCE);
- }
- if (type == DOMRegionContext.XML_PI_CONTENT) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.PI_CONTENT);
- }
- if ((type == DOMRegionContext.XML_PI_OPEN) || (type == DOMRegionContext.XML_PI_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.PI_BORDER);
- }
- if ((type == DOMRegionContext.XML_DECLARATION_OPEN) || (type == DOMRegionContext.XML_DECLARATION_CLOSE)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DECL_BORDER);
- }
- if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSREF) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- }
- if (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBREF) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- }
- if ((type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_PUBLIC) || (type == DOMRegionContext.XML_DOCTYPE_EXTERNAL_ID_SYSTEM)) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- }
- if (type == DOMRegionContext.UNDEFINED) {
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.CDATA_TEXT);
- }
- if (type == DOMRegionContext.WHITE_SPACE) {
- /*
- * White space is normally not on its own ... but when it is,
- * we'll treat as content
- */
- return (TextAttribute) getTextAttributes().get(IStyleConstantsXML.XML_CONTENT);
- }
- /*
- * default, return null to signal "not handled" in which case, other
- * providers should be tried
- */
- return null;
- }
-
- protected IPreferenceStore getColorPreferences() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- protected void handlePropertyChange(PropertyChangeEvent event) {
- String styleKey = null;
-
- if (event != null) {
- String prefKey = event.getProperty();
- // check if preference changed is a style preference
- if (IStyleConstantsXML.TAG_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_NAME;
- }
- else if (IStyleConstantsXML.TAG_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_BORDER;
- }
- else if (IStyleConstantsXML.TAG_ATTRIBUTE_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_NAME;
- }
- else if (IStyleConstantsXML.TAG_ATTRIBUTE_VALUE.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_VALUE;
- }
- else if (IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS.equals(prefKey)) {
- styleKey = IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS;
- }
- else if (IStyleConstantsXML.COMMENT_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.COMMENT_BORDER;
- }
- else if (IStyleConstantsXML.COMMENT_TEXT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.COMMENT_TEXT;
- }
- else if (IStyleConstantsXML.ENTITY_REFERENCE.equals(prefKey)) {
- styleKey = IStyleConstantsXML.ENTITY_REFERENCE;
- }
- else if (IStyleConstantsXML.CDATA_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.CDATA_BORDER;
- }
- else if (IStyleConstantsXML.CDATA_TEXT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.CDATA_TEXT;
- }
- else if (IStyleConstantsXML.DECL_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DECL_BORDER;
- }
- else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID;
- }
- else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF;
- }
- else if (IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF;
- }
- else if (IStyleConstantsXML.DOCTYPE_NAME.equals(prefKey)) {
- styleKey = IStyleConstantsXML.DOCTYPE_NAME;
- }
- else if (IStyleConstantsXML.PI_CONTENT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.PI_CONTENT;
- }
- else if (IStyleConstantsXML.PI_BORDER.equals(prefKey)) {
- styleKey = IStyleConstantsXML.PI_BORDER;
- }
- else if (IStyleConstantsXML.XML_CONTENT.equals(prefKey)) {
- styleKey = IStyleConstantsXML.XML_CONTENT;
- }
- }
-
- if (styleKey != null) {
- // overwrite style preference with new value
- addTextAttribute(styleKey);
- super.handlePropertyChange(event);
- }
- }
-
- /**
- * Loads text attributes into map. Make sure map is cleared before calling
- * this.
- */
- protected void loadColors() {
- addTextAttribute(IStyleConstantsXML.TAG_NAME);
- addTextAttribute(IStyleConstantsXML.TAG_BORDER);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_NAME);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_VALUE);
- addTextAttribute(IStyleConstantsXML.TAG_ATTRIBUTE_EQUALS);
- addTextAttribute(IStyleConstantsXML.COMMENT_BORDER);
- addTextAttribute(IStyleConstantsXML.COMMENT_TEXT);
- addTextAttribute(IStyleConstantsXML.CDATA_BORDER);
- addTextAttribute(IStyleConstantsXML.CDATA_TEXT);
- addTextAttribute(IStyleConstantsXML.DECL_BORDER);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_PUBREF);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_EXTERNAL_ID_SYSREF);
- addTextAttribute(IStyleConstantsXML.DOCTYPE_NAME);
- addTextAttribute(IStyleConstantsXML.PI_CONTENT);
- addTextAttribute(IStyleConstantsXML.PI_BORDER);
- addTextAttribute(IStyleConstantsXML.XML_CONTENT);
- addTextAttribute(IStyleConstantsXML.ENTITY_REFERENCE);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java
deleted file mode 100644
index 9615ad47b3..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/MarkupTagInfoProvider.java
+++ /dev/null
@@ -1,184 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.taginfo;
-
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocumentation;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNodeList;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDescriptionBuilder;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-/**
- * Provides basic tag information such as element/attribute name, data type,
- * and tag info/documentation for CMNodes. Uses HTML to enhance presentation.
- */
-public class MarkupTagInfoProvider {
- protected final static String BOLD_END = "</b>"; //$NON-NLS-1$
- protected final static String BOLD_START = "<b>"; //$NON-NLS-1$
- protected final static String HEADING_END = "</h5>"; //$NON-NLS-1$
- protected final static String HEADING_START = "<h5>"; //$NON-NLS-1$
- protected final static String LIST_BEGIN = "<ul>"; //$NON-NLS-1$
- protected final static String LIST_ELEMENT = "<li>"; //$NON-NLS-1$
- protected final static String NEW_LINE = "<dl>"; //$NON-NLS-1$
- protected final static String PARAGRAPH_END = "</p>"; //$NON-NLS-1$
- protected final static String PARAGRAPH_START = "<p>"; //$NON-NLS-1$
- protected final static String SPACE = " "; //$NON-NLS-1$
-
- /**
- * Returns basic tag information for display given a CMNode
- *
- * @return String
- */
- public String getInfo(CMNode node) {
- if (node == null) {
- return null;
- }
- StringBuffer sb = new StringBuffer();
- // we assume that if there is tagInfo present, only display tagInfo
- printTagInfo(sb, node);
-
- // no tagInfo present, so try to display tag description
- if (sb.length() == 0) {
- printDescription(sb, node);
- }
-
- // no tag description present either, so display default info
- if (sb.length() == 0) {
- printDefaultInfo(node, sb);
- }
-
- return sb.toString();
- }
-
- /**
- * Adds dataType's data type information, including enumerated type values
- * to string buffer, sb
- *
- */
- protected void printDataTypeInfo(StringBuffer sb, CMDataType dataType) {
- String dataTypeName = dataType.getNodeName();
- if ((dataTypeName != null) && (dataTypeName.length() > 0)) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Data_Type____4 + SPACE + BOLD_END);
- sb.append(dataTypeName);
- sb.append(PARAGRAPH_END);
- }
- String defaultValue = dataType.getImpliedValue();
- if(defaultValue != null) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Default_Value____6 + SPACE + BOLD_END);
- sb.append(defaultValue);
- sb.append(PARAGRAPH_END);
- }
- String[] enumeratedValue = dataType.getEnumeratedValues();
- if ((enumeratedValue != null) && (enumeratedValue.length > 0)) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Enumerated_Values____5 + SPACE + BOLD_END);
- sb.append(LIST_BEGIN);
- for (int i = 0; i < enumeratedValue.length; i++) {
- sb.append(LIST_ELEMENT + enumeratedValue[i]);
- }
- sb.append(PARAGRAPH_END);
- }
- }
-
- /**
- * Adds the default info (element name, content model, data type) of
- * CMNode to the string buffer, sb
- *
- */
- protected void printDefaultInfo(CMNode node, StringBuffer sb) {
- {
-
- if (node.getNodeType() == CMNode.ELEMENT_DECLARATION) {
- CMElementDeclaration ed = (CMElementDeclaration) node;
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Element____1 + SPACE + BOLD_END);
- sb.append(node.getNodeName());
- sb.append(PARAGRAPH_END);
- printDocumentation(sb, node);
- if (ed.getContentType() == CMElementDeclaration.PCDATA) {
- CMDataType dataType = ed.getDataType();
- if (dataType != null) {
- printDataTypeInfo(sb, dataType);
- }
- }
- else {
- CMDescriptionBuilder builder = new CMDescriptionBuilder();
- String description = builder.buildDescription(node);
- if ((description != null) && (description.length() > 0)) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Content_Model____2 + SPACE + BOLD_END);
- sb.append(description + PARAGRAPH_END);
- }
- }
- }
- else if (node.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- CMAttributeDeclaration ad = (CMAttributeDeclaration) node;
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Attribute____3 + SPACE + BOLD_END);
- sb.append(node.getNodeName());
- sb.append(PARAGRAPH_END);
- printDocumentation(sb, node);
- CMDataType dataType = ad.getAttrType();
- if (dataType != null) {
- printDataTypeInfo(sb, dataType);
- }
- }
- else if (node.getNodeType() == CMNode.DATA_TYPE) {
- sb.append(PARAGRAPH_START + BOLD_START + XMLUIMessages.Data_Type____4 + SPACE + BOLD_END);
- sb.append(node.getNodeName());
- sb.append(PARAGRAPH_END);
- printDocumentation(sb, node);
- }
- }
- }
-
- /**
- * Adds the description property of the CMNode to the string buffer, sb
- *
- */
- protected void printDescription(StringBuffer sb, CMNode node) {
- String tagInfo = (String) node.getProperty("description"); //$NON-NLS-1$
- if (tagInfo != null) {
- sb.append(PARAGRAPH_START + tagInfo.trim() + PARAGRAPH_END);
- }
- }
-
- /**
- * Adds the tag documentation property of the CMNode to the string buffer,
- * sb
- *
- */
- protected void printDocumentation(StringBuffer sb, CMNode node) {
- CMNodeList nodeList = (CMNodeList) node.getProperty("documentation"); //$NON-NLS-1$
- if ((nodeList != null) && (nodeList.getLength() > 0)) {
- for (int i = 0; i < nodeList.getLength(); i++) {
- CMDocumentation documentation = (CMDocumentation) nodeList.item(i);
- String doc = documentation.getValue();
- if (doc != null) {
- sb.append(PARAGRAPH_START + doc.trim() + PARAGRAPH_END);
- }
- }
- sb.append(NEW_LINE);
- }
- }
-
- /**
- * Adds the tag info property of the CMNode to the string buffer, sb
- *
- */
- protected void printTagInfo(StringBuffer sb, CMNode node) {
- String tagInfo = (String) node.getProperty("tagInfo"); //$NON-NLS-1$
- if (tagInfo != null) {
- sb.append(PARAGRAPH_START + tagInfo.trim() + PARAGRAPH_END);
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java
deleted file mode 100644
index fe76a69dab..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLInformationProvider.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.taginfo;
-
-
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.information.IInformationProvider;
-import org.eclipse.jface.text.information.IInformationProviderExtension;
-import org.eclipse.wst.sse.ui.internal.SSEUIPlugin;
-
-/**
- * Provides context information for XML tags (Shows tooltip description)
- *
- * @deprecated StructuredTextViewerConfiguration creates the appropriate
- * information provider
- */
-public class XMLInformationProvider implements IInformationProvider, IInformationProviderExtension {
-
- private ITextHover fTextHover = null;
-
- public XMLInformationProvider() {
- fTextHover = SSEUIPlugin.getDefault().getTextHoverManager().createBestMatchHover(new XMLTagInfoHoverProcessor());
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.information.IInformationProvider#getInformation(org.eclipse.jface.text.ITextViewer,
- * org.eclipse.jface.text.IRegion)
- */
- public String getInformation(ITextViewer textViewer, IRegion subject) {
- return (String) getInformation2(textViewer, subject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.information.IInformationProviderExtension#getInformation2(org.eclipse.jface.text.ITextViewer,
- * org.eclipse.jface.text.IRegion)
- */
- public Object getInformation2(ITextViewer textViewer, IRegion subject) {
- return fTextHover.getHoverInfo(textViewer, subject);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.text.information.IInformationProvider#getSubject(org.eclipse.jface.text.ITextViewer,
- * int)
- */
- public IRegion getSubject(ITextViewer textViewer, int offset) {
- return fTextHover.getHoverRegion(textViewer, offset);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
deleted file mode 100644
index 47276fc757..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/taginfo/XMLTagInfoHoverProcessor.java
+++ /dev/null
@@ -1,362 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.taginfo;
-
-
-
-import java.util.List;
-
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.core.internal.util.Debug;
-import org.eclipse.wst.sse.ui.internal.contentassist.ContentAssistUtils;
-import org.eclipse.wst.sse.ui.internal.taginfo.AbstractHoverProcessor;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceHelper;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-
-/**
- * Provides hover help documentation for xml tags
- *
- * @see org.eclipse.jface.text.ITextHover
- */
-public class XMLTagInfoHoverProcessor extends AbstractHoverProcessor {
- protected MarkupTagInfoProvider fInfoProvider = null;
-
- /**
- * Constructor for XMLTextHoverProcessor.
- */
- public XMLTagInfoHoverProcessor() {
- // nothing
- }
-
- /**
- * Retreives documentation to display in the hover help popup.
- *
- * @return String any documentation information to display
- * <code>null</code> if there is nothing to display.
- *
- */
- protected String computeHoverHelp(ITextViewer textViewer, int documentPosition) {
- String result = null;
-
- IndexedRegion treeNode = ContentAssistUtils.getNodeAt(textViewer, documentPosition);
- if (treeNode == null) {
- return null;
- }
- Node node = (Node) treeNode;
-
- while ((node != null) && (node.getNodeType() == Node.TEXT_NODE) && (node.getParentNode() != null)) {
- node = node.getParentNode();
- }
- IDOMNode parentNode = (IDOMNode) node;
-
- IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(documentPosition);
- if (flatNode != null) {
- ITextRegion region = flatNode.getRegionAtCharacterOffset(documentPosition);
- if (region != null) {
- result = computeRegionHelp(treeNode, parentNode, flatNode, region);
- }
- }
-
- return result;
- }
-
- /**
- * Computes the hoverhelp based on region
- *
- * @return String hoverhelp
- */
- protected String computeRegionHelp(IndexedRegion treeNode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- String result = null;
- if (region == null) {
- return null;
- }
- String regionType = region.getType();
- if (regionType == DOMRegionContext.XML_TAG_NAME) {
- result = computeTagNameHelp((IDOMNode) treeNode, parentNode, flatNode, region);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- result = computeTagAttNameHelp((IDOMNode) treeNode, parentNode, flatNode, region);
- }
- else if (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- result = computeTagAttValueHelp((IDOMNode) treeNode, parentNode, flatNode, region);
- }
- return result;
- }
-
- /**
- * Computes the hover help for the attribute name
- */
- protected String computeTagAttNameHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
- String attName = flatNode.getText(region);
- CMAttributeDeclaration attDecl = getCMAttributeDeclaration(xmlnode, elementDecl, attName);
- return getAdditionalInfo(elementDecl, attDecl);
- }
-
- /**
- * Computes the hover help for the attribute value (this is the same as
- * the attribute name's help)
- */
- protected String computeTagAttValueHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
- ITextRegion attrNameRegion = getAttrNameRegion(xmlnode, region);
-
- String attName = flatNode.getText(attrNameRegion);
- CMAttributeDeclaration attDecl = getCMAttributeDeclaration(xmlnode, elementDecl, attName);
- return getAdditionalInfo(elementDecl, attDecl);
- }
-
- /**
- * Computes the hover help for the tag name
- */
- protected String computeTagNameHelp(IDOMNode xmlnode, IDOMNode parentNode, IStructuredDocumentRegion flatNode, ITextRegion region) {
- CMElementDeclaration elementDecl = getCMElementDeclaration(xmlnode);
- CMElementDeclaration pelementDecl = getCMElementDeclaration(parentNode);
- return getAdditionalInfo(pelementDecl, elementDecl);
- }
-
- /**
- * Retreives cmnode's documentation to display in the hover help popup. If
- * no documentation exists for cmnode, try displaying parentOrOwner's
- * documentation
- *
- * @return String any documentation information to display for cmnode.
- * <code>null</code> if there is nothing to display.
- */
- protected String getAdditionalInfo(CMNode parentOrOwner, CMNode cmnode) {
- String addlInfo = null;
-
- if (cmnode == null) {
- if (Debug.displayWarnings) {
- new IllegalArgumentException("Null declaration!").printStackTrace(); //$NON-NLS-1$
- }
- return null;
- }
-
- addlInfo = getInfoProvider().getInfo(cmnode);
- if ((addlInfo == null) && (parentOrOwner != null)) {
- addlInfo = getInfoProvider().getInfo(parentOrOwner);
- }
- return addlInfo;
- }
-
- /**
- * Find the region of the attribute name for the given attribute value
- * region
- *
- */
- protected ITextRegion getAttrNameRegion(IDOMNode node, ITextRegion region) {
- // Find the attribute name for which this position should have a value
- IStructuredDocumentRegion open = node.getFirstStructuredDocumentRegion();
- ITextRegionList openRegions = open.getRegions();
- int i = openRegions.indexOf(region);
- if (i < 0) {
- return null;
- }
- ITextRegion nameRegion = null;
- while (i >= 0) {
- nameRegion = openRegions.get(i--);
- if (nameRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) {
- break;
- }
- }
- return nameRegion;
- }
-
- /**
- * Retreives CMAttributeDeclaration indicated by attribute name within
- * elementDecl
- */
- protected CMAttributeDeclaration getCMAttributeDeclaration(IDOMNode node, CMElementDeclaration elementDecl, String attName) {
- CMAttributeDeclaration attrDecl = null;
-
- if (elementDecl != null) {
- CMNamedNodeMap attributes = elementDecl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributes);
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent((Element) node, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attributes = allAttributes;
-
- String noprefixName = DOMNamespaceHelper.getUnprefixedName(attName);
- if (attributes != null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(noprefixName);
- if (attrDecl == null) {
- attrDecl = (CMAttributeDeclaration) attributes.getNamedItem(attName);
- }
- }
- }
- return attrDecl;
- }
-
- /**
- * Retreives CMElementDeclaration for given node
- *
- * @return CMElementDeclaration - CMElementDeclaration of node or
- * <code>null</code> if not possible
- */
- protected CMElementDeclaration getCMElementDeclaration(Node node) {
- CMElementDeclaration result = null;
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- ModelQuery modelQuery = ModelQueryUtil.getModelQuery(node.getOwnerDocument());
- if (modelQuery != null) {
- result = modelQuery.getCMElementDeclaration((Element) node);
- }
- }
- return result;
- }
-
- /*
- * (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 documentOffset = hoverRegion.getOffset();
- displayText = computeHoverHelp(viewer, documentOffset);
-
- return displayText;
- }
-
- /**
- * 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 within tag name,
- * attribute name, or attribute value and if offset is not over
- * invalid whitespace. otherwise, returns <code>null</code>
- *
- * @see org.eclipse.jface.text.ITextHover#getHoverRegion(ITextViewer, int)
- */
- public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- if ((textViewer == null) || (textViewer.getDocument() == null)) {
- return null;
- }
-
- IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(offset);
- ITextRegion region = null;
-
- if (flatNode != null) {
- region = flatNode.getRegionAtCharacterOffset(offset);
- }
-
- if (region != null) {
- // only supply hoverhelp for tag name, attribute name, or
- // attribute value
- String regionType = region.getType();
- if ((regionType == DOMRegionContext.XML_TAG_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- try {
- // check if we are at whitespace before or after line
- IRegion line = textViewer.getDocument().getLineInformationOfOffset(offset);
- if ((offset > (line.getOffset())) && (offset < (line.getOffset() + line.getLength()))) {
- // check if we are in region's trailing whitespace
- // (whitespace after relevant info)
- if (offset < flatNode.getTextEndOffset(region)) {
- return new Region(flatNode.getStartOffset(region), region.getTextLength());
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
- }
- return null;
- }
-
- /**
- * @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) || (textViewer == null) || (textViewer.getDocument() == null)) {
- return null;
- }
-
- IStructuredDocumentRegion flatNode = ((IStructuredDocument) textViewer.getDocument()).getRegionAtCharacterOffset(offset);
- ITextRegion region = null;
-
- if (flatNode != null) {
- region = flatNode.getRegionAtCharacterOffset(offset);
- }
-
- if (region != null) {
- // only supply hoverhelp for tag name, attribute name, or
- // attribute value
- String regionType = region.getType();
- if ((regionType == DOMRegionContext.XML_TAG_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (regionType == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- try {
- // check if we are at whitespace before or after line
- IRegion line = textViewer.getDocument().getLineInformationOfOffset(offset);
- if ((offset > (line.getOffset())) && (offset < (line.getOffset() + line.getLength()))) {
- // check if we are in region's trailing whitespace
- // (whitespace after relevant info)
- if (offset < flatNode.getTextEndOffset(region)) {
- return new Region(flatNode.getStartOffset(region), region.getTextLength());
- }
- }
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- }
- }
- return null;
- }
-
- /**
- * Gets the infoProvider.
- *
- * @return Returns fInfoProvider and if fInfoProvider was
- * <code>null</code> set fInfoProvider to DefaultInfoProvider
- */
- public MarkupTagInfoProvider getInfoProvider() {
- if (fInfoProvider == null) {
- fInfoProvider = new MarkupTagInfoProvider();
- }
- return fInfoProvider;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java
deleted file mode 100644
index 079b04270c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/EncodingTemplateVariableResolverXML.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.templates;
-
-import org.eclipse.jface.text.templates.SimpleTemplateVariableResolver;
-import org.eclipse.jface.text.templates.TemplateContext;
-import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames;
-import org.eclipse.wst.xml.core.internal.XMLCorePlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-
-
-public class EncodingTemplateVariableResolverXML extends SimpleTemplateVariableResolver {
- private static final String ENCODING_TYPE = getEncodingType();
-
- private static String getEncodingType() {
- return "encoding"; //$NON-NLS-1$
- }
-
- /**
- * Creates a new encoding variable
- */
- public EncodingTemplateVariableResolverXML() {
- super(ENCODING_TYPE, XMLUIMessages.Creating_files_encoding);
- }
-
- protected String resolve(TemplateContext context) {
- return XMLCorePlugin.getDefault().getPluginPreferences().getString(CommonEncodingPreferenceNames.OUTPUT_CODESET);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java
deleted file mode 100644
index f7993e295c..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeIdsXML.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.templates;
-
-public class TemplateContextTypeIdsXML {
-
- public static final String ALL = getAll();
-
- public static final String ATTRIBUTE = getAttribute();
-
- public static final String ATTRIBUTE_VALUE = getAttributeValue();
-
- public static final String NEW = getNew();
-
- public static final String TAG = getTag();
-
- private static String getAll() {
- return getPrefix() + "_all"; //$NON-NLS-1$
- }
-
- private static String getAttribute() {
- return getPrefix() + "_attribute"; //$NON-NLS-1$
- }
-
- private static String getAttributeValue() {
- return getPrefix() + "_attribute_value"; //$NON-NLS-1$
- }
-
- private static String getNew() {
- return getPrefix() + "_new"; //$NON-NLS-1$
- }
-
- private static String getPrefix() {
- return "xml"; //$NON-NLS-1$
- }
-
- private static String getTag() {
- return getPrefix() + "_tag"; //$NON-NLS-1$
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java
deleted file mode 100644
index 43ccf20924..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/templates/TemplateContextTypeXML.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.templates;
-
-import org.eclipse.jface.text.templates.GlobalTemplateVariables;
-import org.eclipse.jface.text.templates.TemplateContextType;
-
-/**
- * Base class for XML template context types. Templates of this context type
- * apply to any place within XML content type.
- */
-public class TemplateContextTypeXML extends TemplateContextType {
-
- public TemplateContextTypeXML() {
- super();
- addResolver(new GlobalTemplateVariables.Cursor());
- addResolver(new GlobalTemplateVariables.Date());
- addResolver(new GlobalTemplateVariables.Dollar());
- addResolver(new GlobalTemplateVariables.LineSelection());
- addResolver(new GlobalTemplateVariables.Time());
- addResolver(new GlobalTemplateVariables.User());
- addResolver(new GlobalTemplateVariables.WordSelection());
- addResolver(new GlobalTemplateVariables.Year());
- addResolver(new EncodingTemplateVariableResolverXML());
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/CharacterPairInserter.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/CharacterPairInserter.java
deleted file mode 100644
index fd4b5bcd95..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/CharacterPairInserter.java
+++ /dev/null
@@ -1,106 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.text;
-
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.text.IDocument;
-import org.eclipse.jface.text.source.ISourceViewer;
-import org.eclipse.jface.util.IPropertyChangeListener;
-import org.eclipse.jface.util.PropertyChangeEvent;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.ui.typing.AbstractCharacterPairInserter;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-
-public class CharacterPairInserter extends AbstractCharacterPairInserter implements IPropertyChangeListener {
-
- // preferences
- private boolean fCloseStrings = true;
- private boolean fCloseBrackets = true;
-
- protected boolean shouldPair(ISourceViewer viewer, char c) {
- switch (c) {
- case '\'':
- case '"':
- return fCloseStrings ? checkRegion(viewer) : false;
- default:
- return fCloseBrackets;
- }
- }
-
- /**
- * Checks if the region should support paired quotes
- * @param viewer the viewer
- * @return true if the region is not in an XML attribute value
- */
- private boolean checkRegion(ISourceViewer viewer) {
- IDocument doc = viewer.getDocument();
- final Point selection= viewer.getSelectedRange();
- final int offset= selection.x;
-
- if (doc instanceof IStructuredDocument) {
- IStructuredDocumentRegion[] regions = ((IStructuredDocument) doc).getStructuredDocumentRegions(offset, 0);
- if (regions != null && regions.length > 0) {
- ITextRegion region = regions[0].getRegionAtCharacterOffset(offset);
- return region.getType() != DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE;
- }
- }
- return true;
- }
-
- public boolean hasPair(char c) {
- switch (c) {
- case '"':
- case '\'':
- case '[':
- case '(':
- return true;
- default:
- return false;
- }
- }
-
- protected char getPair(char c) {
- switch (c) {
- case '\'':
- case '"':
- return c;
- case '(':
- return ')';
- case '[':
- return ']';
- default:
- throw new IllegalArgumentException();
- }
- }
-
- public void initialize() {
- IPreferenceStore store = XMLUIPlugin.getInstance().getPreferenceStore();
- fCloseStrings = store.getBoolean(XMLUIPreferenceNames.TYPING_CLOSE_STRINGS);
- fCloseBrackets = store.getBoolean(XMLUIPreferenceNames.TYPING_CLOSE_BRACKETS);
- store.addPropertyChangeListener(this);
- }
-
- public void dispose() {
- XMLUIPlugin.getInstance().getPreferenceStore().removePropertyChangeListener(this);
- }
-
- public void propertyChange(PropertyChangeEvent event) {
- if (XMLUIPreferenceNames.TYPING_CLOSE_BRACKETS.equals(event.getProperty()))
- fCloseBrackets = ((Boolean) event.getNewValue()).booleanValue();
- else if (XMLUIPreferenceNames.TYPING_CLOSE_STRINGS.equals(event.getProperty()))
- fCloseStrings = ((Boolean) event.getNewValue()).booleanValue();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java
deleted file mode 100644
index b29fd9b47b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/text/XMLDocumentRegionEdgeMatcher.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.text;
-
-import org.eclipse.jface.text.source.DefaultCharacterPairMatcher;
-import org.eclipse.wst.sse.ui.internal.text.DocumentRegionEdgeMatcher;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-
-
-public class XMLDocumentRegionEdgeMatcher extends DocumentRegionEdgeMatcher {
-
- private static final char[] PAIRS = {'{', '}', '(', ')', '[', ']','"','"','\'','\''};
-
- public XMLDocumentRegionEdgeMatcher() {
- super(new String[]{DOMRegionContext.XML_TAG_NAME, DOMRegionContext.XML_COMMENT_TEXT, DOMRegionContext.XML_CDATA_TEXT, DOMRegionContext.XML_PI_OPEN, DOMRegionContext.XML_PI_CONTENT}, new DefaultCharacterPairMatcher(PAIRS));
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/SharedXMLEditorPluginImageHelper.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/SharedXMLEditorPluginImageHelper.java
deleted file mode 100644
index 9981244de5..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/SharedXMLEditorPluginImageHelper.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.util;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-
-public class SharedXMLEditorPluginImageHelper {
- public static final String IMG_DTOOL_CONSTRAINOFF = XMLEditorPluginImages.IMG_DTOOL_CONSTRAINOFF;
- public static final String IMG_DTOOL_CONSTRAINON = XMLEditorPluginImages.IMG_DTOOL_CONSTRAINON;
- public static final String IMG_DTOOL_RLDGRMR = XMLEditorPluginImages.IMG_DTOOL_RLDGRMR;
- public static final String IMG_DTOOL_VALIDATE = XMLEditorPluginImages.IMG_DTOOL_VALIDATE;
- public static final String IMG_ETOOL_CONSTRAINOFF = XMLEditorPluginImages.IMG_ETOOL_CONSTRAINOFF;
- public static final String IMG_ETOOL_CONSTRAINON = XMLEditorPluginImages.IMG_ETOOL_CONSTRAINON;
- public static final String IMG_ETOOL_RLDGRMR = XMLEditorPluginImages.IMG_ETOOL_RLDGRMR;
- public static final String IMG_ETOOL_VALIDATE = XMLEditorPluginImages.IMG_ETOOL_VALIDATE;
- public static final String IMG_OBJ_ATTRIBUTE = XMLEditorPluginImages.IMG_OBJ_ATTRIBUTE;
- public static final String IMG_OBJ_CDATASECTION = XMLEditorPluginImages.IMG_OBJ_CDATASECTION;
- public static final String IMG_OBJ_COMMENT = XMLEditorPluginImages.IMG_OBJ_COMMENT;
- public static final String IMG_OBJ_DOCTYPE = XMLEditorPluginImages.IMG_OBJ_DOCTYPE;
- public static final String IMG_OBJ_ELEMENT = XMLEditorPluginImages.IMG_OBJ_ELEMENT;
- public static final String IMG_OBJ_ENTITY = XMLEditorPluginImages.IMG_OBJ_ENTITY;
- public static final String IMG_OBJ_ENTITY_REFERENCE = XMLEditorPluginImages.IMG_OBJ_ENTITY_REFERENCE;
- public static final String IMG_OBJ_NOTATION = XMLEditorPluginImages.IMG_OBJ_NOTATION;
- public static final String IMG_OBJ_PROCESSINGINSTRUCTION = XMLEditorPluginImages.IMG_OBJ_PROCESSINGINSTRUCTION;
- public static final String IMG_OBJ_TAG_GENERIC = XMLEditorPluginImages.IMG_OBJ_TAG_GENERIC;
- public static final String IMG_OBJ_TAG_MACRO = XMLEditorPluginImages.IMG_OBJ_TAG_MACRO;
- public static final String IMG_OBJ_TXTEXT = XMLEditorPluginImages.IMG_OBJ_TXTEXT;
-
- /**
- * Retrieves the specified image from the xml 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 xml
- * source editor
- * @return the image, or <code>null</code> if not found
- */
- public static Image getImage(String symbolicName) {
- return XMLEditorPluginImageHelper.getInstance().getImage(symbolicName);
- }
-
- /**
- * Retrieves the image descriptor for specified image from the xml 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 xml
- * source editor
- * @return the image descriptor, or <code>null</code> if not found
- */
- public static ImageDescriptor getImageDescriptor(String symbolicName) {
- return XMLEditorPluginImageHelper.getInstance().getImageDescriptor(symbolicName);
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java
deleted file mode 100644
index a3ba0bba36..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonResources.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2006 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.util;
-
-import java.text.MessageFormat;
-import java.util.MissingResourceException;
-import java.util.ResourceBundle;
-
-import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.IWorkbench;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-
-/**
- * @deprecated use XMLUIPlugin.getResourceString() instead
- */
-/**
- * This class exists temporarily until the properties files can be
- * re-organized and the various resource references can be updated
- */
-public class XMLCommonResources {
- protected static XMLCommonResources instance;
-
- public synchronized static XMLCommonResources getInstance() {
- if (instance == null) {
- instance = new XMLCommonResources(XMLUIPlugin.getDefault());
- }
- return instance;
- }
-
- private XMLUIPlugin editorPlugin;
-
- private ResourceBundle resourceBundle;
-
- public XMLCommonResources(XMLUIPlugin editorPlugin) {
- instance = this;
- this.editorPlugin = editorPlugin;
- try {
- resourceBundle = ResourceBundle.getBundle("org.eclipse.wst.xml.ui.internal.XMLUIPluginResources"); //$NON-NLS-1$
- }
- catch (MissingResourceException exception) {
- // TODO... log an error message
- // B2BUtilPlugin.getPlugin().getMsgLogger().write(B2BUtilPlugin.getGUIString("_WARN_PLUGIN_PROPERTIES_MISSING")
- // + descriptor.getLabel());
- resourceBundle = null;
- }
- }
-
- ImageDescriptor _getImageDescriptor(String iconName) {
- return AbstractUIPlugin.imageDescriptorFromPlugin(XMLUIPlugin.ID, iconName);
- }
-
-
- public ResourceBundle getResourceBundle() {
- return resourceBundle;
- }
-
- /**
- * This gets the string resource.
- */
- public String getString(String key) {
- return getResourceBundle().getString(key);
- }
-
- /**
- * This gets the string resource and does one substitution.
- */
- public String getString(String key, Object s1) {
- return MessageFormat.format(getString(key), new Object[]{s1});
- }
-
- /**
- * This gets the string resource and does two substitutions.
- */
- public String getString(String key, Object s1, Object s2) {
- return MessageFormat.format(getString(key), new Object[]{s1, s2});
- }
-
- public IWorkbench getWorkbench() {
- return editorPlugin.getWorkbench();
- }
- /*
- * public ImageFactory getImageFactory() { return imageFactory; }
- */
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonUIContextIds.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonUIContextIds.java
deleted file mode 100644
index 763d502b7f..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/util/XMLCommonUIContextIds.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2005 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-
-
-package org.eclipse.wst.xml.ui.internal.util;
-
-/**
- * Context help id constants.
- */
-public interface XMLCommonUIContextIds {
- public static final String PLUGIN_NAME = "org.eclipse.wst.xml.ui"; //$NON-NLS-1$
-
- /* CONTEXT_ID xcui0500 for Edit Attribute Instruction Dialog */
- public static final String XCUI_ATTRIBUTE_DIALOG = PLUGIN_NAME + ".xcui0500"; //$NON-NLS-1$
-
- /* CONTEXT_ID xcui0400 for Select XML Catalog ID Dialog */
- public static final String XCUI_CATALOG_DIALOG = PLUGIN_NAME + ".xcui0400"; //$NON-NLS-1$
-
- /* CONTEXT_IDs for XML Common UI use xcuixxx context IDs */
-
- /* CONTEXT_ID xcui0010 for Edit Doctype Dialog */
- public static final String XCUI_DOCTYPE_DIALOG = PLUGIN_NAME + ".xcui0010"; //$NON-NLS-1$
- /* CONTEXT_ID xcui0030 for Public ID Text Edit */
- public static final String XCUI_DOCTYPE_PUBLIC = PLUGIN_NAME + ".xcui0030"; //$NON-NLS-1$
- /* CONTEXT_ID xcui0020 for Root Element Name Text Edit */
- public static final String XCUI_DOCTYPE_ROOT = PLUGIN_NAME + ".xcui0020"; //$NON-NLS-1$
- /* CONTEXT_ID xcui0040 for System ID Text Edit */
- public static final String XCUI_DOCTYPE_SYSTEM = PLUGIN_NAME + ".xcui0050"; //$NON-NLS-1$
-
- /* CONTEXT_ID xcui0300 for Edit Element Instruction Dialog */
- public static final String XCUI_ELEMENT_DIALOG = PLUGIN_NAME + ".xcui0600"; //$NON-NLS-1$
-
- /* CONTEXT_ID xcui0200 for Edit Namespace Dialog */
- public static final String XCUI_NAMESPACE_DIALOG = PLUGIN_NAME + ".xcui0200"; //$NON-NLS-1$
-
- /* CONTEXT_ID xcui0300 for Edit Processing Instruction Dialog */
- public static final String XCUI_PROCESSING_DIALOG = PLUGIN_NAME + ".xcui0300"; //$NON-NLS-1$
-
- /* CONTEXT_ID xcui0100 for Edit Schema Information Dialog */
- public static final String XCUI_SCHEMA_INFO_DIALOG = PLUGIN_NAME + ".xcui0100"; //$NON-NLS-1$
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java
deleted file mode 100644
index 087019dfc9..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidator.java
+++ /dev/null
@@ -1,619 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.validation;
-
-import java.io.ByteArrayInputStream;
-import java.io.InputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.ResourcesPlugin;
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.core.runtime.Path;
-import org.eclipse.jface.text.BadLocationException;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.IndexedRegion;
-import org.eclipse.wst.validation.internal.core.IMessageAccess;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IProjectValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMAttr;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMText;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
-
-/**
- * A DelegatingReconcileValidator calls its delegate validator to get a list
- * of validation error IMessages. Using information in this IMessage the
- * DelegatingReconcileValidator updates the IMessage with an offset and length
- * to give a good range to be "squiggled" and adds the messages to the
- * IReporter
- *
- * @author Mark Hutchinson
- *
- */
-public abstract class DelegatingSourceValidator implements IValidator {
- // the selection strategies:
- protected static final String ALL_ATTRIBUTES = "ALL_ATTRIBUTES"; //$NON-NLS-1$
- protected static final String ATTRIBUTE_NAME = "ATTRIBUTE_NAME"; //$NON-NLS-1$
- protected static final String ATTRIBUTE_VALUE = "ATTRIBUTE_VALUE"; //$NON-NLS-1$
- protected static final String START_TAG = "START_TAG"; //$NON-NLS-1$
- protected static final String TEXT = "TEXT"; //$NON-NLS-1$
- protected static final String FIRST_NON_WHITESPACE_TEXT = "FIRST_NON_WHITESPACE_TEXT"; //$NON-NLS-1$
- protected static final String TEXT_ENTITY_REFERENCE = "TEXT_ENTITY_REFERENCE"; //$NON-NLS-1$
- protected static final String VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE = "VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE"; //$NON-NLS-1$
- protected static final String END_TAG = "END_TAG"; //$NON-NLS-1$
-
- /**
- * This constant specifies the attribute name that specifies the side of
- * the 'start tag' that the validator has used to report an error. A
- * validator may choose to report a message at the left (the start of the
- * start tag)or at the right (the end of the start tag). When this
- * attribute is not specified error ERROR_SIDE_LEFT is the default.
- */
- protected static final String ERROR_SIDE = "ERROR_SIDE"; //$NON-NLS-1$
-
- /**
- * When the ERROR_SIDE attribute specifies the ERROR_SIDE_LEFT value it is
- * assumed that the message specifies a location to the left of the start
- * tag
- */
- protected static final String ERROR_SIDE_LEFT = "ERROR_SIDE_LEFT"; //$NON-NLS-1$
-
- /**
- * When the ERROR_SIDE attribute specifies the ERROR_SIDE_RIGHT value it
- * is assumed that the message specifies a location to the right of the
- * start tag
- */
- protected static final String ERROR_SIDE_RIGHT = "ERROR_SIDE_RIGHT"; //$NON-NLS-1$
-
- protected static final String COLUMN_NUMBER_ATTRIBUTE = "columnNumber"; //$NON-NLS-1$
- protected static final String SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE = "squiggleSelectionStrategy"; //$NON-NLS-1$
- protected static final String SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE = "squiggleNameOrValue"; //$NON-NLS-1$
-
- public DelegatingSourceValidator() {
- super(); // constructor
- }
-
- public void cleanup(IReporter arg0) { // don't need to implement
- }
-
- // My Implementation of IHelper
- class MyHelper implements IProjectValidationContext {
- InputStream inputStream;
-
- IFile file;
-
- public MyHelper(InputStream inputStream, IFile file) {
- this.inputStream = inputStream;
- this.file = file;
- }
-
- public int getBuildKind() {
- return 0;
- }
-
- public Object loadModel(String symbolicName, Object[] parms) {
- if (symbolicName.equals("getFile")) { //$NON-NLS-1$
- return file;
- }
- return null;
- }
-
- public Object loadModel(String symbolicName) {
- if (symbolicName.equals("inputStream")) { //$NON-NLS-1$
- return inputStream;
- }
- return null;
- }
-
- public String[] getURIs() {
- if (file != null) {
- return new String[]{file.getFullPath().toString()};
- }
- return new String[0];
- }
-
- public IProject getProject() {
- if (file != null) {
- return file.getProject();
- }
- return null;
- }
- }
-
- // My Implementation of IReporter
- class MyReporter implements IReporter {
- List list = new ArrayList();
-
- public MyReporter() {
- super();
- }
-
- public void addMessage(IValidator origin, IMessage message) {
- list.add(message);
- }
-
- public void displaySubtask(IValidator validator, IMessage message) {
- /* do not need to implement */
- }
-
- public IMessageAccess getMessageAccess() {
- return null;
- }
-
- public boolean isCancelled() {
- return false;
- }
-
- public void removeAllMessages(IValidator origin, Object object) { // do
- /* do not need to implement */
- }
-
- public void removeAllMessages(IValidator origin) {
- /* do not need to implement */
- }
-
- public void removeMessageSubset(IValidator validator, Object obj, String groupName) {// do
- /* do not need to implement */
- }
-
- public List getMessages() {
- return list;
- }
- }
-
- protected abstract IValidator getDelegateValidator();
-
- /**
- * Calls a delegate validator getting and updates it's list of
- * ValidationMessages with a good squiggle offset and length.
- *
- * @param helper
- * loads an object.
- * @param reporter
- * Is an instance of an IReporter interface, which is used for
- * interaction with the user.
- */
- public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
- String[] delta = helper.getURIs();
- if (delta.length > 0) {
- // get the file, model and document:
- IFile file = getFile(delta[0]);
- IDOMModel xmlModel = null;
- if (file != null)
- xmlModel = getModelForResource(file);
- // some problem occurred, abort
- if (xmlModel == null)
- return;
-
- try {
- IDOMDocument document = xmlModel.getDocument();
-
- // store the text in a byte array; make a full copy to ease
- // any threading problems
- byte[] byteArray;
- try {
- byteArray = xmlModel.getStructuredDocument().get().getBytes("UTF-8");
- }
- catch (UnsupportedEncodingException e) {
- // Not likely to happen
- byteArray = xmlModel.getStructuredDocument().get().getBytes();
- }
-
- if (isDelegateValidatorEnabled(file)) {
- IValidator validator = getDelegateValidator();
- if (validator != null) {
- // Validate the file:
- IValidationContext vHelper = new MyHelper(new ByteArrayInputStream(byteArray), file);
- MyReporter vReporter = new MyReporter();
- if (validator instanceof IValidatorJob) {
- ((IValidatorJob) validator).validateInJob(vHelper, vReporter);
- }
- else {
- validator.validate(vHelper, vReporter);
- }
- List messages = vReporter.list;
-
- // set the offset and length
- updateValidationMessages(messages, document, reporter);
- }
- }
- }
-
-
- finally {
- if (xmlModel != null) {
- xmlModel.releaseFromRead();
- }
- }
- }
- }
-
- /**
- * iterates through the messages and calculates a "better" offset and
- * length
- *
- * @param messages -
- * a List of IMessages
- * @param document -
- * the document
- * @param reporter -
- * the reporter the messages are to be added to
- */
- protected void updateValidationMessages(List messages, IDOMDocument document, IReporter reporter) {
- for (int i = 0; i < messages.size(); i++) {
- IMessage message = (IMessage) messages.get(i);
- try {
- if (message.getAttribute(COLUMN_NUMBER_ATTRIBUTE) != null) {
- int column = ((Integer) message.getAttribute(COLUMN_NUMBER_ATTRIBUTE)).intValue();
- String selectionStrategy = (String) message.getAttribute(SQUIGGLE_SELECTION_STRATEGY_ATTRIBUTE);
- String nameOrValue = (String) message.getAttribute(SQUIGGLE_NAME_OR_VALUE_ATTRIBUTE);
-
- // convert the line and Column numbers to an offset:
- int start = document.getStructuredDocument().getLineOffset(message.getLineNumber() - 1) + column - 1;
-
- // calculate the "better" start and end offset:
- int[] result = computeStartAndEndLocation(start, selectionStrategy, getErrorSide(message), nameOrValue, document);
- if (result != null) {
- message.setOffset(result[0]);
- message.setLength(result[1] - result[0]);
- reporter.addMessage(this, message);
- }
- }
- }
- catch (BadLocationException e) { // this exception should not
- // occur - it is thrown if
- // trying to convert an
- // invalid line number to and
- // offset
- }
-
- }
- }
-
- /**
- * @param delta
- * the IFileDelta containing the file name to get
- * @return the IFile
- */
- public IFile getFile(String delta) {
- IPath path = new Path(delta);
- if (path.segmentCount() > 1) {
- IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
- if (file != null && file.exists())
- return file;
- }
- return null;
- }
-
- /**
- *
- * @param file
- * the file to get the model for
- * @return the file's XMLModel or null
- */
- protected IDOMModel getModelForResource(IFile file) {
- IStructuredModel model = null;
- IModelManager manager = StructuredModelManager.getModelManager();
-
- try {
- model = manager.getModelForRead(file);
- // TODO.. HTML validator tries again to get a model a 2nd way
- }
- catch (Exception e) {
- Logger.log(Logger.ERROR_DEBUG, file.getFullPath().toString(), e);
- }
-
- if (model instanceof IDOMModel)
- return (IDOMModel) model;
- if (model != null)
- model.releaseFromRead();
- return null;
- }
-
- /**
- * @deprecated use computeStartEndLocation(int startOffset, String
- * errorMessage, String selectionStrategy, boolean leftError,
- * String nameOrValue, IDOMDocument document) {
- *
- */
- protected int[] computeStartEndLocation(int startOffset, String errorMessage, String selectionStrategy, String nameOrValue, IDOMDocument document) {
- return computeStartAndEndLocation(startOffset, selectionStrategy, ERROR_SIDE_RIGHT, nameOrValue, document);
- }
-
- /**
- * Calculates the "better" offsets.
- *
- * @param startOffset -
- * the offset given by Xerces
- * @param errorMessage -
- * the Xerces error Message
- * @param selectionStrategy -
- * the selectionStrategy
- * @param document -
- * the document
- * @return int[] - position 0 has the start offset of the squiggle range,
- * position 1 has the endOffset
- */
- /*
- * The way the offsets is calculated is: - find the indexed region
- * (element) closest to the given offset - if we are between two elements,
- * choosing left or right element will depend on parameter 'errorSide' -
- * based on the selectionStrategy choose the underlining strategy (eg
- * START_TAG means underline the start tag of that element) - use
- * information from nameOrValue and the DOM to get better offsets
- *
- */
- protected int[] computeStartAndEndLocation(int startOffset, String selectionStrategy, String errorSide, String nameOrValue, IDOMDocument document) {
- try {
- int startEndPositions[] = new int[2];
-
- IndexedRegion region = document.getModel().getIndexedRegion(startOffset);
- IndexedRegion prevRegion = document.getModel().getIndexedRegion(startOffset - 1);
-
- if (prevRegion != region) {
- // if between two regions we use the 'errorSide' to understand
- // which
- // element is applicable. if we know the error has been
- // reported to the
- // right of the tag, then we can assume we need to step back
- // to the previous
- // region to land at the 'correct location. Otherwise assume
- // we're
- // exactly where we need to be.
- if (ERROR_SIDE_LEFT.equals(errorSide)) {
- region = prevRegion;
- }
- }
-
- // initialize start and end positions to be the start positions
- // this means if the
- // special case is not taken care of below the start and end
- // offset are set to be
- // the start of the region where the error was
- if (region != null) {
- startEndPositions[0] = region.getStartOffset();
- startEndPositions[1] = startEndPositions[0];
- }
- else { // this will message will not get added to the IReporter
- // since the length is 0
- startEndPositions[0] = 0;
- startEndPositions[1] = 0;
- }
- if (region instanceof Node) {
- Node node = (Node) region;
-
- if (START_TAG.equals(selectionStrategy)) {// then we want to
- // underline the opening tag
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- IDOMElement element = (IDOMElement) node;
- startEndPositions[0] = element.getStartOffset() + 1;
- startEndPositions[1] = startEndPositions[0] + element.getTagName().length();
- }
- }
- else if (END_TAG.equals(selectionStrategy)) {// then we want to
- // underline the end tag
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- IDOMElement element = (IDOMElement) node;
- startEndPositions[0] = element.getEndStartOffset();
- startEndPositions[1] = element.getEndOffset();
- }
- }
- else if (ATTRIBUTE_NAME.equals(selectionStrategy)) { // in
- // underline the attribute's name
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- IDOMElement element = (IDOMElement) node;
- IDOMNode attributeNode = (IDOMNode) (element.getAttributeNode(nameOrValue));
- if (attributeNode != null) {
- startEndPositions[0] = attributeNode.getStartOffset();
- startEndPositions[1] = attributeNode.getStartOffset() + nameOrValue.length();
- }
- }
- }
- else if (ATTRIBUTE_VALUE.equals(selectionStrategy)) {
- // underline the attribute's value
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- IDOMElement element = (IDOMElement) node;
- IDOMAttr attributeNode = (IDOMAttr) (element.getAttributeNode(nameOrValue));
- if (attributeNode != null) {
- startEndPositions[0] = attributeNode.getValueRegionStartOffset();
- String valueRegionText = attributeNode.getValueRegionText();
- int valueRegionLength = valueRegionText == null ? 0 : valueRegionText.length();
- startEndPositions[1] = startEndPositions[0] + valueRegionLength;
- }
- }
- }
- else if (ALL_ATTRIBUTES.equals(selectionStrategy)) {
- // underline all attributes
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- IDOMElement element = (IDOMElement) node;
- NamedNodeMap attributes = element.getAttributes();
- if (attributes != null) {
- IDOMNode first = (IDOMNode) attributes.item(0);
- IDOMNode last = (IDOMNode) attributes.item(attributes.getLength() - 1);
- if ((first != null) && (last != null)) {
- startEndPositions[0] = first.getStartOffset();
- startEndPositions[1] = last.getEndOffset();
- }
- }
- }
- }
- else if (TEXT.equals(selectionStrategy)) {
- // underline the text between the tags
- if (node.getNodeType() == Node.TEXT_NODE) {
- IDOMText textNode = (IDOMText) node;
- int start = textNode.getStartOffset();
- String value = textNode.getNodeValue();
- int index = 0;
- char curChar = value.charAt(index);
- // here we are finding start offset by skipping over
- // whitespace:
- while ((curChar == '\n') || (curChar == '\t') || (curChar == '\r') || (curChar == ' ')) {
- curChar = value.charAt(index);
- index++;
- }
- if (index > 0) {
- index--;
-
- }
- start = start + index;
- startEndPositions[0] = start;
- startEndPositions[1] = start + value.trim().length();
- }
- else if (node.getNodeType() == Node.ELEMENT_NODE) {
- IDOMElement element = (IDOMElement) node;
- Node child = element.getFirstChild();
- if (child instanceof IDOMNode) {
- IDOMNode xmlChild = ((IDOMNode) child);
- startEndPositions[0] = xmlChild.getStartOffset();
- startEndPositions[1] = xmlChild.getEndOffset();
- }
- }
- }
- else if (FIRST_NON_WHITESPACE_TEXT.equals(selectionStrategy)) {
- // search through all child nodes and return range of
- // first non-whitespace
- // text node
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- NodeList nodes = node.getChildNodes();
- for (int i = 0; i < nodes.getLength(); i++) {
- Node currentNode = nodes.item(i);
- if (currentNode.getNodeType() == Node.TEXT_NODE) {
- // TODO (Trung) I don't think we should call
- // getNodeValue(), trim(), length()
- // repeatedly.
- // This is inefficient, to improve use local
- // variables to store values.
- IDOMText textNode = (IDOMText) currentNode;
- if (textNode.getNodeValue().trim().length() > 0) {
- String value = textNode.getNodeValue();
- int index = 0;
- int start = textNode.getStartOffset();
- char curChar = value.charAt(index);
- // here we are finding start offset by
- // skipping over whitespace:
- while ((curChar == '\n') || (curChar == '\t') || (curChar == '\r') || (curChar == ' ')) {
- curChar = value.charAt(index);
- index++;
- }
- if (index > 0) {
- index--;
-
- }
- start = start + index;
- startEndPositions[0] = start;
- startEndPositions[1] = start + value.trim().length();
- break;
- }
- }
-
- }
- }
- }
-
- else if (TEXT_ENTITY_REFERENCE.equals(selectionStrategy)) {
- if (node.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
- startEndPositions[0] = region.getStartOffset();
- startEndPositions[1] = region.getEndOffset();
- }
- else if (node.getNodeType() == Node.ELEMENT_NODE) {
- /*
- * In this case the undeclared entity might be in one
- * of the attribute values. Search through the
- * attributes to find the range of the undeclared
- * entity.
- */
- String entity = "&" + nameOrValue + ";"; //$NON-NLS-1$ //$NON-NLS-2$
- NamedNodeMap attributes = node.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- IDOMAttr attr = (IDOMAttr) attributes.item(i);
- String nodeValue = attr.getNodeValue();
- int index = nodeValue.indexOf(entity);
- if (index != -1) {
- startEndPositions[0] = attr.getValueRegionStartOffset() + index + 1;
- startEndPositions[1] = startEndPositions[0] + entity.length();
- }
- }
- }
-
- }
- else if (VALUE_OF_ATTRIBUTE_WITH_GIVEN_VALUE.equals(selectionStrategy)) {
- // TODO (Trung) do we really need this strategy ?
- // If we know the name of the name of the attribute, we
- // can retrieve its value.
- // Hence, we can incoperate this strategy with
- // ATTRIBUTE_VALUE ?
- if (node.getNodeType() == Node.ELEMENT_NODE) {
- // here we will search through all attributes for the
- // one with the
- // with the value we want:
- // TODO (Trung) I see a potential problem here.
- // What happens when there is another attribute having
- // the same value
- // with this attribute's buggy value ?
- // Need to solve when time permits.
- NamedNodeMap attributes = node.getAttributes();
- for (int i = 0; i < attributes.getLength(); i++) {
- IDOMAttr attr = (IDOMAttr) attributes.item(i);
- String nodeValue = attr.getNodeValue().trim();
- if (nodeValue.equals(nameOrValue)) {
- startEndPositions[0] = attr.getValueRegionStartOffset() + 1;
- startEndPositions[1] = startEndPositions[0] + nodeValue.length();
- break;
- }
- }
- }
- }
- }
- return startEndPositions;
- }
- // catch (Exception e) { // e.printStackTrace();
- // }
- finally {
- }
- // return null;
- }
-
- /**
- * Returns true if delegate validator is enabled based on Validation
- * preferences
- *
- * @param file
- * @return false if delegate validator is not enabled based on Validatoin
- * preferences, true otherwise
- */
- protected boolean isDelegateValidatorEnabled(IFile file) {
- return true;
- }
-
- protected String getErrorSide(IMessage message) {
- // note that if the ERROR_SIDE is unspecified we return the default
- // value ERROR_SIDE_LEFT
- Object value = message.getAttribute(ERROR_SIDE);
- return ERROR_SIDE_RIGHT.equals(value) ? ERROR_SIDE_RIGHT : ERROR_SIDE_LEFT;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java
deleted file mode 100644
index 414a85b8ac..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/DelegatingSourceValidatorForXML.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.wst.xml.ui.internal.validation;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.wst.validation.ValidationFramework;
-import org.eclipse.wst.validation.Validator;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-
-/**
- * This performs as you type validation for XML files
- */
-public class DelegatingSourceValidatorForXML extends DelegatingSourceValidator
-{
- private final static String Id = "org.eclipse.wst.xml.core.xml"; //$NON-NLS-1$
-
- private Validator _validator;
-
- public DelegatingSourceValidatorForXML()
- {
- }
-
- private Validator getValidator()
- {
- if (_validator == null)
- _validator = ValidationFramework.getDefault().getValidator(Id);
- return _validator;
- }
-
- protected IValidator getDelegateValidator()
- {
- Validator v = getValidator();
- if (v == null)
- return null;
- return v.asIValidator();
- }
-
- protected boolean isDelegateValidatorEnabled(IFile file)
- {
- Validator v = getValidator();
- if (v == null)
- return false;
- if (!v.shouldValidate(file, false, false))
- return false;
- return v.isBuildValidation() || v.isManualValidation();
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupQuickAssistProcessor.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupQuickAssistProcessor.java
deleted file mode 100644
index c8c876c130..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupQuickAssistProcessor.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.validation;
-
-import java.util.ArrayList;
-
-import org.eclipse.jface.text.contentassist.CompletionProposal;
-import org.eclipse.jface.text.contentassist.ICompletionProposal;
-import org.eclipse.jface.text.quickassist.IQuickAssistInvocationContext;
-import org.eclipse.jface.text.quickassist.IQuickAssistProcessor;
-import org.eclipse.jface.text.source.Annotation;
-import org.eclipse.swt.graphics.Image;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.correction.ProblemIDsXML;
-import org.eclipse.wst.xml.ui.internal.correction.RemoveUnknownElementQuickFixProposal;
-import org.eclipse.wst.xml.ui.internal.correction.RenameInFileQuickAssistProposal;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImageHelper;
-import org.eclipse.wst.xml.ui.internal.editor.XMLEditorPluginImages;
-
-/**
- * Quick assist processor for problems found by the markup validator
- */
-class MarkupQuickAssistProcessor implements IQuickAssistProcessor {
- private int fProblemId;
- private Object fAdditionalFixInfo = null;
-
- public boolean canAssist(IQuickAssistInvocationContext invocationContext) {
- return false;
- }
-
- public boolean canFix(Annotation annotation) {
- boolean result = false;
-
- switch (fProblemId) {
- case ProblemIDsXML.EmptyTag :
- case ProblemIDsXML.MissingEndTag :
- case ProblemIDsXML.AttrsInEndTag :
- case ProblemIDsXML.MissingAttrValue :
- case ProblemIDsXML.NoAttrValue :
- case ProblemIDsXML.SpacesBeforeTagName :
- case ProblemIDsXML.SpacesBeforePI :
- case ProblemIDsXML.NamespaceInPI :
- case ProblemIDsXML.UnknownElement :
- case ProblemIDsXML.UnknownAttr :
- case ProblemIDsXML.InvalidAttrValue :
- case ProblemIDsXML.MissingRequiredAttr :
- case ProblemIDsXML.AttrValueNotQuoted :
- case ProblemIDsXML.MissingClosingBracket :
- result = true;
- }
-
- return result;
- }
-
- public ICompletionProposal[] computeQuickAssistProposals(IQuickAssistInvocationContext invocationContext) {
- ArrayList proposals = new ArrayList();
-
- switch (fProblemId) {
- case ProblemIDsXML.EmptyTag :
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_0, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.MissingEndTag :
- String tagName = (String) ((Object[]) fAdditionalFixInfo)[0];
- String tagClose = (String) ((Object[]) fAdditionalFixInfo)[1];
- int tagCloseOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[2]).intValue();
- int startTagEndOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[3]).intValue();
- int firstChildStartOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[4]).intValue();
- int endOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[5]).intValue();
- proposals.add(new CompletionProposal(tagClose, tagCloseOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_1, null, "")); //$NON-NLS-1$
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), startTagEndOffset - invocationContext.getOffset(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_2, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- proposals.add(new CompletionProposal("</" + tagName + ">", firstChildStartOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_3, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("</" + tagName + ">", endOffset, 0, 0, getImage(), XMLUIMessages.QuickFixProcessorXML_4, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.AttrsInEndTag :
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_5, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.MissingAttrValue :
- String defaultAttrValue = (String) ((Object[]) fAdditionalFixInfo)[0];
- int insertOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[1]).intValue();
- proposals.add(new CompletionProposal("\"" + defaultAttrValue + "\"", invocationContext.getOffset() + invocationContext.getLength() + insertOffset, 0, defaultAttrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.NoAttrValue :
- defaultAttrValue = (String) fAdditionalFixInfo;
- proposals.add(new CompletionProposal("=\"" + defaultAttrValue + "\"", invocationContext.getOffset() + invocationContext.getLength(), 0, defaultAttrValue.length() + 3, getImage(), XMLUIMessages.QuickFixProcessorXML_6, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.SpacesBeforeTagName :
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_8, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.SpacesBeforePI :
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_9, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.NamespaceInPI :
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_10, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.UnknownElement :
- proposals.add(new RemoveUnknownElementQuickFixProposal(fAdditionalFixInfo, getImage(), XMLUIMessages.QuickFixProcessorXML_11));
- proposals.add(new RenameInFileQuickAssistProposal());
- break;
- case ProblemIDsXML.UnknownAttr :
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_7, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- proposals.add(new RenameInFileQuickAssistProposal());
- break;
- case ProblemIDsXML.InvalidAttrValue :
- proposals.add(new CompletionProposal("", invocationContext.getOffset(), invocationContext.getLength(), 0, getImage(), XMLUIMessages.QuickFixProcessorXML_12, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- case ProblemIDsXML.MissingRequiredAttr :
- String requiredAttr = (String) ((Object[]) fAdditionalFixInfo)[0];
- insertOffset = ((Integer) ((Object[]) fAdditionalFixInfo)[1]).intValue();
- proposals.add(new CompletionProposal(requiredAttr, invocationContext.getOffset() + insertOffset, 0, requiredAttr.length(), getImage(), XMLUIMessages.QuickFixProcessorXML_13, null, "")); //$NON-NLS-1$
- break;
- case ProblemIDsXML.AttrValueNotQuoted :
- String attrValue = (String) fAdditionalFixInfo;
- proposals.add(new CompletionProposal("\"" + attrValue + "\"", invocationContext.getOffset(), invocationContext.getLength(), attrValue.length() + 2, getImage(), XMLUIMessages.QuickFixProcessorXML_14, null, "")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- break;
- case ProblemIDsXML.MissingClosingBracket :
- proposals.add(new CompletionProposal(">", invocationContext.getOffset() + invocationContext.getLength(), 0, 1, getImage(), XMLUIMessages.QuickFixProcessorXML_15, null, "")); //$NON-NLS-1$ //$NON-NLS-2$
- break;
- }
- return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
- }
-
- public String getErrorMessage() {
- return null;
- }
-
- private Image getImage() {
- return XMLEditorPluginImageHelper.getInstance().getImage(XMLEditorPluginImages.IMG_OBJ_CORRECTION_CHANGE);
- }
-
- public void setProblemId(int problemId) {
- fProblemId = problemId;
- }
-
- public void setAdditionalFixInfo(Object fixInfo) {
- fAdditionalFixInfo = fixInfo;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java
deleted file mode 100644
index 17e2ba1050..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/internal/validation/MarkupValidator.java
+++ /dev/null
@@ -1,1036 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.internal.validation;
-
-import java.util.Locale;
-
-import org.eclipse.core.resources.IFile;
-import org.eclipse.core.resources.IProject;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.core.resources.IResourceProxy;
-import org.eclipse.core.resources.IResourceProxyVisitor;
-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.IProgressMonitor;
-import org.eclipse.core.runtime.Path;
-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.jface.text.quickassist.IQuickAssistProcessor;
-import org.eclipse.osgi.util.NLS;
-import org.eclipse.wst.sse.core.StructuredModelManager;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument;
-import org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocumentRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegion;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionContainer;
-import org.eclipse.wst.sse.core.internal.provisional.text.ITextRegionList;
-import org.eclipse.wst.sse.ui.internal.reconcile.AbstractStructuredTextReconcilingStrategy;
-import org.eclipse.wst.sse.ui.internal.reconcile.ReconcileAnnotationKey;
-import org.eclipse.wst.sse.ui.internal.reconcile.validator.AnnotationInfo;
-import org.eclipse.wst.sse.ui.internal.reconcile.validator.ISourceValidator;
-import org.eclipse.wst.sse.ui.internal.reconcile.validator.IncrementalReporter;
-import org.eclipse.wst.validation.AbstractValidator;
-import org.eclipse.wst.validation.ValidationResult;
-import org.eclipse.wst.validation.ValidationState;
-import org.eclipse.wst.validation.internal.core.Message;
-import org.eclipse.wst.validation.internal.core.ValidationException;
-import org.eclipse.wst.validation.internal.operations.IWorkbenchContext;
-import org.eclipse.wst.validation.internal.operations.LocalizedMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IMessage;
-import org.eclipse.wst.validation.internal.provisional.core.IReporter;
-import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
-import org.eclipse.wst.validation.internal.provisional.core.IValidator;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.core.internal.regions.DOMRegionContext;
-import org.eclipse.wst.xml.ui.internal.Logger;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.correction.ProblemIDsXML;
-import org.w3c.dom.Node;
-
-/**
- * Basic XML syntax checking step.
- */
-public class MarkupValidator extends AbstractValidator implements IValidator, ISourceValidator {
- private String DQUOTE = "\""; //$NON-NLS-1$
- private String SQUOTE = "'"; //$NON-NLS-1$
- private final String QUICKASSISTPROCESSOR = IQuickAssistProcessor.class.getName();
-
- private IDocument fDocument;
-
- private IContentType fRootContentType = null;
-
- private int SEVERITY_ATTRIBUTE_HAS_NO_VALUE = IMessage.HIGH_SEVERITY;
- private int SEVERITY_END_TAG_WITH_ATTRIBUTES = IMessage.HIGH_SEVERITY;
- private int SEVERITY_INVALID_WHITESPACE_BEFORE_TAGNAME = IMessage.HIGH_SEVERITY;
- private int SEVERITY_MISSING_CLOSING_BRACKET = IMessage.HIGH_SEVERITY;
- private int SEVERITY_MISSING_CLOSING_QUOTE = IMessage.HIGH_SEVERITY;
- private int SEVERITY_MISSING_END_TAG = IMessage.HIGH_SEVERITY;
- private int SEVERITY_MISSING_START_TAG = IMessage.HIGH_SEVERITY;
- private int SEVERITY_MISSING_QUOTES = IMessage.HIGH_SEVERITY;
- private int SEVERITY_NAMESPACE_IN_PI_TARGET = IMessage.HIGH_SEVERITY;
- private int SEVERITY_TAG_NAME_MISSING = IMessage.HIGH_SEVERITY;
- private int SEVERITY_WHITESPACE_AT_START = IMessage.HIGH_SEVERITY;
-
- private void addAttributeError(String messageText, String attributeValueText, int start, int length, int problemId, IStructuredDocumentRegion sdRegion, IReporter reporter, int messageSeverity) {
-
- if (sdRegion.isDeleted()) {
- return;
- }
-
- int lineNo = getLineNumber(start);
- LocalizedMessage message = new LocalizedMessage(messageSeverity, messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNo);
-
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(problemId);
- processor.setAdditionalFixInfo(attributeValueText);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- }
-
- private void checkAttributesInEndTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- ITextRegionList textRegions = structuredDocumentRegion.getRegions();
- int errorCount = 0;
- int start = structuredDocumentRegion.getEndOffset();
- int end = structuredDocumentRegion.getEndOffset();
- for (int i = 0; (i < textRegions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) {
- ITextRegion textRegion = textRegions.get(i);
- if ((textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) || (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE)) {
- if (start > structuredDocumentRegion.getStartOffset(textRegion)) {
- start = structuredDocumentRegion.getStartOffset(textRegion);
- }
- end = structuredDocumentRegion.getEndOffset(textRegion);
- errorCount++;
- }
- }
- // create one error for all attributes in the end tag
- if (errorCount > 0) {
- // Position p = new Position(start, end - start);
- String messageText = XMLUIMessages.End_tag_has_attributes;
- LocalizedMessage message = new LocalizedMessage(SEVERITY_END_TAG_WITH_ATTRIBUTES, messageText);
- message.setOffset(start);
- message.setLength(end - start);
- message.setLineNo(getLineNumber(start));
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.AttrsInEndTag);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- }
- }
-
-
- private void checkClosingBracket(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- ITextRegion r = null;
- boolean closed = false;
- for (int i = 0; (i < regions.size()) && !structuredDocumentRegion.isDeleted(); i++) {
- r = regions.get(i);
- if ((r.getType() == DOMRegionContext.XML_TAG_CLOSE) || (r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE)) {
- closed = true;
- }
- }
- if (!closed) {
-
- String messageText = XMLUIMessages.ReconcileStepForMarkup_6;
-
- int start = structuredDocumentRegion.getStartOffset();
- int length = structuredDocumentRegion.getText().trim().length();
- int lineNo = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(SEVERITY_MISSING_CLOSING_BRACKET , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNo);
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.MissingClosingBracket);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- }
- }
-
- private void checkEmptyTag(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- // navigate to name
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- if (regions.size() == 2) {
- // missing name region
- if ((regions.get(0).getType() == DOMRegionContext.XML_TAG_OPEN) && (regions.get(1).getType() == DOMRegionContext.XML_TAG_CLOSE)) {
- String messageText = XMLUIMessages.ReconcileStepForMarkup_3;
- int start = structuredDocumentRegion.getStartOffset();
- int length = structuredDocumentRegion.getLength();
- int lineNo = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(SEVERITY_TAG_NAME_MISSING , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNo);
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.EmptyTag);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- }
- }
- }
-
- private int getLineNumber(int start) {
- int lineNo = -1;
- try {
- lineNo = getDocument().getLineOfOffset(start) + 1;
- }
- catch (BadLocationException e) {
- Logger.logException(e);
- }
- return lineNo;
- }
-
- private void checkForAttributeValue(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- // check for attributes without a value
- // track the attribute/equals/value sequence using a state of 0, 1 ,2
- // representing the name, =, and value, respectively
- int attrState = 0;
- ITextRegionList textRegions = structuredDocumentRegion.getRegions();
- // ReconcileAnnotationKey key = createKey(structuredDocumentRegion,
- // getScope());
-
- int errorCount = 0;
- for (int i = 0; (i < textRegions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT); i++) {
- ITextRegion textRegion = textRegions.get(i);
- if ((textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_NAME) || isTagCloseTextRegion(textRegion)) {
- // dangling name and '='
- if ((attrState == 2) && (i >= 2)) {
- // create annotation
- ITextRegion nameRegion = textRegions.get(i - 2);
- if (!(nameRegion instanceof ITextRegionContainer)) {
- Object[] args = {structuredDocumentRegion.getText(nameRegion)};
- String messageText = NLS.bind(XMLUIMessages.Attribute__is_missing_a_value, args);
-
- int start = structuredDocumentRegion.getStartOffset(nameRegion);
- int end = structuredDocumentRegion.getEndOffset();
- int lineNo = getLineNumber(start);
- int textLength = structuredDocumentRegion.getText(nameRegion).trim().length();
-
- LocalizedMessage message = new LocalizedMessage(SEVERITY_ATTRIBUTE_HAS_NO_VALUE , messageText);
- message.setOffset(start);
- message.setLength(textLength);
- message.setLineNo(lineNo);
-
- // quick fix info
- ITextRegion equalsRegion = textRegions.get(i - 2 + 1);
- int insertOffset = structuredDocumentRegion.getTextEndOffset(equalsRegion) - end;
- Object[] additionalFixInfo = {structuredDocumentRegion.getText(nameRegion), new Integer(insertOffset)};
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.MissingAttrValue);
- processor.setAdditionalFixInfo(additionalFixInfo);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- errorCount++;
- }
- }
- // name but no '=' (XML only)
- else if ((attrState == 1) && (i >= 1)) {
- // create annotation
- ITextRegion previousRegion = textRegions.get(i - 1);
- if (!(previousRegion instanceof ITextRegionContainer)) {
- Object[] args = {structuredDocumentRegion.getText(previousRegion)};
- String messageText = NLS.bind(XMLUIMessages.Attribute__has_no_value, args);
- int start = structuredDocumentRegion.getStartOffset(previousRegion);
- int textLength = structuredDocumentRegion.getText(previousRegion).trim().length();
- int lineNo = getLineNumber(start);
-
- LocalizedMessage message = new LocalizedMessage(SEVERITY_ATTRIBUTE_HAS_NO_VALUE, messageText);
- message.setOffset(start);
- message.setLength(textLength);
- message.setLineNo(lineNo);
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.NoAttrValue);
- processor.setAdditionalFixInfo(structuredDocumentRegion.getText(previousRegion));
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
-
- errorCount++;
- }
- }
- attrState = 1;
- }
- else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_EQUALS) {
- attrState = 2;
- }
- else if (textRegion.getType() == DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- attrState = 0;
- }
- }
-
- }
-
- private void checkForSpaceBeforeName(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- String sdRegionText = structuredDocumentRegion.getFullText();
- if (sdRegionText.startsWith(" ")) { //$NON-NLS-1$
- IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious();
- if (prev != null) {
- // this is possibly the case of "< tag"
- if ((prev.getRegions().size() == 1) && isStartTag(prev)) {
- // add the error for preceding space in tag name
- String messageText = XMLUIMessages.ReconcileStepForMarkup_2;
- int start = structuredDocumentRegion.getStartOffset();
- // find length of whitespace
- int length = sdRegionText.trim().equals("") ? sdRegionText.length() : sdRegionText.indexOf(sdRegionText.trim()); //$NON-NLS-1$
-
- LocalizedMessage message = new LocalizedMessage(SEVERITY_INVALID_WHITESPACE_BEFORE_TAGNAME , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(getLineNumber(start));
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.SpacesBeforeTagName);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- }
- }
- }
- }
-
- private void checkNoNamespaceInPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- // navigate to name
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- ITextRegion r = null;
- int errorCount = 0;
- for (int i = 0; (i < regions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT) && !structuredDocumentRegion.isDeleted(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- String piText = structuredDocumentRegion.getText(r);
- int index = piText.indexOf(":"); //$NON-NLS-1$
- if (index != -1) {
- String messageText = XMLUIMessages.ReconcileStepForMarkup_4;
- int start = structuredDocumentRegion.getStartOffset(r) + index;
- int length = piText.trim().length() - index;
-
- LocalizedMessage message = new LocalizedMessage(SEVERITY_NAMESPACE_IN_PI_TARGET , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(getLineNumber(start));
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.NamespaceInPI);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
-
- errorCount++;
- }
- }
- }
- }
-
- private void checkQuotesForAttributeValues(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
- ITextRegionList regions = structuredDocumentRegion.getRegions();
- ITextRegion r = null;
- String attrValueText = ""; //$NON-NLS-1$
- int errorCount = 0;
- for (int i = 0; (i < regions.size()) && (errorCount < AbstractStructuredTextReconcilingStrategy.ELEMENT_ERROR_LIMIT); i++) {
- r = regions.get(i);
- if (r.getType() != DOMRegionContext.XML_TAG_ATTRIBUTE_VALUE) {
- continue;
- }
-
- attrValueText = structuredDocumentRegion.getText(r);
- // attribute value includes quotes in the string
- // split up attribute value on quotes
- /*
- * WORKAROUND till
- * http://dev.icu-project.org/cgi-bin/icu-bugs/incoming?findid=5207
- * is fixed. (Also see BUG143628)
- */
-
- java.util.StringTokenizer st = new java.util.StringTokenizer(attrValueText, "\"'", true); //$NON-NLS-1$
- int size = st.countTokens();
- // get the pieces of the attribute value
- String one = "", two = ""; //$NON-NLS-1$ //$NON-NLS-2$
- if (size > 0) {
- one = st.nextToken();
- }
- if (size > 1) {
- two = st.nextToken();
- }
- if (size > 2) {
- // should be handled by parsing...
- // as in we can't have an attribute value like: <element
- // attr="a"b"c"/>
- // and <element attr='a"b"c' /> is legal
- continue;
- }
-
-
- if (size == 1) {
- if (one.equals(DQUOTE) || one.equals(SQUOTE)) {
- // missing closing quote
- String message = XMLUIMessages.ReconcileStepForMarkup_0;
- addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.Unclassified, structuredDocumentRegion, reporter, SEVERITY_MISSING_CLOSING_QUOTE);
- errorCount++;
- }
- else {
- // missing both
- String message = XMLUIMessages.ReconcileStepForMarkup_1;
- addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.AttrValueNotQuoted, structuredDocumentRegion, reporter, SEVERITY_MISSING_QUOTES);
- errorCount++;
- }
- }
- else if (size == 2) {
- if ((one.equals(SQUOTE) && !two.equals(SQUOTE)) || (one.equals(DQUOTE) && !two.equals(DQUOTE))) {
- // missing closing quote
- String message = XMLUIMessages.ReconcileStepForMarkup_0;
- addAttributeError(message, attrValueText, structuredDocumentRegion.getStartOffset(r), attrValueText.trim().length(), ProblemIDsXML.Unclassified, structuredDocumentRegion, reporter, SEVERITY_MISSING_CLOSING_QUOTE);
- errorCount++;
- }
- }
- }
- // end of region for loop
- }
-
- private void checkStartEndTagPairs(IStructuredDocumentRegion sdRegion, IReporter reporter) {
-
- if (sdRegion.isDeleted()) {
- return;
- }
-
- // check start/end tag pairs
- IDOMNode xmlNode = getXMLNode(sdRegion);
-
- if (xmlNode == null) {
- return;
- }
-
- boolean selfClosed = false;
- String tagName = null;
-
- /**
- * For tags that aren't meant to be EMPTY, make sure it's empty or has an end tag
- */
- if (xmlNode.isContainer()) {
- IStructuredDocumentRegion endRegion = xmlNode.getEndStructuredDocumentRegion();
- if (endRegion == null) {
- IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
- if (startRegion != null && !startRegion.isDeleted() && DOMRegionContext.XML_TAG_OPEN.equals(startRegion.getFirstRegion().getType())) {
- // analyze the tag (check self closing)
- ITextRegionList regions = startRegion.getRegions();
- ITextRegion r = null;
- int start = sdRegion.getStart();
- int length = sdRegion.getTextLength();
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- tagName = sdRegion.getText(r);
- start = sdRegion.getStartOffset(r);
- length = r.getTextLength();
- }
- else if (r.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE) {
- selfClosed = true;
- }
- }
-
-
- if (!selfClosed && (tagName != null)) {
- Object[] args = {tagName};
- String messageText = NLS.bind(XMLUIMessages.Missing_end_tag_, args);
-
- int lineNumber = getLineNumber(start);
-
- IMessage message = new LocalizedMessage(SEVERITY_MISSING_END_TAG , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNumber);
-
- if (reporter instanceof IncrementalReporter) {
- Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);
-
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.MissingEndTag);
- processor.setAdditionalFixInfo(additionalFixInfo);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
-
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- }
- }
- }
- else {
- IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
- if (startRegion == null || startRegion.isDeleted()) {
- // analyze the tag (check self closing)
- ITextRegionList regions = endRegion.getRegions();
- ITextRegion r = null;
- int start = sdRegion.getStart();
- int length = sdRegion.getTextLength();
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- tagName = sdRegion.getText(r);
- start = sdRegion.getStartOffset(r);
- length = r.getTextLength();
- }
- }
-
- if (tagName != null) {
- Object[] args = {tagName};
- String messageText = NLS.bind(XMLUIMessages.Missing_start_tag_, args);
-
- int lineNumber = getLineNumber(start);
-
- IMessage message = new LocalizedMessage(SEVERITY_MISSING_START_TAG, messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(lineNumber);
-
- if (reporter instanceof IncrementalReporter) {
- Object[] additionalFixInfo = getStartEndFixInfo(xmlNode, tagName, r);
-
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.MissingStartTag);
- processor.setAdditionalFixInfo(additionalFixInfo);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
-
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- }
- }
- }
-
- }
- /*
- * Check for an end tag that has no start tag
- */
- else {
- IStructuredDocumentRegion startRegion = xmlNode.getStartStructuredDocumentRegion();
- if (startRegion == null) {
- IStructuredDocumentRegion endRegion = xmlNode.getEndStructuredDocumentRegion();
- if (!endRegion.isDeleted()) {
- // get name
- ITextRegionList regions = endRegion.getRegions();
- ITextRegion r = null;
- for (int i = 0; i < regions.size(); i++) {
- r = regions.get(i);
- if (r.getType() == DOMRegionContext.XML_TAG_NAME) {
- tagName = sdRegion.getText(r);
- }
- }
-
- if (!selfClosed && (tagName != null)) {
- String messageText = XMLUIMessages.Indicate_no_grammar_specified_severities_error;
-
- int start = sdRegion.getStart();
- int lineNumber = getLineNumber(start);
-
- // SEVERITY_STRUCTURE == IMessage.HIGH_SEVERITY
- IMessage message = new LocalizedMessage(IMessage.HIGH_SEVERITY, messageText);
- message.setOffset(start);
- message.setLength(sdRegion.getTextLength());
- message.setLineNo(lineNumber);
-
- reporter.addMessage(this, message);
- }
- }
- }
- }
- }
-
- private Object[] getStartEndFixInfo(IDOMNode xmlNode, String tagName, ITextRegion r) {
- // quick fix info
- String tagClose = "/>"; //$NON-NLS-1$
- int tagCloseOffset = xmlNode.getFirstStructuredDocumentRegion().getEndOffset();
- if ((r != null) && (r.getType() == DOMRegionContext.XML_TAG_CLOSE)) {
- tagClose = "/"; //$NON-NLS-1$
- tagCloseOffset--;
- }
- IDOMNode firstChild = (IDOMNode) xmlNode.getFirstChild();
- while ((firstChild != null) && (firstChild.getNodeType() == Node.TEXT_NODE)) {
- firstChild = (IDOMNode) firstChild.getNextSibling();
- }
- int endOffset = xmlNode.getEndOffset();
- int firstChildStartOffset = firstChild == null ? endOffset : firstChild.getStartOffset();
- Object[] additionalFixInfo = {tagName, tagClose, new Integer(tagCloseOffset), new Integer(xmlNode.getFirstStructuredDocumentRegion().getEndOffset()), // startTagEndOffset
- new Integer(firstChildStartOffset), // firstChildStartOffset
- new Integer(endOffset)}; // endOffset
- return additionalFixInfo;
- }
-
- private void checkStartingSpaceForPI(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion.isDeleted()) {
- return;
- }
-
- IStructuredDocumentRegion prev = structuredDocumentRegion.getPrevious();
- if ((prev != null) && prev.getStartOffset() == 0) {
- if (prev.getType() == DOMRegionContext.XML_CONTENT) {
- String messageText = XMLUIMessages.ReconcileStepForMarkup_5;
- int start = prev.getStartOffset();
- int length = prev.getLength();
-
- LocalizedMessage message = new LocalizedMessage(SEVERITY_WHITESPACE_AT_START , messageText);
- message.setOffset(start);
- message.setLength(length);
- message.setLineNo(getLineNumber(start));
-
- if (reporter instanceof IncrementalReporter) {
- MarkupQuickAssistProcessor processor = new MarkupQuickAssistProcessor();
- processor.setProblemId(ProblemIDsXML.SpacesBeforePI);
- message.setAttribute(QUICKASSISTPROCESSOR, processor);
-
- AnnotationInfo info = new AnnotationInfo(message);
- ((IncrementalReporter) reporter).addAnnotationInfo(this, info);
- }
- else {
- reporter.addMessage(this, message);
- }
- // Position p = new Position(start, length);
- //
- // ReconcileAnnotationKey key =
- // createKey(structuredDocumentRegion, getScope());
- // TemporaryAnnotation annotation = new TemporaryAnnotation(p,
- // SEVERITY_SYNTAX_ERROR, message, key,
- // ProblemIDsXML.SpacesBeforePI);
- // results.add(annotation);
- }
- }
- }
-
- public int getScope() {
- return ReconcileAnnotationKey.PARTIAL;
- }
-
- private IDOMNode getXMLNode(IStructuredDocumentRegion sdRegion) {
-
- if (sdRegion == null) {
- return null;
- }
-
- IStructuredModel xModel = null;
- IDOMNode xmlNode = null;
- // get/release models should always be in a try/finally block
- try {
- xModel = StructuredModelManager.getModelManager().getExistingModelForRead(getDocument());
- // xModel is sometime null, when closing editor, for example
- if (xModel != null) {
- xmlNode = (IDOMNode) xModel.getIndexedRegion(sdRegion.getStart());
- }
- }
- finally {
- if (xModel != null) {
- xModel.releaseFromRead();
- }
- }
- return xmlNode;
- }
-
- /**
- * Determines whether the IStructuredDocumentRegion is a XML "end tag"
- * since they're not allowed to have attribute ITextRegions
- *
- * @param structuredDocumentRegion
- */
- private boolean isEndTag(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_END_TAG_OPEN;
- }
-
- /**
- * Determines if the IStructuredDocumentRegion is an XML Processing
- * Instruction
- *
- * @param structuredDocumentRegion
- *
- */
- private boolean isPI(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_PI_OPEN;
- }
-
- /**
- * Determines whether the IStructuredDocumentRegion is a XML "start tag"
- * since they need to be checked for proper XML attribute region sequences
- *
- * @param structuredDocumentRegion
- *
- */
- private boolean isStartTag(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_TAG_OPEN;
- }
-
- // Because we check the "proper" closing separately from attribute
- // sequencing, we need to know what's
- // an appropriate close.
- private boolean isTagCloseTextRegion(ITextRegion textRegion) {
- return (textRegion.getType() == DOMRegionContext.XML_TAG_CLOSE) || (textRegion.getType() == DOMRegionContext.XML_EMPTY_TAG_CLOSE);
- }
-
- /**
- * Determines if the IStructuredDocumentRegion is XML Content
- *
- * @param structuredDocumentRegion
- *
- */
- private boolean isXMLContent(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_CONTENT;
- }
-
- private void setDocument(IDocument doc) {
- fDocument = doc;
- }
-
- private IDocument getDocument() {
- return fDocument;
- }
-
- public void connect(IDocument document) {
- setDocument(document);
- }
-
- public void disconnect(IDocument document) {
- setDocument(null);
- }
-
- public void validate(IRegion dirtyRegion, IValidationContext helper, IReporter reporter) {
- if (getDocument() == null) {
- return;
- }
- if (!(reporter instanceof IncrementalReporter)) {
- return;
- }
- if (!(getDocument() instanceof IStructuredDocument)) {
- return;
- }
-
- // remove old messages
- reporter.removeAllMessages(this);
-
- IStructuredDocumentRegion[] regions = ((IStructuredDocument) fDocument).getStructuredDocumentRegions(dirtyRegion.getOffset(), dirtyRegion.getLength());
- for (int i = 0; i < regions.length; i++) {
- validate(regions[i], reporter);
- }
- }
-
- public void validate(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
-
- if (structuredDocumentRegion == null) {
- return;
- }
-
- if (isStartTag(structuredDocumentRegion)) {
- // check for attributes without a value
- checkForAttributeValue(structuredDocumentRegion, reporter);
- // check if started tag is ended
- checkStartEndTagPairs(structuredDocumentRegion, reporter);
- // check empty tag <>
- checkEmptyTag(structuredDocumentRegion, reporter);
- // check that each attribute has quotes
- checkQuotesForAttributeValues(structuredDocumentRegion, reporter);
- // check that the closing '>' is there
- checkClosingBracket(structuredDocumentRegion, reporter);
- }
- else if (isEndTag(structuredDocumentRegion)) {
- // check if ending tag was started
- checkStartEndTagPairs(structuredDocumentRegion, reporter);
- // check for attributes in an end tag
- checkAttributesInEndTag(structuredDocumentRegion, reporter);
- // check that the closing '>' is there
- checkClosingBracket(structuredDocumentRegion, reporter);
- }
- else if (isPI(structuredDocumentRegion)) {
- // check validity of processing instruction
- checkStartingSpaceForPI(structuredDocumentRegion, reporter);
- checkNoNamespaceInPI(structuredDocumentRegion, reporter);
- }
- else if (isXMLContent(structuredDocumentRegion)) {
- checkForSpaceBeforeName(structuredDocumentRegion, reporter);
- }
- else if (isXMLDoctypeDeclaration(structuredDocumentRegion)) {
- checkDocumentTypeReferences(structuredDocumentRegion, reporter);
- }
- }
-
- /**
- * @param structuredDocumentRegion
- * @param reporter
- */
- private void checkDocumentTypeReferences(IStructuredDocumentRegion structuredDocumentRegion, IReporter reporter) {
- }
-
- /**
- * @param structuredDocumentRegion
- * @return
- */
- private boolean isXMLDoctypeDeclaration(IStructuredDocumentRegion structuredDocumentRegion) {
- if ((structuredDocumentRegion == null) || structuredDocumentRegion.isDeleted()) {
- return false;
- }
- return structuredDocumentRegion.getFirstRegion().getType() == DOMRegionContext.XML_DECLARATION_OPEN && structuredDocumentRegion.getType().equals(DOMRegionContext.XML_DOCTYPE_DECLARATION);
- }
-
- public void cleanup(IReporter reporter) {
- fDocument = null;
- }
-
- public void validate(IValidationContext helper, IReporter reporter) throws ValidationException {
- String[] uris = helper.getURIs();
- IWorkspaceRoot wsRoot = ResourcesPlugin.getWorkspace().getRoot();
- if (uris.length > 0) {
- IFile currentFile = null;
-
- for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
- // might be called with just project path?
- IPath path = new Path(uris[i]);
- if (path.segmentCount() > 1) {
- currentFile = wsRoot.getFile(path);
- if (shouldValidate(currentFile, true)) {
- validateV1File(currentFile, reporter);
- }
- }
- else if (uris.length == 1) {
- validateV1Project(helper, reporter);
- }
- }
- }
- else
- validateV1Project(helper, reporter);
- }
-
- private boolean shouldValidate(IResourceProxy proxy) {
- if(proxy.getType() == IResource.FILE) {
- String name = proxy.getName();
- if(name.toLowerCase(Locale.US).endsWith(".xml")) {
- return true;
- }
- }
- return shouldValidate(proxy.requestResource(), false);
- }
-
- private boolean shouldValidate(IResource file, boolean checkExtension) {
- if (file == null || !file.exists() || file.getType() != IResource.FILE)
- return false;
- if (checkExtension) {
- String extension = file.getFileExtension();
- if (extension != null && "xml".endsWith(extension.toLowerCase(Locale.US)))
- return true;
- }
-
- IContentDescription contentDescription = null;
- try {
- contentDescription = ((IFile) file).getContentDescription();
- if (contentDescription != null) {
- IContentType contentType = contentDescription.getContentType();
- return contentDescription != null && contentType.isKindOf(getXMLContentType());
- }
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- return false;
- }
-
- /**
- * @param helper
- * @param reporter
- */
- private void validateV1Project(IValidationContext helper, final IReporter reporter) {
- // if uris[] length 0 -> validate() gets called for each project
- if (helper instanceof IWorkbenchContext) {
- IProject project = ((IWorkbenchContext) helper).getProject();
- IResourceProxyVisitor visitor = new IResourceProxyVisitor() {
- public boolean visit(IResourceProxy proxy) throws CoreException {
- if (shouldValidate(proxy)) {
- validateV1File((IFile) proxy.requestResource(), reporter);
- }
- return true;
- }
- };
- try {
- // collect all jsp files for the project
- project.accept(visitor, IResource.DEPTH_INFINITE);
- }
- catch (CoreException e) {
- Logger.logException(e);
- }
- }
- }
-
-
- /**
- * @param currentFile
- * @param reporter
- */
- private void validateV1File(IFile currentFile, IReporter reporter) {
- Message message = new LocalizedMessage(IMessage.LOW_SEVERITY, currentFile.getFullPath().toString().substring(1));
- reporter.displaySubtask(MarkupValidator.this, message);
-
- IStructuredModel model = null;
- try {
- model = StructuredModelManager.getModelManager().getModelForRead(currentFile);
- IStructuredDocument document = null;
- if (model != null) {
- document = model.getStructuredDocument();
- connect(document);
- IStructuredDocumentRegion validationRegion = document.getFirstStructuredDocumentRegion();
- while (validationRegion != null) {
- validate(validationRegion, reporter);
- validationRegion = validationRegion.getNext();
- }
- disconnect(document);
- }
- }
- catch (Exception e) {
- Logger.logException(e);
- }
- finally {
- if (model != null) {
- model.releaseFromRead();
- }
- }
- }
-
- /**
- * @return
- */
- private IContentType getXMLContentType() {
- if (fRootContentType == null) {
- fRootContentType = Platform.getContentTypeManager().getContentType("org.eclipse.core.runtime.xml");
- }
- return fRootContentType;
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.wst.validation.AbstractValidator#validate(org.eclipse.core.resources.IResource, int, org.eclipse.wst.validation.ValidationState, org.eclipse.core.runtime.IProgressMonitor)
- */
- public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
- if (resource.getType() != IResource.FILE)
- return null;
- ValidationResult result = new ValidationResult();
- IReporter reporter = result.getReporter(monitor);
- validateV1File((IFile) resource, reporter);
- return result;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java
deleted file mode 100644
index 00b2cf507b..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/AbstractXMLContentOutlineConfiguration.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.views.contentoutline;
-
-import org.eclipse.core.runtime.IPath;
-import org.eclipse.jface.action.IMenuListener;
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.util.LocalSelectionTransfer;
-import org.eclipse.jface.util.SafeRunnable;
-import org.eclipse.jface.util.TransferDragSourceListener;
-import org.eclipse.jface.util.TransferDropTargetListener;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.swt.dnd.DND;
-import org.eclipse.swt.dnd.DragSourceEvent;
-import org.eclipse.swt.dnd.DropTargetEvent;
-import org.eclipse.swt.dnd.Transfer;
-import org.eclipse.swt.graphics.Point;
-import org.eclipse.swt.graphics.Rectangle;
-import org.eclipse.swt.widgets.Control;
-import org.eclipse.swt.widgets.TableItem;
-import org.eclipse.swt.widgets.TreeItem;
-import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel;
-import org.eclipse.wst.sse.ui.internal.IReleasable;
-import org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration;
-import org.eclipse.wst.xml.ui.internal.XMLUIPlugin;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeContentProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager;
-import org.eclipse.wst.xml.ui.internal.dnd.DragNodeCommand;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
-/**
- * Basic Outline Configuration for generic XML support. Expects that the viewer's
- * input will be the DOM Model, and provides basic label and content providers.
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration
- * @since 3.1
- */
-public abstract class AbstractXMLContentOutlineConfiguration extends ContentOutlineConfiguration {
- private class ActionManagerMenuListener implements IMenuListener, IReleasable {
- private XMLNodeActionManager fActionManager;
- private TreeViewer fTreeViewer;
-
- public ActionManagerMenuListener(TreeViewer viewer) {
- fTreeViewer = viewer;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.action.IMenuListener#menuAboutToShow(org.eclipse.jface.action.IMenuManager)
- */
- public void menuAboutToShow(IMenuManager manager) {
- if (fActionManager == null) {
- fActionManager = createNodeActionManager(fTreeViewer);
- }
- if (fActionManager != null) {
- fActionManager.fillContextMenu(manager, fTreeViewer.getSelection());
- }
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.internal.IReleasable#release()
- */
- public void release() {
- fTreeViewer = null;
- if (fActionManager != null) {
- fActionManager.setModel(null);
- }
- }
- }
-
- private static class StatusLineLabelProvider extends JFaceNodeLabelProvider {
- public StatusLineLabelProvider() {
- super();
- }
-
- public String getText(Object element) {
- if (element == null)
- return null;
-
- if (!(element instanceof Node)) {
- return super.getText(element);
- }
-
- StringBuffer s = new StringBuffer();
- Node node = (Node) element;
- while (node != null) {
- if (node.getNodeType() != Node.DOCUMENT_NODE) {
- s.insert(0, super.getText(node));
- }
-
- if (node.getNodeType() == Node.ATTRIBUTE_NODE)
- node = ((Attr) node).getOwnerElement();
- else
- node = node.getParentNode();
-
- if (node != null && node.getNodeType() != Node.DOCUMENT_NODE) {
- s.insert(0, IPath.SEPARATOR);
- }
- }
- return s.toString();
- }
- }
-
- private IContentProvider fContentProvider = null;
-
- private ActionManagerMenuListener fContextMenuFiller = null;
-
- private ILabelProvider fLabelProvider = null;
-
- boolean fShowAttributes = false;
-
- private ILabelProvider fSimpleLabelProvider;
- private TransferDragSourceListener[] fTransferDragSourceListeners;
-
- private TransferDropTargetListener[] fTransferDropTargetListeners;
-
- /**
- * Create new instance of XMLContentOutlineConfiguration
- */
- public AbstractXMLContentOutlineConfiguration() {
- // Must have empty constructor to createExecutableExtension
- super();
- }
-
- /**
- * Returns the NodeActionManager to use for the given treeViewer.
- * <p>
- * Not API. May be removed in the future.
- * </p>
- *
- * @param treeViewer
- * the TreeViewer associated with this configuration
- * @return a node action manager for use with this tree viewer
- */
- protected XMLNodeActionManager createNodeActionManager(TreeViewer treeViewer) {
- return new XMLNodeActionManager((IStructuredModel) treeViewer.getInput(), treeViewer);
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getContentProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public IContentProvider getContentProvider(TreeViewer viewer) {
- if (fContentProvider == null) {
- fContentProvider = new JFaceNodeContentProvider();
- }
- return fContentProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getLabelProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public ILabelProvider getLabelProvider(TreeViewer viewer) {
- if (fLabelProvider == null) {
- fLabelProvider = new JFaceNodeLabelProvider();
- }
- return fLabelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getMenuListener(org.eclipse.jface.viewers.TreeViewer)
- */
- public IMenuListener getMenuListener(TreeViewer viewer) {
- if (fContextMenuFiller == null) {
- fContextMenuFiller = new ActionManagerMenuListener(viewer);
- }
- return fContextMenuFiller;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getPreferenceStore()
- */
- protected IPreferenceStore getPreferenceStore() {
- return XMLUIPlugin.getDefault().getPreferenceStore();
- }
-
- public ILabelProvider getStatusLineLabelProvider(TreeViewer treeViewer) {
- if (fSimpleLabelProvider == null) {
- fSimpleLabelProvider = new StatusLineLabelProvider();
- }
- return fSimpleLabelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getTransferDragSourceListeners(org.eclipse.jface.viewers.TreeViewer)
- */
- public TransferDragSourceListener[] getTransferDragSourceListeners(final TreeViewer treeViewer) {
- if (fTransferDragSourceListeners == null) {
- fTransferDragSourceListeners = new TransferDragSourceListener[]{new TransferDragSourceListener() {
-
- public void dragFinished(DragSourceEvent event) {
- LocalSelectionTransfer.getTransfer().setSelection(null);
- }
-
- public void dragSetData(DragSourceEvent event) {
- }
-
- public void dragStart(DragSourceEvent event) {
- LocalSelectionTransfer.getTransfer().setSelection(treeViewer.getSelection());
- }
-
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getTransfer();
- }
- }};
- }
-
- return fTransferDragSourceListeners;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getTransferDropTargetListeners(org.eclipse.jface.viewers.TreeViewer)
- */
- public TransferDropTargetListener[] getTransferDropTargetListeners(final TreeViewer treeViewer) {
- if (fTransferDropTargetListeners == null) {
- fTransferDropTargetListeners = new TransferDropTargetListener[]{new TransferDropTargetListener() {
- public void dragEnter(DropTargetEvent event) {
- }
-
- public void dragLeave(DropTargetEvent event) {
- }
-
- public void dragOperationChanged(DropTargetEvent event) {
- }
-
- public void dragOver(DropTargetEvent event) {
- event.feedback = DND.FEEDBACK_SELECT;
- float feedbackFloat = getHeightInItem(event);
- if (feedbackFloat > 0.75) {
- event.feedback = DND.FEEDBACK_INSERT_AFTER;
- }
- else if (feedbackFloat < 0.25) {
- event.feedback = DND.FEEDBACK_INSERT_BEFORE;
- }
- event.feedback |= DND.FEEDBACK_EXPAND | DND.FEEDBACK_SCROLL;
- }
-
- public void drop(DropTargetEvent event) {
- if (event.operations != DND.DROP_NONE && LocalSelectionTransfer.getTransfer().getSelection() != null && !LocalSelectionTransfer.getTransfer().getSelection().isEmpty()) {
- IStructuredSelection selection = (IStructuredSelection) LocalSelectionTransfer.getTransfer().getSelection();
- if (selection != null && !selection.isEmpty() && event.item != null && event.item.getData() != null) {
- /*
- * the command uses these numbers instead of the
- * feedback constants (even though it converts in
- * the other direction as well)
- */
- float feedbackFloat = getHeightInItem(event);
-
- final DragNodeCommand command = new DragNodeCommand(event.item.getData(), feedbackFloat, event.operations, event.detail, selection.toList(), treeViewer);
- if (command != null && command.canExecute()) {
- SafeRunnable.run(new SafeRunnable() {
- public void run() throws Exception {
- command.execute();
- }
- });
- }
- }
- }
- }
-
- public void dropAccept(DropTargetEvent event) {
- }
-
- private float getHeightInItem(DropTargetEvent event) {
- if (event.item == null)
- return .5f;
- if (event.item instanceof TreeItem) {
- TreeItem treeItem = (TreeItem) event.item;
- Control control = treeItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = treeItem.getBounds();
- return (float) (point.y - bounds.y) / (float) bounds.height;
- }
- else if (event.item instanceof TableItem) {
- TableItem tableItem = (TableItem) event.item;
- Control control = tableItem.getParent();
- Point point = control.toControl(new Point(event.x, event.y));
- Rectangle bounds = tableItem.getBounds(0);
- return (float) (point.y - bounds.y) / (float) bounds.height;
- }
- else {
- return 0.0F;
- }
- }
-
- public Transfer getTransfer() {
- return LocalSelectionTransfer.getTransfer();
- }
-
- public boolean isEnabled(DropTargetEvent event) {
- return getTransfer().isSupportedType(event.currentDataType);
- }
- }};
- }
- return fTransferDropTargetListeners;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#unconfigure(org.eclipse.jface.viewers.TreeViewer)
- */
- public void unconfigure(TreeViewer viewer) {
- super.unconfigure(viewer);
- fTransferDragSourceListeners = null;
- fTransferDropTargetListeners = null;
- if (fContextMenuFiller != null) {
- fContextMenuFiller.release();
- fContextMenuFiller = null;
- }
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
deleted file mode 100644
index ec3f156834..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/contentoutline/XMLContentOutlineConfiguration.java
+++ /dev/null
@@ -1,411 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2008 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.views.contentoutline;
-
-import java.util.List;
-
-import org.eclipse.jface.action.IContributionItem;
-import org.eclipse.jface.preference.IPreferenceStore;
-import org.eclipse.jface.viewers.IContentProvider;
-import org.eclipse.jface.viewers.ILabelProvider;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.wst.sse.core.utils.StringUtils;
-import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateAction;
-import org.eclipse.wst.sse.ui.internal.contentoutline.PropertyChangeUpdateActionContributionItem;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImageHelper;
-import org.eclipse.wst.sse.ui.internal.editor.EditorPluginImages;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMAttributeDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDataType;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNamedNodeMap;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMNode;
-import org.eclipse.wst.xml.core.internal.contentmodel.basic.CMNamedNodeMapImpl;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeContentProvider;
-import org.eclipse.wst.xml.ui.internal.contentoutline.JFaceNodeLabelProvider;
-import org.eclipse.wst.xml.ui.internal.preferences.XMLUIPreferenceNames;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.NamedNodeMap;
-import org.w3c.dom.Node;
-
-/**
- * More advanced Outline Configuration for XML support. Expects that the viewer's
- * input will be the DOM Model.
- *
- * @see AbstractXMLContentOutlineConfiguration
- * @since 1.0
- */
-public class XMLContentOutlineConfiguration extends AbstractXMLContentOutlineConfiguration {
- static final String ATTR_NAME = "name";
- static final String ATTR_ID = "id";
-
- private class AttributeShowingLabelProvider extends JFaceNodeLabelProvider {
- public boolean isLabelProperty(Object element, String property) {
- return true;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object)
- */
- public String getText(Object o) {
- StringBuffer text = null;
- if (o instanceof Node) {
- Node node = (Node) o;
- if ((node.getNodeType() == Node.ELEMENT_NODE) && fShowAttributes) {
- text = new StringBuffer(super.getText(o));
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
- if (node.hasAttributes()) {
- Element element = (Element) node;
- NamedNodeMap attributes = element.getAttributes();
- Node idTypedAttribute = null;
- Node requiredAttribute = null;
- boolean hasId = false;
- boolean hasName = false;
- Node shownAttribute = null;
-
- // try to get content model element
- // declaration
- CMElementDeclaration elementDecl = null;
- ModelQuery mq = ModelQueryUtil.getModelQuery(element.getOwnerDocument());
- if (mq != null) {
- elementDecl = mq.getCMElementDeclaration(element);
- }
- // find an attribute of type (or just named)
- // ID
- if (elementDecl != null) {
- int i = 0;
- while ((i < attributes.getLength()) && (idTypedAttribute == null)) {
- Node attr = attributes.item(i);
- String attrName = attr.getNodeName();
- CMNamedNodeMap attributeDeclarationMap = elementDecl.getAttributes();
-
- CMNamedNodeMapImpl allAttributes = new CMNamedNodeMapImpl(attributeDeclarationMap);
- List nodes = ModelQueryUtil.getModelQuery(node.getOwnerDocument()).getAvailableContent(element, elementDecl, ModelQuery.INCLUDE_ATTRIBUTES);
- for (int k = 0; k < nodes.size(); k++) {
- CMNode cmnode = (CMNode) nodes.get(k);
- if (cmnode.getNodeType() == CMNode.ATTRIBUTE_DECLARATION) {
- allAttributes.put(cmnode);
- }
- }
- attributeDeclarationMap = allAttributes;
-
- CMAttributeDeclaration attrDecl = (CMAttributeDeclaration) attributeDeclarationMap.getNamedItem(attrName);
- if (attrDecl != null) {
- if ((attrDecl.getAttrType() != null) && (CMDataType.ID.equals(attrDecl.getAttrType().getDataTypeName()))) {
- idTypedAttribute = attr;
- }
- else if ((attrDecl.getUsage() == CMAttributeDeclaration.REQUIRED) && (requiredAttribute == null)) {
- // as a backup, keep tabs on
- // any required
- // attributes
- requiredAttribute = attr;
- }
- else {
- hasId = hasId || attrName.equals(ATTR_ID);
- hasName = hasName || attrName.equals(ATTR_NAME);
- }
- }
- ++i;
- }
- }
-
- /*
- * If no suitable attribute was found, try using a
- * required attribute, if none, then prefer "id" or
- * "name", otherwise just use first attribute
- */
- if (idTypedAttribute != null) {
- shownAttribute = idTypedAttribute;
- }
- else if (requiredAttribute != null) {
- shownAttribute = requiredAttribute;
- }
- else if (hasId) {
- shownAttribute = attributes.getNamedItem(ATTR_ID);
- }
- else if (hasName) {
- shownAttribute = attributes.getNamedItem(ATTR_NAME);
- }
- if (shownAttribute == null) {
- shownAttribute = attributes.item(0);
- }
-
- // display the attribute and value (without quotes)
- String attributeName = shownAttribute.getNodeName();
- if ((attributeName != null) && (attributeName.length() > 0)) {
- text.append(" "); //$NON-NLS-1$
- text.append(attributeName);
- String attributeValue = shownAttribute.getNodeValue();
- if ((attributeValue != null) && (attributeValue.length() > 0)) {
- text.append("="); //$NON-NLS-1$
- text.append(StringUtils.strip(attributeValue));
- }
- }
- }
- }
- else {
- text = new StringBuffer(super.getText(o));
- }
- }
- else {
- return super.toString();
- }
- return text.toString();
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.jface.viewers.CellLabelProvider#getToolTipText(java.lang.Object)
- */
- public String getToolTipText(Object element) {
- if (element instanceof Node) {
- switch (((Node) element).getNodeType()) {
- case Node.COMMENT_NODE :
- case Node.CDATA_SECTION_NODE :
- case Node.PROCESSING_INSTRUCTION_NODE :
- case Node.TEXT_NODE : {
- String nodeValue = ((Node) element).getNodeValue().trim();
- return prepareText(nodeValue);
- }
- case Node.ELEMENT_NODE : {
- // show the preceding comment's tooltip information
- Node previous = ((Node) element).getPreviousSibling();
- if (previous != null && previous.getNodeType() == Node.TEXT_NODE)
- previous = previous.getPreviousSibling();
- if (previous != null && previous.getNodeType() == Node.COMMENT_NODE)
- return getToolTipText(previous);
- }
- }
- }
- return super.getToolTipText(element);
- }
-
- /**
- * Remove leading indentation from each line in the give string.
- * @param text
- * @return
- */
- private String prepareText(String text) {
- StringBuffer nodeText = new StringBuffer();
- for (int i = 0; i < text.length(); i++) {
- char c = text.charAt(i);
- if (c != '\r' && c != '\n') {
- nodeText.append(c);
- }
- else if (c == '\r' || c == '\n') {
- nodeText.append('\n');
- while (Character.isWhitespace(c) && i < text.length()) {
- i++;
- c = text.charAt(i);
- }
- nodeText.append(c);
- }
- }
- return nodeText.toString();
- }
- }
-
- /**
- * Toggle action for whether or not to display element's first attribute
- */
- private class ToggleShowAttributeAction extends PropertyChangeUpdateAction {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
- private TreeViewer fTreeViewer;
-
- public ToggleShowAttributeAction(IPreferenceStore store, String preference, TreeViewer treeViewer) {
- super(XMLUIMessages.XMLContentOutlineConfiguration_0, store, preference, true);
- setToolTipText(getText());
- // images needed
- // setDisabledImageDescriptor(SYNCED_D);
- // (nsd) temporarily re-use Properties view image
- setImageDescriptor(EditorPluginImageHelper.getInstance().getImageDescriptor(EditorPluginImages.IMG_OBJ_PROP_PS));
- fTreeViewer = treeViewer;
- update();
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.ui.texteditor.IUpdate#update()
- */
- public void update() {
- super.update();
- fShowAttributes = isChecked();
-
- // notify the configuration of the change
- enableShowAttributes(fShowAttributes, fTreeViewer);
-
- // refresh the outline view
- fTreeViewer.refresh(true);
- }
- }
-
- private ILabelProvider fAttributeShowingLabelProvider;
- private IContentProvider fContentProvider = null;
-
- boolean fShowAttributes = false;
-
- /*
- * Preference key for Show Attributes
- */
- private final String OUTLINE_SHOW_ATTRIBUTE_PREF = "outline-show-attribute"; //$NON-NLS-1$
-
- /**
- * Create new instance of XMLContentOutlineConfiguration
- */
- public XMLContentOutlineConfiguration() {
- // Must have empty constructor to createExecutableExtension
- super();
-
- /**
- * Set up our preference store here. This is done so that subclasses
- * aren't required to set their own values, although if they have,
- * those will be used instead.
- */
- IPreferenceStore store = getPreferenceStore();
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_NODE, "1, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.PROCESSING_INSTRUCTION_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.PROCESSING_INSTRUCTION_NODE, "2, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_TYPE_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_TYPE_NODE, "3, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_FRAGMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.DOCUMENT_FRAGMENT_NODE, "4, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.COMMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.COMMENT_NODE, "5, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ATTRIBUTE_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ATTRIBUTE_NODE, "6, false");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ELEMENT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ELEMENT_NODE, "7, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_REFERENCE_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_REFERENCE_NODE, "8, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.CDATA_SECTION_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.CDATA_SECTION_NODE, "9, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.ENTITY_NODE, "10, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.NOTATION_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.NOTATION_NODE, "11, true");
- if (store.getDefaultString(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.TEXT_NODE).length() == 0)
- store.setDefault(XMLUIPreferenceNames.OUTLINE_BEHAVIOR.TEXT_NODE, "12, false");
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#createMenuContributions(org.eclipse.jface.viewers.TreeViewer)
- */
- protected IContributionItem[] createMenuContributions(TreeViewer viewer) {
- IContributionItem[] items;
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=88444
- IContributionItem showAttributeItem = new PropertyChangeUpdateActionContributionItem(new ToggleShowAttributeAction(getPreferenceStore(), OUTLINE_SHOW_ATTRIBUTE_PREF, viewer));
-
- items = super.createMenuContributions(viewer);
- if (items == null) {
- items = new IContributionItem[]{showAttributeItem};
- }
- else {
- IContributionItem[] combinedItems = new IContributionItem[items.length + 1];
- System.arraycopy(items, 0, combinedItems, 0, items.length);
- combinedItems[items.length] = showAttributeItem;
- items = combinedItems;
- }
- return items;
- }
-
- /**
- * Notifies this configuration that the flag that indicates whether or not
- * to show attribute values in the tree viewer has changed. The tree
- * viewer is automatically refreshed afterwards to update the labels.
- *
- * Clients should not call this method, but rather should react to it.
- *
- * @param showAttributes
- * flag indicating whether or not to show attribute values in
- * the tree viewer
- * @param treeViewer
- * the TreeViewer associated with this configuration
- */
- protected void enableShowAttributes(boolean showAttributes, TreeViewer treeViewer) {
- // nothing by default
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getContentProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public IContentProvider getContentProvider(TreeViewer viewer) {
- if (fContentProvider == null) {
- fContentProvider = new JFaceNodeContentProvider();
- }
- return fContentProvider;
- }
-
- private Object getFilteredNode(Object object) {
- if (object instanceof Node) {
- Node node = (Node) object;
- short nodeType = node.getNodeType();
- // replace attribute node in selection with its parent
- if (nodeType == Node.ATTRIBUTE_NODE) {
- node = ((Attr) node).getOwnerElement();
- }
- // anything else not visible, replace with parent node
- else if (nodeType == Node.TEXT_NODE) {
- node = node.getParentNode();
- }
- return node;
- }
- return object;
- }
-
- private Object[] getFilteredNodes(Object[] filteredNodes) {
- for (int i = 0; i < filteredNodes.length; i++) {
- filteredNodes[i] = getFilteredNode(filteredNodes[i]);
- }
- return filteredNodes;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getLabelProvider(org.eclipse.jface.viewers.TreeViewer)
- */
- public ILabelProvider getLabelProvider(TreeViewer viewer) {
- if (fAttributeShowingLabelProvider == null) {
- fAttributeShowingLabelProvider = new AttributeShowingLabelProvider();
- }
- return fAttributeShowingLabelProvider;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.eclipse.wst.sse.ui.views.contentoutline.ContentOutlineConfiguration#getSelection(org.eclipse.jface.viewers.TreeViewer,
- * org.eclipse.jface.viewers.ISelection)
- */
- public ISelection getSelection(TreeViewer viewer, ISelection selection) {
- ISelection filteredSelection = selection;
- if (selection instanceof IStructuredSelection) {
- Object[] filteredNodes = getFilteredNodes(((IStructuredSelection) selection).toArray());
- filteredSelection = new StructuredSelection(filteredNodes);
- }
- return filteredSelection;
- }
-}
diff --git a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java b/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java
deleted file mode 100644
index a4f3a4e164..0000000000
--- a/bundles/org.eclipse.wst.xml.ui/src/org/eclipse/wst/xml/ui/views/properties/XMLPropertySheetConfiguration.java
+++ /dev/null
@@ -1,282 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2001, 2009 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * IBM Corporation - initial API and implementation
- * Jens Lukowski/Innoopract - initial renaming/restructuring
- *
- *******************************************************************************/
-package org.eclipse.wst.xml.ui.views.properties;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.IStatus;
-import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.jobs.Job;
-import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.progress.UIJob;
-import org.eclipse.ui.views.properties.IPropertySheetPage;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.IPropertySourceProvider;
-import org.eclipse.ui.views.properties.PropertySheetPage;
-import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter;
-import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier;
-import org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration;
-import org.eclipse.wst.xml.core.internal.contentmodel.CMDocument;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManager;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.CMDocumentManagerListener;
-import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery;
-import org.eclipse.wst.xml.core.internal.contentmodel.util.CMDocumentCache;
-import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil;
-import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode;
-import org.eclipse.wst.xml.ui.internal.XMLUIMessages;
-import org.eclipse.wst.xml.ui.internal.properties.XMLPropertySource;
-import org.w3c.dom.Attr;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Configuration for property sheet page which shows XML content.
- *
- * @see org.eclipse.wst.sse.ui.views.properties.PropertySheetConfiguration
- * @since 1.0
- */
-public class XMLPropertySheetConfiguration extends PropertySheetConfiguration {
- private class CMDocumentManagerListenerImpl implements CMDocumentManagerListener {
- public void cacheCleared(CMDocumentCache cache) {
- // nothing to do
- }
-
- public void cacheUpdated(CMDocumentCache cache, final String uri, int oldStatus, int newStatus, CMDocument cmDocument) {
- if ((newStatus == CMDocumentCache.STATUS_LOADED) || (newStatus == CMDocumentCache.STATUS_ERROR)) {
- refreshPages();
- }
- }
-
- public void propertyChanged(CMDocumentManager cmDocumentManager, String propertyName) {
- if (cmDocumentManager.getPropertyEnabled(CMDocumentManager.PROPERTY_AUTO_LOAD)) {
- refreshPages();
- }
- }
-
- private void refreshPages() {
- getPropertiesRefreshJob().addPropertySheetPage(fPropertySheetPage);
- getPropertiesRefreshJob().schedule(PropertiesRefreshJob.UPDATE_DELAY);
- }
- }
-
- private class PropertiesRefreshJob extends UIJob {
- public static final int UPDATE_DELAY = 200;
-
- Set propertySheetPages = null;
-
- public PropertiesRefreshJob() {
- super(XMLUIMessages.JFaceNodeAdapter_1);
- setSystem(true);
- setPriority(Job.SHORT);
- propertySheetPages = new HashSet(1);
- }
-
- void addPropertySheetPage(IPropertySheetPage page) {
- if (page != null && propertySheetPages != null) {
- propertySheetPages.add(page);
- schedule(UPDATE_DELAY);
- }
- }
-
- /* (non-Javadoc)
- * @see org.eclipse.core.runtime.jobs.Job#canceling()
- */
- protected void canceling() {
- propertySheetPages.clear();
- super.canceling();
- }
-
- public IStatus runInUIThread(IProgressMonitor monitor) {
- Object[] pages = propertySheetPages.toArray();
- propertySheetPages.clear();
-
- for (int i = 0; i < pages.length; i++) {
- PropertySheetPage page = (PropertySheetPage) pages[i];
- if ((page != null) && (page.getControl() != null) && !page.getControl().isDisposed()) {
- page.refresh();
- }
- }
-
- return Status.OK_STATUS;
- }
- }
-
- private class XMLPropertySheetRefreshAdapter implements INodeAdapter {
- public boolean isAdapterForType(Object type) {
- return false;
- }
-
- public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) {
- if (fPropertySheetPage != null) {
- getPropertiesRefreshJob().addPropertySheetPage(fPropertySheetPage);
- }
- }
- }
-
- private class XMLPropertySourceProvider implements IPropertySourceProvider {
- private IPropertySource fPropertySource = null;
- private INodeNotifier fSource = null;
-
- public IPropertySource getPropertySource(Object object) {
- if ((fSource != null) && object.equals(fSource)) {
- return fPropertySource;
- }
-
- if (object instanceof IDOMNode) {
- fSource = (INodeNotifier) object;
- fPropertySource = (IPropertySource) fSource.getAdapterFor(IPropertySource.class);
- if (fPropertySource == null) {
- fPropertySource = new XMLPropertySource((INodeNotifier) object) {
- public void setPropertyValue(Object nameObject, Object value) {
- // https://bugs.eclipse.org/bugs/show_bug.cgi?id=218979
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
- }
- super.setPropertyValue(nameObject, value);
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].addAdapter(fRefreshAdapter);
- }
- }
- };
- }
- }
- else {
- fSource = null;
- fPropertySource = null;
- }
- return fPropertySource;
- }
- }
-
- private CMDocumentManagerListenerImpl fCMDocumentManagerListener = new CMDocumentManagerListenerImpl();
- private PropertiesRefreshJob fPropertiesRefreshJob = null;
- IPropertySheetPage fPropertySheetPage = null;
- private IPropertySourceProvider fPropertySourceProvider = null;
- private INodeAdapter fRefreshAdapter = new XMLPropertySheetRefreshAdapter();
- private CMDocumentManager[] fSelectedCMDocumentManagers = new CMDocumentManager[0];
- private INodeNotifier[] fSelectedNotifiers = new INodeNotifier[0];
-
-
- /**
- * Create new instance of XMLPropertySheetConfiguration
- */
- public XMLPropertySheetConfiguration() {
- // Must have empty constructor to createExecutableExtension
- super();
- }
-
- public ISelection getInputSelection(IWorkbenchPart selectingPart, ISelection selection) {
- if (fSelectedNotifiers != null) {
- for (int i = 0; i < fSelectedNotifiers.length; i++) {
- fSelectedNotifiers[i].removeAdapter(fRefreshAdapter);
- }
- fSelectedNotifiers = null;
- }
- for (int i = 0; i < fSelectedCMDocumentManagers.length; i++) {
- fSelectedCMDocumentManagers[i].removeListener(fCMDocumentManagerListener);
- }
-
- ISelection preferredSelection = selection;
- if (selection instanceof IStructuredSelection) {
- IStructuredSelection structuredSel = (IStructuredSelection) selection;
-
- /*
- * On Attr nodes, select the owner Element. On Text nodes, select
- * the parent Element.
- */
- Object[] selectedObjects = new Object[structuredSel.size()];
- System.arraycopy(structuredSel.toArray(), 0, selectedObjects, 0, selectedObjects.length);
- for (int i = 0; i < selectedObjects.length; i++) {
- Object inode = selectedObjects[i];
- if (inode instanceof Node) {
- Node node = (Node) inode;
- // replace Attribute Node with its owner
- Node parentNode = node.getParentNode();
- if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
- Element ownerElement = ((Attr) node).getOwnerElement();
- selectedObjects[i] = ownerElement;
- }
- // replace Text Node with its parent
- else if (((node.getNodeType() == Node.TEXT_NODE) || (node.getNodeType() == Node.CDATA_SECTION_NODE)) && (parentNode != null)) {
- selectedObjects[i] = parentNode;
- }
- }
- }
-
- if (selectedObjects.length > 0) {
- Set managers = new HashSet(1);
- Set selectedNotifiers = new HashSet(1);
-
- for (int i = 0; i < selectedObjects.length; i++) {
- if (selectedObjects[i] instanceof Node) {
- ModelQuery query = ModelQueryUtil.getModelQuery(((Node) selectedObjects[i]).getOwnerDocument());
- if (query != null) {
- CMDocumentManager mgr = query.getCMDocumentManager();
- if (mgr != null) {
- managers.add(mgr);
- mgr.addListener(fCMDocumentManagerListener);
- }
- }
- }
- /*
- * Add UI refresh adapters and remember notifiers for
- * later removal
- */
- if (selectedObjects[i] instanceof INodeNotifier) {
- selectedNotifiers.add(selectedObjects[i]);
- ((INodeNotifier) selectedObjects[i]).addAdapter(fRefreshAdapter);
- }
- }
- fSelectedCMDocumentManagers = (CMDocumentManager[]) managers.toArray(new CMDocumentManager[managers.size()]);
- fSelectedNotifiers = (INodeNotifier[]) selectedNotifiers.toArray(new INodeNotifier[selectedNotifiers.size()]);
- }
-
-
- preferredSelection = new StructuredSelection(selectedObjects);
- }
- return preferredSelection;
- }
-
- PropertiesRefreshJob getPropertiesRefreshJob() {
- if (fPropertiesRefreshJob == null) {
- fPropertiesRefreshJob = new PropertiesRefreshJob();
- }
- return fPropertiesRefreshJob;
- }
-
- public IPropertySourceProvider getPropertySourceProvider(IPropertySheetPage page) {
- if (fPropertySourceProvider == null) {
- fPropertySheetPage = page;
- fPropertySourceProvider = new XMLPropertySourceProvider();
- }
- return fPropertySourceProvider;
- }
-
-
- public void unconfigure() {
- super.unconfigure();
- for (int i = 0; i < fSelectedCMDocumentManagers.length; i++) {
- fSelectedCMDocumentManagers[i].removeListener(fCMDocumentManagerListener);
- }
- if(fPropertiesRefreshJob != null) {
- fPropertiesRefreshJob.cancel();
- fPropertiesRefreshJob.propertySheetPages = null;
- }
- fPropertySheetPage = null;
- }
-}

Back to the top