From fd1ce52dd8422a3e966d89a33b6227fe7d204b98 Mon Sep 17 00:00:00 2001 From: nitind Date: Mon, 12 Feb 2007 21:29:55 +0000 Subject: This commit was manufactured by cvs2svn to create tag 'v200702122131'. --- .../common/actions/AddXSDAnyAttributeAction.java | 90 -- .../common/actions/AddXSDAnyElementAction.java | 84 -- .../actions/AddXSDAttributeDeclarationAction.java | 105 --- .../AddXSDAttributeGroupDefinitionAction.java | 78 -- .../actions/AddXSDComplexTypeDefinitionAction.java | 52 -- .../common/actions/AddXSDElementAction.java | 126 --- .../common/actions/AddXSDModelGroupAction.java | 95 -- .../actions/AddXSDModelGroupDefinitionAction.java | 62 -- .../actions/AddXSDSchemaDirectiveAction.java | 75 -- .../actions/AddXSDSimpleTypeDefinitionAction.java | 53 -- .../actions/DeleteXSDConcreteComponentAction.java | 53 -- .../internal/common/actions/OpenInNewEditor.java | 112 --- .../common/actions/SetMultiplicityAction.java | 88 -- .../ui/internal/common/actions/SetTypeAction.java | 49 -- .../ui/internal/common/actions/XSDBaseAction.java | 76 -- .../common/commands/AddDocumentationCommand.java | 132 --- .../common/commands/AddEnumerationsCommand.java | 50 -- .../commands/AddExtensibilityElementCommand.java | 81 -- .../commands/AddExtensionAttributeCommand.java | 110 --- .../common/commands/AddExtensionCommand.java | 48 - .../commands/AddExtensionElementCommand.java | 152 ---- .../common/commands/AddXSDAnyAttributeCommand.java | 64 -- .../common/commands/AddXSDAnyElementCommand.java | 45 - .../AddXSDAttributeDeclarationCommand.java | 176 ---- .../AddXSDAttributeGroupDefinitionCommand.java | 159 ---- .../AddXSDComplexTypeDefinitionCommand.java | 122 --- .../common/commands/AddXSDElementCommand.java | 340 ------- .../common/commands/AddXSDImportCommand.java | 42 - .../common/commands/AddXSDIncludeCommand.java | 43 - .../common/commands/AddXSDModelGroupCommand.java | 151 ---- .../AddXSDModelGroupDefinitionCommand.java | 116 --- .../common/commands/AddXSDRedefineCommand.java | 44 - .../commands/AddXSDSchemaDirectiveCommand.java | 60 -- .../AddXSDSimpleTypeDefinitionCommand.java | 91 -- .../ui/internal/common/commands/BaseCommand.java | 196 ----- .../commands/ChangeToLocalSimpleTypeCommand.java | 80 -- .../ui/internal/common/commands/DeleteCommand.java | 164 ---- .../commands/ExtensibleAddExtensionCommand.java | 214 ----- .../ExtensibleRemoveExtensionNodeCommand.java | 94 -- .../commands/RemoveExtensionAttributerCommand.java | 43 - .../commands/RemoveExtensionElementCommand.java | 46 - .../commands/RemoveExtensionNodeCommand.java | 61 -- .../SetBaseTypeAndManagerDirectivesCommand.java | 37 - .../common/commands/SetBaseTypeCommand.java | 85 -- .../common/commands/SetMultiplicityCommand.java | 70 -- .../internal/common/commands/SetTypeCommand.java | 116 --- .../common/commands/SetXSDFacetValueCommand.java | 43 - .../commands/UpdateAttributeValueCommand.java | 70 -- .../commands/UpdateComplexTypeDerivationBy.java | 51 -- ...mponentReferenceAndManageDirectivesCommand.java | 150 ---- .../common/commands/UpdateContentModelCommand.java | 49 -- ...ElementReferenceAndManageDirectivesCommand.java | 57 -- .../commands/UpdateElementReferenceCommand.java | 39 - .../common/commands/UpdateMaxOccursCommand.java | 65 -- .../common/commands/UpdateMinOccursCommand.java | 92 -- .../common/commands/UpdateNameCommand.java | 90 -- .../UpdateNamespaceInformationCommand.java | 298 ------- .../commands/UpdateNumericBoundsFacetCommand.java | 168 ---- .../commands/UpdateStringLengthFacetCommand.java | 230 ----- .../common/commands/UpdateTextValueCommand.java | 61 -- ...ateTypeReferenceAndManageDirectivesCommand.java | 60 -- .../commands/UpdateTypeReferenceCommand.java | 78 -- .../commands/UpdateXSDPatternFacetCommand.java | 76 -- .../commands/UpdateXSDWhiteSpaceFacetCommand.java | 60 -- .../providers/XSDSectionLabelProvider.java | 163 ---- .../sections/AbstractExtensionsSection.java | 574 ------------ .../properties/sections/AbstractSection.java | 365 -------- .../sections/AbstractSectionDescriptor.java | 108 --- .../properties/sections/AnnotationSection.java | 162 ---- .../sections/CommonDirectivesSection.java | 156 ---- .../properties/sections/EnumerationsSection.java | 405 --------- .../properties/sections/ExtensionsSection.java | 287 ------ .../common/properties/sections/FacetViewer.java | 559 ------------ .../sections/IDocumentChangedNotifier.java | 19 - .../properties/sections/MultiplicitySection.java | 216 ----- .../properties/sections/RefactoringSection.java | 93 -- .../properties/sections/SchemaLocationSection.java | 207 ----- .../SimpleContentUnionMemberTypesDialog.java | 312 ------- .../sections/SpecificConstraintsWidget.java | 692 --------------- .../properties/sections/XSDActionManager.java | 148 ---- .../sections/XSDAnyElementContentsSection.java | 251 ------ .../sections/XSDAttributeDeclarationSection.java | 399 --------- .../XSDAttributeGroupDefinitionSection.java | 284 ------ .../sections/XSDComplexTypeAdvancedSection.java | 221 ----- .../properties/sections/XSDComplexTypeSection.java | 357 -------- .../XSDElementDeclarationAdvancedSection.java | 367 -------- .../sections/XSDElementDeclarationSection.java | 583 ------------ .../properties/sections/XSDFacetSection.java | 979 --------------------- .../properties/sections/XSDFacetSectionFilter.java | 42 - .../properties/sections/XSDImportSection.java | 376 -------- .../sections/XSDModelGroupDefinitionSection.java | 334 ------- .../properties/sections/XSDModelGroupSection.java | 163 ---- .../properties/sections/XSDSchemaSection.java | 314 ------- .../properties/sections/XSDSimpleTypeSection.java | 752 ---------------- .../properties/sections/XSDTableTreeViewer.java | 126 --- .../appinfo/AddExtensionsComponentDialog.java | 778 ---------------- .../sections/appinfo/AddNewCategoryDialog.java | 385 -------- .../sections/appinfo/CategoryProvider.java | 81 -- .../DOMExtensionDetailsContentProvider.java | 201 ----- .../sections/appinfo/DOMExtensionItem.java | 216 ----- .../appinfo/DOMExtensionItemEditManager.java | 40 - .../appinfo/DOMExtensionItemMenuListener.java | 117 --- .../appinfo/DOMExtensionTreeContentProvider.java | 73 -- .../appinfo/DOMExtensionTreeLabelProvider.java | 78 -- .../appinfo/ExtensionDetailsContentProvider.java | 9 - .../sections/appinfo/ExtensionDetailsViewer.java | 269 ------ .../properties/sections/appinfo/ExtensionItem.java | 21 - .../sections/appinfo/ExtensionItemEditManager.java | 22 - .../sections/appinfo/ExtensionItemFilter.java | 18 - .../appinfo/ExtensionsSchemasRegistry.java | 361 -------- .../sections/appinfo/SelectFromCatalogDialog.java | 212 ----- .../appinfo/SpecificationForExtensionsSchema.java | 177 ---- .../appinfo/XSDExtensionTreeContentProvider.java | 109 --- .../custom/DefaultListNodeEditorConfiguration.java | 17 - .../custom/DialogNodeEditorConfiguration.java | 23 - .../custom/ListNodeEditorConfiguration.java | 25 - .../appinfo/custom/NodeCustomizationRegistry.java | 157 ---- .../appinfo/custom/NodeEditorConfiguration.java | 33 - .../appinfo/custom/NodeEditorProvider.java | 8 - .../sections/appinfo/custom/NodeFilter.java | 11 - .../wst/xsd/ui/internal/common/util/Messages.java | 113 --- .../ui/internal/common/util/XSDCommonUIUtils.java | 510 ----------- .../ui/internal/common/util/messages.properties | 96 -- 123 files changed, 20341 deletions(-) delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyAttributeAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeDeclarationAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeGroupDefinitionAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDComplexTypeDefinitionAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDElementAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupDefinitionAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSchemaDirectiveAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSimpleTypeDefinitionAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/DeleteXSDConcreteComponentAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetMultiplicityAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetTypeAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/XSDBaseAction.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddDocumentationCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddEnumerationsCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensibilityElementCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionAttributeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionElementCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyAttributeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyElementCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeDeclarationCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeGroupDefinitionCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDComplexTypeDefinitionCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDElementCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDImportCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDIncludeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDRedefineCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSchemaDirectiveCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSimpleTypeDefinitionCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/BaseCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ChangeToLocalSimpleTypeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/DeleteCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleAddExtensionCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleRemoveExtensionNodeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionAttributerCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionElementCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionNodeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeAndManagerDirectivesCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetMultiplicityCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetTypeCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetXSDFacetValueCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateAttributeValueCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComplexTypeDerivationBy.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComponentReferenceAndManageDirectivesCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateContentModelCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceAndManageDirectivesCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMaxOccursCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMinOccursCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNamespaceInformationCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNumericBoundsFacetCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateStringLengthFacetCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTextValueCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceAndManageDirectivesCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDPatternFacetCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDWhiteSpaceFacetCommand.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractExtensionsSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSectionDescriptor.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AnnotationSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/EnumerationsSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/ExtensionsSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/FacetViewer.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/IDocumentChangedNotifier.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/MultiplicitySection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/RefactoringSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SimpleContentUnionMemberTypesDialog.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SpecificConstraintsWidget.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDActionManager.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAnyElementContentsSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeGroupDefinitionSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeAdvancedSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSectionFilter.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDTableTreeViewer.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddExtensionsComponentDialog.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddNewCategoryDialog.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/CategoryProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionDetailsContentProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItem.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemEditManager.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemMenuListener.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeContentProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeLabelProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsContentProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsViewer.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItem.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemEditManager.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemFilter.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionsSchemasRegistry.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SelectFromCatalogDialog.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SpecificationForExtensionsSchema.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/XSDExtensionTreeContentProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DefaultListNodeEditorConfiguration.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DialogNodeEditorConfiguration.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/ListNodeEditorConfiguration.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeCustomizationRegistry.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorConfiguration.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorProvider.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeFilter.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/Messages.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java delete mode 100644 bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/messages.properties (limited to 'bundles/org.eclipse.wst.xsd.ui/src-common/org') diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyAttributeAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyAttributeAction.java deleted file mode 100644 index 07785fc680..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyAttributeAction.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAnyAttributeCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDComplexTypeDefinition; - -public class AddXSDAnyAttributeAction extends XSDBaseAction -{ - public static String ID = "org.eclipse.wst.xsd.ui.AddXSDAnyAttributeAction"; //$NON-NLS-1$ - protected XSDComplexTypeDefinition xsdComplexTypeDefinition; - - public AddXSDAnyAttributeAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_ADD_ANY_ATTRIBUTE); - setId(ID); - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - AddXSDAnyAttributeCommand command = null; - if (selection instanceof XSDComplexTypeDefinition) - { - command = new AddXSDAnyAttributeCommand(Messages._UI_ACTION_ADD_ANY_ATTRIBUTE, (XSDComplexTypeDefinition) selection); - getCommandStack().execute(command); - } - else if (selection instanceof XSDAttributeGroupDefinition) - { - command = new AddXSDAnyAttributeCommand(Messages._UI_ACTION_ADD_ANY_ATTRIBUTE, (XSDAttributeGroupDefinition)selection); - getCommandStack().execute(command); - } - - if (command != null) - { - addedComponent = command.getAddedComponent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent); - selectAddedComponent(adapter); - } - } - - - protected boolean calculateEnabled() - { - boolean rc = super.calculateEnabled(); - if (rc) - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - if (selection instanceof XSDComplexTypeDefinition) - { - return ((XSDComplexTypeDefinition)selection).getAttributeWildcardContent() == null; - } - else if (selection instanceof XSDAttributeGroupDefinition) - { - return ((XSDAttributeGroupDefinition)selection).getAttributeWildcardContent() == null; - } - - } - return rc; - } - - - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java deleted file mode 100644 index 56e41d8a4c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAnyElementAction.java +++ /dev/null @@ -1,84 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import java.util.Iterator; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAnyElementCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDWildcard; - -public class AddXSDAnyElementAction extends XSDBaseAction -{ - public static String ID = "org.eclipse.wst.xsd.ui.AddXSDAnyElementAction"; //$NON-NLS-1$ - - public AddXSDAnyElementAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_ADD_ANY_ELEMENT); - setId(ID); - } - - public void run() - { - XSDModelGroup modelGroup = getModelGroup(); - if (modelGroup != null) - { - AddXSDAnyElementCommand command = new AddXSDAnyElementCommand(getText(), modelGroup); - getCommandStack().execute(command); - } - } - - private XSDModelGroup getModelGroup() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - if (selection instanceof XSDModelGroup) - { - return (XSDModelGroup) selection; - } - return null; - } - - protected boolean calculateEnabled() - { - boolean rc = super.calculateEnabled(); - if (rc) - { - XSDModelGroup modelGroup = getModelGroup(); - if (modelGroup != null) - { - boolean hasAnyElement = false; - for (Iterator i = modelGroup.getContents().iterator(); i.hasNext();) - { - XSDParticle obj = (XSDParticle) i.next(); - if (obj.getContent() instanceof XSDWildcard) - { - hasAnyElement = true; - break; - } - } - return !hasAnyElement; - } - } - return rc; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeDeclarationAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeDeclarationAction.java deleted file mode 100644 index 2ac96078a8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeDeclarationAction.java +++ /dev/null @@ -1,105 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAttributeDeclarationCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDAttributeDeclarationAction extends XSDBaseAction -{ - public static String ID = "AddXSDAttributeAction"; //$NON-NLS-1$ - public static String REF_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDAttributeReferenceAction"; //$NON-NLS-1$ - boolean isReference = false; - - public AddXSDAttributeDeclarationAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_ADD_ATTRIBUTE); - setId(ID); - isReference = false; - } - - public AddXSDAttributeDeclarationAction(IWorkbenchPart part, String id, String label, boolean isReference) - { - super(part); - setText(label); - setId(id); - this.isReference = isReference; - doDirectEdit = !isReference; - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - AddXSDAttributeDeclarationCommand command = null; - if (selection instanceof XSDComplexTypeDefinition) - { - command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDComplexTypeDefinition) selection); - command.setReference(isReference); - getCommandStack().execute(command); - } - else if (selection instanceof XSDAttributeUse) - { - XSDAttributeUse xsdAttributeUse = (XSDAttributeUse) selection; - XSDConcreteComponent parent = null; - XSDComplexTypeDefinition ct = null; - for (parent = xsdAttributeUse.getContainer(); parent != null;) - { - if (parent instanceof XSDComplexTypeDefinition) - { - ct = (XSDComplexTypeDefinition) parent; - break; - } - parent = parent.getContainer(); - } - if (ct != null) - { - command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, ct); - command.setReference(isReference); - getCommandStack().execute(command); - } - } - else if (selection instanceof XSDAttributeGroupDefinition) - { - command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDAttributeGroupDefinition)selection); - command.setReference(isReference); - getCommandStack().execute(command); - } - else if (selection instanceof XSDSchema) - { - command = new AddXSDAttributeDeclarationCommand(Messages._UI_ACTION_ADD_ATTRIBUTE, (XSDSchema)selection); - getCommandStack().execute(command); - } - - if (command != null) - { - addedComponent = command.getAddedComponent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent); - selectAddedComponent(adapter); - } - - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeGroupDefinitionAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeGroupDefinitionAction.java deleted file mode 100644 index f30a3e78de..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDAttributeGroupDefinitionAction.java +++ /dev/null @@ -1,78 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDAttributeGroupDefinitionCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDAttributeGroupDefinitionAction extends XSDBaseAction -{ - public static String ID = "AddXSDAttributeGroupDefinitionAction"; //$NON-NLS-1$ - public static String REF_ID = "AddXSDAttributeGroupDefinitionRefAction"; //$NON-NLS-1$ - - public AddXSDAttributeGroupDefinitionAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_ADD_ATTRIBUTE_GROUP); - setId(ID); - } - - public AddXSDAttributeGroupDefinitionAction(IWorkbenchPart part, String id) - { - super(part); - if (id.equals(REF_ID)) - { - setText(Messages._UI_ACTION_ADD_ATTRIBUTE_GROUP_REF); - } - else - { - setText(Messages._UI_ACTION_ADD_ATTRIBUTE_GROUP_DEFINITION); - } - setId(id); - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - - AddXSDAttributeGroupDefinitionCommand command = null; - if (selection instanceof XSDComplexTypeDefinition) - { - command = new AddXSDAttributeGroupDefinitionCommand(Messages._UI_ACTION_ADD_ATTRIBUTE_GROUP_REF, (XSDComplexTypeDefinition) selection); - getCommandStack().execute(command); - } - else if (selection instanceof XSDSchema) - { - command = new AddXSDAttributeGroupDefinitionCommand(Messages._UI_ACTION_ADD_ATTRIBUTE_GROUP_DEFINITION, (XSDSchema) selection); - getCommandStack().execute(command); - } - - if (command != null) - { - addedComponent = command.getAddedComponent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent); - selectAddedComponent(adapter); - } - - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDComplexTypeDefinitionAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDComplexTypeDefinitionAction.java deleted file mode 100644 index c55f4eff43..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDComplexTypeDefinitionAction.java +++ /dev/null @@ -1,52 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDComplexTypeDefinitionCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDComplexTypeDefinitionAction extends XSDBaseAction -{ - public static final String ID = "org.eclipse.wst.xsd.ui.internal.editor.AddXSDComplexTypeDefinitionAction"; //$NON-NLS-1$ - - public AddXSDComplexTypeDefinitionAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_ADD_COMPLEX_TYPE); - setId(ID); - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - - if (selection instanceof XSDSchema) - { - AddXSDComplexTypeDefinitionCommand command = new AddXSDComplexTypeDefinitionCommand(Messages._UI_ACTION_ADD_COMPLEX_TYPE, (XSDSchema) selection); - getCommandStack().execute(command); - - addedComponent = command.getAddedComponent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent); - selectAddedComponent(adapter); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDElementAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDElementAction.java deleted file mode 100644 index 5930728d95..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDElementAction.java +++ /dev/null @@ -1,126 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDElementCommand; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDSchema; - -//revisit this and see if we can reuse AddFieldAction?? - -public class AddXSDElementAction extends XSDBaseAction -{ - public static String ID = "org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementAction"; //$NON-NLS-1$ - public static String REF_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDElementReferenceAction"; //$NON-NLS-1$ - boolean isReference; - - public AddXSDElementAction(IWorkbenchPart part, String id, String label, boolean isReference) - { - super(part); - setText(label); - setId(id); - this.isReference = isReference; - doDirectEdit = !isReference; - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - AddXSDElementCommand command = null; - if (selection instanceof XSDComplexTypeDefinition) - { - command = new AddXSDElementCommand(getText(), (XSDComplexTypeDefinition) selection); - command.setReference(isReference); - getCommandStack().execute(command); - } - else if (selection instanceof XSDModelGroupDefinition) - { - command = new AddXSDElementCommand(getText(), (XSDModelGroupDefinition) selection); - command.setReference(isReference); - getCommandStack().execute(command); - } - else if (selection instanceof XSDSchema) - { - command = new AddXSDElementCommand(getText(), (XSDSchema) selection); - getCommandStack().execute(command); - } - else if (selection instanceof XSDModelGroup) - { - XSDModelGroup modelGroup = (XSDModelGroup) selection; - XSDConcreteComponent component = modelGroup.getContainer(); - XSDComplexTypeDefinition ct = null; - while (component != null) - { - if (component instanceof XSDComplexTypeDefinition) - { - ct = (XSDComplexTypeDefinition) component; - break; - } - component = component.getContainer(); - } - - if (ct != null) - { - command = new AddXSDElementCommand(getText(), (XSDModelGroup) selection, ct); - } - else - { - command = new AddXSDElementCommand(getText(), (XSDModelGroup) selection); - } - command.setReference(isReference); - getCommandStack().execute(command); - } - else if (selection instanceof XSDElementDeclaration || selection instanceof XSDAttributeUse) - { - XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent) selection; - XSDConcreteComponent parent = null; - XSDComplexTypeDefinition ct = null; - for (parent = xsdConcreteComponent.getContainer(); parent != null; ) - { - if (parent instanceof XSDComplexTypeDefinition) - { - ct = (XSDComplexTypeDefinition)parent; - break; - } - parent = parent.getContainer(); - } - if (ct != null) - { - command = new AddXSDElementCommand(getText(), ct); - command.setReference(isReference); - getCommandStack().execute(command); - } - } - - if (command != null) - { - addedComponent = command.getAddedComponent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent); - selectAddedComponent(adapter); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupAction.java deleted file mode 100644 index 826334e1d4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupAction.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDModelGroupCommand; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; - -public class AddXSDModelGroupAction extends XSDBaseAction -{ - public static String SEQUENCE_ID = "AddXSDSequenceModelGroupAction"; //$NON-NLS-1$ - public static String CHOICE_ID = "AddXSDChoiceModelGroupAction"; //$NON-NLS-1$ - public static String ALL_ID = "AddXSDAllModelGroupAction"; //$NON-NLS-1$ - XSDCompositor xsdCompositor; - - public AddXSDModelGroupAction(IWorkbenchPart part, XSDCompositor compositor, String ID) - { - super(part); - setText(getLabel(compositor)); - setId(ID); - this.xsdCompositor = compositor; - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - if (selection instanceof XSDBaseAdapter) - { - XSDConcreteComponent xsdComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget(); - AddXSDModelGroupCommand command = null; - if (xsdComponent instanceof XSDElementDeclaration) - { - XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) xsdComponent; - - command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdElementDeclaration, xsdCompositor); - getCommandStack().execute(command); - } - else if (xsdComponent instanceof XSDModelGroup) - { - XSDModelGroup xsdModelGroup = (XSDModelGroup) xsdComponent; - - command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdModelGroup, xsdCompositor); - getCommandStack().execute(command); - } - else if (xsdComponent instanceof XSDComplexTypeDefinition) - { - command = new AddXSDModelGroupCommand(getLabel(xsdCompositor), xsdComponent, xsdCompositor); - getCommandStack().execute(command); - } - - if (command != null) - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent()); - if (adapter != null) - provider.setSelection(new StructuredSelection(adapter)); - } - - } - } - - private String getLabel(XSDCompositor compositor) - { - String result = XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_SEQUENCE"); //$NON-NLS-1$ - if (compositor != null) - { - if (compositor == XSDCompositor.CHOICE_LITERAL) - { - result = XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_CHOICE"); //$NON-NLS-1$ - } - else if (compositor == XSDCompositor.ALL_LITERAL) - { - result = XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_ALL");//$NON-NLS-1$ - } - } - return result; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupDefinitionAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupDefinitionAction.java deleted file mode 100644 index d49a367a58..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDModelGroupDefinitionAction.java +++ /dev/null @@ -1,62 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDModelGroupDefinitionCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDConcreteComponent; - -public class AddXSDModelGroupDefinitionAction extends XSDBaseAction -{ - public static final String MODELGROUPDEFINITION_ID = "AddXSDModelGroupDefinitionAction"; //$NON-NLS-1$ - public static final String MODELGROUPDEFINITIONREF_ID = "AddXSDModelGroupDefinitionRefAction"; //$NON-NLS-1$ - boolean isReference; - - public AddXSDModelGroupDefinitionAction(IWorkbenchPart part, boolean isReference) - { - super(part); - this.isReference = isReference; - if (isReference) - { - setText(Messages._UI_ACTION_ADD_GROUP_REF); - setId(MODELGROUPDEFINITION_ID); - } - else - { - setText(Messages._UI_ACTION_ADD_GROUP); - setId(MODELGROUPDEFINITIONREF_ID); - } - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - XSDConcreteComponent xsdConcreteComponent = null; - if (selection instanceof XSDBaseAdapter) - { - xsdConcreteComponent = (XSDConcreteComponent) ((XSDBaseAdapter) selection).getTarget(); - } - if (xsdConcreteComponent != null) - { - AddXSDModelGroupDefinitionCommand command = new AddXSDModelGroupDefinitionCommand(getText(), xsdConcreteComponent, isReference); - getCommandStack().execute(command); - - addedComponent = command.getAddedComponent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent); - selectAddedComponent(adapter); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSchemaDirectiveAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSchemaDirectiveAction.java deleted file mode 100644 index a9d833ace2..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSchemaDirectiveAction.java +++ /dev/null @@ -1,75 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDImportCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDIncludeCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDRedefineCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.BaseCommand; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDSchemaDirectiveAction extends XSDBaseAction -{ - public static String INCLUDE_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDIncludeAction"; //$NON-NLS-1$ - public static String IMPORT_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDImportAction"; //$NON-NLS-1$ - public static String REDEFINE_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.AddXSDRedefineAction"; //$NON-NLS-1$ - String label; - - public AddXSDSchemaDirectiveAction(IWorkbenchPart part, String ID, String label) - { - super(part); - setText(label); - setId(ID); - this.label = label; - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - - BaseCommand command = null; - if (selection instanceof XSDSchema) - { - if (INCLUDE_ID.equals(getId())) - { - command = new AddXSDIncludeCommand(label, (XSDSchema) selection); - } - else if (IMPORT_ID.equals(getId())) - { - command = new AddXSDImportCommand(label, (XSDSchema) selection); - } - else if (REDEFINE_ID.equals(getId())) - { - command = new AddXSDRedefineCommand(label, (XSDSchema) selection); - } - getCommandStack().execute(command); - } - - if (command != null) - { - Adapter adapter = XSDAdapterFactory.getInstance().adapt(command.getAddedComponent()); - if (adapter != null) - provider.setSelection(new StructuredSelection(adapter)); - } - - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSimpleTypeDefinitionAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSimpleTypeDefinitionAction.java deleted file mode 100644 index bc7cd73e62..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/AddXSDSimpleTypeDefinitionAction.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.emf.common.notify.Adapter; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddXSDSimpleTypeDefinitionCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDSimpleTypeDefinitionAction extends XSDBaseAction -{ - public static final String ID = "org.eclipse.wst.xsd.ui.internal.editor.AddXSDSimpleTypeDefinitionAction"; //$NON-NLS-1$ - - public AddXSDSimpleTypeDefinitionAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_ADD_SIMPLE_TYPE); - setId(ID); - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - - if (selection instanceof XSDSchema) - { - AddXSDSimpleTypeDefinitionCommand command = new AddXSDSimpleTypeDefinitionCommand(Messages._UI_ACTION_ADD_SIMPLE_TYPE, (XSDSchema) selection); - getCommandStack().execute(command); - - addedComponent = command.getAddedComponent(); - Adapter adapter = XSDAdapterFactory.getInstance().adapt(addedComponent); - selectAddedComponent(adapter); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/DeleteXSDConcreteComponentAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/DeleteXSDConcreteComponentAction.java deleted file mode 100644 index ef66379880..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/DeleteXSDConcreteComponentAction.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import java.util.Iterator; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDConcreteComponent; - -public class DeleteXSDConcreteComponentAction extends XSDBaseAction -{ - public static final String DELETE_XSD_COMPONENT_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.DeleteXSDConcreteComponentAction"; //$NON-NLS-1$ - - public DeleteXSDConcreteComponentAction(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_DELETE); - setId(DELETE_XSD_COMPONENT_ID); - setImageDescriptor(XSDEditorPlugin.getImageDescriptor("icons/delete_obj.gif") ); //$NON-NLS-1$ - } - - public void run() - { - for (Iterator i = ((IStructuredSelection) getSelection()).iterator(); i.hasNext();) - { - Object selection = i.next(); - - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - - if (selection instanceof XSDConcreteComponent) - { - DeleteCommand command = new DeleteCommand(getText(), (XSDConcreteComponent) selection); - getCommandStack().execute(command); - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java deleted file mode 100644 index 3fc2aecc35..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/OpenInNewEditor.java +++ /dev/null @@ -1,112 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -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.viewers.IStructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PartInitException; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.part.FileEditorInput; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDComplexTypeDefinitionAdapter; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDSchemaDirectiveAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor; -import org.eclipse.wst.xsd.ui.internal.utils.OpenOnSelectionHelper; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDSchemaDirective; -import org.eclipse.xsd.impl.XSDImportImpl; - -public class OpenInNewEditor extends BaseSelectionAction -{ - public static final String ID = "OpenInNewEditor"; //$NON-NLS-1$ - - public OpenInNewEditor(IWorkbenchPart part) - { - super(part); - setText(Messages._UI_ACTION_OPEN_IN_NEW_EDITOR); //$NON-NLS-1$ - setId(ID); - } - - protected boolean calculateEnabled() - { - return true; - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDComplexTypeDefinitionAdapter) - { - XSDComplexTypeDefinitionAdapter xsdAdapter = (XSDComplexTypeDefinitionAdapter) selection; - XSDComplexTypeDefinition fComponent = (XSDComplexTypeDefinition) xsdAdapter.getTarget(); - - if (fComponent.getSchema() != null) - { - String schemaLocation = URIHelper.removePlatformResourceProtocol(fComponent.getSchema().getSchemaLocation()); - IPath schemaPath = new Path(schemaLocation); - IFile schemaFile = ResourcesPlugin.getWorkspace().getRoot().getFile(schemaPath); - if (schemaFile != null && schemaFile.exists()) - { - IWorkbenchWindow workbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); - if (workbenchWindow != null) - { - IWorkbenchPage page = workbenchWindow.getActivePage(); - try - { - // TODO: Should use this to open in default editor - // IEditorPart editorPart = IDE.openEditor(page, schemaFile, true); - IEditorPart editorPart = page.openEditor(new FileEditorInput(schemaFile), "org.eclipse.wst.xsd.ui.internal.editor.InternalXSDMultiPageEditor", true); //$NON-NLS-1$ - - if (editorPart instanceof InternalXSDMultiPageEditor) - { - InternalXSDMultiPageEditor xsdEditor = (InternalXSDMultiPageEditor) editorPart; - - xsdEditor.openOnGlobalReference(fComponent); - } - - } - catch (PartInitException pie) - { - } - } - } - } - } - else if (selection instanceof XSDSchemaDirectiveAdapter) - { - XSDSchemaDirective dir = (XSDSchemaDirective)((XSDSchemaDirectiveAdapter)selection).getTarget(); - String schemaLocation = ""; - // force load of imported schema - if (dir instanceof XSDImportImpl) - { - ((XSDImportImpl)dir).importSchema(); - } - if (dir.getResolvedSchema() != null) - { - schemaLocation = URIHelper.removePlatformResourceProtocol(dir.getResolvedSchema().getSchemaLocation()); - if (schemaLocation != null) - { - OpenOnSelectionHelper.openXSDEditor(schemaLocation); - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetMultiplicityAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetMultiplicityAction.java deleted file mode 100644 index a33996a005..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetMultiplicityAction.java +++ /dev/null @@ -1,88 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.SetMultiplicityCommand; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; - -public class SetMultiplicityAction extends XSDBaseAction -{ - public static String REQUIRED_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.SetMultiplicity.REQUIRED_ID"; //$NON-NLS-1$ - public static String ZERO_OR_ONE_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.SetMultiplicity.ZERO_OR_ONE_ID"; //$NON-NLS-1$ - public static String ZERO_OR_MORE_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.SetMultiplicity.ZERO_OR_MORE_ID"; //$NON-NLS-1$ - public static String ONE_OR_MORE_ID = "org.eclipse.wst.xsd.ui.internal.common.actions.SetMultiplicity.ONE_OR_MORE_ID"; //$NON-NLS-1$ - - SetMultiplicityCommand command; - - public SetMultiplicityAction(IWorkbenchPart part, String label, String ID) - { - super(part); - setText(label); - setId(ID); - command = new SetMultiplicityCommand(label); - } - - public void setMaxOccurs(int i) - { - command.setMaxOccurs(i); - } - - public void setMinOccurs(int i) - { - command.setMinOccurs(i); - } - - protected boolean calculateEnabled() - { - boolean state = super.calculateEnabled(); - if (state) - { - XSDConcreteComponent xsdConcreteComponent = getXSDInput(); - if (xsdConcreteComponent instanceof XSDElementDeclaration) - { - return !((XSDElementDeclaration)xsdConcreteComponent).isGlobal(); - } - else if (xsdConcreteComponent instanceof XSDModelGroup) - { - return !(((XSDModelGroup)xsdConcreteComponent).eContainer() instanceof XSDModelGroupDefinition); - } - } - return state; - } - - private XSDConcreteComponent getXSDInput() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - XSDConcreteComponent xsdConcreteComponent = null; - if (selection instanceof XSDBaseAdapter) - { - xsdConcreteComponent = (XSDConcreteComponent)((XSDBaseAdapter) selection).getTarget(); - } - return xsdConcreteComponent; - } - - public void run() - { - XSDConcreteComponent xsdConcreteComponent = getXSDInput(); - if (xsdConcreteComponent != null) - { - command.setXSDConcreteComponent(xsdConcreteComponent); - getCommandStack().execute(command); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetTypeAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetTypeAction.java deleted file mode 100644 index 6b879ad2b5..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/SetTypeAction.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.commands.SetTypeCommand; -import org.eclipse.xsd.XSDConcreteComponent; - -public class SetTypeAction extends XSDBaseAction -{ - public static final String SET_NEW_TYPE_ID = "SetTypeAction_AddType"; //$NON-NLS-1$ - public static final String SELECT_EXISTING_TYPE_ID = "SetTypeAction_ExistingType"; //$NON-NLS-1$ - - SetTypeCommand command; - - public SetTypeAction(String label, String ID, IWorkbenchPart part) - { - super(part); - setText(label); - setId(ID); - } - - public void run() - { - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - - if (selection instanceof XSDBaseAdapter) - { - Object target = ((XSDBaseAdapter) selection).getTarget(); - - if (target instanceof XSDConcreteComponent) - { - command = new SetTypeCommand(getText(), getId(), (XSDConcreteComponent) target); - command.setAdapter((XSDBaseAdapter) selection); - getCommandStack().execute(command); - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/XSDBaseAction.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/XSDBaseAction.java deleted file mode 100644 index 3edf43f691..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/actions/XSDBaseAction.java +++ /dev/null @@ -1,76 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.actions; - -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.contentoutline.ContentOutline; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.actions.BaseSelectionAction; -import org.eclipse.wst.xsd.ui.internal.adt.design.editparts.BaseFieldEditPart; -import org.eclipse.wst.xsd.ui.internal.design.editparts.TopLevelComponentEditPart; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; - -public class XSDBaseAction extends BaseSelectionAction -{ - XSDConcreteComponent addedComponent; - - public XSDBaseAction(IWorkbenchPart part) - { - super(part); - } - - protected boolean calculateEnabled() - { - if (getWorkbenchPart() instanceof IEditorPart) - { - IEditorPart owningEditor = (IEditorPart)getWorkbenchPart(); - - Object selection = ((IStructuredSelection) getSelection()).getFirstElement(); - if (selection instanceof XSDBaseAdapter) - { - selection = ((XSDBaseAdapter) selection).getTarget(); - } - XSDSchema xsdSchema = null; - if (selection instanceof XSDConcreteComponent) - { - xsdSchema = ((XSDConcreteComponent)selection).getSchema(); - } - - if (xsdSchema != null && xsdSchema == owningEditor.getAdapter(XSDSchema.class)) - { - return true; - } - } - return false; - } - - protected void doEdit(Object obj, IWorkbenchPart part) - { - if (obj instanceof TopLevelComponentEditPart) - { - TopLevelComponentEditPart editPart = (TopLevelComponentEditPart)obj; - if (addedComponent == ((XSDBaseAdapter)editPart.getModel()).getTarget()) - { - editPart.setScroll(true); - editPart.addFeedback(); - editPart.doEditName(!(part instanceof ContentOutline)); - } - } - else if (obj instanceof BaseFieldEditPart) - { - BaseFieldEditPart editPart = (BaseFieldEditPart)obj; - editPart.doEditName(!(part instanceof ContentOutline)); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddDocumentationCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddDocumentationCommand.java deleted file mode 100644 index 5647467812..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddDocumentationCommand.java +++ /dev/null @@ -1,132 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.List; - -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDAnnotation; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class AddDocumentationCommand extends BaseCommand -{ - XSDAnnotation xsdAnnotation; - XSDConcreteComponent input; - String newValue, oldValue; - boolean documentationExists; - Element documentationElement; - - public AddDocumentationCommand(String label, XSDAnnotation xsdAnnotation, XSDConcreteComponent input, String newValue, String oldValue) - { - super(label); - this.xsdAnnotation = xsdAnnotation; - this.input = input; - this.newValue = newValue; - this.oldValue = oldValue; - } - - public void execute() - { - if (input instanceof XSDSchema) - { - ensureSchemaElement((XSDSchema)input); - } - - try - { - beginRecording(input.getElement()); - - xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation(input, true); - Element element = xsdAnnotation.getElement(); - - List documentationList = xsdAnnotation.getUserInformation(); - documentationElement = null; - documentationExists = false; - if (documentationList.size() > 0) - { - documentationExists = true; - documentationElement = (Element) documentationList.get(0); - } - - if (documentationElement == null) - { - documentationElement = xsdAnnotation.createUserInformation(null); - element.appendChild(documentationElement); - formatChild(documentationElement); - // Defect in model....I create it but the model object doesn't appear - // to be updated - xsdAnnotation.updateElement(); - xsdAnnotation.setElement(element); - } - - if (documentationElement.hasChildNodes()) - { - if (documentationElement instanceof IDOMElement) - { - IDOMElement domElement = (IDOMElement) documentationElement; - - Node firstChild = documentationElement.getFirstChild(); - Node lastChild = documentationElement.getLastChild(); - int start = 0; - int end = 0; - - // IDOMModel model = domElement.getModel(); - // IDOMDocument doc = model.getDocument(); - IDOMNode first = null; - if (firstChild instanceof IDOMNode) - { - first = (IDOMNode) firstChild; - start = first.getStartOffset(); - } - if (lastChild instanceof IDOMNode) - { - IDOMNode last = (IDOMNode) lastChild; - end = last.getEndOffset(); - } - - if (domElement != null) - { - oldValue = domElement.getModel().getStructuredDocument().get(start, end - start); - domElement.getModel().getStructuredDocument().replaceText(documentationElement, start, end - start, newValue); - } - } - } - else - { - if (newValue.length() > 0) - { - oldValue = ""; //$NON-NLS-1$ - Node childNode = documentationElement.getOwnerDocument().createTextNode(newValue); - documentationElement.appendChild(childNode); - } - } - formatChild(xsdAnnotation.getElement()); - } - catch (Exception e) - { - - } - finally - { - endRecording(); - } - } - - public void undo() - { - super.undo(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddEnumerationsCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddEnumerationsCommand.java deleted file mode 100644 index f8c2a5151d..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddEnumerationsCommand.java +++ /dev/null @@ -1,50 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDEnumerationFacet; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.util.XSDSchemaBuildingTools; - -public class AddEnumerationsCommand extends BaseCommand -{ - XSDSimpleTypeDefinition simpleType; - String value; - - public AddEnumerationsCommand(String label, XSDSimpleTypeDefinition simpleType) - { - super(label); - this.simpleType = simpleType; - } - - public void setValue(String value) - { - this.value = value; - } - - public void execute() - { - try - { - beginRecording(simpleType.getElement()); - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDEnumerationFacet enumerationFacet = factory.createXSDEnumerationFacet(); - enumerationFacet.setLexicalValue(value); - simpleType.getFacetContents().add(enumerationFacet); - formatChild(simpleType.getElement()); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensibilityElementCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensibilityElementCommand.java deleted file mode 100644 index 6747f59c12..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensibilityElementCommand.java +++ /dev/null @@ -1,81 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema; -import org.w3c.dom.Attr; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class AddExtensibilityElementCommand extends BaseCommand -{ - Element input, elementToAdd; - SpecificationForExtensionsSchema extensionSchemaSpec; - - public AddExtensibilityElementCommand(String label, Element input, Element elementToAdd) - { - super(label); - this.input = input; - this.elementToAdd = elementToAdd; - } - - public void execute() - { - super.execute(); - try - { - beginRecording(input); - addElement(); - } - finally - { - endRecording(); - } - } - - public void undo() - { - super.undo(); - // TODO - } - - public void setSchemaProperties(SpecificationForExtensionsSchema appInfoSchemaSpec) - { - this.extensionSchemaSpec = appInfoSchemaSpec; - } - - private void addElement() - { - if (input != null) - { - Document doc = input.getOwnerDocument(); - String name = elementToAdd.getAttribute("name"); //$NON-NLS-1$ - try - { - Element rootElement = doc.createElementNS(extensionSchemaSpec.getNamespaceURI(), name); - String prefix = input.getPrefix(); - rootElement.setPrefix(prefix); - String xmlns = (prefix == null || prefix.equals("")) ? "xmlns" : "xmlns:" + prefix; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - Attr nsURIAttribute = doc.createAttribute(xmlns); - nsURIAttribute.setValue(extensionSchemaSpec.getNamespaceURI()); - rootElement.setAttributeNode(nsURIAttribute); - input.appendChild(rootElement); - - } - catch (Exception e) - { - - } - - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionAttributeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionAttributeCommand.java deleted file mode 100644 index 2e6616b4ad..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionAttributeCommand.java +++ /dev/null @@ -1,110 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import org.eclipse.wst.xml.core.internal.contentmodel.util.DOMNamespaceInfoManager; -import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDConcreteComponent; -import org.w3c.dom.Element; - -public class AddExtensionAttributeCommand extends AddExtensionCommand -{ - private static DOMNamespaceInfoManager manager = new DOMNamespaceInfoManager(); - private XSDAttributeDeclaration attribute; - private boolean appInfoAttributeAdded = false; - private String attributeQName; - private String namespacePrefix; - - public AddExtensionAttributeCommand(String label, XSDConcreteComponent component, - XSDAttributeDeclaration attribute) - { - super(label); - this.component = component; - this.attribute = attribute; - } - - public void execute() - { - try - { - beginRecording(component.getElement()); - super.execute(); - namespacePrefix = handleNamespacePrefices(); - - attributeQName = namespacePrefix + ":" + attribute.getName(); //$NON-NLS-1$ - String value = component.getElement().getAttribute(attributeQName); - if (value == null) - { - appInfoAttributeAdded = true; - component.getElement().setAttribute(attributeQName, ""); //$NON-NLS-1$ - } - } - finally - { - endRecording(); - } - } - - public void undo() - { - super.undo(); - if (appInfoAttributeAdded){ - component.getElement().removeAttribute(attributeQName); - } - } - - /** Create a namespace prefix if needed, other wise retrieve - * a predefined namespace prefix - * @return */ - private String handleNamespacePrefices() - { - Element schemaElement = component.getSchema().getElement(); - String prefix = null; - - // If target namespace of the attribute already exists - List namespacePrefices = manager.getNamespaceInfoList(schemaElement); - for (int i = 0; i < namespacePrefices.size(); i++){ - NamespaceInfo info = (NamespaceInfo) namespacePrefices.get(i); - if ( info.uri.equals(attribute.getTargetNamespace())) { - prefix = info.prefix; - } - } - - // Create unquie namespace prefix - if ( prefix == null){ - prefix = createUniquePrefix(component); - } - - NamespaceInfo info = new NamespaceInfo(attribute.getTargetNamespace(), prefix, ""); //$NON-NLS-1$ - List infoList = new ArrayList(1); - infoList.add(info); - manager.addNamespaceInfo(schemaElement, infoList, false); - return prefix; - } - - protected String createUniquePrefix(XSDConcreteComponent component) - { - String prefix = "p"; //$NON-NLS-1$ - Map prefMapper = component.getSchema().getQNamePrefixToNamespaceMap(); - if ( prefMapper.get(prefix) != null){ - int i = 1; - while ( prefMapper.get(prefix + i) != null) - i++; - prefix += i; - } - return prefix; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionCommand.java deleted file mode 100644 index 5672104048..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionCommand.java +++ /dev/null @@ -1,48 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; - -public class AddExtensionCommand extends BaseCommand -{ - protected SpecificationForExtensionsSchema extensionsSchemaSpec; - protected XSDConcreteComponent component; - - protected AddExtensionCommand(String label) - { - super(label); - } - - public void setSchemaProperties(SpecificationForExtensionsSchema appInfoSchemaSpec) - { - this.extensionsSchemaSpec = appInfoSchemaSpec; - } - - public Object getNewObject() - { - return null; - } - - public void execute() - { - if (component instanceof XSDSchema) - { - ensureSchemaElement((XSDSchema)component); - } - - super.execute(); - } - - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionElementCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionElementCommand.java deleted file mode 100644 index ca4d8a8aa3..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddExtensionElementCommand.java +++ /dev/null @@ -1,152 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.List; -import java.util.Map; -import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDAnnotation; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class AddExtensionElementCommand extends AddExtensionCommand -{ - XSDElementDeclaration element; - Element appInfo; - Element newElement; - - public AddExtensionElementCommand(String label, XSDConcreteComponent input, XSDElementDeclaration element) - { - super(label); - this.component = input; - this.element = element; - } - - public void execute() - { - try - { - beginRecording(component.getElement()); - super.execute(); - addAnnotationSet(component.getSchema(), extensionsSchemaSpec); - formatChild(component.getElement()); - } - finally - { - endRecording(); - } - } - - public void undo() - { - super.undo(); - XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation(component, false); - xsdAnnotation.getElement().removeChild(appInfo); - List appInfos = xsdAnnotation.getApplicationInformation(); - appInfos.remove(appInfo); - xsdAnnotation.updateElement(); - - } - - public void setSchemaProperties(SpecificationForExtensionsSchema spec) - { - this.extensionsSchemaSpec = spec; - } - - public void addAnnotationSet(XSDSchema xsdSchema, SpecificationForExtensionsSchema spec) - { - XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation(component, true); - addAnnotationSet(spec, xsdAnnotation); - } - - private void addAnnotationSet(SpecificationForExtensionsSchema spec, XSDAnnotation xsdAnnotation) - { - XSDSchema schema= xsdAnnotation.getSchema(); - Element schemaElement = schema.getElement(); - - if (xsdAnnotation.getApplicationInformation().size() == 0) - { - appInfo = xsdAnnotation.createApplicationInformation(null); - xsdAnnotation.getElement().appendChild(appInfo); - List appInfos = xsdAnnotation.getApplicationInformation(); - appInfos.add(appInfo); - } - else - { - // use the first appInfo - appInfo = (Element)xsdAnnotation.getApplicationInformation().get(0); - } - - String prefix = addNamespaceDeclarationIfRequired(schemaElement, "p", spec.getNamespaceURI()); - - if (appInfo != null) - { - Document doc = appInfo.getOwnerDocument(); - - newElement = doc.createElementNS(spec.getNamespaceURI(), element.getName()); - newElement.setPrefix(prefix); - appInfo.appendChild(newElement); - - xsdAnnotation.updateElement(); - } - } - - public Object getNewObject() - { - return newElement; - } - - /** - * @deprecated - */ - protected String createUniquePrefix(XSDConcreteComponent component) - { - String prefix = "p"; //$NON-NLS-1$ - Map prefMapper = component.getSchema().getQNamePrefixToNamespaceMap(); - if ( prefMapper.get(prefix) != null){ - int i = 1; - while ( prefMapper.get(prefix + i) != null) - i++; - prefix += i; - } - return prefix; - } - - // TODO... common this up with wsdl.ui - private String addNamespaceDeclarationIfRequired(Element schemaElement, String prefixHint, String namespace) - { - String prefix = null; - NamespaceTable namespaceTable = new NamespaceTable(schemaElement.getOwnerDocument()); - namespaceTable.addElement(schemaElement); - prefix = namespaceTable.getPrefixForURI(namespace); - if (prefix == null) - { - String basePrefix = prefixHint; - prefix = basePrefix; - String xmlnsColon = "xmlns:"; //$NON-NLS-1$ - String attributeName = xmlnsColon + prefix; - int count = 0; - while (schemaElement.getAttribute(attributeName) != null) - { - count++; - prefix = basePrefix + count; - attributeName = xmlnsColon + prefix; - } - schemaElement.setAttribute(attributeName, namespace); - } - return prefix; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyAttributeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyAttributeCommand.java deleted file mode 100644 index 211cbc9d82..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyAttributeCommand.java +++ /dev/null @@ -1,64 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDWildcard; - -public class AddXSDAnyAttributeCommand extends BaseCommand -{ - XSDComplexTypeDefinition xsdComplexTypeDefinition; - XSDAttributeGroupDefinition xsdAttributeGroupDefinition; - XSDConcreteComponent input; - - public AddXSDAnyAttributeCommand(String label, XSDComplexTypeDefinition xsdComplexTypeDefinition) - { - super(label); - this.xsdComplexTypeDefinition = xsdComplexTypeDefinition; - this.input = xsdComplexTypeDefinition; - } - - public AddXSDAnyAttributeCommand(String label, XSDAttributeGroupDefinition xsdAttributeGroupDefinition) - { - super(label); - this.xsdAttributeGroupDefinition = xsdAttributeGroupDefinition; - this.input = xsdAttributeGroupDefinition; - } - - public void execute() - { - try - { - beginRecording(input.getElement()); - - XSDWildcard anyAttribute = XSDFactory.eINSTANCE.createXSDWildcard(); - if (xsdComplexTypeDefinition != null) - { - xsdComplexTypeDefinition.setAttributeWildcardContent(anyAttribute); - formatChild(xsdComplexTypeDefinition.getElement()); - } - else if (xsdAttributeGroupDefinition != null) - { - xsdAttributeGroupDefinition.setAttributeWildcardContent(anyAttribute); - formatChild(xsdAttributeGroupDefinition.getElement()); - } - addedXSDConcreteComponent = anyAttribute; - } - finally - { - endRecording(); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyElementCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyElementCommand.java deleted file mode 100644 index d777ec3329..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAnyElementCommand.java +++ /dev/null @@ -1,45 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDWildcard; - -public class AddXSDAnyElementCommand extends BaseCommand -{ - XSDModelGroup parent; - - public AddXSDAnyElementCommand(String label, XSDModelGroup parent) - { - super(label); - this.parent = parent; - } - - public void execute() - { - try - { - beginRecording(parent.getElement()); - XSDWildcard wildCard = XSDFactory.eINSTANCE.createXSDWildcard(); - XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); - particle.setContent(wildCard); - parent.getContents().add(particle); - addedXSDConcreteComponent = wildCard; - formatChild(parent.getElement()); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeDeclarationCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeDeclarationCommand.java deleted file mode 100644 index 15355640eb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeDeclarationCommand.java +++ /dev/null @@ -1,176 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Text; - -public class AddXSDAttributeDeclarationCommand extends BaseCommand -{ - XSDComplexTypeDefinition xsdComplexTypeDefinition; - XSDModelGroup xsdModelGroup; - XSDConcreteComponent parent; - boolean isReference; - - public AddXSDAttributeDeclarationCommand(String label, XSDComplexTypeDefinition xsdComplexTypeDefinition) - { - super(label); - this.xsdComplexTypeDefinition = xsdComplexTypeDefinition; - } - - public AddXSDAttributeDeclarationCommand(String label, XSDConcreteComponent parent) - { - super(label); - this.parent = parent; - } - - public void execute() - { - XSDAttributeDeclaration attribute = XSDFactory.eINSTANCE.createXSDAttributeDeclaration(); - try - { - if (parent == null) - { - beginRecording(xsdComplexTypeDefinition.getElement()); - if (!isReference) - { - attribute.setName(getNewName("NewAttribute")); //$NON-NLS-1$ - attribute.setTypeDefinition(xsdComplexTypeDefinition.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string")); //$NON-NLS-1$ - } - else - { - attribute.setResolvedAttributeDeclaration(setGlobalAttributeReference(xsdComplexTypeDefinition.getSchema())); - } - XSDAttributeUse attributeUse = XSDFactory.eINSTANCE.createXSDAttributeUse(); - attributeUse.setAttributeDeclaration(attribute); - attributeUse.setContent(attribute); - - if (xsdComplexTypeDefinition.getAttributeContents() != null) - { - xsdComplexTypeDefinition.getAttributeContents().add(attributeUse); - formatChild(xsdComplexTypeDefinition.getElement()); - } - } - else - { - beginRecording(parent.getElement()); - if (parent instanceof XSDSchema) - { - XSDSchema xsdSchema = (XSDSchema) parent; - attribute = createGlobalXSDAttributeDeclaration(xsdSchema); - } - else if (parent instanceof XSDAttributeGroupDefinition) - { - if (!isReference) - { - attribute.setTypeDefinition(parent.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string")); //$NON-NLS-1$ - - List list = new ArrayList(); - Iterator i = ((XSDAttributeGroupDefinition) parent).getResolvedAttributeGroupDefinition().getAttributeUses().iterator(); - while (i.hasNext()) - { - XSDAttributeUse use = (XSDAttributeUse) i.next(); - list.add(use.getAttributeDeclaration()); - } - attribute.setName(XSDCommonUIUtils.createUniqueElementName("NewAttribute", list)); //$NON-NLS-1$ - } - else - { - attribute.setResolvedAttributeDeclaration(setGlobalAttributeReference(parent.getSchema())); - } - - XSDAttributeUse attributeUse = XSDFactory.eINSTANCE.createXSDAttributeUse(); - attributeUse.setAttributeDeclaration(attribute); - attributeUse.setContent(attribute); - - ((XSDAttributeGroupDefinition) parent).getResolvedAttributeGroupDefinition().getContents().add(attributeUse); - formatChild(parent.getElement()); - } - } - } - finally - { - endRecording(); - } - addedXSDConcreteComponent = attribute; - } - - ArrayList names; - - protected String getNewName(String description) - { - ArrayList usedAttributeNames = new ArrayList(); - usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes(xsdComplexTypeDefinition)); - usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes(xsdComplexTypeDefinition)); - return XSDCommonUIUtils.createUniqueElementName(description, usedAttributeNames); //$NON-NLS-1$ - } - - public void setReference(boolean isReference) - { - this.isReference = isReference; - } - - protected XSDAttributeDeclaration createGlobalXSDAttributeDeclaration(XSDSchema xsdSchema) - { - ensureSchemaElement(xsdSchema); - XSDAttributeDeclaration attribute = XSDFactory.eINSTANCE.createXSDAttributeDeclaration(); - attribute.setTypeDefinition(xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string")); //$NON-NLS-1$ - attribute.setName(XSDCommonUIUtils.createUniqueElementName("NewAttribute", xsdSchema.getAttributeDeclarations())); //$NON-NLS-1$ - Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ - xsdSchema.getElement().appendChild(textNode); - xsdSchema.getContents().add(attribute); - return attribute; - } - - protected XSDAttributeDeclaration setGlobalAttributeReference(XSDSchema xsdSchema) - { - List list = xsdSchema.getAttributeDeclarations(); - XSDAttributeDeclaration referencedAttribute = null; - boolean isUserDefined = false; - for (Iterator i = list.iterator(); i.hasNext(); ) - { - Object obj = i.next(); - if (obj instanceof XSDAttributeDeclaration) - { - XSDAttributeDeclaration attr = (XSDAttributeDeclaration) obj; - if (!XSDConstants.SCHEMA_INSTANCE_URI_2001.equals(attr.getTargetNamespace())) - { - referencedAttribute = attr; - isUserDefined = true; - break; - } - } - } - if (!isUserDefined) - { - referencedAttribute = createGlobalXSDAttributeDeclaration(xsdSchema); - Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ - xsdSchema.getElement().appendChild(textNode); - xsdSchema.getContents().add(referencedAttribute); - } - - return referencedAttribute; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeGroupDefinitionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeGroupDefinitionCommand.java deleted file mode 100644 index 2ee575e73a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDAttributeGroupDefinitionCommand.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; -import org.w3c.dom.Text; - -public class AddXSDAttributeGroupDefinitionCommand extends BaseCommand -{ - XSDComplexTypeDefinition xsdComplexTypeDefinition; - XSDSchema xsdSchema; - - public AddXSDAttributeGroupDefinitionCommand(String label, XSDComplexTypeDefinition xsdComplexTypeDefinition) - { - super(label); - this.xsdComplexTypeDefinition = xsdComplexTypeDefinition; - } - - public AddXSDAttributeGroupDefinitionCommand(String label, XSDSchema xsdSchema) - { - super(label); - this.xsdSchema = xsdSchema; - } - - public void execute() - { - XSDAttributeGroupDefinition attributeGroup = XSDFactory.eINSTANCE.createXSDAttributeGroupDefinition(); - try - { - if (xsdSchema == null) - { - beginRecording(xsdComplexTypeDefinition.getElement()); - attributeGroup.setName(getNewName("AttributeGroup")); //$NON-NLS-1$ - - List list = xsdComplexTypeDefinition.getSchema().getAttributeGroupDefinitions(); - if (list.size() > 0) - { - attributeGroup.setResolvedAttributeGroupDefinition((XSDAttributeGroupDefinition) list.get(0)); - } - else - { - attributeGroup.setName(null); - XSDAttributeGroupDefinition attributeGroup2 = XSDFactory.eINSTANCE.createXSDAttributeGroupDefinition(); - attributeGroup2.setName(XSDCommonUIUtils.createUniqueElementName("NewAttributeGroup", xsdComplexTypeDefinition.getSchema().getAttributeGroupDefinitions())); //$NON-NLS-1$ - xsdComplexTypeDefinition.getSchema().getContents().add(attributeGroup2); - attributeGroup.setResolvedAttributeGroupDefinition(attributeGroup2); - } - - if (xsdComplexTypeDefinition.getAttributeContents() != null) - { - xsdComplexTypeDefinition.getAttributeContents().add(attributeGroup); - } - addedXSDConcreteComponent = attributeGroup; - } - else - { - ensureSchemaElement(xsdSchema); - // put this after, since we don't have a DOM node yet - beginRecording(xsdSchema.getElement()); - attributeGroup.setName(XSDCommonUIUtils.createUniqueElementName("NewAttributeGroup", xsdSchema.getAttributeGroupDefinitions())); //$NON-NLS-1$ - Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ - xsdSchema.getElement().appendChild(textNode); - xsdSchema.getContents().add(attributeGroup); - addedXSDConcreteComponent = attributeGroup; - } - } - finally - { - endRecording(); - } - } - - ArrayList names; - - protected String getNewName(String description) - { - String candidateName = "New" + description; //$NON-NLS-1$ - XSDConcreteComponent parent = xsdComplexTypeDefinition; - names = new ArrayList(); - int i = 1; - if (parent instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition) parent; - walkUpInheritance(ct); - - boolean ready = false; - while (!ready) - { - ready = true; - for (Iterator iter = names.iterator(); iter.hasNext();) - { - String attrName = (String) iter.next(); - if (candidateName.equals(attrName)) - { - ready = false; - candidateName = "New" + description + String.valueOf(i); //$NON-NLS-1$ - i++; - } - } - } - } - return candidateName; - } - - private void walkUpInheritance(XSDComplexTypeDefinition ct) - { - updateNames(ct); - XSDTypeDefinition typeDef = ct.getBaseTypeDefinition(); - if (ct != ct.getRootType()) - { - if (typeDef instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition ct2 = (XSDComplexTypeDefinition) typeDef; - walkUpInheritance(ct2); - } - } - } - - private void updateNames(XSDComplexTypeDefinition ct) - { - Iterator iter = ct.getAttributeContents().iterator(); - while (iter.hasNext()) - { - Object obj = iter.next(); - if (obj instanceof XSDAttributeUse) - { - XSDAttributeUse use = (XSDAttributeUse) obj; - XSDAttributeDeclaration attr = use.getAttributeDeclaration(); - String attrName = attr.getName(); - if (attrName != null) - { - names.add(attrName); - } - } - } - - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDComplexTypeDefinitionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDComplexTypeDefinitionCommand.java deleted file mode 100644 index 757feaf14a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDComplexTypeDefinitionCommand.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDSchemaBuildingTools; -import org.w3c.dom.Text; - -public final class AddXSDComplexTypeDefinitionCommand extends BaseCommand -{ - protected XSDConcreteComponent parent; - protected XSDComplexTypeDefinition createdComplexType; - private String nameToAdd; - - public AddXSDComplexTypeDefinitionCommand(String label, XSDConcreteComponent parent) - { - super(label); - this.parent = parent; - } - - public void setNameToAdd(String nameToAdd) - { - this.nameToAdd = nameToAdd; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() - { - try - { - beginRecording(parent.getElement()); - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDComplexTypeDefinition complexType = factory.createXSDComplexTypeDefinition(); - addedXSDConcreteComponent = complexType; - String newName = getNewName(nameToAdd == null ? "NewXSDComplexType" : nameToAdd, parent.getSchema()); //$NON-NLS-1$ - complexType.setName(newName); - if (parent instanceof XSDSchema) - { - try - { - XSDSchema xsdSchema = (XSDSchema) parent; - ensureSchemaElement(xsdSchema); - Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ - xsdSchema.getElement().appendChild(textNode); - xsdSchema.getContents().add(complexType); - } - catch (Exception e) - { - - } - } - else if (parent instanceof XSDElementDeclaration) - { - ((XSDElementDeclaration) parent).setAnonymousTypeDefinition(complexType); - formatChild(parent.getElement()); - } - createdComplexType = complexType; - } - finally - { - endRecording(); - } - } - - protected String getNewName(String description, XSDSchema schema) - { - String candidateName = description; //$NON-NLS-1$ - int i = 1; - - List list = schema.getTypeDefinitions(); - List listOfNames = new ArrayList(); - for (Iterator iter = list.iterator(); iter.hasNext();) - { - XSDTypeDefinition typeDef = (XSDTypeDefinition) iter.next(); - String name = typeDef.getName(); - if (name == null) - name = ""; //$NON-NLS-1$ - if (typeDef.getTargetNamespace() == schema.getTargetNamespace()) - listOfNames.add(name); - } - - boolean flag = true; - while (flag) - { - if (!listOfNames.contains(candidateName)) - { - flag = false; - break; - } - candidateName = description + String.valueOf(i); //$NON-NLS-1$ - i++; - } - - return candidateName; - } - - public XSDComplexTypeDefinition getCreatedComplexType() - { - return createdComplexType; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDElementCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDElementCommand.java deleted file mode 100644 index 448f738b3a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDElementCommand.java +++ /dev/null @@ -1,340 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDComplexTypeContent; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.util.XSDSchemaBuildingTools; -import org.w3c.dom.Text; - -public class AddXSDElementCommand extends BaseCommand -{ - XSDComplexTypeDefinition xsdComplexTypeDefinition; - XSDModelGroupDefinition xsdModelGroupDefinition; - XSDModelGroup xsdModelGroup; - XSDSchema xsdSchema; - boolean isReference; - private String nameToAdd; - - public AddXSDElementCommand() - { - super(); - } - - public AddXSDElementCommand(String label, XSDComplexTypeDefinition xsdComplexTypeDefinition) - { - super(label); - this.xsdComplexTypeDefinition = xsdComplexTypeDefinition; - xsdModelGroup = getModelGroup(xsdComplexTypeDefinition); - } - - public AddXSDElementCommand(String label, XSDModelGroupDefinition xsdModelGroupDefinition) - { - super(label); - this.xsdModelGroupDefinition = xsdModelGroupDefinition; - xsdModelGroup = getModelGroup(xsdModelGroupDefinition); - } - - public AddXSDElementCommand(String label, XSDModelGroup xsdModelGroup, XSDComplexTypeDefinition xsdComplexTypeDefinition) - { - super(label); - this.xsdModelGroup = xsdModelGroup; - this.xsdComplexTypeDefinition = xsdComplexTypeDefinition; - } - - public AddXSDElementCommand(String label, XSDModelGroup xsdModelGroup) - { - super(label); - this.xsdModelGroup = xsdModelGroup; - } - - public AddXSDElementCommand(String label, XSDSchema xsdSchema) - { - super(label); - this.xsdSchema = xsdSchema; - } - - public void setReference(boolean isReference) - { - this.isReference = isReference; - } - - public void setNameToAdd(String name){ - nameToAdd = name; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() - { - try - { - if (xsdSchema != null) - { - beginRecording(xsdSchema.getElement()); - XSDElementDeclaration element = createGlobalXSDElementDeclaration(); - Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ - xsdSchema.getElement().appendChild(textNode); - xsdSchema.getContents().add(element); - addedXSDConcreteComponent = element; - } - else if (xsdModelGroupDefinition != null) - { - beginRecording(xsdModelGroupDefinition.getElement()); - if (xsdModelGroup == null) - { - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDParticle particle = factory.createXSDParticle(); - xsdModelGroup = factory.createXSDModelGroup(); - xsdModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - particle.setContent(xsdModelGroup); - xsdModelGroupDefinition.setModelGroup(xsdModelGroup); - } - xsdSchema = xsdModelGroupDefinition.getSchema(); - if (!isReference) - { - xsdModelGroup.getContents().add(createXSDElementDeclarationForModelGroupDefinitions()); - } - else - { - xsdModelGroup.getContents().add(createXSDElementReference()); - } - formatChild(xsdModelGroupDefinition.getElement()); - } - else if (xsdModelGroup != null && (xsdComplexTypeDefinition == null || xsdModelGroupDefinition == null) ) - { - xsdSchema = xsdModelGroup.getSchema(); - beginRecording(xsdSchema.getElement()); - if (!isReference) - { - xsdModelGroup.getContents().add(createXSDElementDeclaration()); - } - else - { - xsdModelGroup.getContents().add(createXSDElementReference()); - } - formatChild(xsdModelGroup.getElement()); - } - else - { - xsdSchema = xsdComplexTypeDefinition.getSchema(); - beginRecording(xsdSchema.getElement()); - if (xsdModelGroup == null) - { - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDParticle particle = factory.createXSDParticle(); - xsdModelGroup = factory.createXSDModelGroup(); - xsdModelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - particle.setContent(xsdModelGroup); - xsdComplexTypeDefinition.setContent(particle); - } - if (!isReference) - { - xsdModelGroup.getContents().add(createXSDElementDeclarationForComplexType()); - } - else - { - xsdModelGroup.getContents().add(createXSDElementReference()); - } - formatChild(xsdComplexTypeDefinition.getElement()); - } - } - finally - { - endRecording(); - } - } - - protected XSDParticle createXSDElementDeclaration() - { - XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ - - XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); - - XSDConcreteComponent comp = xsdModelGroup.getContainer(); - ArrayList usedAttributeNames = new ArrayList(); - usedAttributeNames.addAll(XSDCommonUIUtils.getChildElements(xsdModelGroup)); - while (comp != null) - { - if (comp instanceof XSDModelGroupDefinition) - { - usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDModelGroupDefinition)comp)); - break; - } - else if (comp instanceof XSDComplexTypeDefinition) - { - usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes((XSDComplexTypeDefinition)comp)); - usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes((XSDComplexTypeDefinition)comp)); - break; - } - comp = comp.getContainer(); - } - element.setName(XSDCommonUIUtils.createUniqueElementName( - nameToAdd == null ? "NewElement" : nameToAdd , usedAttributeNames)); //$NON-NLS-1$ - element.setTypeDefinition(type); - - XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); - particle.setContent(element); - addedXSDConcreteComponent = element; - return particle; - } - - protected XSDParticle createXSDElementReference() - { - List list = xsdModelGroup.getSchema().getElementDeclarations(); - XSDElementDeclaration referencedElement = null; - if (list.size() > 0) - { - referencedElement = (XSDElementDeclaration)list.get(0); - } - else - { - referencedElement = createGlobalXSDElementDeclaration(); - Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ - xsdSchema.getElement().appendChild(textNode); - xsdSchema.getContents().add(referencedElement); - } - - XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); - - element.setResolvedElementDeclaration(referencedElement); - XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); - particle.setContent(element); - addedXSDConcreteComponent = element; - return particle; - } - - protected XSDParticle createXSDElementDeclarationForComplexType() - { - XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ - - XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); - - ArrayList usedAttributeNames = new ArrayList(); - usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes(xsdComplexTypeDefinition)); - usedAttributeNames.addAll(XSDCommonUIUtils.getInheritedAttributes(xsdComplexTypeDefinition)); - element.setName(XSDCommonUIUtils.createUniqueElementName( - nameToAdd == null ? "NewElement" : nameToAdd , usedAttributeNames)); //$NON-NLS-1$ - element.setTypeDefinition(type); - - XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); - particle.setContent(element); - addedXSDConcreteComponent = element; - return particle; - } - - protected XSDParticle createXSDElementDeclarationForModelGroupDefinitions() - { - XSDSimpleTypeDefinition type = xsdModelGroup.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ - - XSDElementDeclaration element = XSDFactory.eINSTANCE.createXSDElementDeclaration(); - - ArrayList usedAttributeNames = new ArrayList(); - usedAttributeNames.addAll(XSDCommonUIUtils.getAllAttributes(xsdModelGroupDefinition)); - element.setName(XSDCommonUIUtils.createUniqueElementName( - nameToAdd == null ? "NewElement" : nameToAdd , usedAttributeNames)); //$NON-NLS-1$ - element.setTypeDefinition(type); - - XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); - particle.setContent(element); - addedXSDConcreteComponent = element; - return particle; - } - - protected XSDElementDeclaration createGlobalXSDElementDeclaration() - { - ensureSchemaElement(xsdSchema); - XSDSimpleTypeDefinition type = xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDElementDeclaration element = factory.createXSDElementDeclaration(); - - element.setName(XSDCommonUIUtils.createUniqueElementName( - nameToAdd == null ? "NewElement" : nameToAdd , xsdSchema.getElementDeclarations())); //$NON-NLS-1$ - element.setTypeDefinition(type); - - return element; - } - - public XSDModelGroup getModelGroup(XSDModelGroupDefinition modelGroupDef) - { - return modelGroupDef.getModelGroup(); - } - - //PORT - public XSDModelGroup getModelGroup(XSDComplexTypeDefinition cType) - { - XSDParticle particle = null; - - XSDComplexTypeContent xsdComplexTypeContent = cType.getContent(); - if (xsdComplexTypeContent instanceof XSDParticle) - { - particle = (XSDParticle)xsdComplexTypeContent; - } - - if (particle == null) - { - return null; - } - - Object particleContent = particle.getContent(); - XSDModelGroup group = null; - - if (particleContent instanceof XSDModelGroupDefinition) - { - group = ((XSDModelGroupDefinition) particleContent).getResolvedModelGroupDefinition().getModelGroup(); - } - else if (particleContent instanceof XSDModelGroup) - { - group = (XSDModelGroup) particleContent; - } - - if (group == null) - { - return null; - } - -// if (group.getContents().isEmpty() || group.eResource() != cType.eResource()) -// { -// if (cType.getBaseType() != null) -// { -// XSDComplexTypeContent content = cType.getContent(); -// if (content instanceof XSDParticle) -// { -// group = (XSDModelGroup) ((XSDParticle) content).getContent(); -// } -// } -// } - - return group; - } - - public XSDConcreteComponent getAddedComponent() - { - return super.getAddedComponent(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDImportCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDImportCommand.java deleted file mode 100644 index e91f872f2a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDImportCommand.java +++ /dev/null @@ -1,42 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDImportCommand extends AddXSDSchemaDirectiveCommand -{ - public AddXSDImportCommand(String label, XSDSchema schema) - { - super(label); - this.xsdSchema = schema; - } - - public void execute() - { - try - { - super.execute(); - // Add this after if we don't have a DOM Node yet - beginRecording(xsdSchema.getElement()); - XSDImport xsdImport = XSDFactory.eINSTANCE.createXSDImport(); - xsdSchema.getContents().add(findNextPositionToInsert(), xsdImport); - addedXSDConcreteComponent = xsdImport; - formatChild(xsdSchema.getElement()); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDIncludeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDIncludeCommand.java deleted file mode 100644 index e69b309467..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDIncludeCommand.java +++ /dev/null @@ -1,43 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDInclude; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDIncludeCommand extends AddXSDSchemaDirectiveCommand -{ - public AddXSDIncludeCommand(String label, XSDSchema schema) - { - super(label); - this.xsdSchema = schema; - } - - public void execute() - { - try - { - super.execute(); - // Add this after if we don't have a DOM Node yet - beginRecording(xsdSchema.getElement()); - XSDInclude xsdInclude = XSDFactory.eINSTANCE.createXSDInclude(); - xsdInclude.setSchemaLocation(""); //$NON-NLS-1$ - xsdSchema.getContents().add(findNextPositionToInsert(), xsdInclude); - addedXSDConcreteComponent = xsdInclude; - formatChild(xsdSchema.getElement()); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupCommand.java deleted file mode 100644 index 19872de637..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupCommand.java +++ /dev/null @@ -1,151 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.util.XSDSchemaBuildingTools; - -public class AddXSDModelGroupCommand extends BaseCommand -{ - XSDConcreteComponent parent; - XSDCompositor xsdCompositor; - XSDModelGroup newModelGroup; - - public AddXSDModelGroupCommand(String label, XSDConcreteComponent parent, XSDCompositor xsdCompositor) - { - super(label); - this.parent = parent; - this.xsdCompositor = xsdCompositor; - } - - public void execute() - { - try - { - beginRecording(parent.getElement()); - XSDConcreteComponent owner = getOwner(); - if (owner != null) - { - XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); - newModelGroup = createModelGroup(); - particle.setContent(newModelGroup); - - XSDComplexTypeDefinition ctd = (XSDComplexTypeDefinition) owner; - ctd.setContent(particle); - } - formatChild(parent.getElement()); - } - finally - { - endRecording(); - } - } - - public void undo() - { - super.undo(); - - if (parent instanceof XSDModelGroup) - { - XSDModelGroup model = (XSDModelGroup) parent; - model.getContents().remove(newModelGroup.getContainer()); - } - } - - private XSDConcreteComponent getOwner() - { - XSDConcreteComponent owner = null; - if (parent instanceof XSDElementDeclaration) - { - XSDElementDeclaration ed = (XSDElementDeclaration)parent; - if (ed.getTypeDefinition() != null) - { - if (ed.getAnonymousTypeDefinition() == null) - { - ed.setTypeDefinition(null); - XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - ed.setAnonymousTypeDefinition(td); - owner = ed.getTypeDefinition(); - } - else - { - XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - ed.setAnonymousTypeDefinition(td); - owner = td; - } - } - else if (ed.getAnonymousTypeDefinition() == null) - { - XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - ed.setAnonymousTypeDefinition(td); - owner = td; - } - else if (ed.getAnonymousTypeDefinition() instanceof XSDComplexTypeDefinition) - { - owner = ed.getAnonymousTypeDefinition(); - } - else if (ed.getAnonymousTypeDefinition() instanceof XSDSimpleTypeDefinition) - { - XSDComplexTypeDefinition td = XSDFactory.eINSTANCE.createXSDComplexTypeDefinition(); - ed.setAnonymousTypeDefinition(td); - owner = td; - } - } - else if (parent instanceof XSDModelGroup) - { - newModelGroup = createModelGroup(); - ((XSDModelGroup) parent).getContents().add(newModelGroup.getContainer()); - } - else if (parent instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition ct = (XSDComplexTypeDefinition)parent; - owner = parent; - if (ct.getContent() instanceof XSDParticle) - { - XSDParticle particle = (XSDParticle)ct.getContent(); - if (particle.getContent() instanceof XSDModelGroup) - { - owner = null; - newModelGroup = createModelGroup(); - XSDModelGroup newParent = (XSDModelGroup)particle.getContent(); - newParent.getContents().add(newModelGroup.getContainer()); - } - - } - } - return owner; - } - - - protected boolean adopt(XSDConcreteComponent model) - { - return false; - } - - protected XSDModelGroup createModelGroup() - { - - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDParticle particle = factory.createXSDParticle(); - XSDModelGroup modelGroup = factory.createXSDModelGroup(); - modelGroup.setCompositor(xsdCompositor); - particle.setContent(modelGroup); - addedXSDConcreteComponent = modelGroup; - return modelGroup; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.java deleted file mode 100644 index 8e0596defc..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDModelGroupDefinitionCommand.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.List; - -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDSchemaBuildingTools; -import org.w3c.dom.Text; - -public class AddXSDModelGroupDefinitionCommand extends BaseCommand -{ - XSDConcreteComponent parent; - boolean isReference; - - public AddXSDModelGroupDefinitionCommand(String label, XSDConcreteComponent parent, boolean isReference) - { - super(label); - this.parent = parent; - this.isReference = isReference; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() - { - if (parent instanceof XSDSchema) - { - ensureSchemaElement((XSDSchema)parent); - } - try - { - beginRecording(parent.getElement()); - if (!isReference) - { - XSDModelGroupDefinition def = createXSDModelGroupDefinition(); - addedXSDConcreteComponent = def; - } - else - { - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDModelGroupDefinition def = factory.createXSDModelGroupDefinition(); - XSDParticle particle = XSDFactory.eINSTANCE.createXSDParticle(); - particle.setContent(def); - List list = parent.getSchema().getModelGroupDefinitions(); - if (list.size() > 0) - { - def.setResolvedModelGroupDefinition((XSDModelGroupDefinition) list.get(0)); - } - else - { - XSDModelGroupDefinition newGroupDef = createXSDModelGroupDefinition(); - def.setResolvedModelGroupDefinition(newGroupDef); - } - - if (parent instanceof XSDModelGroup) - { - ((XSDModelGroup) parent).getContents().add(particle); - } - formatChild(def.getElement()); - addedXSDConcreteComponent = def; - } - } - finally - { - endRecording(); - } - } - - protected XSDModelGroupDefinition createXSDModelGroupDefinition() - { - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDModelGroupDefinition def = factory.createXSDModelGroupDefinition(); - List list = parent.getSchema().getModelGroupDefinitions(); - String newName = XSDCommonUIUtils.createUniqueElementName("ModelGroupDefinition", list); //$NON-NLS-1$ - def.setName(newName); - - XSDModelGroup modelGroup = createModelGroup(); - def.setModelGroup(modelGroup); - Text textNode = parent.getSchema().getDocument().createTextNode("\n"); //$NON-NLS-1$ - parent.getSchema().getElement().appendChild(textNode); - parent.getSchema().getContents().add(def); - formatChild(def.getElement()); - return def; - } - - protected XSDModelGroup createModelGroup() - { - XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); - XSDParticle particle = factory.createXSDParticle(); - XSDModelGroup modelGroup = factory.createXSDModelGroup(); - modelGroup.setCompositor(XSDCompositor.SEQUENCE_LITERAL); - particle.setContent(modelGroup); - - return modelGroup; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDRedefineCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDRedefineCommand.java deleted file mode 100644 index e2fd36721a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDRedefineCommand.java +++ /dev/null @@ -1,44 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; - -public class AddXSDRedefineCommand extends AddXSDSchemaDirectiveCommand -{ - public AddXSDRedefineCommand(String label, XSDSchema schema) - { - super(label); - this.xsdSchema = schema; - } - - public void execute() - { - super.execute(); - try - { - // Add this after if we don't have a DOM Node yet - beginRecording(xsdSchema.getElement()); - XSDRedefine xsdRedefine = XSDFactory.eINSTANCE.createXSDRedefine(); - xsdRedefine.setSchemaLocation(""); //$NON-NLS-1$ - xsdSchema.getContents().add(findNextPositionToInsert(), xsdRedefine); - addedXSDConcreteComponent = xsdRedefine; - formatChild(xsdSchema.getElement()); - } - finally - { - endRecording(); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSchemaDirectiveCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSchemaDirectiveCommand.java deleted file mode 100644 index a4f9008868..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSchemaDirectiveCommand.java +++ /dev/null @@ -1,60 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.Iterator; - -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaDirective; - -public abstract class AddXSDSchemaDirectiveCommand extends BaseCommand -{ - protected XSDSchema xsdSchema; - - public AddXSDSchemaDirectiveCommand(String label) - { - super(label); - } - - public void undo() - { - super.undo(); - } - - protected boolean adopt(XSDConcreteComponent model) - { - return false; - } - - protected int findNextPositionToInsert() - { - int index = 0; - for (Iterator i = xsdSchema.getContents().iterator(); i.hasNext(); ) - { - Object o = i.next(); - if (o instanceof XSDSchemaDirective) - { - index ++; - } - else - { - break; - } - } - return index; - } - - public void execute() - { - ensureSchemaElement(xsdSchema); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSimpleTypeDefinitionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSimpleTypeDefinitionCommand.java deleted file mode 100644 index b2bdcc48b0..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/AddXSDSimpleTypeDefinitionCommand.java +++ /dev/null @@ -1,91 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Text; - -public final class AddXSDSimpleTypeDefinitionCommand extends BaseCommand -{ - XSDConcreteComponent parent; - XSDSimpleTypeDefinition createdSimpleType; - private String nameToAdd; - - public AddXSDSimpleTypeDefinitionCommand(String label, XSDConcreteComponent parent) - { - super(label); - this.parent = parent; - } - - public void setNameToAdd(String nameToAdd) - { - this.nameToAdd = nameToAdd; - } - - public void execute() - { - if (parent instanceof XSDSchema) - { - ensureSchemaElement((XSDSchema)parent); - } - - try - { - beginRecording(parent.getElement()); - XSDSimpleTypeDefinition typeDef = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - typeDef.setBaseTypeDefinition(parent.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string")); //$NON-NLS-1$ - - if (parent instanceof XSDSchema) - { - typeDef.setName(XSDCommonUIUtils.createUniqueElementName(nameToAdd == null ? "XSDSimpleType" : nameToAdd, ((XSDSchema) parent).getTypeDefinitions())); //$NON-NLS-1$ - createdSimpleType = typeDef; - try - { - XSDSchema xsdSchema = (XSDSchema) parent; - Text textNode = xsdSchema.getDocument().createTextNode("\n"); //$NON-NLS-1$ - xsdSchema.getElement().appendChild(textNode); - xsdSchema.getContents().add(typeDef); - } - catch (Exception e) - { - - } - } - else if (parent instanceof XSDElementDeclaration) - { - ((XSDElementDeclaration) parent).setAnonymousTypeDefinition(typeDef); - } - else if (parent instanceof XSDAttributeDeclaration) - { - ((XSDAttributeDeclaration) parent).setAnonymousTypeDefinition(typeDef); - } - formatChild(createdSimpleType.getElement()); - - addedXSDConcreteComponent = createdSimpleType; - } - finally - { - endRecording(); - } - } - - public XSDSimpleTypeDefinition getCreatedSimpleType() - { - return createdSimpleType; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/BaseCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/BaseCommand.java deleted file mode 100644 index 7a2334e788..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/BaseCommand.java +++ /dev/null @@ -1,196 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.util.Map; - -import org.eclipse.core.runtime.IPath; -import org.eclipse.core.runtime.Path; -import org.eclipse.core.runtime.Preferences; -import org.eclipse.emf.common.util.URI; -import org.eclipse.gef.commands.Command; -import org.eclipse.wst.sse.core.internal.encoding.CommonEncodingPreferenceNames; -import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor; -import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -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.format.FormatProcessorXML; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.ProcessingInstruction; -import org.w3c.dom.Text; - -public class BaseCommand extends Command -{ - private static final String XML = "xml"; //$NON-NLS-1$ - - XSDConcreteComponent addedXSDConcreteComponent; - - public BaseCommand() - { - super(); - } - - public BaseCommand(String label) - { - super(label); - } - - public XSDConcreteComponent getAddedComponent() - { - return addedXSDConcreteComponent; - } - - IDOMNode domNode; - protected void beginRecording(Object element) { - if (element instanceof IDOMNode) - { - domNode = (IDOMNode) element; - domNode.getModel().beginRecording(this, getUndoDescription()); - } - } - - protected void endRecording() - { - if (domNode != null) - domNode.getModel().endRecording(this); - } - - protected String getUndoDescription() { - return getLabel(); - } - - protected void formatChild(Element child) - { - if (child instanceof IDOMNode) - { - IDOMModel model = ((IDOMNode)child).getModel(); - try - { - // tell the model that we are about to make a big model change - model.aboutToChangeModel(); - - IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); - formatProcessor.formatNode(child); - } - finally - { - // tell the model that we are done with the big model change - model.changedModel(); - } - } - } - - protected static void ensureSchemaElement(XSDSchema schema) - { - Document document = schema.getDocument(); - - Element schemaElement = document.getDocumentElement(); - - if (schemaElement == null) - { - String targetNamespace = getDefaultNamespace(schema); - schema.setTargetNamespace(targetNamespace); - Map qNamePrefixToNamespaceMap = schema.getQNamePrefixToNamespaceMap(); - qNamePrefixToNamespaceMap.put("tns", targetNamespace); - if (XSDEditorPlugin.getDefault().isQualifyXMLSchemaLanguage()) - { - String prefix = XSDEditorPlugin.getDefault().getXMLSchemaPrefix(); - schema.setSchemaForSchemaQNamePrefix(prefix); - qNamePrefixToNamespaceMap.put(prefix, XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); - } - else - { - qNamePrefixToNamespaceMap.put(null, XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); - } - - schema.updateElement(); - ensureXMLDirective(document); - } - } - - private static void ensureXMLDirective(Document document) - { - if (hasXMLDirective(document)) - { - return; - } - - Node firstChild = document.getFirstChild(); - ProcessingInstruction xmlDeclaration = getXMLDeclaration(document); - document.insertBefore(xmlDeclaration, firstChild); - Text textNode = document.createTextNode(System.getProperty("line.separator")); - document.insertBefore(textNode, firstChild); - } - - private static boolean hasXMLDirective(Document document) - { - Node firstChild = document.getFirstChild(); - - if (firstChild == null) - { - return false; - } - - if (firstChild.getNodeType() != Node.PROCESSING_INSTRUCTION_NODE) - { - return false; - } - - ProcessingInstruction processingInstruction = (ProcessingInstruction)firstChild; - - if (!XML.equals(processingInstruction.getTarget())) - { - return false; - } - - return true; - } - - private static ProcessingInstruction getXMLDeclaration(Document document) - { - Preferences preference = XMLCorePlugin.getDefault().getPluginPreferences(); - String charSet = preference.getString(CommonEncodingPreferenceNames.OUTPUT_CODESET); - if (charSet == null || charSet.trim().equals("")) - { - charSet = "UTF-8"; - } - ProcessingInstruction xmlDeclaration = document.createProcessingInstruction(XML, "version=\"1.0\" encoding=\"" + charSet + "\""); - return xmlDeclaration; - } - - private static String getDefaultNamespace(XSDSchema schema) - { - String namespace = XSDEditorPlugin.getDefault().getXMLSchemaTargetNamespace(); - - if (!namespace.endsWith("/")) - { - namespace = namespace.concat("/"); - } - - namespace += getFileName(schema) + "/"; - - return namespace; - - } - - private static String getFileName(XSDSchema schema) - { - URI schemaURI = schema.eResource().getURI(); - IPath filePath = new Path(schemaURI.toString()); - return filePath.removeFileExtension().lastSegment().toString(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ChangeToLocalSimpleTypeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ChangeToLocalSimpleTypeCommand.java deleted file mode 100644 index bf10d8b590..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ChangeToLocalSimpleTypeCommand.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDFeature; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - -public class ChangeToLocalSimpleTypeCommand extends BaseCommand -{ - XSDFeature parent; - XSDSimpleTypeDefinition anonymousSimpleType; - XSDSimpleTypeDefinition currentType; - - public ChangeToLocalSimpleTypeCommand(String label, XSDFeature parent) - { - super(label); - this.parent = parent; - -// if (parent instanceof XSDElementDeclaration) -// { -// XSDElementDeclaration element = (XSDElementDeclaration) parent; -// XSDTypeDefinition aType = element.getResolvedElementDeclaration().getTypeDefinition(); -// -// if (aType instanceof XSDSimpleTypeDefinition) -// { -// currentType = (XSDSimpleTypeDefinition) aType; -// } -// } - } - - public void execute() - { -// anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); -// anonymousSimpleType.setBaseTypeDefinition(currentType); - try - { - beginRecording(parent.getElement()); - - if (parent instanceof XSDElementDeclaration) - { - ((XSDElementDeclaration) parent).setAnonymousTypeDefinition(anonymousSimpleType); - } - else if (parent instanceof XSDAttributeDeclaration) - { - ((XSDAttributeDeclaration) parent).setAnonymousTypeDefinition(anonymousSimpleType); - } - formatChild(parent.getElement()); - } - finally - { - endRecording(); - } - } - - public void setAnonymousSimpleType(XSDSimpleTypeDefinition anonymousSimpleType) - { - this.anonymousSimpleType = anonymousSimpleType; - } - - public XSDSimpleTypeDefinition getAnonymousType() - { - if (anonymousSimpleType == null) - { - anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - anonymousSimpleType.setBaseTypeDefinition(currentType); - } - return anonymousSimpleType; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/DeleteCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/DeleteCommand.java deleted file mode 100644 index c86acec43e..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/DeleteCommand.java +++ /dev/null @@ -1,164 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDVisitor; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDEnumerationFacet; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDConstants; - -public class DeleteCommand extends BaseCommand -{ - XSDConcreteComponent target; - - public DeleteCommand(String label, XSDConcreteComponent target) - { - super(label); - this.target = target; - } - - public void execute() - { - XSDVisitor visitor = new XSDVisitor() - { - public void visitElementDeclaration(org.eclipse.xsd.XSDElementDeclaration element) - { - if (element.getTypeDefinition() == target) - { - XSDSimpleTypeDefinition type = target.getSchema().getSchemaForSchema().resolveSimpleTypeDefinition("string"); //$NON-NLS-1$ - element.setTypeDefinition(type); - } - super.visitElementDeclaration(element); - } - }; - - XSDConcreteComponent parent = target.getContainer(); - - try - { - beginRecording(parent.getElement()); - - if (target instanceof XSDModelGroup || target instanceof XSDElementDeclaration || target instanceof XSDModelGroupDefinition) - { - if (parent instanceof XSDParticle) - { - if (parent.getContainer() instanceof XSDModelGroup) - { - XSDModelGroup modelGroup = (XSDModelGroup) ((XSDParticle) parent).getContainer(); - - modelGroup.getContents().remove(parent); - } - else if (parent.getContainer() instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) parent.getContainer(); - complexType.setContent(null); - } - } - else if (parent instanceof XSDSchema) - { - visitor.visitSchema(target.getSchema()); - ((XSDSchema) parent).getContents().remove(target); - } - - } - else if (target instanceof XSDAttributeDeclaration) - { - if (parent instanceof XSDAttributeUse) - { - EObject obj = parent.eContainer(); - XSDComplexTypeDefinition complexType = null; - while (obj != null) - { - if (obj instanceof XSDComplexTypeDefinition) - { - complexType = (XSDComplexTypeDefinition) obj; - break; - } - obj = obj.eContainer(); - } - if (complexType != null) - { - complexType.getAttributeContents().remove(parent); - } - - if (parent.getContainer() instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) parent.getContainer(); - - attrGroup.getContents().remove(parent); - } - } - else if (parent instanceof XSDSchema) - { - visitor.visitSchema(target.getSchema()); - ((XSDSchema) parent).getContents().remove(target); - } - } - else if (target instanceof XSDAttributeGroupDefinition && parent instanceof XSDComplexTypeDefinition) - { - ((XSDComplexTypeDefinition) parent).getAttributeContents().remove(target); - } - else if (target instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumerationFacet = (XSDEnumerationFacet) target; - enumerationFacet.getSimpleTypeDefinition().getFacetContents().remove(enumerationFacet); - } - else if (target instanceof XSDWildcard) - { - if (parent instanceof XSDParticle) - { - if (parent.getContainer() instanceof XSDModelGroup) - { - XSDModelGroup modelGroup = (XSDModelGroup) ((XSDParticle) parent).getContainer(); - modelGroup.getContents().remove(parent); - } - } - else if (parent instanceof XSDComplexTypeDefinition) - { - ((XSDComplexTypeDefinition) parent).setAttributeWildcardContent(null); - } - else if (parent instanceof XSDAttributeGroupDefinition) - { - ((XSDAttributeGroupDefinition) parent).setAttributeWildcardContent(null); - } - } - else if (target instanceof XSDComplexTypeDefinition && parent instanceof XSDElementDeclaration) - { - ((XSDElementDeclaration) parent).setTypeDefinition(target.resolveSimpleTypeDefinition(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, "string")); - } - else - { - if (parent instanceof XSDSchema) - { - visitor.visitSchema(target.getSchema()); - ((XSDSchema) parent).getContents().remove(target); - } - } - - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleAddExtensionCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleAddExtensionCommand.java deleted file mode 100644 index 9e371586fa..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleAddExtensionCommand.java +++ /dev/null @@ -1,214 +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.xsd.ui.internal.common.commands; - -import java.util.List; - -import org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceTable; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDAnnotation; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class ExtensibleAddExtensionCommand extends AddExtensionCommand -{ - protected XSDElementDeclaration element; - protected Element appInfo; - protected Element newElement; - - public ExtensibleAddExtensionCommand(String label) - { - super(label); - } - - public XSDElementDeclaration getXSDElementDeclarationElement() - { - return element; - } - - public Element getNewElement() - { - return newElement; - } - - public Element getAppInfo() - { - return appInfo; - } - - public XSDSchema getXSDSchema() - { - return component.getSchema(); - } - - public void setInputs(XSDConcreteComponent input, XSDElementDeclaration element) - { - this.component = input; - this.element = element; - } - - public XSDAnnotation getXSDAnnotation() - { - if (component != null) - { - XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation(component, false); - return xsdAnnotation; - } - return null; - } - - public void execute() - { - try - { - beginRecording(component.getElement()); - super.execute(); - doPreprocessing(); - addExtensionNode(); - doCustomizedActions(); - - formatChild(component.getElement()); - } - finally - { - endRecording(); - } - } - - protected void doPreprocessing() - { - - } - - protected void addExtensionNode() - { - XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation(component, true); - XSDSchema schema= xsdAnnotation.getSchema(); - Element schemaElement = schema.getElement(); - - if (xsdAnnotation.getApplicationInformation().size() == 0) - { - appInfo = xsdAnnotation.createApplicationInformation(null); - xsdAnnotation.getElement().appendChild(appInfo); - List appInfos = xsdAnnotation.getApplicationInformation(); - appInfos.add(appInfo); - } - else - { - // use the first appInfo - appInfo = (Element)xsdAnnotation.getApplicationInformation().get(0); - } - - if (appInfo != null) - { - Document doc = appInfo.getOwnerDocument(); - String prefix = addToNamespaceTable(schemaElement); - newElement = doc.createElementNS(extensionsSchemaSpec.getNamespaceURI(), element.getName()); - newElement.setPrefix(prefix); - appInfo.appendChild(newElement); - - xsdAnnotation.updateElement(); - } - } - - protected String addToNamespaceTable(Element schemaElement) - { - String prefix = addNamespaceDeclarationIfRequired(schemaElement, "p", extensionsSchemaSpec.getNamespaceURI()); - return prefix; - } - - - protected void doCustomizedActions() - { - - } - - public void undo() - { - super.undo(); - } - - public Object getNewObject() - { - return newElement; - } - - // TODO... common this up with wsdl.ui - protected String addNamespaceDeclarationIfRequired(Element schemaElement, String prefixHint, String namespace) - { - String prefix = null; - NamespaceTable namespaceTable = new NamespaceTable(schemaElement.getOwnerDocument()); - namespaceTable.addElement(schemaElement); - prefix = namespaceTable.getPrefixForURI(namespace); - if (prefix == null) - { - String basePrefix = prefixHint; - prefix = basePrefix; - String xmlnsColon = "xmlns:"; //$NON-NLS-1$ - String attributeName = xmlnsColon + prefix; - int count = 0; - while (schemaElement.getAttribute(attributeName) != null) - { - count++; - prefix = basePrefix + count; - attributeName = xmlnsColon + prefix; - } - schemaElement.setAttribute(attributeName, namespace); - } - return prefix; - } - - protected void addSchemaAttribute(Element schemaElement, String namespace, String attributeName, String attributeValue) - { - String prefix = null; - NamespaceTable namespaceTable = new NamespaceTable(schemaElement.getOwnerDocument()); - namespaceTable.addElement(schemaElement); - prefix = namespaceTable.getPrefixForURI(namespace); - try - { - if (prefix != null) - { - if (schemaElement.getAttributeNode(prefix + ":" + attributeName) == null) - schemaElement.setAttribute(prefix + ":" + attributeName, attributeValue); - } - else - { - if (schemaElement.getAttributeNode(attributeName) == null) - schemaElement.setAttribute(attributeName, attributeValue); - } - } - catch (Exception e) - { - - } - } - - protected void addSourceAttributeToAppInfo(String namespace) - { - if (appInfo.getAttributeNode(XSDConstants.SOURCE_ATTRIBUTE) == null) - appInfo.setAttribute(XSDConstants.SOURCE_ATTRIBUTE, namespace); - } - - /** - * - * @param element - * @param attributeName - * @param attributeValue - */ - protected void addAttribute(Element element, String attributeName, String attributeValue) - { - element.setAttribute(attributeName, attributeValue); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleRemoveExtensionNodeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleRemoveExtensionNodeCommand.java deleted file mode 100644 index cb5ff38f82..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/ExtensibleRemoveExtensionNodeCommand.java +++ /dev/null @@ -1,94 +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.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Attr; -import org.w3c.dom.Node; - -public class ExtensibleRemoveExtensionNodeCommand extends BaseCommand -{ - protected Node node; - protected XSDConcreteComponent input; - - public ExtensibleRemoveExtensionNodeCommand(String label) - { - super(label); - } - - public void setNode(Node node) - { - this.node = node; - } - - public XSDConcreteComponent getInput() - { - return input; - } - - public void setInput(XSDConcreteComponent input) - { - this.input = input; - } - - public void execute() - { - super.execute(); - try - { - beginRecording(node); - - doPreprocessing(); - - if (node.getNodeType() == Node.ATTRIBUTE_NODE) - { - Attr attr = (Attr) node; - attr.getOwnerElement().removeAttributeNode(attr); - } - else if (node.getNodeType() == Node.ELEMENT_NODE) - { - Node parent = node.getParentNode(); - if (parent != null) - { - XSDDOMHelper.removeNodeAndWhitespace(node); - - if (XSDDOMHelper.hasOnlyWhitespace(parent)) - { - if (XSDConstants.APPINFO_ELEMENT_TAG.equals(parent.getLocalName())) - { - XSDDOMHelper.removeNodeAndWhitespace(parent); - } - } - } - } - - doCustomizedActions(); - - } - finally - { - endRecording(); - } - } - - protected void doPreprocessing() - { - - } - - protected void doCustomizedActions() - { - - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionAttributerCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionAttributerCommand.java deleted file mode 100644 index a173a43def..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionAttributerCommand.java +++ /dev/null @@ -1,43 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.gef.commands.Command; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; - -/** - * @deprecated - */ -public class RemoveExtensionAttributerCommand extends Command -{ - Element hostElement; - Attr attr; - - public RemoveExtensionAttributerCommand(String label, Element hostElement, Attr attr) - { - super(label); - this.hostElement = hostElement; - this.attr = attr; - } - - public void execute() - { - super.execute(); - hostElement.removeAttributeNode(attr); - } - - public void undo() - { - super.undo(); - //TODO implement me - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionElementCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionElementCommand.java deleted file mode 100644 index d33c756093..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionElementCommand.java +++ /dev/null @@ -1,46 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.gef.commands.Command; -import org.eclipse.xsd.XSDAnnotation; -import org.w3c.dom.Node; - -/** - * @deprecated - */ -public class RemoveExtensionElementCommand extends Command -{ - XSDAnnotation xsdAnnotation; - Node appInfo; - - public RemoveExtensionElementCommand(String label, XSDAnnotation xsdAnnotation, Node appInfo) - { - super(label); - this.xsdAnnotation = xsdAnnotation; - this.appInfo = appInfo; - } - - public void execute() - { - super.execute(); - xsdAnnotation.getApplicationInformation().remove(appInfo); - xsdAnnotation.getElement().removeChild(appInfo); - xsdAnnotation.updateElement(); - } - - public void undo() - { - super.undo(); - xsdAnnotation.getApplicationInformation().add(appInfo); - xsdAnnotation.getElement().appendChild(appInfo); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionNodeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionNodeCommand.java deleted file mode 100644 index 2626cb36ba..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/RemoveExtensionNodeCommand.java +++ /dev/null @@ -1,61 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Attr; -import org.w3c.dom.Node; - -public class RemoveExtensionNodeCommand extends BaseCommand -{ - Node node; - - public RemoveExtensionNodeCommand(String label, Node node) - { - super(label); - this.node = node; - } - - public void execute() - { - super.execute(); - try - { - beginRecording(node); - if (node.getNodeType() == Node.ATTRIBUTE_NODE) - { - Attr attr = (Attr) node; - attr.getOwnerElement().removeAttributeNode(attr); - } - else if (node.getNodeType() == Node.ELEMENT_NODE) - { - Node parent = node.getParentNode(); - if (parent != null) - { - XSDDOMHelper.removeNodeAndWhitespace(node); - - if (XSDDOMHelper.hasOnlyWhitespace(parent)) - { - if (XSDConstants.APPINFO_ELEMENT_TAG.equals(parent.getLocalName())) - { - XSDDOMHelper.removeNodeAndWhitespace(parent); - } - } - } - } - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeAndManagerDirectivesCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeAndManagerDirectivesCommand.java deleted file mode 100644 index 82aa5efe21..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeAndManagerDirectivesCommand.java +++ /dev/null @@ -1,37 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.core.resources.IFile; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDTypeDefinition; - -public class SetBaseTypeAndManagerDirectivesCommand extends UpdateTypeReferenceAndManageDirectivesCommand -{ - - public SetBaseTypeAndManagerDirectivesCommand(XSDConcreteComponent concreteComponent, String componentName, String componentNamespace, IFile file) - { - super(concreteComponent, componentName, componentNamespace, file); - } - - public void execute() - { - try - { - beginRecording(concreteComponent.getElement()); - XSDComponent td = computeComponent(); - if (td != null && td instanceof XSDTypeDefinition) - { - SetBaseTypeCommand command = new SetBaseTypeCommand(concreteComponent, (XSDTypeDefinition) td); - command.execute(); - } - } - catch (Exception e) - { - - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeCommand.java deleted file mode 100644 index e1106e52e8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetBaseTypeCommand.java +++ /dev/null @@ -1,85 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDDerivationMethod; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDVariety; - -public class SetBaseTypeCommand extends BaseCommand -{ - XSDConcreteComponent concreteComponent; - XSDTypeDefinition baseType; - XSDBaseAdapter adapter; - - - public SetBaseTypeCommand(XSDConcreteComponent concreteComponent, XSDTypeDefinition baseType) - { - super(Messages._UI_ACTION_SET_BASE_TYPE); - this.concreteComponent = concreteComponent; - this.baseType = baseType; - } - - public void execute() - { - try - { - beginRecording(concreteComponent.getElement()); - if (concreteComponent instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) concreteComponent; - - if (baseType instanceof XSDSimpleTypeDefinition) - { - if (!(complexType.getContent() instanceof XSDSimpleTypeDefinition)) - { - XSDSimpleTypeDefinition simpleContent = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - complexType.setContent(simpleContent); - } - } - - complexType.setBaseTypeDefinition(baseType); - complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); - formatChild(complexType.getElement()); - } - else if (concreteComponent instanceof XSDSimpleTypeDefinition) - { - XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) concreteComponent; - if (baseType instanceof XSDSimpleTypeDefinition) - { - XSDVariety variety = simpleType.getVariety(); - if (variety.getValue() == XSDVariety.ATOMIC) - { - simpleType.setBaseTypeDefinition((XSDSimpleTypeDefinition) baseType); - } - else if (variety.getValue() == XSDVariety.UNION) - { - simpleType.getMemberTypeDefinitions().add(baseType); - } - else if (variety.getValue() == XSDVariety.LIST) - { - simpleType.setItemTypeDefinition((XSDSimpleTypeDefinition) baseType); - } - } - } - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetMultiplicityCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetMultiplicityCommand.java deleted file mode 100644 index 1679feca03..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetMultiplicityCommand.java +++ /dev/null @@ -1,70 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDParticleContent; - -public class SetMultiplicityCommand extends BaseCommand -{ - XSDConcreteComponent parent; - int maxOccurs, minOccurs; - - /** - * @param parent - */ - public SetMultiplicityCommand(String label) - { - super(label); - } - - public void setMaxOccurs(int i) - { - maxOccurs=i; - } - - public void setMinOccurs(int i) - { - minOccurs=i; - } - - public void setXSDConcreteComponent(XSDConcreteComponent parent) - { - this.parent = parent; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.xsd.ui.internal.commands.AbstractCommand#run() - */ - public void execute() - { - try - { - beginRecording(parent.getElement()); - if (parent instanceof XSDParticleContent) - { - XSDParticleContent xsdParticleContent = (XSDParticleContent) parent; - XSDParticle xsdParticle = (XSDParticle) xsdParticleContent.getContainer(); - if (maxOccurs < 0) - { - maxOccurs = XSDParticle.UNBOUNDED; - } - xsdParticle.setMaxOccurs(maxOccurs); - xsdParticle.setMinOccurs(minOccurs); - } - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetTypeCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetTypeCommand.java deleted file mode 100644 index da4cb49c22..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetTypeCommand.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.jface.window.Window; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.actions.SetTypeAction; -import org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; - -public class SetTypeCommand extends BaseCommand -{ - XSDConcreteComponent parent; - private boolean continueApply; - XSDBaseAdapter adapter; - String action; - - public SetTypeCommand(String label, String ID, XSDConcreteComponent parent) - { - super(label); - this.parent = parent; - this.action = ID; - } - - public void setAdapter(XSDBaseAdapter adapter) - { - this.adapter = adapter; - } - - public void execute() - { - try - { - beginRecording(parent.getElement()); - ComponentReferenceEditManager componentReferenceEditManager = getComponentReferenceEditManager(); - continueApply = true; - if (parent instanceof XSDElementDeclaration) - { - if (action.equals(SetTypeAction.SET_NEW_TYPE_ID)) - { - ComponentSpecification newValue = (ComponentSpecification) invokeDialog(componentReferenceEditManager.getNewDialog()); - if (continueApply) - componentReferenceEditManager.modifyComponentReference(adapter, newValue); - } - else - { - ComponentSpecification newValue = (ComponentSpecification) invokeDialog(componentReferenceEditManager.getBrowseDialog()); - if (continueApply) - componentReferenceEditManager.modifyComponentReference(adapter, newValue); - } - formatChild(parent.getElement()); - } - } - finally - { - endRecording(); - } - } - - private Object invokeDialog(IComponentDialog dialog) - { - Object newValue = null; - - if (dialog == null) - { - return null; - } - - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - } - else - { - continueApply = false; - } - - return newValue; - } - - protected ComponentReferenceEditManager getComponentReferenceEditManager() - { - ComponentReferenceEditManager result = null; - IEditorPart editor = getActiveEditor(); - if (editor != null) - { - result = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class); - } - return result; - } - - private IEditorPart getActiveEditor() - { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - return editorPart; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetXSDFacetValueCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetXSDFacetValueCommand.java deleted file mode 100644 index 3d71717f71..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/SetXSDFacetValueCommand.java +++ /dev/null @@ -1,43 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFacet; - -public class SetXSDFacetValueCommand extends BaseCommand -{ - protected XSDFacet facet; - protected String value; - - public SetXSDFacetValueCommand(String label, XSDFacet facet) - { - super(label); - this.facet = facet; - } - - public void setValue(String value) - { - this.value = value; - } - - public void execute() - { - try - { - beginRecording(facet.getElement()); - facet.setLexicalValue(value); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateAttributeValueCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateAttributeValueCommand.java deleted file mode 100644 index f6dbe8117f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateAttributeValueCommand.java +++ /dev/null @@ -1,70 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.w3c.dom.Element; - -/* - * This command is used from the extension view to edit extension elements - * and attributes which are implemented as DOM objects (not part of the EMF model) - * - * (trung) also used in XSDComplexTypeAdvancedSection to change attribute of - * specical attributes like block, restriction which is not part of EMF Model - */ -public class UpdateAttributeValueCommand extends BaseCommand -{ - Element element; - String attributeName; - String attributeValue; - - /** Whether the attribute should be deleted if value to - * be set is an empty String or null */ - protected boolean deleteIfValueEmpty = false; - - public UpdateAttributeValueCommand(Element element, String attributeName, String attributeValue, boolean deleteIfValueEmpty) - { - this.element = element; - this.attributeName = attributeName; - this.attributeValue = attributeValue; - this.deleteIfValueEmpty = deleteIfValueEmpty; - } - - public UpdateAttributeValueCommand(Element element, String attributeName, String attributeValue) - { - this(element, attributeName, attributeValue, false); - } - - public void setDeleteIfEmpty(boolean v) - { - deleteIfValueEmpty = v; - } - - public void execute() - { - try - { - beginRecording(element); - if (deleteIfValueEmpty && - (attributeValue == null || attributeValue.equals("") ) ) - { - element.removeAttribute(attributeName); - } - else - { - element.setAttribute(attributeName, attributeValue); - } - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComplexTypeDerivationBy.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComplexTypeDerivationBy.java deleted file mode 100644 index 6c0bbab47c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComplexTypeDerivationBy.java +++ /dev/null @@ -1,51 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDDerivationMethod; -import org.eclipse.xsd.util.XSDConstants; - -public class UpdateComplexTypeDerivationBy extends BaseCommand -{ - private XSDComplexTypeDefinition complexType; - private String derivation; - - public UpdateComplexTypeDerivationBy(XSDComplexTypeDefinition complexType, String derivation) - { - this.complexType = complexType; - this.derivation = derivation; - // TODO: use new Message bundle mechanism - setLabel(XSDEditorPlugin.getXSDString("_UI_DERIVEDBY_CHANGE")); - } - - public void execute() - { - super.execute(); - try - { - beginRecording(complexType.getElement()); - if (derivation.equals(XSDConstants.EXTENSION_ELEMENT_TAG)) - { - complexType.setDerivationMethod(XSDDerivationMethod.EXTENSION_LITERAL); - } - else if (derivation.equals(XSDConstants.RESTRICTION_ELEMENT_TAG)) - { - complexType.setDerivationMethod(XSDDerivationMethod.RESTRICTION_LITERAL); - } - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComponentReferenceAndManageDirectivesCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComponentReferenceAndManageDirectivesCommand.java deleted file mode 100644 index b7b74c7a0f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateComponentReferenceAndManageDirectivesCommand.java +++ /dev/null @@ -1,150 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSchemaDirective; -import org.eclipse.xsd.util.XSDResourceImpl; -public abstract class UpdateComponentReferenceAndManageDirectivesCommand extends BaseCommand -{ - protected XSDConcreteComponent concreteComponent; - protected String componentName; - protected String componentNamespace; - protected IFile file; - - public UpdateComponentReferenceAndManageDirectivesCommand(XSDConcreteComponent concreteComponent, String componentName, String componentNamespace, IFile file) - { - this.concreteComponent = concreteComponent; - this.componentName = componentName; - this.componentNamespace = componentNamespace; - this.file = file; - } - - protected XSDComponent computeComponent() - { - XSDComponent result = null; - XSDSchema schema = concreteComponent.getSchema(); - XSDSchemaDirective directive = null; - - // lets see if the element is already visible to our schema - result = getDefinedComponent(schema, componentName, componentNamespace); - if (result == null) - { - // TODO (cs) we need to provide a separate command to do this part - // - // apparently the element is not yet visible, we need to add - // includes/imports to get to it - if (componentNamespace != null && componentNamespace.equals(schema.getTargetNamespace())) - { - // we need to add an include - // if the component's namespace is not null and matches the schema's - // target namespace - directive = XSDFactory.eINSTANCE.createXSDInclude(); - } - else if (componentNamespace == null) - { - // we need to add an include - // if the component's namespace is null, then we can just add it - // only if the current namespace is not null - directive = XSDFactory.eINSTANCE.createXSDInclude(); - - // we have to ensure the schema for schema prefix is NOT null - if (schema.getSchemaForSchemaQNamePrefix() == null) - { - String targetNS = schema.getTargetNamespace(); - if (targetNS == null) - targetNS = ""; - // this will just update the schema for schema prefix to be, say, xsd - UpdateNamespaceInformationCommand command = new UpdateNamespaceInformationCommand("", schema, "", targetNS); - command.execute(); - } - } - else - { - // we need to add an import - XSDImport xsdImport = XSDFactory.eINSTANCE.createXSDImport(); - xsdImport.setNamespace(componentNamespace); - directive = xsdImport; - } - - String location = computeNiceLocation(schema.getSchemaLocation(), file); - directive.setSchemaLocation(location); - // TODO (cs) we should at the directive 'next' in the list of directives - // for now I'm just adding as the first thing in the schema :-( - // - schema.getContents().add(0, directive); - XSDSchema resolvedSchema = directive.getResolvedSchema(); - if (resolvedSchema == null) - { - String platformLocation = "platform:/resource" + file.getFullPath(); - Resource resource = concreteComponent.eResource().getResourceSet().createResource(URI.createURI(platformLocation)); - if (resource instanceof XSDResourceImpl) - { - try - { - resource.load(null); - XSDResourceImpl resourceImpl = (XSDResourceImpl) resource; - resolvedSchema = resourceImpl.getSchema(); - if (resolvedSchema != null) - { - directive.setResolvedSchema(resolvedSchema); - } - } - catch (Exception e) - { - } - } - } - if (resolvedSchema != null) - { - result = getDefinedComponent(resolvedSchema, componentName, componentNamespace); - } - else - { - // TODO (cs) consider setting some error state so that the client can - // provide a pop-dialog error - // we should also remove the import/include so save from cluttering - // the file with bogus directives - } - } - - return result; - } - - private final static String PLATFORM_RESOURCE_PREFIX = "platform:/resource"; - private String computeNiceLocation(String baseLocation, IFile file) - { - if (baseLocation.startsWith(PLATFORM_RESOURCE_PREFIX)) - { - URI baseURI = URI.createURI(baseLocation); - URI fileURI = URI.createPlatformResourceURI(file.getFullPath().toString()); - URI relative = fileURI.deresolve(baseURI, false, true, true); - return relative.toString(); - } - else - { - URI baseURI = URI.createURI(baseLocation); - URI fileURI = URI.createFileURI(file.getLocation().toOSString()); - URI relative = fileURI.deresolve(baseURI, false, true, true); - return relative.toString(); - } - } - - protected abstract XSDComponent getDefinedComponent(XSDSchema schema, String componentName, String componentNamespace); - - public abstract void execute(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateContentModelCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateContentModelCommand.java deleted file mode 100644 index 87a560efbb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateContentModelCommand.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDModelGroup; - -public class UpdateContentModelCommand extends BaseCommand -{ - XSDModelGroup xsdModelGroup; - XSDCompositor oldXSDCompositor, newXSDCompositor; - - - public UpdateContentModelCommand(String label, XSDModelGroup xsdModelGroup, XSDCompositor xsdCompositor) - { - super(label); - this.xsdModelGroup = xsdModelGroup; - this.newXSDCompositor = xsdCompositor; - this.oldXSDCompositor = xsdModelGroup.getCompositor(); - } - - - public void execute() - { - try - { - super.execute(); - beginRecording(xsdModelGroup.getElement()); - xsdModelGroup.setCompositor(newXSDCompositor); - } - finally - { - endRecording(); - } - } - - public void undo() - { - xsdModelGroup.setCompositor(oldXSDCompositor); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceAndManageDirectivesCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceAndManageDirectivesCommand.java deleted file mode 100644 index d2801815cb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceAndManageDirectivesCommand.java +++ /dev/null @@ -1,57 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; -import org.eclipse.core.resources.IFile; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; - -public class UpdateElementReferenceAndManageDirectivesCommand extends UpdateComponentReferenceAndManageDirectivesCommand -{ - public UpdateElementReferenceAndManageDirectivesCommand(XSDConcreteComponent concreteComponent, String componentName, String componentNamespace, IFile file) - { - super(concreteComponent, componentName, componentNamespace, file); - } - - protected XSDComponent getDefinedComponent(XSDSchema schema, String componentName, String componentNamespace) - { - XSDElementDeclaration result = schema.resolveElementDeclaration(componentNamespace, componentName); - if (result.eContainer() == null) - { - result = null; - } - return result; - } - - public void execute() - { - try - { - beginRecording(concreteComponent.getElement()); - XSDComponent elementDef = computeComponent(); - if (elementDef != null) - { - UpdateElementReferenceCommand command = new UpdateElementReferenceCommand(Messages._UI_ACTION_UPDATE_ELEMENT_REFERENCE, (XSDElementDeclaration) concreteComponent, - (XSDElementDeclaration) elementDef); - command.execute(); - } - } - catch (Exception e) - { - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceCommand.java deleted file mode 100644 index d4b52781f4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateElementReferenceCommand.java +++ /dev/null @@ -1,39 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDElementDeclaration; - -public class UpdateElementReferenceCommand extends BaseCommand -{ - XSDElementDeclaration element, ref; - - public UpdateElementReferenceCommand(String label, XSDElementDeclaration element, XSDElementDeclaration ref) - { - super(label); - this.element = element; - this.ref = ref; - } - - public void execute() - { - try - { - beginRecording(element.getElement()); - element.setResolvedElementDeclaration(ref); - } - finally - { - endRecording(); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMaxOccursCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMaxOccursCommand.java deleted file mode 100644 index c49051f2bf..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMaxOccursCommand.java +++ /dev/null @@ -1,65 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class UpdateMaxOccursCommand extends BaseCommand -{ - private int oldMaxOccurs; - private int newMaxOccurs; - private boolean removeMaxOccursAttribute; - - XSDParticle particle; - - public UpdateMaxOccursCommand(String label, XSDParticle particle, int MaxOccurs) - { - super(label); - this.newMaxOccurs = MaxOccurs; - this.particle = particle; - } - - public void execute() - { - try - { - Element element = particle.getElement(); - beginRecording(element); - String currentMax = element.getAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE); - removeMaxOccursAttribute = (currentMax == null)? true: false; - oldMaxOccurs = particle.getMaxOccurs(); - particle.setMaxOccurs(newMaxOccurs); - } - finally - { - endRecording(); - } - } - - public void redo() - { - execute(); - } - - public void undo() - { - if (removeMaxOccursAttribute) - { - particle.unsetMaxOccurs(); - } - else - { - particle.setMaxOccurs(oldMaxOccurs); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMinOccursCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMinOccursCommand.java deleted file mode 100644 index 364523f4bb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateMinOccursCommand.java +++ /dev/null @@ -1,92 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDAttributeUseCategory; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class UpdateMinOccursCommand extends BaseCommand -{ - private int oldMinOccurs; - private int newMinOccurs; - private boolean removeMinOccursAttribute; - - XSDComponent component; - - public UpdateMinOccursCommand(String label, XSDComponent component, int minOccurs) - { - super(label); - this.newMinOccurs = minOccurs; - this.component = component; - } - - public void execute() - { - Element element = component.getElement(); - try - { - beginRecording(element); - String currentMin = element.getAttribute(XSDConstants.MINOCCURS_ATTRIBUTE); - removeMinOccursAttribute = (currentMin == null) ? true : false; - - if (component instanceof XSDParticle) - { - oldMinOccurs = ((XSDParticle) component).getMinOccurs(); - ((XSDParticle) component).setMinOccurs(newMinOccurs); - } - else if (component instanceof XSDAttributeUse) - { - oldMinOccurs = (((XSDAttributeUse) component).getUse() == XSDAttributeUseCategory.REQUIRED_LITERAL ? 1 : 0); - if (newMinOccurs == 1) - ((XSDAttributeUse) component).setUse(XSDAttributeUseCategory.REQUIRED_LITERAL); - else - ((XSDAttributeUse) component).setUse(XSDAttributeUseCategory.OPTIONAL_LITERAL); - } - } - finally - { - endRecording(); - } - } - - public void undo() - { - if (component instanceof XSDParticle) - { - if (removeMinOccursAttribute) - { - ((XSDParticle) component).unsetMinOccurs(); - } - else - { - ((XSDParticle) component).setMinOccurs(oldMinOccurs); - } - } - else if (component instanceof XSDAttributeUse) - { - if (removeMinOccursAttribute) - { - ((XSDParticle) component).unsetMinOccurs(); - } - else - { - if (oldMinOccurs == 1) - ((XSDAttributeUse) component).setUse(XSDAttributeUseCategory.REQUIRED_LITERAL); - else - ((XSDAttributeUse) component).setUse(XSDAttributeUseCategory.OPTIONAL_LITERAL); - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.java deleted file mode 100644 index 064207d684..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNameCommand.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.ltk.core.refactoring.participants.RenameRefactoring; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; -import org.eclipse.wst.xsd.ui.internal.refactor.PerformUnsavedRefactoringOperation; -import org.eclipse.wst.xsd.ui.internal.refactor.RefactoringComponent; -import org.eclipse.wst.xsd.ui.internal.refactor.XMLRefactoringComponent; -import org.eclipse.wst.xsd.ui.internal.refactor.rename.RenameComponentProcessor; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDSchema; - -public class UpdateNameCommand extends BaseCommand -{ -// private String oldName; - private String newName; - private XSDNamedComponent component; - - public UpdateNameCommand(String label, XSDNamedComponent component, String newName) - { - super(label); - - if (component instanceof XSDComplexTypeDefinition && component.getName() == null && component.eContainer() instanceof XSDNamedComponent && ((XSDNamedComponent) component.eContainer()).getName() != null) - { - component = (XSDNamedComponent) component.eContainer(); - } - - this.component = component; - this.newName = newName; -// this.oldName = component.getName(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.gef.commands.Command#execute() - */ - public void execute() - { - try - { - beginRecording(component.getElement()); - renameComponent(newName); - } - finally - { - endRecording(); - } - } - - /** - * Performs a rename refactoring to rename the component and all the - * references to it within the current schema. - * - * @param newName the new component name. - */ - private void renameComponent(String newName) - { - // this is a 'globally' defined component (e.g. global element) - if (component.eContainer() instanceof XSDSchema) - { - RefactoringComponent refactoringComponent = new XMLRefactoringComponent( - component, - (IDOMElement)component.getElement(), - component.getName(), - component.getTargetNamespace()); - - RenameComponentProcessor processor = new RenameComponentProcessor(refactoringComponent, newName, true); - RenameRefactoring refactoring = new RenameRefactoring(processor); - PerformUnsavedRefactoringOperation operation = new PerformUnsavedRefactoringOperation(refactoring); - operation.run(null); - } - else - { - // this is a 'locally' defined component (e.g. local element) - // no need to call refactoring since this component can't be referenced - component.setName(newName); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNamespaceInformationCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNamespaceInformationCommand.java deleted file mode 100644 index f0791b67db..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNamespaceInformationCommand.java +++ /dev/null @@ -1,298 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import java.net.URI; -import java.net.URISyntaxException; -import java.util.Collection; -import java.util.Iterator; -import java.util.Map; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.emf.ecore.EReference; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.nsedit.TargetNamespaceChangeHandler; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class UpdateNamespaceInformationCommand extends BaseCommand -{ - protected XSDSchema xsdSchema; - protected String newPrefix, newTargetNamespace; - - public UpdateNamespaceInformationCommand(String label, XSDSchema xsdSchema, String newPrefix, String newTargetNamespace) - { - super(label); - this.xsdSchema = xsdSchema; - this.newPrefix = newPrefix; - this.newTargetNamespace = newTargetNamespace; - } - - public void execute() - { - ensureSchemaElement(xsdSchema); - - Element element = xsdSchema.getElement(); - try - { - //DocumentImpl doc = (DocumentImpl) element.getOwnerDocument(); - - String modelTargetNamespace = xsdSchema.getTargetNamespace(); - String oldNamespace = xsdSchema.getTargetNamespace(); - - TypesHelper helper = new TypesHelper(xsdSchema); - String oldPrefix = helper.getPrefix(element.getAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE), false); - - if (modelTargetNamespace == null) - { - modelTargetNamespace = ""; //$NON-NLS-1$ - } - - String targetNamespace = newTargetNamespace.trim(); - String prefix = newPrefix.trim(); - - if (!validatePrefix(prefix) || !validateTargetNamespace(targetNamespace)) - { - return; - } - - if (prefix.length() > 0 && targetNamespace.length() == 0) - { - // can't have blank targetnamespace and yet specify a prefix - return; - } - - //doc.getModel().beginRecording(this, XSDEditorPlugin.getXSDString("_UI_TARGETNAMESPACE_CHANGE")); //$NON-NLS-1$ - beginRecording(element); - - String xsdForXSDPrefix = xsdSchema.getSchemaForSchemaQNamePrefix(); - Map map = xsdSchema.getQNamePrefixToNamespaceMap(); - - // Check if prefix is blank - // if it is, then make sure we have a prefix - // for schema for schema - if (prefix.length() == 0) - { - // if prefix for schema for schema is blank - // then set it to value specified in preference - // and update ALL nodes with this prefix - if (xsdForXSDPrefix == null || (xsdForXSDPrefix != null && xsdForXSDPrefix.trim().length() == 0)) - { - // get preference prefix - xsdForXSDPrefix = XSDEditorPlugin.getPlugin().getXMLSchemaPrefix(); - // get a unique prefix by checking what's in the map - - xsdForXSDPrefix = getUniqueSchemaForSchemaPrefix(xsdForXSDPrefix, map); - element.setAttribute("xmlns:" + xsdForXSDPrefix, XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001); //$NON-NLS-1$ - - updateAllNodes(element, xsdForXSDPrefix); - - // remove the old xmlns attribute for the schema for schema - if (element.getAttribute("xmlns") != null && //$NON-NLS-1$ - element.getAttribute("xmlns").equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) //$NON-NLS-1$ - { - element.removeAttribute("xmlns"); //$NON-NLS-1$ - } - } - } - - if (targetNamespace.length() > 0 || (targetNamespace.length() == 0 && prefix.length() == 0)) - { - // clean up the old prefix for this schema - if (oldPrefix != null && oldPrefix.length() > 0) - { - element.removeAttribute("xmlns:" + oldPrefix); //$NON-NLS-1$ - // element.setAttribute("xmlns:" + prefix, targetNamespace); - // java.util.Map prefixToNameSpaceMap = - // xsdSchema.getQNamePrefixToNamespaceMap(); - // prefixToNameSpaceMap.remove(oldPrefix); - } - else - // if no prefix - { - if (element.getAttribute("xmlns") != null) //$NON-NLS-1$ - { - if (!element.getAttribute("xmlns").equals(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001)) //$NON-NLS-1$ - { - element.removeAttribute("xmlns"); //$NON-NLS-1$ - } - } - } - } - - if (targetNamespace.length() > 0) - { - if (!modelTargetNamespace.equals(targetNamespace)) - { - element.setAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE, targetNamespace); - } - // now set the new xmlns:prefix attribute - if (prefix.length() > 0) - { - element.setAttribute("xmlns:" + prefix, targetNamespace); //$NON-NLS-1$ - } - else - { - element.setAttribute("xmlns", targetNamespace); //$NON-NLS-1$ - } - // set the targetNamespace attribute - } - else - // else targetNamespace is blank - { - if (prefix.length() == 0) - { - element.removeAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE); - } - } - - // do our own referential integrity - TargetNamespaceChangeHandler targetNamespaceChangeHandler = new TargetNamespaceChangeHandler(xsdSchema, oldNamespace, targetNamespace); - targetNamespaceChangeHandler.resolve(); - - updateElement(xsdSchema); - - //doc.getModel().endRecording(this); - } - finally - { - endRecording(); - } - } - - - // issue (cs) I don't have a clue why we need to call this method - // - private static void updateElement(XSDConcreteComponent concreteComp) - { - try - { - concreteComp.updateElement(); - } - catch (Exception e) - { - for (Iterator containments = concreteComp.eClass().getEAllReferences().iterator(); containments.hasNext(); ) - { - EReference eReference = (EReference)containments.next(); - if (eReference.isContainment()) - { - if (eReference.isMany()) - { - for (Iterator objects = ((Collection)concreteComp.eGet(eReference)).iterator(); objects.hasNext(); ) - { - XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent)objects.next(); - try - { - xsdConcreteComponent.updateElement(); - } - catch (Exception ex) {} - } - } - else - { - XSDConcreteComponent xsdConcreteComponent = (XSDConcreteComponent)concreteComp.eGet(eReference); - if (xsdConcreteComponent != null) - { - try - { - xsdConcreteComponent.updateElement(); - } - catch (Exception ex) {} - } - } - } - } - } - } - private String getUniqueSchemaForSchemaPrefix(String xsdForXSDPrefix, Map map) - { - if (xsdForXSDPrefix == null || (xsdForXSDPrefix != null && xsdForXSDPrefix.trim().length() == 0)) - { - xsdForXSDPrefix = "xsd"; //$NON-NLS-1$ - } - // ensure prefix is unique - int prefixExtension = 1; - while (map.containsKey(xsdForXSDPrefix) && prefixExtension < 100) - { - xsdForXSDPrefix = xsdForXSDPrefix + String.valueOf(prefixExtension); - prefixExtension++; - } - return xsdForXSDPrefix; - } - - private void updateAllNodes(Element element, String prefix) - { - element.setPrefix(prefix); - NodeList list = element.getChildNodes(); - if (list != null) - { - for (int i = 0; i < list.getLength(); i++) - { - Node child = list.item(i); - if (child != null && child instanceof Element) - { - child.setPrefix(prefix); - if (child.hasChildNodes()) - { - updateAllNodes((Element) child, prefix); - } - } - } - } - } - - private boolean validateTargetNamespace(String ns) - { - // will allow blank namespace !! - if (ns.equals("")) //$NON-NLS-1$ - { - return true; - } - - String errorMessage = null; - try - { - URI testURI = new URI(ns); - testURI.isAbsolute(); - } - catch (URISyntaxException e) - { - errorMessage = XSDEditorPlugin.getXSDString("_WARN_INVALID_TARGET_NAMESPACE"); //$NON-NLS-1$ - } - - if (errorMessage == null || errorMessage.length() == 0) - { - return true; - } - return false; - } - - protected boolean validatePrefix(String prefix) - { - if (prefix != null && prefix.equals("")) return true; - return XMLChar.isValidNCName(prefix); - } - - public void redo() - { - execute(); - } - - public void undo() - { - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNumericBoundsFacetCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNumericBoundsFacetCommand.java deleted file mode 100644 index 0f5cea91e8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateNumericBoundsFacetCommand.java +++ /dev/null @@ -1,168 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDMaxExclusiveFacet; -import org.eclipse.xsd.XSDMaxInclusiveFacet; -import org.eclipse.xsd.XSDMinExclusiveFacet; -import org.eclipse.xsd.XSDMinInclusiveFacet; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - -public class UpdateNumericBoundsFacetCommand extends BaseCommand -{ - XSDSimpleTypeDefinition xsdSimpleType; - String max, min; - boolean includeMin, includeMax; - private boolean doUpdateMax = false, doUpdateMin = false; - XSDMinInclusiveFacet minInclusiveFacet; - XSDMinExclusiveFacet minExclusiveFacet; - XSDMaxInclusiveFacet maxInclusiveFacet; - XSDMaxExclusiveFacet maxExclusiveFacet; - - - public UpdateNumericBoundsFacetCommand(String label, XSDSimpleTypeDefinition xsdSimpleType, boolean includeMin, boolean includeMax) - { - super(label); - this.xsdSimpleType = xsdSimpleType; - this.includeMin = includeMin; - this.includeMax = includeMax; - - minInclusiveFacet = xsdSimpleType.getMinInclusiveFacet(); - minExclusiveFacet = xsdSimpleType.getMinExclusiveFacet(); - maxInclusiveFacet = xsdSimpleType.getMaxInclusiveFacet(); - maxExclusiveFacet = xsdSimpleType.getMaxExclusiveFacet(); - - } - - public void setMin(String min) - { - this.min = min; - doUpdateMin = true; - } - - public void setMax(String max) - { - this.max = max; - doUpdateMax = true; - } - - public void execute() - { - try - { - beginRecording(xsdSimpleType.getElement()); - - if (doUpdateMin) - { - if (includeMin) - { - if (minInclusiveFacet == null && min != null) - { - minInclusiveFacet = XSDFactory.eINSTANCE.createXSDMinInclusiveFacet(); - minInclusiveFacet.setLexicalValue(min); - xsdSimpleType.getFacetContents().add(minInclusiveFacet); - - if (minExclusiveFacet != null) - { - xsdSimpleType.getFacetContents().remove(minExclusiveFacet); - } - } - else if (minInclusiveFacet != null && min != null) - { - minInclusiveFacet.setLexicalValue(min); - } - else if (minInclusiveFacet != null && min == null) - { - xsdSimpleType.getFacetContents().remove(minInclusiveFacet); - } - } - else - // !includeMin - { - if (minExclusiveFacet == null && min != null) - { - minExclusiveFacet = XSDFactory.eINSTANCE.createXSDMinExclusiveFacet(); - minExclusiveFacet.setLexicalValue(min); - xsdSimpleType.getFacetContents().add(minExclusiveFacet); - - if (minInclusiveFacet != null) - { - xsdSimpleType.getFacetContents().remove(minInclusiveFacet); - } - } - else if (minExclusiveFacet != null && min != null) - { - minExclusiveFacet.setLexicalValue(min); - } - else if (minExclusiveFacet != null && min == null) - { - xsdSimpleType.getFacetContents().remove(minExclusiveFacet); - } - } - } - else if (doUpdateMax) - { - if (includeMax) - { - if (maxInclusiveFacet == null && max != null) - { - maxInclusiveFacet = XSDFactory.eINSTANCE.createXSDMaxInclusiveFacet(); - maxInclusiveFacet.setLexicalValue(max); - xsdSimpleType.getFacetContents().add(maxInclusiveFacet); - - if (maxExclusiveFacet != null) - { - xsdSimpleType.getFacetContents().remove(maxExclusiveFacet); - } - } - else if (maxInclusiveFacet != null && max != null) - { - maxInclusiveFacet.setLexicalValue(max); - } - else if (maxInclusiveFacet != null && max == null) - { - xsdSimpleType.getFacetContents().remove(maxInclusiveFacet); - } - } - else - // !includeMax - { - if (maxExclusiveFacet == null && max != null) - { - maxExclusiveFacet = XSDFactory.eINSTANCE.createXSDMaxExclusiveFacet(); - maxExclusiveFacet.setLexicalValue(max); - xsdSimpleType.getFacetContents().add(maxExclusiveFacet); - - if (maxInclusiveFacet != null) - { - xsdSimpleType.getFacetContents().remove(maxInclusiveFacet); - } - } - else if (maxExclusiveFacet != null && max != null) - { - maxExclusiveFacet.setLexicalValue(max); - } - else if (maxExclusiveFacet != null && max == null) - { - xsdSimpleType.getFacetContents().remove(maxExclusiveFacet); - } - } - } - - formatChild(xsdSimpleType.getElement()); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateStringLengthFacetCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateStringLengthFacetCommand.java deleted file mode 100644 index b5e78e9280..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateStringLengthFacetCommand.java +++ /dev/null @@ -1,230 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDLengthFacet; -import org.eclipse.xsd.XSDMaxLengthFacet; -import org.eclipse.xsd.XSDMinLengthFacet; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - -public class UpdateStringLengthFacetCommand extends BaseCommand -{ - XSDSimpleTypeDefinition xsdSimpleType; - String max, min; - private boolean doUpdateMax = false, doUpdateMin = false; - - public UpdateStringLengthFacetCommand(String label, XSDSimpleTypeDefinition xsdSimpleType) - { - super(label); - this.xsdSimpleType = xsdSimpleType; - } - - public void setMin(String min) - { - this.min = min; - doUpdateMin = true; - } - - public void setMax(String max) - { - this.max = max; - doUpdateMax = true; - } - - public void execute() - { - try - { - beginRecording(xsdSimpleType.getElement()); - XSDLengthFacet lengthFacet = xsdSimpleType.getEffectiveLengthFacet(); - XSDMinLengthFacet minLengthFacet = xsdSimpleType.getEffectiveMinLengthFacet(); - XSDMaxLengthFacet maxLengthFacet = xsdSimpleType.getEffectiveMaxLengthFacet(); - - String currentLength = null, currentMin = null, currentMax = null; - if (lengthFacet != null) - { - currentLength = lengthFacet.getLexicalValue(); - } - if (minLengthFacet != null) - { - currentMin = minLengthFacet.getLexicalValue(); - } - if (maxLengthFacet != null) - { - currentMax = maxLengthFacet.getLexicalValue(); - } - - if (doUpdateMax && !doUpdateMin) - { - if (maxLengthFacet != null) - { - if (max != null) - { - if (max.equals(currentMin)) - { - lengthFacet = XSDFactory.eINSTANCE.createXSDLengthFacet(); - lengthFacet.setLexicalValue(max); - xsdSimpleType.getFacetContents().add(lengthFacet); - xsdSimpleType.getFacetContents().remove(maxLengthFacet); - xsdSimpleType.getFacetContents().remove(minLengthFacet); - } - else - { - if (lengthFacet != null) - { - xsdSimpleType.getFacetContents().remove(lengthFacet); - } - if (minLengthFacet == null && currentLength != null) - { - minLengthFacet = XSDFactory.eINSTANCE.createXSDMinLengthFacet(); - minLengthFacet.setLexicalValue(currentLength); - xsdSimpleType.getFacetContents().add(minLengthFacet); - } - maxLengthFacet.setLexicalValue(max); - } - } - else - { - xsdSimpleType.getFacetContents().remove(maxLengthFacet); - } - } - else - { - if (currentMin != null && currentMin.equals(max)) - { - if (lengthFacet == null) - { - lengthFacet = XSDFactory.eINSTANCE.createXSDLengthFacet(); - xsdSimpleType.getFacetContents().add(lengthFacet); - } - lengthFacet.setLexicalValue(max); - xsdSimpleType.getFacetContents().remove(minLengthFacet); - } - else if (currentLength != null && !currentLength.equals(max)) - { - xsdSimpleType.getFacetContents().remove(lengthFacet); - - if (max != null) - { - maxLengthFacet = XSDFactory.eINSTANCE.createXSDMaxLengthFacet(); - maxLengthFacet.setLexicalValue(max); - xsdSimpleType.getFacetContents().add(maxLengthFacet); - } - - minLengthFacet = XSDFactory.eINSTANCE.createXSDMinLengthFacet(); - minLengthFacet.setLexicalValue(currentLength); - xsdSimpleType.getFacetContents().add(minLengthFacet); - } - else - { - if (lengthFacet != null) - { - xsdSimpleType.getFacetContents().remove(lengthFacet); - - minLengthFacet = XSDFactory.eINSTANCE.createXSDMinLengthFacet(); - minLengthFacet.setLexicalValue(currentLength); - xsdSimpleType.getFacetContents().add(minLengthFacet); - - } - maxLengthFacet = XSDFactory.eINSTANCE.createXSDMaxLengthFacet(); - maxLengthFacet.setLexicalValue(max); - xsdSimpleType.getFacetContents().add(maxLengthFacet); - } - } - } - else if (!doUpdateMax && doUpdateMin) - { - if (minLengthFacet != null) - { - if (min != null) - { - if (min.equals(currentMax)) - { - lengthFacet = XSDFactory.eINSTANCE.createXSDLengthFacet(); - lengthFacet.setLexicalValue(min); - xsdSimpleType.getFacetContents().add(lengthFacet); - xsdSimpleType.getFacetContents().remove(maxLengthFacet); - xsdSimpleType.getFacetContents().remove(minLengthFacet); - } - else - { - if (lengthFacet != null) - { - xsdSimpleType.getFacetContents().remove(lengthFacet); - } - if (maxLengthFacet == null && currentLength != null) - { - maxLengthFacet = XSDFactory.eINSTANCE.createXSDMaxLengthFacet(); - maxLengthFacet.setLexicalValue(currentLength); - xsdSimpleType.getFacetContents().add(maxLengthFacet); - } - minLengthFacet.setLexicalValue(min); - } - } - else - { - xsdSimpleType.getFacetContents().remove(minLengthFacet); - } - } - else - { - if (currentMax != null && currentMax.equals(min)) - { - if (lengthFacet == null) - { - lengthFacet = XSDFactory.eINSTANCE.createXSDLengthFacet(); - xsdSimpleType.getFacetContents().add(lengthFacet); - } - lengthFacet.setLexicalValue(min); - xsdSimpleType.getFacetContents().remove(maxLengthFacet); - } - else if (currentLength != null && !currentLength.equals(min)) - { - xsdSimpleType.getFacetContents().remove(lengthFacet); - - if (min != null) - { - minLengthFacet = XSDFactory.eINSTANCE.createXSDMinLengthFacet(); - minLengthFacet.setLexicalValue(min); - xsdSimpleType.getFacetContents().add(minLengthFacet); - } - - maxLengthFacet = XSDFactory.eINSTANCE.createXSDMaxLengthFacet(); - maxLengthFacet.setLexicalValue(currentLength); - xsdSimpleType.getFacetContents().add(maxLengthFacet); - } - else - { - minLengthFacet = XSDFactory.eINSTANCE.createXSDMinLengthFacet(); - minLengthFacet.setLexicalValue(min); - xsdSimpleType.getFacetContents().add(minLengthFacet); - - if (lengthFacet != null) - { - xsdSimpleType.getFacetContents().remove(lengthFacet); - - maxLengthFacet = XSDFactory.eINSTANCE.createXSDMaxLengthFacet(); - maxLengthFacet.setLexicalValue(currentLength); - xsdSimpleType.getFacetContents().add(maxLengthFacet); - } - } - } - } - formatChild(xsdSimpleType.getElement()); - } - finally - { - endRecording(); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTextValueCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTextValueCommand.java deleted file mode 100644 index 66636465db..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTextValueCommand.java +++ /dev/null @@ -1,61 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.wst.xml.ui.internal.tabletree.TreeContentHelper; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -/* - * This command is used from the extension view to edit extension elements - * and which are implemented as DOM objects (not part of the EMF model) - */ -public class UpdateTextValueCommand extends BaseCommand -{ - Element element; - String value; - - public UpdateTextValueCommand(Element element, String value) - { - this.element = element; - this.value = value; - } - - - public void execute() - { - try - { - beginRecording(element); - Node textNode = null; - TreeContentHelper helper = new TreeContentHelper(); - for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) - { - if (node.getNodeType() == Node.TEXT_NODE && - !helper.isIgnorableText(node)) - { - textNode = node; - break; - } - } - if (textNode == null) - { - textNode = element.getOwnerDocument().createTextNode(""); - element.appendChild(textNode); - } - helper.setNodeValue(textNode, value); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceAndManageDirectivesCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceAndManageDirectivesCommand.java deleted file mode 100644 index fa34bbee5c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceAndManageDirectivesCommand.java +++ /dev/null @@ -1,60 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.core.resources.IFile; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDTypeDefinition; - -public class UpdateTypeReferenceAndManageDirectivesCommand extends UpdateComponentReferenceAndManageDirectivesCommand -{ - - public UpdateTypeReferenceAndManageDirectivesCommand(XSDConcreteComponent concreteComponent, - String componentName, String componentNamespace, IFile file) - { - super(concreteComponent, componentName, componentNamespace, file); - } - - - protected XSDComponent getDefinedComponent(XSDSchema schema, String componentName, String componentNamespace) - { - XSDTypeDefinition result = schema.resolveTypeDefinition(componentNamespace, componentName); - if (result.eContainer() == null) - { - result = null; - } - return result; - } - - - public void execute() - { - try - { - beginRecording(concreteComponent.getElement()); - XSDComponent td = computeComponent(); - if (td != null && td instanceof XSDTypeDefinition) - { - UpdateTypeReferenceCommand command = new UpdateTypeReferenceCommand(concreteComponent, (XSDTypeDefinition) td); - command.execute(); - } - } - catch (Exception e) - { - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceCommand.java deleted file mode 100644 index cda106c5bb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateTypeReferenceCommand.java +++ /dev/null @@ -1,78 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; - -public class UpdateTypeReferenceCommand extends BaseCommand -{ - XSDConcreteComponent concreteComponent; - XSDTypeDefinition newType; - - public UpdateTypeReferenceCommand(XSDConcreteComponent concreteComponent, XSDTypeDefinition newType) - { - this.concreteComponent = concreteComponent; - this.newType = newType; - } - - public void execute() - { - try - { - beginRecording(concreteComponent.getElement()); - - if (concreteComponent instanceof XSDElementDeclaration) - { - setElementType((XSDElementDeclaration) concreteComponent); - } - else if (concreteComponent instanceof XSDAttributeUse) - { - setAttributeType((XSDAttributeUse) concreteComponent); - } - else if (concreteComponent instanceof XSDAttributeDeclaration) - { - setAttributeType((XSDAttributeDeclaration) concreteComponent); - } - } - finally - { - endRecording(); - } - } - - protected void setElementType(XSDElementDeclaration ed) - { - ed = ed.getResolvedElementDeclaration(); - if (ed != null) - { - ed.setTypeDefinition(newType); - } - } - - protected void setAttributeType(XSDAttributeUse attributeUse) - { - setAttributeType(attributeUse.getAttributeDeclaration()); - } - - protected void setAttributeType(XSDAttributeDeclaration ad) - { - ad = ad.getResolvedAttributeDeclaration(); - if (ad != null && newType instanceof XSDSimpleTypeDefinition) - { - ad.setTypeDefinition((XSDSimpleTypeDefinition)newType); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDPatternFacetCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDPatternFacetCommand.java deleted file mode 100644 index 3d1b6adc1d..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDPatternFacetCommand.java +++ /dev/null @@ -1,76 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.core.runtime.Assert; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDPatternFacet; -import org.eclipse.xsd.XSDSimpleTypeDefinition; - -public class UpdateXSDPatternFacetCommand extends BaseCommand -{ - public static final int ADD = 0; - public static final int DELETE = 1; - public static final int UPDATE = 2; - - XSDSimpleTypeDefinition xsdSimpleTypeDefinition; - String value; - int actionType; - XSDPatternFacet patternToEdit; - - public UpdateXSDPatternFacetCommand(String label, XSDSimpleTypeDefinition xsdSimpleTypeDefinition, int actionType) - { - super(label); - this.xsdSimpleTypeDefinition = xsdSimpleTypeDefinition; - this.actionType = actionType; - - } - - public void setValue(String value) - { - this.value = value; - } - - public void setPatternToEdit(XSDPatternFacet patternToEdit) - { - this.patternToEdit = patternToEdit; - } - - public void execute() - { - try - { - beginRecording(xsdSimpleTypeDefinition.getElement()); - if (actionType == ADD) - { - XSDPatternFacet pattern = XSDFactory.eINSTANCE.createXSDPatternFacet(); - pattern.setLexicalValue(value); - xsdSimpleTypeDefinition.getFacetContents().add(pattern); - } - else if (actionType == DELETE) - { - Assert.isNotNull(patternToEdit); - if (xsdSimpleTypeDefinition.getFacetContents().contains(patternToEdit)) - xsdSimpleTypeDefinition.getFacetContents().remove(patternToEdit); - } - else if (actionType == UPDATE) - { - Assert.isNotNull(patternToEdit); - patternToEdit.setLexicalValue(value); - } - formatChild(xsdSimpleTypeDefinition.getElement()); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDWhiteSpaceFacetCommand.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDWhiteSpaceFacetCommand.java deleted file mode 100644 index bd92c3fab8..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/commands/UpdateXSDWhiteSpaceFacetCommand.java +++ /dev/null @@ -1,60 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.commands; - -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDWhiteSpace; -import org.eclipse.xsd.XSDWhiteSpaceFacet; - -public class UpdateXSDWhiteSpaceFacetCommand extends BaseCommand -{ - XSDSimpleTypeDefinition xsdSimpleTypeDefinition; - boolean doAddFacet; - - public UpdateXSDWhiteSpaceFacetCommand(String label, XSDSimpleTypeDefinition xsdSimpleType, boolean doAddFacet) - { - super(label); - this.xsdSimpleTypeDefinition = xsdSimpleType; - this.doAddFacet = doAddFacet; - } - - public void execute() - { - try - { - beginRecording(xsdSimpleTypeDefinition.getElement()); - XSDWhiteSpaceFacet whitespaceFacet = xsdSimpleTypeDefinition.getWhiteSpaceFacet(); - - if (doAddFacet) - { - if (whitespaceFacet == null) - { - whitespaceFacet = XSDFactory.eINSTANCE.createXSDWhiteSpaceFacet(); - xsdSimpleTypeDefinition.getFacetContents().add(whitespaceFacet); - } - whitespaceFacet.setLexicalValue(XSDWhiteSpace.COLLAPSE_LITERAL.getName()); - } - else - { - if (whitespaceFacet != null) - { - xsdSimpleTypeDefinition.getFacetContents().remove(whitespaceFacet); - } - } - formatChild(xsdSimpleTypeDefinition.getElement()); - } - finally - { - endRecording(); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.java deleted file mode 100644 index ef9b4690c0..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/providers/XSDSectionLabelProvider.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.providers; - -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.graphics.Image; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPage; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDAdapterFactory; -import org.eclipse.wst.xsd.ui.internal.adapters.XSDBaseAdapter; -import org.eclipse.wst.xsd.ui.internal.adt.outline.ITreeElement; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDSectionLabelProvider extends LabelProvider -{ - /** - * - */ - public XSDSectionLabelProvider() - { - super(); - } - - /** - * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object object) - { - if (object == null || object.equals(StructuredSelection.EMPTY)) - { - return null; - } - Image result = null; - if (object instanceof StructuredSelection) - { - Object selected = ((StructuredSelection) object).getFirstElement(); - - if (selected instanceof XSDConcreteComponent) - { - XSDBaseAdapter adapter = (XSDBaseAdapter)XSDAdapterFactory.getInstance().adapt((XSDConcreteComponent)selected); - return ((ITreeElement)adapter).getImage(); - } - } - return result; - } - - /** - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - public String getText(Object object) - { - if (object == null || object.equals(StructuredSelection.EMPTY)) - { - return org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_NO_ITEMS_SELECTED; - } - - String result = null; - - boolean isReference = false; - Object selected = null; - if (object instanceof StructuredSelection) - { - selected = ((StructuredSelection) object).getFirstElement(); - - if (selected instanceof XSDConcreteComponent) - { - if (selected instanceof XSDElementDeclaration) - { - XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) selected; - if (xsdElementDeclaration.isElementDeclarationReference()) - { - isReference = true; - } - } else if (selected instanceof XSDAttributeDeclaration) - { - if (((XSDAttributeDeclaration) selected).isAttributeDeclarationReference()) - { - isReference = true; - } - } else if (selected instanceof XSDModelGroupDefinition) - { - if (((XSDModelGroupDefinition) selected).isModelGroupDefinitionReference()) - { - isReference = true; - } - } - StringBuffer sb = new StringBuffer(); - Element element = ((XSDConcreteComponent) selected).getElement(); - if (element != null) - { - sb.append(((XSDConcreteComponent) selected).getElement().getLocalName()); - - if (isReference) - { - sb.append(" ref");//$NON-NLS-1$ - // This string is not easily translatable to other languages. - // For now, make it english-only since we use the element tag as the title anyway -// sb.append(Messages.UI_PAGE_HEADING_REFERENCE); - } - - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - if (workbenchWindow != null) - { - IWorkbenchPage page = workbenchWindow.getActivePage(); - if (page != null) - { - IEditorPart editorPart = page.getActiveEditor(); - XSDSchema xsdSchema = ((XSDConcreteComponent) selected).getSchema(); - if (editorPart != null && xsdSchema != editorPart.getAdapter(XSDSchema.class)) - { - sb.append(" (" + Messages.UI_LABEL_READ_ONLY + ")"); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - } - return sb.toString(); - } - else - { - // If the element is null, then let's use the model object to find - // an appropriate name - if ((XSDConcreteComponent) selected instanceof XSDNamedComponent) - { - return ((XSDNamedComponent)selected).getName(); - } - else if ((XSDConcreteComponent) selected instanceof XSDSchema) - { - return XSDConstants.SCHEMA_ELEMENT_TAG; - } - // last resort.... - return "(" + Messages.UI_LABEL_READ_ONLY + ")"; //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - if (object instanceof Element) - { - return ((Element) object).getLocalName(); - } - } - - return result; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractExtensionsSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractExtensionsSection.java deleted file mode 100644 index 1e31aa84fa..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractExtensionsSection.java +++ /dev/null @@ -1,574 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.List; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ITreeContentProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.SashForm; -import org.eclipse.swt.custom.ScrolledComposite; -import org.eclipse.swt.events.MouseTrackAdapter; -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.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Tree; -import org.eclipse.swt.widgets.TreeItem; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.widgets.ExpandableComposite; -import org.eclipse.ui.forms.widgets.Section; -import org.eclipse.ui.views.properties.PropertySheet; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; -import org.eclipse.wst.sse.core.internal.provisional.INodeNotifier; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.DOMExtensionDetailsContentProvider; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.DOMExtensionItemMenuListener; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionDetailsViewer; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionsSchemasRegistry; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public abstract class AbstractExtensionsSection extends AbstractSection -{ - protected ExtensionDetailsViewer extensionDetailsViewer; - protected TreeViewer extensionTreeViewer; - protected ITreeContentProvider extensionTreeContentProvider; - protected ILabelProvider extensionTreeLabelProvider; - protected Label contentLabel; - protected ISelectionChangedListener elementSelectionChangedListener; - protected IDocumentChangedNotifier documentChangeNotifier; - protected INodeAdapter internalNodeAdapter = new InternalNodeAdapter(); - - private Composite page; - protected Button addButton, removeButton; - private Object prevInput; - private SpecificationForExtensionsSchema prevCategory; - - /** - * - */ - public AbstractExtensionsSection() - { - super(); - } - - class InternalNodeAdapter implements INodeAdapter - { - - public boolean isAdapterForType(Object type) - { - // this method should never be called - // we don't use objects of this class as 'standard' adapters - return true; - } - - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) - { - boolean isRoot = false; - if (notifier instanceof Element) - { - if (isTreeViewerInputElement((Element)notifier))// TODO - { - isRoot = true; - extensionTreeViewer.refresh(extensionTreeViewer.getInput()); - } - } - if (!isRoot) - { - extensionTreeViewer.refresh(notifier); - if ( newValue instanceof Element) - { - extensionTreeViewer.expandToLevel(notifier, 1); - extensionTreeViewer.setSelection(new StructuredSelection(newValue)); - } - } - } - } - - protected boolean isTreeViewerInputElement(Element element) - { - return false; - } - - public void createContents(Composite parent) - { - // TODO (cs) add assertion - if (extensionTreeContentProvider == null) - return; - - IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - documentChangeNotifier = (IDocumentChangedNotifier)editor.getAdapter(IDocumentChangedNotifier.class); - - if (documentChangeNotifier != null) - { - documentChangeNotifier.addListener(internalNodeAdapter); - } - - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 1; - composite.setLayout(gridLayout); - - GridData gridData = new GridData(); - - page = getWidgetFactory().createComposite(composite); - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 1; - page.setLayout(gridLayout); - - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.verticalAlignment = GridData.FILL; - gridData.horizontalAlignment = GridData.FILL; - page.setLayoutData(gridData); - - SashForm sashForm = new SashForm(page, SWT.HORIZONTAL); - // Try to limit the initial width of the section - - int w = SWT.DEFAULT; - try - { - IWorkbenchPart part = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActivePart(); - - // Find the width of the Tabbed Property Sheet's composite excluding the tab - if (part instanceof PropertySheet) - { - PropertySheet sheet = (PropertySheet)part; - if (sheet.getCurrentPage() instanceof TabbedPropertySheetPage) - { - TabbedPropertySheetPage tabbedPage = (TabbedPropertySheetPage)sheet.getCurrentPage(); - Composite targetComposite = null; - if (tabbedPage.getControl() instanceof Composite) - { - Composite c = (Composite)tabbedPage.getControl(); - int length = c.getChildren().length; - for (int i = 0; i < length; i++) - { - Control ctrl = c.getChildren()[i]; - int length2 = (((Composite)ctrl).getChildren()).length; - for (int j = 0; j < length2; j++ ) - { - if ((((Composite)ctrl).getChildren())[j] instanceof ScrolledComposite) - { - targetComposite = (Composite)(((Composite)ctrl).getChildren())[j]; - break; - } - } - } - } - if (targetComposite != null) - { - w = targetComposite.getSize().x - 20; // ensure scrollbars don't show - } - // The above can be accomplished by the following code - // but because TabbedPropertyComposite is in an internal package, I will get a discouraged - // access warning. - // w = ((TabbedPropertyComposite)(tabbedPage.getControl())).getTabComposite().getSize().x; - } - } - } - catch(Exception e) - { - w = SWT.DEFAULT; - } - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.verticalAlignment = GridData.FILL; - gridData.horizontalAlignment = GridData.FILL; - gridData.widthHint = w; - sashForm.setLayoutData(gridData); - sashForm.setForeground(ColorConstants.white); - sashForm.setBackground(ColorConstants.white); - Control[] children = sashForm.getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].setVisible(false); - } - Composite leftContent = getWidgetFactory().createComposite(sashForm, SWT.FLAT); - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - leftContent.setLayout(gridLayout); - - Section section = getWidgetFactory().createSection(leftContent, SWT.FLAT | ExpandableComposite.TITLE_BAR); - section.setText(Messages._UI_LABEL_EXTENSIONS); - section.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite tableAndButtonComposite = getWidgetFactory().createComposite(leftContent, SWT.FLAT); - tableAndButtonComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - tableAndButtonComposite.setLayout(gridLayout); - - extensionTreeViewer = new TreeViewer(tableAndButtonComposite, SWT.FLAT | SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.LINE_SOLID); - MenuManager menuManager = new MenuManager(); - extensionTreeViewer.getTree().setMenu(menuManager.createContextMenu(extensionTreeViewer.getTree())); - menuManager.addMenuListener(new DOMExtensionItemMenuListener(extensionTreeViewer)); - - gridLayout = new GridLayout(); - gridLayout.numColumns = 1; - extensionTreeViewer.getTree().setLayout(gridLayout); - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.verticalAlignment = GridData.FILL; - gridData.horizontalAlignment = GridData.FILL; - - extensionTreeViewer.getTree().setLayoutData(gridData); - extensionTreeViewer.setContentProvider(extensionTreeContentProvider); - extensionTreeViewer.setLabelProvider(extensionTreeLabelProvider); - elementSelectionChangedListener = new ElementSelectionChangedListener(); - extensionTreeViewer.addSelectionChangedListener(elementSelectionChangedListener); - extensionTreeViewer.getTree().addMouseTrackListener(new MouseTrackAdapter() - { - public void mouseHover(org.eclipse.swt.events.MouseEvent e) - { - ISelection selection = extensionTreeViewer.getSelection(); - if (selection instanceof StructuredSelection) - { - Object obj = ((StructuredSelection) selection).getFirstElement(); - if (obj instanceof Element) - { - Element element = (Element) obj; - ExtensionsSchemasRegistry registry = getExtensionsSchemasRegistry(); - // ApplicationSpecificSchemaProperties[] properties = - // registry.getAllApplicationSpecificSchemaProperties(); - // ApplicationSpecificSchemaProperties[] properties = - // (ApplicationSpecificSchemaProperties[]) - // registry.getAllApplicationSpecificSchemaProperties().toArray(new - // ApplicationSpecificSchemaProperties[0]); - List properties = registry.getAllExtensionsSchemasContribution(); - - int length = properties.size(); - for (int i = 0; i < length; i++) - { - SpecificationForExtensionsSchema current = (SpecificationForExtensionsSchema) properties.get(i); - if (current.getNamespaceURI().equals(element.getNamespaceURI())) - { - extensionTreeViewer.getTree().setToolTipText(current.getDescription()); - break; - } - } - } - } - } - - }); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(extensionTreeViewer.getControl(), - XSDEditorCSHelpIds.EXTENSIONS_TAB__EXTENSIONS); - - Composite buttonComposite = getWidgetFactory().createComposite(tableAndButtonComposite, SWT.FLAT); - //ColumnLayout columnLayout = new ColumnLayout(); - //buttonComposite.setLayout(columnLayout); - buttonComposite.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 1; - gridLayout.makeColumnsEqualWidth = true; - buttonComposite.setLayout(gridLayout); - - addButton = getWidgetFactory().createButton(buttonComposite, Messages._UI_ACTION_ADD_WITH_DOTS, SWT.FLAT); - addButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - addButton.addSelectionListener(this); - addButton.setToolTipText(Messages._UI_ACTION_ADD_EXTENSION_COMPONENT); - //addButton.setLayoutData(new ColumnLayoutData(ColumnLayoutData.FILL)); - addButton.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(addButton, - XSDEditorCSHelpIds.EXTENSIONS_TAB__ADD); - - removeButton = getWidgetFactory().createButton(buttonComposite, Messages._UI_ACTION_DELETE, SWT.FLAT); - removeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - removeButton.addSelectionListener(this); - removeButton.setToolTipText(Messages._UI_ACTION_DELETE_EXTENSION_COMPONENT); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(removeButton, - XSDEditorCSHelpIds.EXTENSIONS_TAB__DELETE); - - //removeButton.setLayoutData(new ColumnLayoutData(ColumnLayoutData.FILL)); - - // TODO (cs) uncomment the up/down button when we have time to implement - // - //Button up = getWidgetFactory().createButton(buttonComposite, Messages._UI_LABEL_UP, SWT.FLAT); - //up.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - //Button down = getWidgetFactory().createButton(buttonComposite, Messages._UI_LABEL_DOWN, SWT.FLAT); - //down.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - - Composite rightContent = getWidgetFactory().createComposite(sashForm, SWT.FLAT); - Section section2 = getWidgetFactory().createSection(rightContent, SWT.FLAT | ExpandableComposite.TITLE_BAR); - section2.setText(Messages._UI_LABEL_EXTENSION_DETAILS); - section2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - //contentLabel = getWidgetFactory().createLabel(rightContent, "Content"); - - Composite testComp = getWidgetFactory().createComposite(rightContent, SWT.FLAT); - - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.marginLeft = 0; - gridLayout.marginRight = 0; - gridLayout.numColumns = 1; - gridLayout.marginHeight = 3; - gridLayout.marginWidth = 3; - rightContent.setLayout(gridLayout); - - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.verticalAlignment = GridData.FILL; - gridData.horizontalAlignment = GridData.FILL; - rightContent.setLayoutData(gridData); - - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginLeft = 0; - gridLayout.marginRight = 0; - gridLayout.marginBottom = 0; - gridLayout.marginHeight = 3; - gridLayout.marginWidth = 3; - gridLayout.numColumns = 2; - testComp.setLayout(gridLayout); - - gridData = new GridData(); - gridData.grabExcessHorizontalSpace = true; - gridData.grabExcessVerticalSpace = true; - gridData.verticalAlignment = GridData.FILL; - gridData.horizontalAlignment = GridData.FILL; - testComp.setLayoutData(gridData); - - createElementContentWidget(testComp); - - int[] weights = { 40, 60 }; - sashForm.setWeights(weights); - } - - protected void createElementContentWidget(Composite parent) - { - extensionDetailsViewer = new ExtensionDetailsViewer(parent, getWidgetFactory()); - extensionDetailsViewer.setContentProvider(new DOMExtensionDetailsContentProvider()); - extensionDetailsViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(extensionDetailsViewer.getControl(), - XSDEditorCSHelpIds.EXTENSIONS_TAB__EXTENSIONS_DETAILS); - } - - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - setListenerEnabled(false); - if (input != null) - { - if ( prevInput == input) - return; - else - prevInput = input; - - Tree tree = extensionTreeViewer.getTree(); - extensionDetailsViewer.setInput(null); - tree.removeAll(); - - extensionTreeViewer.setInput(input); - if (tree.getSelectionCount() == 0 && tree.getItemCount() > 0) - { - TreeItem treeItem = tree.getItem(0); - extensionTreeViewer.setSelection(new StructuredSelection(treeItem.getData())); - } - removeButton.setEnabled(tree.getSelectionCount() > 0); - } - setListenerEnabled(true); - } - - public Composite getPage() - { - return page; - } - - protected abstract AddExtensionCommand getAddExtensionCommand(Object o); - protected abstract Command getRemoveExtensionCommand(Object o); - protected abstract ExtensionsSchemasRegistry getExtensionsSchemasRegistry(); - - protected AddExtensionsComponentDialog createAddExtensionsComponentDialog() - { - return new AddExtensionsComponentDialog(composite.getShell(), getExtensionsSchemasRegistry()); - } - - public void widgetSelected(SelectionEvent event) - { - if (event.widget == addButton) - { - ExtensionsSchemasRegistry registry = getExtensionsSchemasRegistry(); - AddExtensionsComponentDialog dialog = createAddExtensionsComponentDialog(); - - List properties = registry.getAllExtensionsSchemasContribution(); - - dialog.setInput(properties); - dialog.setBlockOnOpen(true); - dialog.setPrefStore( getPrefStore() ); - - if (prevCategory != null) - dialog.setInitialCategorySelection(prevCategory); - - if (dialog.open() == Window.OK) - { - Object newSelection = null; - Object[] result = dialog.getResult(); - if (result != null) - { - SpecificationForExtensionsSchema extensionsSchemaSpec = (SpecificationForExtensionsSchema) result[1]; - AddExtensionCommand addExtensionCommand = getAddExtensionCommand(result[0]); - if (addExtensionCommand != null) - { - addExtensionCommand.setSchemaProperties(extensionsSchemaSpec); - if (getCommandStack() != null) - { - getCommandStack().execute(addExtensionCommand); - newSelection = addExtensionCommand.getNewObject(); - } - } - } - //refresh(); - if (newSelection != null) - { - extensionTreeViewer.setSelection(new StructuredSelection(newSelection)); - } - } - - prevCategory = dialog.getSelectedCategory(); - } - else if (event.widget == removeButton) - { - ISelection selection = extensionTreeViewer.getSelection(); - - if (selection instanceof StructuredSelection) - { - Object o = ((StructuredSelection) selection).getFirstElement(); - Command command = getRemoveExtensionCommand(o); - if (getCommandStack() != null) - { - getCommandStack().execute(command); - } - } - } - else if (event.widget == extensionTreeViewer.getTree()) - { - - } - } - - // TODO make this one an abstract method. XSDEditor and WSDLEditor should return - // diferent IpreferenceStore objects - protected IPreferenceStore getPrefStore() { - return null; - } - - public void widgetDefaultSelected(SelectionEvent event) - { - - } - - public boolean shouldUseExtraSpace() - { - return true; - } - - public void dispose() - { - if (documentChangeNotifier != null) - documentChangeNotifier.removeListener(internalNodeAdapter); - } - - - Node selectedNode; - - class ElementSelectionChangedListener implements ISelectionChangedListener - { - public void selectionChanged(SelectionChangedEvent event) - { - boolean isDeleteEnabled = false; - ISelection selection = event.getSelection(); - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - if (structuredSelection.size() > 0) - { - Object obj = structuredSelection.getFirstElement(); - if (obj instanceof Node) - { - selectedNode = (Node) obj; - extensionDetailsViewer.setInput(obj); - isDeleteEnabled = true; - } - } - else - { - // if nothing is selected then don't show any details - // - extensionDetailsViewer.setInput(null); - } - } - removeButton.setEnabled(isDeleteEnabled); - } - } - - public ITreeContentProvider getExtensionTreeContentProvider() - { - return extensionTreeContentProvider; - } - - public void setExtensionTreeContentProvider(ITreeContentProvider extensionTreeContentProvider) - { - this.extensionTreeContentProvider = extensionTreeContentProvider; - } - - public ILabelProvider getExtensionTreeLabelProvider() - { - return extensionTreeLabelProvider; - } - - public void setExtensionTreeLabelProvider(ILabelProvider extensionTreeLabelProvider) - { - this.extensionTreeLabelProvider = extensionTreeLabelProvider; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java deleted file mode 100644 index c90c0a99fa..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSection.java +++ /dev/null @@ -1,365 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.emf.ecore.EObject; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.jface.action.IStatusLineManager; -import org.eclipse.jface.action.SubContributionManager; -import org.eclipse.jface.action.SubStatusLineManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.PaintEvent; -import org.eclipse.swt.events.PaintListener; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.GC; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IEditorSite; -import org.eclipse.ui.ISharedImages; -import org.eclipse.ui.IViewSite; -import org.eclipse.ui.IWorkbench; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.IWorkbenchWindow; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.FormColors; -import org.eclipse.ui.views.properties.tabbed.AbstractPropertySection; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetPage; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDComponent; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDSchema; - -public abstract class AbstractSection extends AbstractPropertySection implements SelectionListener, Listener -{ - protected Composite composite; - protected PaintListener painter; - protected XSDSchema xsdSchema; - protected Object input; - protected boolean isReadOnly; - protected boolean listenerEnabled = true; - protected boolean isSimple; - protected CustomListener customListener = new CustomListener(); - protected IEditorPart owningEditor; - private IStatusLineManager statusLine; - - public static final Image ICON_ERROR = XSDEditorPlugin.getDefault().getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJS_ERROR_TSK); - - public AbstractSection() - { - super(); - } - - public void createControls(Composite parent, TabbedPropertySheetPage aTabbedPropertySheetPage) - { - super.createControls(parent, aTabbedPropertySheetPage); - isSimple = getIsSimple(); - createContents(parent); - } - - protected abstract void createContents(Composite parent); - - protected PaintListener createPainter() { - return new PaintListener() { - - public void paintControl(PaintEvent e) { -// Rectangle bounds = composite.getClientArea(); - GC gc = e.gc; - - gc.setForeground(gc.getBackground()); - gc.setBackground(getWidgetFactory().getColors().getColor( - FormColors.TB_BG)); - -// gc.fillGradientRectangle(4 + bounds.width / 2, 0, -// bounds.width / 2 - 9, bounds.height, false); - - gc.setForeground(getWidgetFactory().getColors().getColor( - FormColors.TB_BORDER)); -// gc.drawLine(bounds.width - 5, 0, bounds.width - 5, -// bounds.height); - } - - }; - - } - - public void dispose() - { - if (composite != null && ! composite.isDisposed() && painter != null) - composite.removePaintListener(painter); - - super.dispose(); - } - - public void setInput(IWorkbenchPart part, ISelection selection) { - super.setInput(part, selection); - isSimple = getIsSimple(); - Object input = ((IStructuredSelection)selection).getFirstElement(); - this.input = input; - - if (input instanceof XSDConcreteComponent) - { - xsdSchema = ((XSDConcreteComponent)input).getSchema(); - } - - // set owning editor of this section - if (part!=null) - { - if (part instanceof IEditorPart) - { - owningEditor = (IEditorPart)part; - } - else - { - owningEditor = part.getSite().getWorkbenchWindow().getActivePage().getActiveEditor(); - } - } - if (xsdSchema == owningEditor.getAdapter(XSDSchema.class)) - { - isReadOnly = false; - } - else - { - isReadOnly = true; - } - - } - - public void refresh() - { - super.refresh(); - - if (isReadOnly) - { - composite.setEnabled(false); - } - else - { - composite.setEnabled(true); - } - } - - public void applyAllListeners(Control control) - { - control.addListener(SWT.Modify, customListener); - control.addListener(SWT.FocusOut, customListener); - control.addListener(SWT.KeyDown, customListener); - } - - public void applyModifyListeners(Control control) - { - control.addListener(SWT.Modify, customListener); - control.addListener(SWT.FocusOut, customListener); - } - - public void applyKeyListener(Control control) - { - control.addListener(SWT.KeyDown, customListener); - } - - public void removeListeners(Control control) - { - control.removeListener(SWT.Modify, customListener); - control.removeListener(SWT.FocusOut, customListener); - control.removeListener(SWT.KeyDown, customListener); - } - - public void doWidgetDefaultSelected(SelectionEvent e) - {} - - public void doWidgetSelected(SelectionEvent e) - {} - - public void widgetSelected(SelectionEvent e) - { - if (isListenerEnabled() && - input != null && - !isReadOnly) - { - doWidgetSelected(e); - } - } - - public void widgetDefaultSelected(SelectionEvent e) - { - if (isListenerEnabled() && - input != null && - !isReadOnly) - { - doWidgetDefaultSelected(e); - } - } - - /** - * Get the value of listenerEnabled. - * @return value of listenerEnabled. - */ - public boolean isListenerEnabled() - { - return listenerEnabled; - } - - /** - * Set the value of listenerEnabled. - * @param v Value to assign to listenerEnabled. - */ - public void setListenerEnabled(boolean v) - { - this.listenerEnabled = v; - } - - /** - * Sent when an event that the receiver has registered for occurs. - * - * @param event the event which occurred - */ - public void handleEvent(Event event) - { - if (isListenerEnabled() && !isReadOnly) - { - doHandleEvent(event); - } - } - - /** - * Subclasses should override - * @param event - */ - protected void doHandleEvent(Event event) - { - } - - protected IEditorPart getActiveEditor() - { - IWorkbench workbench = PlatformUI.getWorkbench(); - IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow(); - IEditorPart editorPart = workbenchWindow.getActivePage().getActiveEditor(); - this.owningEditor = editorPart; - return editorPart; - } - - public CommandStack getCommandStack() - { - Object commandStack = owningEditor.getAdapter(CommandStack.class); - - if (commandStack==null) - return null; - else - return (CommandStack)commandStack; - } - - public boolean getIsSimple() - { - return false; - } - - - - /** - * Intended to display error messages. - * @return - */ - private IStatusLineManager getStatusLineManager() - { - if (statusLine==null && getPart()!=null) - { - if(getPart().getSite() instanceof IEditorSite) - statusLine = ((IEditorSite)getPart().getSite()).getActionBars().getStatusLineManager(); - else if (getPart().getSite() instanceof IViewSite) - statusLine = ((IViewSite)getPart().getSite()).getActionBars().getStatusLineManager(); - - /* - * We must manually set the visibility of the status line since the action bars are from the editor - * which means the status line only shows up when the editor is in focus (by default). - * Note only a SubStatusLineManager can set the visibility. - */ - if (statusLine instanceof SubStatusLineManager) - ((SubStatusLineManager)statusLine).setVisible(true); - } - - return statusLine; - } - - /** - * Display an error message in the status line. - * Call setErrorMessage(null) to clear the status line. - * @param text - */ - public void setErrorMessage(String text) - { - IStatusLineManager statusLine = getStatusLineManager(); - - if (statusLine!=null) - { - if (text==null || text.length()<1) - statusLine.setErrorMessage(null); - else - statusLine.setErrorMessage(ICON_ERROR, text); - - // ensure our message gets displayed - if (statusLine instanceof SubContributionManager) - ((SubContributionManager)statusLine).setVisible(true); - - statusLine.update(true); - } - } - - - protected EObject getModel() - { - return (XSDComponent)input; - } - - - class CustomListener implements Listener - { - boolean handlingEvent = false; - public void handleEvent(Event event) - { - if (isListenerEnabled() && !isReadOnly) - { - switch (event.type) - { - case SWT.KeyDown : - { - if (event.character == SWT.CR) - { - if (!handlingEvent) - { - handlingEvent = true; - doHandleEvent(event); - handlingEvent = false; - } - } - break; - } - case SWT.FocusOut : - { - if (!handlingEvent) - { - handlingEvent = true; - doHandleEvent(event); - handlingEvent = false; - } - break; - } - } - } - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSectionDescriptor.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSectionDescriptor.java deleted file mode 100644 index e0b33bb5c0..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AbstractSectionDescriptor.java +++ /dev/null @@ -1,108 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.ArrayList; -import java.util.List; - -import org.eclipse.jface.viewers.IFilter; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.views.properties.tabbed.ISection; -import org.eclipse.ui.views.properties.tabbed.ISectionDescriptor; -import org.eclipse.xsd.XSDConcreteComponent; -import org.w3c.dom.Element; - -public class AbstractSectionDescriptor implements ISectionDescriptor -{ - /** - * - */ - public AbstractSectionDescriptor() - { - super(); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getId() - */ - public String getId() - { - return ""; //$NON-NLS-1$ - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getFilter() - */ - public IFilter getFilter() - { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getInputTypes() - */ - public List getInputTypes() - { - List list = new ArrayList(); - list.add(XSDConcreteComponent.class); - return list; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getSectionClass() - */ - public ISection getSectionClass() - { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getTargetTab() - */ - public String getTargetTab() - { - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#appliesTo(org.eclipse.ui.IWorkbenchPart, org.eclipse.jface.viewers.ISelection) - */ - public boolean appliesTo(IWorkbenchPart part, ISelection selection) - { - Object object = null; - if (selection instanceof StructuredSelection) - { - StructuredSelection structuredSelection = (StructuredSelection)selection; - object = structuredSelection.getFirstElement(); - if (object instanceof XSDConcreteComponent || object instanceof Element) - { - return true; - } - } - return false; - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISectionDescriptor#getAfterSection() - */ - public String getAfterSection() - { - return ""; //$NON-NLS-1$ - } - - - public int getEnablesFor() - { - return ENABLES_FOR_ANY; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AnnotationSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AnnotationSection.java deleted file mode 100644 index 2215338173..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/AnnotationSection.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.io.IOException; -import java.util.List; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.PlatformUI; -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.xsd.ui.internal.common.commands.AddDocumentationCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.xsd.XSDAnnotation; -import org.eclipse.xsd.XSDConcreteComponent; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class AnnotationSection extends AbstractSection -{ - Text simpleText; - - public void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - simpleText = getWidgetFactory().createText(composite, "", SWT.V_SCROLL | SWT.H_SCROLL); //$NON-NLS-1$ - simpleText.addListener(SWT.Modify, this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(simpleText, - XSDEditorCSHelpIds.DOCUMENTATION_TAB__NO_LABEL); - - - FormData data = new FormData(); - data.left = new FormAttachment(0, 1); - data.right = new FormAttachment(100, -1); - data.top = new FormAttachment(0, 1); - data.bottom = new FormAttachment(100, -1); - simpleText.setLayoutData(data); - } - - public AnnotationSection() - { - super(); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - - if (simpleText.isFocusControl()) return; - setListenerEnabled(false); - if (input instanceof XSDConcreteComponent) - { - XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation((XSDConcreteComponent) input, false); - setInitialText(xsdAnnotation); - } - setListenerEnabled(true); - } - - public void doHandleEvent(Event event) - { - if (input instanceof XSDConcreteComponent) - { - if (event.widget == simpleText) - { - AddDocumentationCommand command = new AddDocumentationCommand(Messages._UI_ACTION_ADD_DOCUMENTATION, null, (XSDConcreteComponent) input, simpleText.getText(), ""); //$NON-NLS-1$ - getCommandStack().execute(command); - } - } - - } - - public boolean shouldUseExtraSpace() - { - return true; - } - - public void dispose() - { - - } - - private void setInitialText(XSDAnnotation an) - { - if (an != null) - { - try - { - List documentationList = an.getUserInformation(); - if (documentationList.size() > 0) - { - Element docElement = (Element) documentationList.get(0); - if (docElement != null) - { - simpleText.setText(doSerialize(docElement)); - } - } - } - catch (Exception e) - { - - } - } - else - { - simpleText.setText(""); //$NON-NLS-1$ - } - } - - private String doSerialize(Element element) throws IOException - { - String source = ""; //$NON-NLS-1$ - - Node firstChild = element.getFirstChild(); - Node lastChild = element.getLastChild(); - int start = 0; - int end = 0; - - if (element instanceof IDOMElement) - { - IDOMElement domElement = (IDOMElement) element; - IDOMModel model = domElement.getModel(); - IDOMDocument doc = model.getDocument(); - - if (firstChild instanceof IDOMNode) - { - IDOMNode first = (IDOMNode) firstChild; - start = first.getStartOffset(); - } - if (lastChild instanceof IDOMNode) - { - IDOMNode last = (IDOMNode) lastChild; - end = last.getEndOffset(); - } - source = doc.getSource().substring(start, end); - } - - return source; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java deleted file mode 100644 index 652d247c09..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/CommonDirectivesSection.java +++ /dev/null @@ -1,156 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.core.resources.IFile; -import org.eclipse.emf.common.util.URI; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.graphics.Color; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDInclude; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDParser; - -public abstract class CommonDirectivesSection extends AbstractSection -{ - Text schemaLocationText; - Button wizardButton; - StyledText errorText; - Color red; - protected boolean isValidSchemaLocation = true; - - // TODO: common up code with XSDSelectIncludeFileWizard - public void doHandleEvent(Event event) - { - errorText.setText(""); //$NON-NLS-1$ - - if (event.widget == schemaLocationText) - { - String errorMessage = ""; //$NON-NLS-1$ - isValidSchemaLocation = true; - String xsdModelFile = schemaLocationText.getText(); - String namespace = ""; //$NON-NLS-1$ - XSDSchema externalSchema = null; - - if (xsdModelFile.length() == 0) - { - handleSchemaLocationChange(xsdModelFile, "", null); //$NON-NLS-1$ - return; - } - - try - { - IFile currentIFile = ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile(); - - URI newURI = URI.createURI(xsdModelFile); - String xsdFile = URIHelper.getRelativeURI(newURI.toString(), currentIFile.getFullPath().toString()); - final String normalizedXSDFile = URIHelper.normalize(xsdFile, currentIFile.getLocation().toString(), ""); //$NON-NLS-1$ - - XSDParser parser = new XSDParser(); - parser.parse(normalizedXSDFile); - - externalSchema = parser.getSchema(); - - if (externalSchema != null) - { - String extNamespace = externalSchema.getTargetNamespace(); - if (extNamespace == null) extNamespace = ""; //$NON-NLS-1$ - namespace = extNamespace; - - if (externalSchema.getDiagnostics() != null && - externalSchema.getDiagnostics().size() > 0) - { - isValidSchemaLocation = false; - errorMessage = XSDEditorPlugin.getResourceString("_UI_INCORRECT_XML_SCHEMA", xsdModelFile); //$NON-NLS-1$ - } - else - { - String currentNameSpace = xsdSchema.getTargetNamespace(); - if (input instanceof XSDInclude || input instanceof XSDRedefine) - { - // Check the namespace to make sure they are the same as current file - if (extNamespace != null) - { - if (currentNameSpace != null && !extNamespace.equals(currentNameSpace)) - { - errorMessage = XSDEditorPlugin.getResourceString("_UI_DIFFERENT_NAME_SPACE", xsdModelFile); //$NON-NLS-1$ - isValidSchemaLocation = false; - } - } - } - else - { - // Check the namespace to make sure they are different from the current file - if (extNamespace != null) - { - if (currentNameSpace != null && extNamespace.equals(currentNameSpace)) - { - errorMessage = XSDEditorPlugin.getResourceString("_UI_SAME_NAME_SPACE", xsdModelFile); //$NON-NLS-1$ - isValidSchemaLocation = false; - } - } - } - } - } - else - { - errorMessage = Messages._UI_ERROR_INVALID_FILE; - isValidSchemaLocation = false; - } - } - catch(Exception e) - { - errorMessage = Messages._UI_ERROR_INVALID_FILE; - isValidSchemaLocation = false; - } - finally - { - if (!isValidSchemaLocation) - { - errorText.setText(errorMessage); - int length = errorText.getText().length(); - red = new Color(null, 255, 0, 0); - StyleRange style = new StyleRange(0, length, red, schemaLocationText.getBackground()); - errorText.setStyleRange(style); - } - else - { - handleSchemaLocationChange(xsdModelFile, namespace, externalSchema); - } - } - } - } - - protected void handleSchemaLocationChange(String schemaFileString, String namespace, XSDSchema externalSchema) - { - - } - - - public void dispose() - { - super.dispose(); - if (red != null) - { - red.dispose(); - red = null; - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/EnumerationsSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/EnumerationsSection.java deleted file mode 100644 index e33e4a18ac..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/EnumerationsSection.java +++ /dev/null @@ -1,405 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import com.ibm.icu.util.StringTokenizer; - -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.FormAttachment; -import org.eclipse.swt.layout.FormData; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -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.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.common.ui.internal.viewers.NavigableTableViewer; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddEnumerationsCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.SetXSDFacetValueCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.widgets.EnumerationsDialog; -import org.eclipse.xsd.XSDEnumerationFacet; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; - -public class EnumerationsSection extends AbstractSection -{ - private EnumerationsTableViewer enumerationsTable; - private Button addButton; - private Button addManyButton; - private Button deleteButton; - - /** - * - */ - public EnumerationsSection() - { - super(); - } - - public void widgetSelected(SelectionEvent e) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; - - if (e.widget == addButton) - { - List enumList = st.getEnumerationFacets(); - StringBuffer newName = new StringBuffer("value1"); //$NON-NLS-1$ - int suffix = 1; - for (Iterator i = enumList.iterator(); i.hasNext();) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) i.next(); - String value = enumFacet.getLexicalValue(); - if (value != null) - { - if (value.equals(newName.toString())) - { - suffix++; - newName = new StringBuffer("value" + String.valueOf(suffix)); //$NON-NLS-1$ - } - } - } - - AddEnumerationsCommand command = new AddEnumerationsCommand(Messages._UI_ACTION_ADD_ENUMERATION, (XSDSimpleTypeDefinition) input); - command.setValue(newName.toString()); - getCommandStack().execute(command); - - enumerationsTable.refresh(); - int newItemIndex = enumerationsTable.getTable().getItemCount() - 1; - enumerationsTable.editElement(enumerationsTable.getElementAt(newItemIndex), 0); - } - else if (e.widget == addManyButton) - { - Display display = Display.getCurrent(); - // if it is null, get the default one - display = display == null ? Display.getDefault() : display; - Shell parentShell = display.getActiveShell(); - EnumerationsDialog dialog = new EnumerationsDialog(parentShell); - dialog.setBlockOnOpen(true); - int result = dialog.open(); - - if (result == Window.OK) - { - String text = dialog.getText(); - String delimiter = dialog.getDelimiter(); - StringTokenizer tokenizer = new StringTokenizer(text, delimiter); - CompoundCommand compoundCommand = new CompoundCommand(Messages._UI_ACTION_ADD_ENUMERATIONS); - while (tokenizer.hasMoreTokens()) - { - String token = tokenizer.nextToken(); - if (dialog.isPreserveWhitespace() == false) - { - token = token.trim(); - } - AddEnumerationsCommand command = new AddEnumerationsCommand(Messages._UI_ACTION_ADD_ENUMERATIONS, (XSDSimpleTypeDefinition) input); - command.setValue(token); - compoundCommand.add(command); - } - getCommandStack().execute(compoundCommand); - } - enumerationsTable.refresh(); - } - else if (e.widget == deleteButton) - { - StructuredSelection selection = (StructuredSelection) enumerationsTable.getSelection(); - if (selection != null) - { - Iterator i = selection.iterator(); - CompoundCommand compoundCommand = new CompoundCommand(Messages._UI_ACTION_DELETE_ENUMERATION); - while (i.hasNext()) - { - Object obj = i.next(); - if (obj != null) - { - if (obj instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) obj; - - DeleteCommand deleteCommand = new DeleteCommand(Messages._UI_ACTION_DELETE_ENUMERATION, enumFacet); - compoundCommand.add(deleteCommand); - } - } - } - getCommandStack().execute(compoundCommand); - enumerationsTable.refresh(); - } - } - else if (e.widget == enumerationsTable.getTable()) - { - StructuredSelection selection = (StructuredSelection) enumerationsTable.getSelection(); - if (selection.getFirstElement() != null) - { - deleteButton.setEnabled(true); - } - else - { - deleteButton.setEnabled(false); - } - } - - } - - public void widgetDefaultSelected(SelectionEvent e) - { - - } - - public void createContents(Composite parent) - { - TabbedPropertySheetWidgetFactory factory = getWidgetFactory(); - composite = factory.createFlatFormComposite(parent); - - enumerationsTable = new EnumerationsTableViewer(getWidgetFactory().createTable(composite, SWT.MULTI | SWT.FULL_SELECTION)); - enumerationsTable.setInput(input); - Table table = enumerationsTable.getTable(); - table.addSelectionListener(this); - - addButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_ADD_BUTTON_LABEL"), SWT.PUSH); //$NON-NLS-1$ - addManyButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_REGEX_WIZARD_ADD_BUTTON_LABEL") + "...", SWT.PUSH); //$NON-NLS-1$ //$NON-NLS-2$ - deleteButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_ACTION_DELETE_INCLUDE"), SWT.PUSH); //$NON-NLS-1$ - - FormData data2 = new FormData(); - data2.top = new FormAttachment(0, 0); - data2.left = new FormAttachment(100, -100); - data2.right = new FormAttachment(100, 0); - // data2.width = 50; - addButton.setLayoutData(data2); - addButton.addSelectionListener(this); - - FormData data = new FormData(); - data.left = new FormAttachment(addButton, 0, SWT.LEFT); - data.right = new FormAttachment(100, 0); - data.top = new FormAttachment(addButton, 0); - addManyButton.setLayoutData(data); - addManyButton.addSelectionListener(this); - - data = new FormData(); - data.left = new FormAttachment(addButton, 0, SWT.LEFT); - data.right = new FormAttachment(100, 0); - data.top = new FormAttachment(addManyButton, 0); - deleteButton.setLayoutData(data); - deleteButton.setEnabled(false); - deleteButton.addSelectionListener(this); - - data = new FormData(); - data.top = new FormAttachment(0, 0); - data.left = new FormAttachment(0, 0); - data.right = new FormAttachment(addButton, 0); - data.bottom = new FormAttachment(100, 0); - data.width = 50; - table.setLayoutData(data); - table.addListener(SWT.Resize, this); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - if (isReadOnly) - { - composite.setEnabled(false); - } - else - { - composite.setEnabled(true); - } - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; - - Iterator validFacets = st.getValidFacets().iterator(); - - boolean isApplicable = false; - while (validFacets.hasNext()) - { - String aValidFacet = (String) validFacets.next(); - if (aValidFacet.equals(XSDConstants.ENUMERATION_ELEMENT_TAG)) - { - isApplicable = true; - } - } - - if (isApplicable) - { - addButton.setEnabled(true); - addManyButton.setEnabled(true); - } - else - { - addButton.setEnabled(false); - addManyButton.setEnabled(false); - } - enumerationsTable.setInput(input); - } - - public void handleEvent(Event event) - { - Table table = enumerationsTable.getTable(); - if (event.type == SWT.Resize && event.widget == table) - { - TableColumn tableColumn = table.getColumn(0); - tableColumn.setWidth(table.getSize().x); - } - } - - public void dispose() - { - } - - public boolean shouldUseExtraSpace() - { - return true; - } - - class EnumerationsTableViewer extends NavigableTableViewer implements ICellModifier - { - protected String[] columnProperties = { XSDConstants.ENUMERATION_ELEMENT_TAG }; - - protected CellEditor[] cellEditors; - - Table table; - - public EnumerationsTableViewer(Table table) - { - super(table); - table = getTable(); - - table.setLinesVisible(true); - - setContentProvider(new EnumerationsTableContentProvider()); - setLabelProvider(new EnumerationsTableLabelProvider()); - setColumnProperties(columnProperties); - - setCellModifier(this); - - TableColumn column = new TableColumn(table, SWT.NONE, 0); - column.setText(columnProperties[0]); - column.setAlignment(SWT.LEFT); - column.setResizable(true); - - cellEditors = new CellEditor[1]; - - TableLayout layout = new TableLayout(); - ColumnWeightData data = new ColumnWeightData(100); - - layout.addColumnData(data); - cellEditors[0] = new TextCellEditor(table); - - getTable().setLayout(layout); - setCellEditors(cellEditors); - } - - public boolean canModify(Object element, String property) - { - return true; - } - - public void modify(Object element, String property, Object value) - { - if (element instanceof TableItem && (value != null)) - { - TableItem item = (TableItem) element; - - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) item.getData(); - SetXSDFacetValueCommand command = new SetXSDFacetValueCommand(Messages._UI_ACTION_SET_ENUMERATION_VALUE, enumFacet); - command.setValue((String) value); - getCommandStack().execute(command); - item.setData(enumFacet); - item.setText((String) value); - } - } - - public Object getValue(Object element, String property) - { - if (element instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) element; - String value = enumFacet.getLexicalValue(); - if (value == null) - value = ""; //$NON-NLS-1$ - return value; - } - return ""; //$NON-NLS-1$ - } - - } - - class EnumerationsTableContentProvider implements IStructuredContentProvider - { - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - } - - public java.lang.Object[] getElements(java.lang.Object inputElement) - { - java.util.List list = new ArrayList(); - if (inputElement instanceof XSDSimpleTypeDefinition) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) inputElement; - return st.getEnumerationFacets().toArray(); - } - return list.toArray(); - } - - public void dispose() - { - } - } - - class EnumerationsTableLabelProvider extends LabelProvider implements ITableLabelProvider - { - public EnumerationsTableLabelProvider() - { - - } - - public Image getColumnImage(Object element, int columnIndex) - { - return XSDEditorPlugin.getXSDImage("icons/XSDSimpleEnum.gif"); //$NON-NLS-1$ - } - - public String getColumnText(Object element, int columnIndex) - { - if (element instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) element; - String value = enumFacet.getLexicalValue(); - if (value == null) - value = ""; //$NON-NLS-1$ - return value; - } - return ""; //$NON-NLS-1$ - } - - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/ExtensionsSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/ExtensionsSection.java deleted file mode 100644 index 498baa4ca1..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/ExtensionsSection.java +++ /dev/null @@ -1,287 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionAttributeCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddExtensionElementCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.RemoveExtensionNodeCommand; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.AddExtensionsComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.CategoryProvider; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.DOMExtensionTreeLabelProvider; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionItemFilter; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.ExtensionsSchemasRegistry; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.SpecificationForExtensionsSchema; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.XSDExtensionTreeContentProvider; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.NodeFilter; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.text.XSDModelAdapter; -import org.eclipse.wst.xsd.ui.internal.util.ModelReconcileAdapter; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class ExtensionsSection extends AbstractExtensionsSection -{ - XSDModelAdapter adapter = null; - - public ExtensionsSection() - { - super(); - setExtensionTreeLabelProvider(new DOMExtensionTreeLabelProvider()); - setExtensionTreeContentProvider(new XSDExtensionTreeContentProvider()); - } - - protected AddExtensionsComponentDialog createAddExtensionsComponentDialog() - { - AddExtensionsComponentDialog dialog = new AddExtensionsComponentDialog(composite.getShell(), getExtensionsSchemasRegistry()) - { - protected IStructuredContentProvider getCategoryContentProvider() - { - return new XSDCategoryContentProvider(); - } - }; - dialog.addElementsTableFilter(new AddExtensionsComponentDialogFilter(input, dialog)); - return dialog; - } - - public void setInput(IWorkbenchPart part, ISelection selection) - { - super.setInput(part, selection); - if (adapter == null) - { - if (selection instanceof StructuredSelection) - { - Object obj = ((StructuredSelection) selection).getFirstElement(); - if (obj instanceof XSDConcreteComponent) - { - Element element = ((XSDConcreteComponent)obj).getElement(); - if (element != null) - { - adapter = XSDModelAdapter.lookupOrCreateModelAdapter(element.getOwnerDocument()); - if (adapter != null) - { - ModelReconcileAdapter modelReconcileAdapter = adapter.getModelReconcileAdapter(); - if (modelReconcileAdapter != null) - { - modelReconcileAdapter.addListener(internalNodeAdapter); - } - } - } - } - } - } - extensionTreeViewer.expandToLevel(2); - } - - public void dispose() - { - super.dispose(); - if (adapter != null) - { - ModelReconcileAdapter modelReconciler = adapter.getModelReconcileAdapter(); - if (modelReconciler != null) - { - modelReconciler.removeListener(internalNodeAdapter); - } - } - } - - protected AddExtensionCommand getAddExtensionCommand(Object o) - { - AddExtensionCommand addExtensionCommand = null; - if (o instanceof XSDElementDeclaration) - { - XSDElementDeclaration element = (XSDElementDeclaration) o; - ExtensibleAddExtensionCommand extensibleAddExtensionCommand = getExtensionsSchemasRegistry().getAddExtensionCommand(element.getTargetNamespace()); - if (extensibleAddExtensionCommand != null) - { - extensibleAddExtensionCommand.setInputs((XSDConcreteComponent) input, element); - addExtensionCommand = extensibleAddExtensionCommand; - } - else - { - addExtensionCommand = new AddExtensionElementCommand(Messages._UI_ACTION_ADD_APPINFO_ELEMENT, (XSDConcreteComponent) input, element); - } - } - else if (o instanceof XSDAttributeDeclaration) - { - XSDAttributeDeclaration attribute = (XSDAttributeDeclaration) o; - addExtensionCommand = new AddExtensionAttributeCommand(Messages._UI_ACTION_ADD_APPINFO_ATTRIBUTE, (XSDConcreteComponent) input, attribute); - } - return addExtensionCommand; - } - - protected Command getRemoveExtensionCommand(Object o) - { - Command command = null; - try - { - if (o instanceof Node) - { - Node node = (Node)o; - ExtensibleRemoveExtensionNodeCommand removeCommand = getExtensionsSchemasRegistry().getRemoveExtensionNodeCommand(node.getNamespaceURI()); - if (removeCommand != null) - { - removeCommand.setInput((XSDConcreteComponent)input); - removeCommand.setNode(node); - return removeCommand; - } - else - { - command = new RemoveExtensionNodeCommand(Messages._UI_ACTION_DELETE_APPINFO_ELEMENT, node); - // command.execute(); - } - } - } - catch (Exception e) - { - } - return command; - } - - protected ExtensionsSchemasRegistry getExtensionsSchemasRegistry() - { - return XSDEditorPlugin.getDefault().getExtensionsSchemasRegistry(); - } - - protected boolean isTreeViewerInputElement(Element element) - { - if (input instanceof XSDConcreteComponent) - { - XSDConcreteComponent component = (XSDConcreteComponent)input; - Element componentElement = component.getElement(); - Node parent = element.getParentNode(); - Node grandParent = parent != null ? parent.getParentNode() : null; - return componentElement == element || componentElement == parent || componentElement == grandParent; - } - return false; - } - - protected IPreferenceStore getPrefStore() - { - return XSDEditorPlugin.getPlugin().getPreferenceStore(); - } - - static class XSDCategoryContentProvider implements IStructuredContentProvider - { - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) - { - SpecificationForExtensionsSchema[] extensionsSchemaSpecs = null; - try - { - List inputList = (List) inputElement; - - List total = new ArrayList(); - total.addAll(inputList); - - List dynamicCategories = XSDEditorPlugin.getPlugin().getExtensionsSchemasRegistry().getCategoryProviders(); - for (Iterator iter = dynamicCategories.iterator(); iter.hasNext(); ) - { - CategoryProvider categoryProvider = (CategoryProvider)iter.next(); - for (Iterator it = categoryProvider.getCategories().iterator(); it.hasNext(); ) - { - SpecificationForExtensionsSchema sp = (SpecificationForExtensionsSchema)it.next(); - total.add(sp); - } - } - - extensionsSchemaSpecs = (SpecificationForExtensionsSchema[]) total.toArray(new SpecificationForExtensionsSchema[0]); - } - catch (Exception e) - { - } - return extensionsSchemaSpecs; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() - { - // Do nothing - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - // Do nothing - - } - } - - /** - * This filter is to be used by the dialog invoked when addButton is pressed - */ - private class AddExtensionsComponentDialogFilter extends ViewerFilter - { - private Object input; - private AddExtensionsComponentDialog dialog; - - public AddExtensionsComponentDialogFilter(Object input, AddExtensionsComponentDialog dialog) - { - this.input = input; - this.dialog = dialog; - } - - public boolean select(Viewer viewer, Object parentElement, Object element) - { - if (input instanceof XSDConcreteComponent && - element instanceof XSDConcreteComponent) - { - SpecificationForExtensionsSchema spec = dialog.getSelectedCategory(); - // here we obtain the node filter that was registered for the applicable namespace - // notied - NodeFilter filter = XSDEditorPlugin.getPlugin().getNodeCustomizationRegistry().getNodeFilter(spec.getNamespaceURI()); - if (filter instanceof ExtensionItemFilter) - { - ExtensionItemFilter extensionItemFilter = (ExtensionItemFilter)filter; - return extensionItemFilter.isApplicableContext((XSDConcreteComponent)input, (XSDConcreteComponent)element); - } - else - { - // TODO cs: even if it's just a plain old NodeFilter we should still be able to use it! - } - } - return true; - } - } - -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/FacetViewer.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/FacetViewer.java deleted file mode 100644 index e13d74d745..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/FacetViewer.java +++ /dev/null @@ -1,559 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -//import java.util.ArrayList; -//import java.util.Iterator; -//import java.util.List; -// -//import org.eclipse.jface.viewers.CellEditor; -//import org.eclipse.jface.viewers.ColumnWeightData; -//import org.eclipse.jface.viewers.ICellModifier; -//import org.eclipse.jface.viewers.ISelectionChangedListener; -//import org.eclipse.jface.viewers.IStructuredContentProvider; -//import org.eclipse.jface.viewers.ITableLabelProvider; -//import org.eclipse.jface.viewers.LabelProvider; -//import org.eclipse.jface.viewers.SelectionChangedEvent; -//import org.eclipse.jface.viewers.StructuredSelection; -//import org.eclipse.jface.viewers.TableLayout; -//import org.eclipse.jface.viewers.TextCellEditor; -//import org.eclipse.jface.viewers.Viewer; -//import org.eclipse.swt.SWT; -//import org.eclipse.swt.events.MouseEvent; -//import org.eclipse.swt.events.MouseTrackAdapter; -//import org.eclipse.swt.graphics.Image; -//import org.eclipse.swt.graphics.Point; -//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.common.ui.internal.viewers.NavigableTableViewer; -//import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -//import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute; -//import org.eclipse.wst.xsd.ui.internal.properties.XSDComboBoxPropertyDescriptor; -//import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -//import org.eclipse.xsd.XSDConstrainingFacet; -//import org.eclipse.xsd.XSDFactory; -//import org.eclipse.xsd.XSDMaxExclusiveFacet; -//import org.eclipse.xsd.XSDMaxFacet; -//import org.eclipse.xsd.XSDMaxInclusiveFacet; -//import org.eclipse.xsd.XSDMinExclusiveFacet; -//import org.eclipse.xsd.XSDMinFacet; -//import org.eclipse.xsd.XSDMinInclusiveFacet; -//import org.eclipse.xsd.XSDSimpleTypeDefinition; -//import org.eclipse.xsd.util.XSDConstants; -//import org.eclipse.xsd.util.XSDSchemaBuildingTools; -//import org.w3c.dom.Element; - -public class FacetViewer //extends NavigableTableViewer implements ICellModifier -{ -// public static final String FACET_NAME = XSDEditorPlugin.getXSDString("_UI_FACET_NAME"); // "Name"; -// public static final String FACET_VALUE = XSDEditorPlugin.getXSDString("_UI_FACET_VALUE"); // "Value"; -// public static final String FACET_OTHER = XSDEditorPlugin.getXSDString("_UI_FACET_FIXED"); // "Fixed"; -// -// protected FacetsTableLabelProvider facetsTableLabelProvider = new FacetsTableLabelProvider(); -// protected FacetsTableContentProvider facetsTableContentProvider = new FacetsTableContentProvider(); -// protected String[] columnProperties = { FACET_NAME, FACET_VALUE, FACET_OTHER }; -// protected CellEditor[] cellEditors; // these cellEditors are used when -// // non-whitespace facet is selected -// protected CellEditor[] altCellEditors; // these cellEditors are used when -// // whitespace facet is selected -// -// protected String[] whiteSpaceValues = new String[] { "", "preserve", "replace", "collapse" }; -// protected String[] trueFalseValues = new String[] { "", "false", "true" }; -// -// /** -// * @param parent -// */ -// public FacetViewer(Composite parent) -// { -// super(new Table(parent, SWT.FULL_SELECTION | SWT.SINGLE)); -// -// getTable().setLinesVisible(true); -// getTable().setHeaderVisible(true); -// -// addSelectionChangedListener(new SelectionChangedListener()); -// getTable().addMouseTrackListener(new MyMouseTrackListener()); -// -// setContentProvider(facetsTableContentProvider); -// setLabelProvider(facetsTableLabelProvider); -// setColumnProperties(columnProperties); -// -// setCellModifier(this); -// -// for (int i = 0; i < 3; i++) -// { -// TableColumn column = new TableColumn(getTable(), SWT.NONE, i); -// column.setText(columnProperties[i]); -// column.setAlignment(SWT.LEFT); -// column.setResizable(true); -// } -// -// cellEditors = new CellEditor[3]; -// altCellEditors = new CellEditor[3]; -// -// TableLayout layout = new TableLayout(); -// ColumnWeightData data = new ColumnWeightData(60, 80, true); -// layout.addColumnData(data); -// cellEditors[0] = null; -// -// ColumnWeightData data2 = new ColumnWeightData(120, 80, true); -// layout.addColumnData(data2); -// -// cellEditors[1] = new TextCellEditor(getTable()); -// XSDComboBoxPropertyDescriptor pd = new XSDComboBoxPropertyDescriptor("combo", "whitespace", whiteSpaceValues); -// altCellEditors[1] = pd.createPropertyEditor(getTable()); -// -// ColumnWeightData data3 = new ColumnWeightData(60, 60, true); -// layout.addColumnData(data3); -// -// XSDComboBoxPropertyDescriptor pd2 = new XSDComboBoxPropertyDescriptor("combo", "other", trueFalseValues); -// cellEditors[2] = pd2.createPropertyEditor(getTable()); -// altCellEditors[2] = pd2.createPropertyEditor(getTable()); -// -// getTable().setLayout(layout); -// setCellEditors(cellEditors); -// -// } -// -// /* -// * (non-Javadoc) -// * -// * @see org.eclipse.jface.viewers.ICellModifier#canModify(java.lang.Object, -// * java.lang.String) -// */ -// public boolean canModify(Object element, String property) -// { -// return property.equals(FACET_VALUE) || property.equals(FACET_OTHER); -// } -// -// /* -// * (non-Javadoc) -// * -// * @see org.eclipse.jface.viewers.ICellModifier#getValue(java.lang.Object, -// * java.lang.String) -// */ -// public Object getValue(Object element, String property) -// { -// int column = 0; -// if (property.equals(columnProperties[0])) -// { -// column = 0; -// } -// else if (property.equals(columnProperties[1])) -// { -// column = 1; -// } -// else if (property.equals(columnProperties[2])) -// { -// column = 2; -// } -// -// return facetsTableLabelProvider.getColumnText(element, column); -// } -// -// /* -// * (non-Javadoc) -// * -// * @see org.eclipse.jface.viewers.ICellModifier#modify(java.lang.Object, -// * java.lang.String, java.lang.Object) -// */ -// public void modify(Object element, String property, Object value) -// { -// XSDSimpleTypeDefinition xsdSimpleType = (XSDSimpleTypeDefinition) getInput(); -// TableItem item = (TableItem) element; -// if (item != null) -// { -// Object o = item.getData(); -// if (o != null) -// { -// if (o instanceof String) -// { -// String facet = (String) o; -// -// Element simpleTypeElement = xsdSimpleType.getElement(); -// XSDDOMHelper xsdDOMHelper = new XSDDOMHelper(); -// Element derivedByElement = xsdDOMHelper.getDerivedByElement(simpleTypeElement); -// -// String prefix = simpleTypeElement.getPrefix(); -// prefix = (prefix == null) ? "" : (prefix + ":"); -// -// Element childNodeElement = null; -// DOMAttribute valueAttr = null; -// -// XSDConstrainingFacet targetFacet = getXSDConstrainingFacet(facet); -// -// String newValue = ""; -// if (value != null && value instanceof String) -// { -// newValue = (String) value; -// } -// -// if (property.equals(columnProperties[1])) -// { -// if (targetFacet == null && newValue.length() > 0) -// { -// targetFacet = createFacet(facet); -// childNodeElement = (derivedByElement.getOwnerDocument()).createElementNS(XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001, prefix + facet); -// valueAttr = new DOMAttribute(XSDConstants.VALUE_ATTRIBUTE, newValue); -// childNodeElement.setAttribute(valueAttr.getName(), valueAttr.getValue()); -// // add and format child -// derivedByElement.appendChild(childNodeElement); -// targetFacet.setElement(childNodeElement); -// XSDDOMHelper.formatChild(childNodeElement); -// -// // XSDSchemaHelper.updateElement(xsdSimpleType); -// } -// if (targetFacet == null) -// { -// return; -// } -// -// if (newValue.length() > 0) -// { -// targetFacet.setLexicalValue(newValue); -// -// if (targetFacet instanceof XSDMaxFacet || targetFacet instanceof XSDMinFacet) -// { -// if (targetFacet instanceof XSDMaxFacet) -// { -// if (targetFacet instanceof XSDMaxExclusiveFacet) -// { -// XSDMaxInclusiveFacet xsdMaxInclusiveFacet = xsdSimpleType.getMaxInclusiveFacet(); -// if (xsdMaxInclusiveFacet != null) -// { -// Element xsdMaxInclusiveFacetElement = xsdMaxInclusiveFacet.getElement(); -// XSDDOMHelper.removeNodeAndWhitespace(xsdMaxInclusiveFacetElement); -// } -// } -// else if (targetFacet instanceof XSDMaxInclusiveFacet) -// { -// XSDMaxExclusiveFacet xsdMaxExclusiveFacet = xsdSimpleType.getMaxExclusiveFacet(); -// if (xsdMaxExclusiveFacet != null) -// { -// Element xsdMaxExclusiveFacetElement = xsdMaxExclusiveFacet.getElement(); -// XSDDOMHelper.removeNodeAndWhitespace(xsdMaxExclusiveFacetElement); -// } -// } -// } -// else if (targetFacet instanceof XSDMinFacet) -// { -// if (targetFacet instanceof XSDMinExclusiveFacet) -// { -// XSDMinInclusiveFacet xsdMinInclusiveFacet = xsdSimpleType.getMinInclusiveFacet(); -// if (xsdMinInclusiveFacet != null) -// { -// Element xsdMinInclusiveFacetElement = xsdMinInclusiveFacet.getElement(); -// XSDDOMHelper.removeNodeAndWhitespace(xsdMinInclusiveFacetElement); -// } -// } -// else if (targetFacet instanceof XSDMinInclusiveFacet) -// { -// XSDMinExclusiveFacet xsdMinExclusiveFacet = xsdSimpleType.getMinExclusiveFacet(); -// if (xsdMinExclusiveFacet != null) -// { -// Element xsdMinExclusiveFacetElement = xsdMinExclusiveFacet.getElement(); -// XSDDOMHelper.removeNodeAndWhitespace(xsdMinExclusiveFacetElement); -// } -// } -// } -// } -// } -// else -// // newValue.length == 0 -// { -// Element targetFacetElement = targetFacet.getElement(); -// XSDDOMHelper.removeNodeAndWhitespace(targetFacetElement); -// } -// } -// else if (property.equals(columnProperties[2])) -// { -// if (targetFacet != null) -// { -// if (newValue.length() > 0) -// { -// targetFacet.getElement().setAttribute(XSDConstants.FIXED_ATTRIBUTE, newValue); -// } -// else -// { -// targetFacet.getElement().removeAttribute(XSDConstants.FIXED_ATTRIBUTE); -// } -// } -// } -// xsdSimpleType.setElement(simpleTypeElement); -// // xsdSimpleType.updateElement(); -// refresh(); -// } -// } -// } -// } -// -// private XSDConstrainingFacet getXSDConstrainingFacet(String facetString) -// { -// XSDSimpleTypeDefinition xsdSimpleType = (XSDSimpleTypeDefinition) getInput(); -// List list = xsdSimpleType.getFacetContents(); -// if (list == null) -// { -// return null; -// } -// Iterator iter = list.iterator(); -// XSDConstrainingFacet targetFacet = null; -// -// while (iter.hasNext()) -// { -// XSDConstrainingFacet xsdConstrainingFacet = (XSDConstrainingFacet) iter.next(); -// if (xsdConstrainingFacet.getFacetName().equals(facetString)) -// { -// targetFacet = xsdConstrainingFacet; -// break; -// } -// } -// return targetFacet; -// } -// -// private XSDConstrainingFacet createFacet(String facet) -// { -// XSDFactory factory = XSDSchemaBuildingTools.getXSDFactory(); -// XSDConstrainingFacet xsdFacet = null; -// if (facet.equals("length")) -// { -// xsdFacet = factory.createXSDLengthFacet(); -// } -// else if (facet.equals("minLength")) -// { -// xsdFacet = factory.createXSDMinLengthFacet(); -// } -// else if (facet.equals("maxLength")) -// { -// xsdFacet = factory.createXSDMaxLengthFacet(); -// } -// else if (facet.equals("minInclusive")) -// { -// xsdFacet = factory.createXSDMinInclusiveFacet(); -// } -// else if (facet.equals("minExclusive")) -// { -// xsdFacet = factory.createXSDMinExclusiveFacet(); -// } -// else if (facet.equals("maxInclusive")) -// { -// xsdFacet = factory.createXSDMaxInclusiveFacet(); -// } -// else if (facet.equals("maxExclusive")) -// { -// xsdFacet = factory.createXSDMaxExclusiveFacet(); -// } -// -// else if (facet.equals("totalDigits")) -// { -// xsdFacet = factory.createXSDTotalDigitsFacet(); -// } -// else if (facet.equals("fractionDigits")) -// { -// xsdFacet = factory.createXSDFractionDigitsFacet(); -// } -// else if (facet.equals("whiteSpace")) -// { -// xsdFacet = factory.createXSDWhiteSpaceFacet(); -// } -// return xsdFacet; -// } -// -// /** -// * Get the tooltip for the facet -// */ -// public String getToolTip(String facet) -// { -// String key = ""; -// if (facet.equals("length")) -// { -// key = "_UI_TOOLTIP_LENGTH"; -// } -// else if (facet.equals("minLength")) -// { -// key = "_UI_TOOLTIP_MIN_LEN"; -// } -// else if (facet.equals("maxLength")) -// { -// key = "_UI_TOOLTIP_MAX_LEN"; -// } -// -// else if (facet.equals("minInclusive")) -// { -// key = "_UI_TOOLTIP_MIN_INCLUSIVE"; -// } -// else if (facet.equals("minExclusive")) -// { -// key = "_UI_TOOLTIP_MIN_EXCLUSIVE"; -// } -// -// else if (facet.equals("maxInclusive")) -// { -// key = "_UI_TOOLTIP_MAX_INCLUSIVE"; -// } -// else if (facet.equals("maxExclusive")) -// { -// key = "_UI_TOOLTIP_MAX_EXCLUSIVE"; -// } -// -// else if (facet.equals("totalDigits")) -// { -// key = "_UI_TOOLTIP_TOTAL_DIGITS"; -// } -// else if (facet.equals("fractionDigits")) -// { -// key = "_UI_TOOLTIP_FRACTION_DIGITS"; -// } -// -// else if (facet.equals("whiteSpace")) -// { -// key = "_UI_TOOLTIP_WHITE_SPACE"; -// } -// -// return (key != null) ? XSDEditorPlugin.getXSDString(key) : ""; -// } -// -// /** -// * This listener detects which row is selected and add a tool tip for that row -// */ -// public class MyMouseTrackListener extends MouseTrackAdapter -// { -// public void mouseHover(MouseEvent e) -// { -// TableItem item = getTable().getItem(new Point(e.x, e.y)); -// if (item != null) -// { -// Object o = item.getData(); -// if (o != null) -// { -// String facetName = (String) o; -// getTable().setToolTipText(getToolTip(facetName)); -// } -// } -// } -// } -// -// /** -// * Based on the selection, detects if it is a white space or not, and add the -// * corresponding cell editors -// */ -// public class SelectionChangedListener implements ISelectionChangedListener -// { -// public void selectionChanged(SelectionChangedEvent event) -// { -// Object selection = event.getSelection(); -// if (selection instanceof StructuredSelection) -// { -// Object o = ((StructuredSelection) selection).getFirstElement(); -// if (o != null) -// { -// String facet = (String) o; -// if (facet.equals("whiteSpace")) -// { -// setCellEditors(altCellEditors); -// } -// else -// { -// setCellEditors(cellEditors); -// } -// } -// } -// } -// } -// -// class FacetsTableContentProvider implements IStructuredContentProvider -// { -// protected String facet; -// -// public void inputChanged(Viewer viewer, Object oldInput, Object newInput) -// { -// } -// -// public java.lang.Object[] getElements(java.lang.Object inputElement) -// { -// List v = new ArrayList(); -// XSDSimpleTypeDefinition inputXSDSimpleType = (XSDSimpleTypeDefinition) inputElement; -// XSDSimpleTypeDefinition base = inputXSDSimpleType.getPrimitiveTypeDefinition(); -// -// if (base != null) -// { -// Iterator validFacets = inputXSDSimpleType.getValidFacets().iterator(); -// while (validFacets.hasNext()) -// { -// String aValidFacet = (String) validFacets.next(); -// if (!(aValidFacet.equals("pattern") || aValidFacet.equals("enumeration"))) -// { -// v.add(aValidFacet); -// } -// } -// } -// return v.toArray(); -// } -// -// public void dispose() -// { -// } -// } -// -// class FacetsTableLabelProvider extends LabelProvider implements ITableLabelProvider -// { -// public Image getColumnImage(Object element, int columnIndex) -// { -// return null; -// } -// -// public String getColumnText(Object element, int columnIndex) -// { -// if (element instanceof String) -// { -// String value = null; -// XSDConstrainingFacet targetFacet = getXSDConstrainingFacet((String) element); -// switch (columnIndex) -// { -// case 0: -// { -// value = (String) element; -// break; -// } -// case 1: -// { -// if (targetFacet == null) -// { -// value = ""; -// } -// else -// { -// value = targetFacet.getLexicalValue(); -// } -// -// break; -// } -// case 2: -// { -// if (targetFacet == null) -// { -// value = ""; -// } -// else -// { -// Element elem = targetFacet.getElement(); -// value = elem.getAttribute(XSDConstants.FIXED_ATTRIBUTE); -// if (value == null) -// value = ""; -// } -// } -// } -// return value; -// } -// return ""; -// } -// } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/IDocumentChangedNotifier.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/IDocumentChangedNotifier.java deleted file mode 100644 index a72e632f4e..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/IDocumentChangedNotifier.java +++ /dev/null @@ -1,19 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.wst.sse.core.internal.provisional.INodeAdapter; - -public interface IDocumentChangedNotifier -{ - public void addListener(INodeAdapter adapter); - public void removeListener(INodeAdapter adapter); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/MultiplicitySection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/MultiplicitySection.java deleted file mode 100644 index 94593d4068..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/MultiplicitySection.java +++ /dev/null @@ -1,216 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateMaxOccursCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateMinOccursCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDParticleContent; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - - -public class MultiplicitySection extends RefactoringSection -{ - protected CCombo minCombo, maxCombo; - - public MultiplicitySection() - { - super(); - } - - protected void createContents(Composite parent) - { - } - - - public void doHandleEvent(Event event) - { - if (event.widget == minCombo) - { - updateMinAttribute(); - } - else if (event.widget == maxCombo) - { - updateMaxAttribute(); - } - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == minCombo) - { - updateMinAttribute(); - } - else if (e.widget == maxCombo) - { - updateMaxAttribute(); - } - super.doWidgetSelected(e); - } - - protected void updateMaxAttribute() - { - setErrorMessage(null); - XSDParticle particle = null; - - if (input instanceof XSDParticleContent) - { - particle = getAssociatedParticle((XSDParticleContent) input); - } - if (particle != null) - { - String newValue = maxCombo.getText().trim(); - - if (newValue.length() == 0) - { - particle.unsetMaxOccurs(); - return; - } - try - { - int newMax = 1; - if (newValue.equals("unbounded") || newValue.equals("*")) //$NON-NLS-1$ //$NON-NLS-2$ - { - newMax = XSDParticle.UNBOUNDED; - } - else - { - if (newValue.length() > 0) - { - newMax = Integer.parseInt(newValue); - } - } - setListenerEnabled(false); - UpdateMaxOccursCommand command = new UpdateMaxOccursCommand(Messages._UI_ACTION_CHANGE_MAXIMUM_OCCURRENCE, particle, newMax); - getCommandStack().execute(command); - setListenerEnabled(true); - - } - catch (NumberFormatException e) - { - setErrorMessage(Messages._UI_ERROR_INVALID_VALUE_FOR_MAXIMUM_OCCURRENCE); - } - } - } - - protected void updateMinAttribute() - { - setErrorMessage(null); - XSDParticle particle = null; - - if (input instanceof XSDParticleContent) - { - particle = getAssociatedParticle((XSDParticleContent) input); - } - if (particle != null) - { - String newValue = minCombo.getText(); - if (newValue.length() == 0) - { - particle.unsetMinOccurs(); - } - try - { - int newMin = 1; - if (newValue.equals("unbounded") || newValue.equals("*")) //$NON-NLS-1$ //$NON-NLS-2$ - { - newMin = XSDParticle.UNBOUNDED; - } - else - { - newMin = Integer.parseInt(newValue); - } - UpdateMinOccursCommand command = new UpdateMinOccursCommand(Messages._UI_ACTION_CHANGE_MINIMUM_OCCURRENCE, particle, newMin); - getCommandStack().execute(command); - } - catch (NumberFormatException e) - { - - } - } - } - - protected void refreshMinMax() - { - boolean refreshMinText = true; - boolean refreshMaxText = true; - if (minCombo.isFocusControl()) - { - refreshMinText = false; - } - if (maxCombo.isFocusControl()) - { - refreshMaxText = false; - } - if (refreshMinText) - { - minCombo.setText(""); //$NON-NLS-1$ - } - if (refreshMaxText) - { - maxCombo.setText(""); //$NON-NLS-1$ - } - - if (input != null) - { - if (input instanceof XSDParticleContent) - { - XSDParticle particle = getAssociatedParticle((XSDParticleContent) input); - if (particle != null) - { - // minText.setText(String.valueOf(particle.getMinOccurs())); - // maxText.setText(String.valueOf(particle.getMaxOccurs())); - Element element = particle.getElement(); - if (element != null) - { - String min = element.getAttribute(XSDConstants.MINOCCURS_ATTRIBUTE); - String max = element.getAttribute(XSDConstants.MAXOCCURS_ATTRIBUTE); - if (min != null && refreshMinText) - { - minCombo.setText(min); - } - if (max != null && refreshMaxText) - { - maxCombo.setText(max); - } - } - } - } - } - } - - protected XSDParticle getAssociatedParticle(XSDParticleContent particleContent) - { - XSDConcreteComponent xsdComp = particleContent.getContainer(); - if (xsdComp instanceof XSDParticle) - { - return (XSDParticle) xsdComp; - } - return null; - } - - public void dispose() - { - if (minCombo != null && !minCombo.isDisposed()) - removeListeners(minCombo); - if (maxCombo != null && !maxCombo.isDisposed()) - removeListeners(maxCombo); - super.dispose(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/RefactoringSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/RefactoringSection.java deleted file mode 100644 index a209eb0a06..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/RefactoringSection.java +++ /dev/null @@ -1,93 +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.xsd.ui.internal.common.properties.sections; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.forms.events.HyperlinkEvent; -import org.eclipse.ui.forms.events.IHyperlinkListener; -import org.eclipse.ui.forms.widgets.ImageHyperlink; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.ISelectionMapper; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.refactor.actions.RenameComponentAction; -import org.eclipse.xsd.XSDSchema; - -public abstract class RefactoringSection extends AbstractSection implements IHyperlinkListener -{ - /** - * Clicking on it invokes the refactor->rename action. - */ - private ImageHyperlink renameHyperlink; - - /** - * Invokes the refactor->rename action on the current selection. - */ - private void invokeRenameRefactoring() - { - IEditorPart editor = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor(); - XSDSchema schema = (XSDSchema) editor.getAdapter(XSDSchema.class); - ISelection selection = editor.getSite().getSelectionProvider().getSelection(); - ISelectionMapper mapper = (ISelectionMapper) editor.getAdapter(ISelectionMapper.class); - selection = mapper != null ? mapper.mapSelection(selection) : selection; - RenameComponentAction action = new RenameComponentAction(selection, schema); - action.update(selection); - action.run(); - } - - /** - * Creates the refactor/rename hyperlink shown beside a component name. - * Clicking on the hyperlink invokes the refactor/rename action. - * - * @param parent - * the parent composite. Must not be null. - */ - protected void createRenameHyperlink(Composite parent) - { - renameHyperlink = getWidgetFactory().createImageHyperlink(parent, SWT.NONE); - - renameHyperlink.setImage(XSDEditorPlugin.getXSDImage("icons/quickassist.gif")); //$NON-NLS-1$ - renameHyperlink.setToolTipText(Messages._UI_TOOLTIP_RENAME_REFACTOR); - renameHyperlink.addHyperlinkListener(this); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkActivated(org.eclipse.ui.forms.events.HyperlinkEvent) - */ - public void linkActivated(HyperlinkEvent e) - { - invokeRenameRefactoring(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkEntered(org.eclipse.ui.forms.events.HyperlinkEvent) - */ - public void linkEntered(HyperlinkEvent e) - { - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.forms.events.IHyperlinkListener#linkExited(org.eclipse.ui.forms.events.HyperlinkEvent) - */ - public void linkExited(HyperlinkEvent e) - { - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java deleted file mode 100644 index 129eafd5ab..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SchemaLocationSection.java +++ /dev/null @@ -1,207 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.ui.internal.viewers.ResourceFilter; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.wizards.XSDSelectIncludeFileWizard; -import org.eclipse.xsd.XSDInclude; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.impl.XSDIncludeImpl; -import org.eclipse.xsd.impl.XSDRedefineImpl; -import org.w3c.dom.Element; - -public class SchemaLocationSection extends CommonDirectivesSection -{ - IWorkbenchPart part; - - /** - * - */ - public SchemaLocationSection() - { - super(); - } - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - GridData data = new GridData(); - - // Create Schema Location Label - CLabel schemaLocationLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_LOCATION")); //$NON-NLS-1$ - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - schemaLocationLabel.setLayoutData(data); - - // Create Schema Location Text - schemaLocationText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$ - schemaLocationText.setEditable(true); - applyAllListeners(schemaLocationText); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - schemaLocationText.setLayoutData(data); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(schemaLocationText, - XSDEditorCSHelpIds.GENERAL_TAB__INCLUDE_REDEFINE__SCHEMALOCATION); - - // Create Wizard Button - wizardButton = getWidgetFactory().createButton(composite, "", SWT.NONE); //$NON-NLS-1$ - wizardButton.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - wizardButton.setLayoutData(data); - wizardButton.addSelectionListener(this); - - // error text - errorText = new StyledText(composite, SWT.FLAT); - errorText.setEditable(false); - errorText.setEnabled(false); - errorText.setText(""); //$NON-NLS-1$ - - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 3; - data.grabExcessHorizontalSpace = true; - errorText.setLayoutData(data); - - } - - public void doWidgetSelected(SelectionEvent event) - { - if (event.widget == wizardButton) - { - Shell shell = Display.getCurrent().getActiveShell(); - - IFile currentIFile = ((IFileEditorInput)getActiveEditor().getEditorInput()).getFile(); - ViewerFilter filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$ - new IFile[] { currentIFile }, - null); - - XSDSelectIncludeFileWizard fileSelectWizard = - new XSDSelectIncludeFileWizard(xsdSchema, true, - XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_SCHEMA"), //$NON-NLS-1$ - XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_DESC"), //$NON-NLS-1$ - filter, - (IStructuredSelection) getSelection()); - - WizardDialog wizardDialog = new WizardDialog(shell, fileSelectWizard); - wizardDialog.create(); - wizardDialog.setBlockOnOpen(true); - int result = wizardDialog.open(); - - String value = schemaLocationText.getText(); - if (result == Window.OK) - { - errorText.setText(""); //$NON-NLS-1$ - IFile selectedIFile = fileSelectWizard.getResultFile(); - String schemaFileString = value; - if (selectedIFile != null) - { - schemaFileString = URIHelper.getRelativeURI(selectedIFile.getLocation(), currentIFile.getLocation()); - } - else - { - schemaFileString = fileSelectWizard.getURL(); - } - - handleSchemaLocationChange(schemaFileString, fileSelectWizard.getNamespace(), null); - refresh(); - } - } - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - setListenerEnabled(false); - - Element element = null; - if (input instanceof XSDInclude) - { - element = ((XSDIncludeImpl) input).getElement(); - } - else if (input instanceof XSDRedefine) - { - element = ((XSDRedefineImpl) input).getElement(); - } - - if (element != null) - { - String location = ""; //$NON-NLS-1$ - location = element.getAttribute("schemaLocation"); //$NON-NLS-1$ - if (location == null) - { - location = ""; //$NON-NLS-1$ - } - schemaLocationText.setText(location); - } - - setListenerEnabled(true); - } - - /* (non-Javadoc) - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace() - */ - public boolean shouldUseExtraSpace() - { - return true; - } - - protected void handleSchemaLocationChange(String schemaFileString, String namespace, XSDSchema externalSchema) - { - if (input instanceof XSDInclude) - { - Element element = ((XSDIncludeImpl) input).getElement(); - element.setAttribute("schemaLocation", schemaFileString); //$NON-NLS-1$ - } - else if (input instanceof XSDRedefine) - { - Element element = ((XSDRedefineImpl) input).getElement(); - element.setAttribute("schemaLocation", schemaFileString); //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SimpleContentUnionMemberTypesDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SimpleContentUnionMemberTypesDialog.java deleted file mode 100644 index a090be1f09..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SimpleContentUnionMemberTypesDialog.java +++ /dev/null @@ -1,312 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.jface.window.Window; -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.swt.widgets.Label; -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.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.wst.xsd.ui.internal.util.ViewUtility; -import org.eclipse.wst.xsd.ui.internal.widgets.TypeSection; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; - - -public class SimpleContentUnionMemberTypesDialog extends Dialog implements SelectionListener -{ - XSDSimpleTypeDefinition simpleType; - /** - * @param parentShell - */ - public SimpleContentUnionMemberTypesDialog(Shell parentShell, XSDSimpleTypeDefinition simpleType) - { - super(parentShell); - this.simpleType = simpleType; - } - - Table table; - TypeSection typeSection; - Button addButton, removeButton; - org.eclipse.swt.widgets.List memberTypesList; - - private String result; - - protected void configureShell(Shell shell) - { - super.configureShell(shell); - } - - protected void buttonPressed(int buttonId) - { - if (buttonId == Window.OK) - { - StringBuffer sb = new StringBuffer(); - int length = memberTypesList.getItemCount(); - for (int i=0 ; i < length; i++) - { - sb.append(memberTypesList.getItem(i)); - if (i < length - 1) - { - sb.append(" "); //$NON-NLS-1$ - } - } - result = sb.toString(); - } - super.buttonPressed(buttonId); - } - - public String getResult() { return result; } - - // - // Create the controls - // - public Control createDialogArea(Composite parent) - { - Composite client = (Composite)super.createDialogArea(parent); - getShell().setText("Union " + XSDConstants.MEMBERTYPES_ATTRIBUTE); //$NON-NLS-1$ - - Label instructions = new Label(client, SWT.LEFT | SWT.WRAP); - instructions.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_SELECT_MEMBERTYPES")); //$NON-NLS-1$ - - Composite columnsComposite = new Composite(client, SWT.NONE); - GridLayout ccGL = new GridLayout(); - ccGL.verticalSpacing = 0; - ccGL.horizontalSpacing = 0; - ccGL.marginHeight = 0; - ccGL.marginWidth = 0; - ccGL.makeColumnsEqualWidth = true; - ccGL.numColumns = 3; - columnsComposite.setLayout(ccGL); - - GridData ccGD = new GridData(); - ccGD.grabExcessHorizontalSpace = true; - ccGD.horizontalAlignment = GridData.FILL; - columnsComposite.setLayoutData(ccGD); - - typeSection = new TypeSection(columnsComposite); - typeSection.setShowUserComplexType(false); - - typeSection.createClient(columnsComposite); - typeSection.getSimpleType().setSelection(false); - typeSection.getSimpleType().addSelectionListener(this); - typeSection.getUserSimpleType().addSelectionListener(this); - - ViewUtility.createHorizontalFiller(columnsComposite, 1); - - Label memberListLabel = new Label(columnsComposite, SWT.LEFT); - memberListLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES_VALUE")); //$NON-NLS-1$ - - Composite dataComposite = new Composite(client, SWT.NONE); - GridLayout dcGL = new GridLayout(); - dcGL.verticalSpacing = 0; - dcGL.marginHeight = 0; - dcGL.marginWidth = 0; - dcGL.numColumns = 3; - dataComposite.setLayout(dcGL); - - GridData dcGD = new GridData(); - dcGD.grabExcessHorizontalSpace = true; - dcGD.grabExcessVerticalSpace = true; - dataComposite.setLayoutData(dcGD); - - table = new Table(dataComposite, - SWT.SINGLE | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - table.setHeaderVisible(false); - table.setLinesVisible(true); - GridData gd2 = new GridData(); - gd2.grabExcessHorizontalSpace = true; - gd2.grabExcessVerticalSpace = true; - gd2.horizontalAlignment = GridData.FILL; - gd2.verticalAlignment = GridData.FILL; - gd2.heightHint = 200; - gd2.widthHint = 200; - table.setLayoutData(gd2); - - // Fill table - handleSetInput(); - table.getItemCount(); - - TableColumn tc = new TableColumn(table, SWT.LEFT); - tc.setWidth(200); - tc.setResizable(true); - - Composite buttonComposite = new Composite(dataComposite, SWT.NONE); - GridLayout bcGL = new GridLayout(); - bcGL.numColumns = 1; - buttonComposite.setLayout(bcGL); - addButton = new Button(buttonComposite, SWT.PUSH); - addButton.setText(">"); //$NON-NLS-1$ - addButton.addSelectionListener(this); - removeButton = new Button(buttonComposite, SWT.PUSH); - removeButton.setText("<"); //$NON-NLS-1$ - removeButton.addSelectionListener(this); - - Composite listComposite = new Composite(dataComposite, SWT.NONE); - GridLayout mtGL = new GridLayout(); - mtGL.numColumns = 1; - mtGL.marginHeight = 0; - mtGL.marginWidth = 0; - mtGL.horizontalSpacing = 0; - mtGL.verticalSpacing = 0; - listComposite.setLayout(mtGL); - - GridData mtGD = new GridData(); - mtGD.grabExcessHorizontalSpace = true; - mtGD.grabExcessVerticalSpace = true; - mtGD.verticalAlignment = GridData.FILL; - mtGD.horizontalAlignment = GridData.FILL; - listComposite.setLayoutData(mtGD); - - memberTypesList = new org.eclipse.swt.widgets.List(listComposite, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER); - GridData mtlGD = new GridData(); - mtlGD.grabExcessHorizontalSpace = true; - mtlGD.grabExcessVerticalSpace = true; - mtlGD.verticalAlignment = GridData.FILL; - mtlGD.horizontalAlignment = GridData.FILL; - mtlGD.heightHint = 200; - mtlGD.widthHint = 200; - memberTypesList.setLayoutData(mtlGD); - - initializeMemberListContent(); - return client; - } - - private void initializeMemberListContent() - { -// String result = element.getAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE); -// if (result == null) -// { -// return; -// } -// StringTokenizer token = new StringTokenizer(result); -// while (token.hasMoreTokens()) -// { -// memberTypesList.add(token.nextToken()); -// } - XSDSchema schema = simpleType.getSchema(); - for (Iterator i = simpleType.getMemberTypeDefinitions().iterator(); i.hasNext(); ) - { - String name = ((XSDSimpleTypeDefinition)i.next()).getQName(schema); - if (name != null) - memberTypesList.add(name); - } - } - - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) - { - if (e.widget == typeSection.getSimpleType() && typeSection.getSimpleType().getSelection()) - { - populateBuiltInType(); - } - else if (e.widget == typeSection.getUserSimpleType() && typeSection.getUserSimpleType().getSelection()) - { - populateUserSimpleType(false); - } - else if (e.widget == addButton) - { - TableItem[] items = table.getItems(); - int selection = table.getSelectionIndex(); - if (items != null && items.length > 0 && selection >= 0) - { - String typeToAdd = items[selection].getData().toString(); - if (memberTypesList.indexOf(typeToAdd) < 0) - { - memberTypesList.add(items[selection].getData().toString()); - } - } - } - else if (e.widget == removeButton) - { - String[] typesToRemove = memberTypesList.getSelection(); - for (int i=0; i < typesToRemove.length; i++) - { - memberTypesList.remove(typesToRemove[i]); - } - } - } - - /* (non-Javadoc) - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent e) - { - } - - public void handleSetInput() - { - populateBuiltInType(); - } - - public void populateBuiltInType() - { - table.removeAll(); - List items = getBuiltInTypeNamesList(); - for (int i = 0; i < items.size(); i++) - { - TableItem item = new TableItem(table, SWT.NONE); - item.setText(items.get(i).toString()); - item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif")); //$NON-NLS-1$ - item.setData(items.get(i)); - } - } - - public void populateUserSimpleType(boolean showAnonymous) - { - table.removeAll(); - if (showAnonymous) - { - TableItem anonymousItem = new TableItem(table, SWT.NONE); - anonymousItem.setText("**anonymous**"); //$NON-NLS-1$ - anonymousItem.setData("**anonymous**"); //$NON-NLS-1$ - } - List items = getUserSimpleTypeNamesList(); - for (int i = 0; i < items.size(); i++) - { - TableItem item = new TableItem(table, SWT.NONE); - item.setText(items.get(i).toString()); - item.setImage(XSDEditorPlugin.getXSDImage("icons/XSDSimpleType.gif")); //$NON-NLS-1$ - item.setData(items.get(i)); - } - } - - public java.util.List getBuiltInTypeNamesList() - { - TypesHelper helper = new TypesHelper(simpleType.getSchema()); - return helper.getBuiltInTypeNamesList(); - } - - public java.util.List getUserSimpleTypeNamesList() - { - TypesHelper helper = new TypesHelper(simpleType.getSchema()); - return helper.getUserSimpleTypeNamesList(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SpecificConstraintsWidget.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SpecificConstraintsWidget.java deleted file mode 100644 index 4d9baa0d41..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/SpecificConstraintsWidget.java +++ /dev/null @@ -1,692 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import com.ibm.icu.util.StringTokenizer; - -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.jface.viewers.CellEditor; -import org.eclipse.jface.viewers.ColumnWeightData; -import org.eclipse.jface.viewers.ICellModifier; -import org.eclipse.jface.viewers.IStructuredContentProvider; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableLayout; -import org.eclipse.jface.viewers.TextCellEditor; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Button; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Listener; -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.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.common.ui.internal.viewers.NavigableTableViewer; -import org.eclipse.wst.xsd.ui.internal.common.commands.AddEnumerationsCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.ChangeToLocalSimpleTypeCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.DeleteCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.SetXSDFacetValueCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateXSDPatternFacetCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.widgets.EnumerationsDialog; -import org.eclipse.wst.xsd.ui.internal.wizards.RegexWizard; -import org.eclipse.xsd.XSDEnumerationFacet; -import org.eclipse.xsd.XSDFacet; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDFeature; -import org.eclipse.xsd.XSDPatternFacet; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class SpecificConstraintsWidget implements SelectionListener, Listener -{ - public static int ENUMERATION = 0; - public static int PATTERN = 1; - - int kind; - ConstraintsTableViewer constraintsTableViewer; - Button addButton; - Button addUsingDialogButton; - Button deleteButton; - Button editButton; - Composite composite; - boolean isEnabled; - TabbedPropertySheetWidgetFactory factory; - XSDSimpleTypeDefinition input; - XSDFeature feature; - boolean isReadOnly; - CommandStack commandStack; - XSDFacetSection facetSection; - - public SpecificConstraintsWidget(Composite composite, TabbedPropertySheetWidgetFactory factory, XSDFeature feature, XSDSimpleTypeDefinition input, XSDFacetSection facetSection) - { - this.factory = factory; - this.input = input; - this.composite = composite; - this.feature = feature; - this.facetSection = facetSection; - createControl(composite); - } - - public void setCommandStack(CommandStack commandStack) - { - this.commandStack = commandStack; - } - - public void setIsReadOnly(boolean isReadOnly) - { - this.isReadOnly = isReadOnly; - } - - public TabbedPropertySheetWidgetFactory getWidgetFactory() - { - return factory; - } - - public Control getControl() - { - return composite; - } - - public void setEnabled(boolean isEnabled) - { - this.isEnabled = isEnabled; - addButton.setEnabled(isEnabled); - addUsingDialogButton.setEnabled(isEnabled); - editButton.setEnabled(isEnabled); - constraintsTableViewer.getTable().setEnabled(isEnabled); - composite.setEnabled(isEnabled); - } - - public Control createControl(Composite parent) - { - composite = factory.createFlatFormComposite(parent); - GridData data = new GridData(); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 2; - composite.setLayout(gridLayout); - - constraintsTableViewer = new ConstraintsTableViewer(getWidgetFactory().createTable(composite, SWT.MULTI | SWT.FULL_SELECTION)); - constraintsTableViewer.setInput(input); - Table table = constraintsTableViewer.getTable(); - table.addSelectionListener(this); - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = true; - data.widthHint = 150; - data.grabExcessVerticalSpace = true; - table.setLayoutData(data); - table.addListener(SWT.Resize, this); - - Composite buttonComposite = getWidgetFactory().createComposite(composite, SWT.FLAT); - GridLayout buttonCompositeLayout = new GridLayout(); - buttonCompositeLayout.marginTop = 0; - buttonCompositeLayout.marginBottom = 0; - buttonCompositeLayout.numColumns = 1; - buttonComposite.setLayout(buttonCompositeLayout); - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.grabExcessHorizontalSpace = false; - buttonComposite.setLayoutData(data); - - - addButton = getWidgetFactory().createButton(buttonComposite, Messages._UI_ACTION_ADD, SWT.PUSH); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.BEGINNING; - addButton.setLayoutData(data); - addButton.addSelectionListener(this); - - addUsingDialogButton = getWidgetFactory().createButton(buttonComposite, Messages._UI_ACTION_ADD_WITH_DOTS, SWT.PUSH); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.BEGINNING; - addUsingDialogButton.setLayoutData(data); - addUsingDialogButton.addSelectionListener(this); - - editButton = getWidgetFactory().createButton(buttonComposite, Messages._UI_ACTION_EDIT_WITH_DOTS, SWT.PUSH); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - editButton.setLayoutData(data); - editButton.setEnabled(false); - editButton.addSelectionListener(this); - - - deleteButton = getWidgetFactory().createButton(buttonComposite, Messages._UI_ACTION_DELETE, SWT.PUSH); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - deleteButton.setLayoutData(data); - deleteButton.setEnabled(false); - deleteButton.addSelectionListener(this); - - - return composite; - } - - public void handleEvent(Event event) - { - Table table = constraintsTableViewer.getTable(); - if (event.type == SWT.Resize && event.widget == table) - { - TableColumn tableColumn = table.getColumn(0); - tableColumn.setWidth(table.getSize().x); - } - } - - public void setInput(Object input) - { - constraintsTableViewer.setInput(input); - if (isReadOnly) - { - composite.setEnabled(false); - } - else - { - composite.setEnabled(true); - } -// constraintsTableViewer.refresh(); - } - - public void widgetSelected(SelectionEvent e) - { - XSDSimpleTypeDefinition st = input; - Element element = st.getElement(); - - if (e.widget == addButton) - { - List enumList = st.getEnumerationFacets(); - StringBuffer newName = new StringBuffer("value1"); //$NON-NLS-1$ - int suffix = 1; - for (Iterator i = enumList.iterator(); i.hasNext();) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) i.next(); - String value = enumFacet.getLexicalValue(); - if (value != null) - { - if (value.equals(newName.toString())) - { - suffix++; - newName = new StringBuffer("value" + String.valueOf(suffix)); //$NON-NLS-1$ - } - } - } - - if (kind == ENUMERATION) - { - CompoundCommand compoundCommand = new CompoundCommand(); - XSDSimpleTypeDefinition targetSimpleType = null; - if (feature != null) - { - XSDSimpleTypeDefinition anonymousSimpleType = XSDCommonUIUtils.getAnonymousSimpleType(feature, input); - if (anonymousSimpleType == null) - { - anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - anonymousSimpleType.setBaseTypeDefinition(input); - - ChangeToLocalSimpleTypeCommand changeToAnonymousCommand = new ChangeToLocalSimpleTypeCommand(Messages._UI_ACTION_CHANGE_PATTERN, feature); - changeToAnonymousCommand.setAnonymousSimpleType(anonymousSimpleType); - compoundCommand.add(changeToAnonymousCommand); - input = anonymousSimpleType; - } - targetSimpleType = anonymousSimpleType; - } - else - { - targetSimpleType = input; - } - - AddEnumerationsCommand command = new AddEnumerationsCommand(Messages._UI_ACTION_ADD_ENUMERATION, targetSimpleType); - command.setValue(newName.toString()); - compoundCommand.add(command); - commandStack.execute(compoundCommand); - setInput(input); - constraintsTableViewer.refresh(); - int newItemIndex = constraintsTableViewer.getTable().getItemCount() - 1; - constraintsTableViewer.editElement(constraintsTableViewer.getElementAt(newItemIndex), 0); - } - } - else if (e.widget == addUsingDialogButton) - { - Display display = Display.getCurrent(); - // if it is null, get the default one - display = display == null ? Display.getDefault() : display; - Shell shell = display.getActiveShell(); - - if (kind == PATTERN) - { - String initialValue = ""; //$NON-NLS-1$ - RegexWizard wizard = new RegexWizard(initialValue); - - WizardDialog wizardDialog = new WizardDialog(shell, wizard); - wizardDialog.setBlockOnOpen(true); - wizardDialog.create(); - - int result = wizardDialog.open(); - - if (result == Window.OK) - { - String newPattern = wizard.getPattern(); - CompoundCommand compoundCommand = new CompoundCommand(); - XSDSimpleTypeDefinition targetSimpleType = null; - if (feature != null) - { - XSDSimpleTypeDefinition anonymousSimpleType = XSDCommonUIUtils.getAnonymousSimpleType(feature, input); - if (anonymousSimpleType == null) - { - anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - anonymousSimpleType.setBaseTypeDefinition(input); - - ChangeToLocalSimpleTypeCommand changeToAnonymousCommand = new ChangeToLocalSimpleTypeCommand(Messages._UI_ACTION_CHANGE_PATTERN, feature); - changeToAnonymousCommand.setAnonymousSimpleType(anonymousSimpleType); - compoundCommand.add(changeToAnonymousCommand); - input = anonymousSimpleType; - } - targetSimpleType = anonymousSimpleType; - } - else - { - targetSimpleType = input; - } - - UpdateXSDPatternFacetCommand command = new UpdateXSDPatternFacetCommand(Messages._UI_ACTION_ADD_PATTERN, targetSimpleType, UpdateXSDPatternFacetCommand.ADD); - command.setValue(newPattern); - setInput(input); - compoundCommand.add(command); - commandStack.execute(compoundCommand); - facetSection.doSetInput(); - } - constraintsTableViewer.refresh(); - } - else - { - EnumerationsDialog dialog = new EnumerationsDialog(shell); - dialog.setBlockOnOpen(true); - int result = dialog.open(); - - if (result == Window.OK) - { - String text = dialog.getText(); - String delimiter = dialog.getDelimiter(); - StringTokenizer tokenizer = new StringTokenizer(text, delimiter); - CompoundCommand compoundCommand = new CompoundCommand(Messages._UI_ACTION_ADD_ENUMERATIONS); - - XSDSimpleTypeDefinition targetSimpleType = null; - if (feature != null) - { - XSDSimpleTypeDefinition anonymousSimpleType = XSDCommonUIUtils.getAnonymousSimpleType(feature, input); - if (anonymousSimpleType == null) - { - anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - anonymousSimpleType.setBaseTypeDefinition(input); - - ChangeToLocalSimpleTypeCommand changeToAnonymousCommand = new ChangeToLocalSimpleTypeCommand("", feature); //$NON-NLS-1$ - changeToAnonymousCommand.setAnonymousSimpleType(anonymousSimpleType); - compoundCommand.add(changeToAnonymousCommand); - input = anonymousSimpleType; - } - targetSimpleType = anonymousSimpleType; - } - else - { - targetSimpleType = input; - } - - while (tokenizer.hasMoreTokens()) - { - String token = tokenizer.nextToken(); - if (dialog.isPreserveWhitespace() == false) - { - token = token.trim(); - } - AddEnumerationsCommand command = new AddEnumerationsCommand(Messages._UI_ACTION_ADD_ENUMERATIONS, targetSimpleType); - command.setValue(token); - compoundCommand.add(command); - } - commandStack.execute(compoundCommand); - } - //setInput(input); - facetSection.doSetInput(); - constraintsTableViewer.refresh(); - } - } - else if (e.widget == deleteButton) - { - StructuredSelection selection = (StructuredSelection) constraintsTableViewer.getSelection(); - CompoundCommand compoundCommand = new CompoundCommand(); - if (selection != null) - { - Iterator i = selection.iterator(); - if (selection.size() > 0) - { - compoundCommand.setLabel(Messages._UI_ACTION_DELETE_CONSTRAINTS); - } - else - { - compoundCommand.setLabel(Messages._UI_ACTION_DELETE_PATTERN); - } - while (i.hasNext()) - { - Object obj = i.next(); - if (obj != null) - { - if (obj instanceof XSDPatternFacet) - { - UpdateXSDPatternFacetCommand command = new UpdateXSDPatternFacetCommand("", input, UpdateXSDPatternFacetCommand.DELETE); //$NON-NLS-1$ - command.setPatternToEdit((XSDPatternFacet)obj); - compoundCommand.add(command); - } - else if (obj instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) obj; - DeleteCommand deleteCommand = new DeleteCommand(Messages._UI_ACTION_DELETE_ENUMERATION, enumFacet); - compoundCommand.add(deleteCommand); - } - } - } - commandStack.execute(compoundCommand); - constraintsTableViewer.refresh(); - - if (constraintsTableViewer.getTable().getItemCount() == 0) - { - editButton.setEnabled(false); - deleteButton.setEnabled(false); - } - } - } - else if (e.widget == editButton) - { - StructuredSelection selection = (StructuredSelection) constraintsTableViewer.getSelection(); - if (selection != null) - { - Object obj = selection.getFirstElement(); - if (obj instanceof XSDPatternFacet) - { - XSDPatternFacet pattern = (XSDPatternFacet) obj; - String initialValue = pattern.getLexicalValue(); - if (initialValue == null) - { - initialValue = ""; //$NON-NLS-1$ - } - - Shell shell = Display.getCurrent().getActiveShell(); - - RegexWizard wizard = new RegexWizard(initialValue); - - WizardDialog wizardDialog = new WizardDialog(shell, wizard); - wizardDialog.setBlockOnOpen(true); - wizardDialog.create(); - - int result = wizardDialog.open(); - - if (result == Window.OK) - { - String newPattern = wizard.getPattern(); - element.setAttribute(XSDConstants.VALUE_ATTRIBUTE, newPattern); - pattern.setLexicalValue(newPattern); - constraintsTableViewer.refresh(); - } - } - } - } - else if (e.widget == constraintsTableViewer.getTable()) - { - StructuredSelection selection = (StructuredSelection) constraintsTableViewer.getSelection(); - if (selection.getFirstElement() != null) - { - editButton.setEnabled(true); - deleteButton.setEnabled(true); - } - else - { - editButton.setEnabled(false); - deleteButton.setEnabled(false); - } - } - } - - public void widgetDefaultSelected(SelectionEvent e) - { - - } - - - public void setConstraintKind(int kind) - { - this.kind = kind; - constraintsTableViewer.setInput(input); - constraintsTableViewer.refresh(); - } - - public void doModify(Object element, String property, Object value) - { - if (element instanceof TableItem && (value != null)) - { - TableItem item = (TableItem) element; - - if (item.getData() instanceof XSDPatternFacet) - { - XSDPatternFacet patternFacet = (XSDPatternFacet) item.getData(); - patternFacet.setLexicalValue((String) value); - - item.setData(patternFacet); - item.setText((String) value); - } - else if (item.getData() instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) item.getData(); - SetXSDFacetValueCommand command = new SetXSDFacetValueCommand(Messages._UI_ACTION_SET_ENUMERATION_VALUE, enumFacet); - command.setValue((String) value); - commandStack.execute(command); - item.setData(enumFacet); - item.setText((String) value); - } - } - } - - public Object doGetValue(Object element, String property) - { - if (element instanceof XSDPatternFacet) - { - XSDPatternFacet patternFacet = (XSDPatternFacet) element; - String value = patternFacet.getLexicalValue(); - if (value == null) - value = ""; //$NON-NLS-1$ - return value; - } - else if (element instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) element; - String value = enumFacet.getLexicalValue(); - if (value == null) - value = ""; //$NON-NLS-1$ - return value; - } - - return ""; //$NON-NLS-1$ - } - - class ConstraintsTableViewer extends NavigableTableViewer implements ICellModifier - { - protected String[] columnProperties = { Messages._UI_LABEL_PATTERN }; - - protected CellEditor[] cellEditors; - - Table table; - - public ConstraintsTableViewer(Table table) - { - super(table); - table = getTable(); - - table.setLinesVisible(true); - - setContentProvider(new ConstraintsContentProvider()); - setLabelProvider(new ConstraintsTableLabelProvider()); - setColumnProperties(columnProperties); - - setCellModifier(this); - - TableColumn column = new TableColumn(table, SWT.NONE, 0); - column.setText(columnProperties[0]); - column.setAlignment(SWT.LEFT); - column.setResizable(true); - - cellEditors = new CellEditor[1]; - - TableLayout layout = new TableLayout(); - ColumnWeightData data = new ColumnWeightData(100); - - layout.addColumnData(data); - cellEditors[0] = new TextCellEditor(table); - - getTable().setLayout(layout); - setCellEditors(cellEditors); - } - - public boolean canModify(Object element, String property) - { - return true; - } - - public void modify(Object element, String property, Object value) - { - doModify(element, property, value); - } - - public Object getValue(Object element, String property) - { - return doGetValue(element, property); - } - - } - - class ConstraintsContentProvider implements IStructuredContentProvider - { - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - } - - public java.lang.Object[] getElements(java.lang.Object inputElement) - { - java.util.List list = new ArrayList(); - if (inputElement instanceof XSDSimpleTypeDefinition) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) inputElement; - boolean isDefined = false; - Iterator iter; - if (kind == PATTERN) - { - iter = st.getPatternFacets().iterator(); - } - else - { - iter = st.getEnumerationFacets().iterator(); - } - - while (iter.hasNext()) - { - XSDFacet facet = (XSDFacet) iter.next(); - isDefined = (facet.getRootContainer() == facetSection.xsdSchema); - } - - if (kind == PATTERN) - { - if (isDefined) - { - return st.getPatternFacets().toArray(); - } - } - else - { - if (isDefined) - { - return st.getEnumerationFacets().toArray(); - } - } - } - return list.toArray(); - } - - public void dispose() - { - } - } - - class ConstraintsTableLabelProvider extends LabelProvider implements ITableLabelProvider - { - public ConstraintsTableLabelProvider() - { - - } - - public Image getColumnImage(Object element, int columnIndex) - { - if (kind == PATTERN) - { - return XSDEditorPlugin.getXSDImage("icons/XSDSimplePattern.gif"); //$NON-NLS-1$ - } - else - { - return XSDEditorPlugin.getXSDImage("icons/XSDSimpleEnum.gif"); //$NON-NLS-1$ - } - } - - public String getColumnText(Object element, int columnIndex) - { - if (element instanceof XSDPatternFacet) - { - XSDPatternFacet pattern = (XSDPatternFacet) element; - String value = pattern.getLexicalValue(); - if (value == null) - value = ""; //$NON-NLS-1$ - return value; - } - else if (element instanceof XSDEnumerationFacet) - { - XSDEnumerationFacet enumFacet = (XSDEnumerationFacet) element; - String value = enumFacet.getLexicalValue(); - if (value == null) - value = ""; //$NON-NLS-1$ - return value; - } - return ""; //$NON-NLS-1$ - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDActionManager.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDActionManager.java deleted file mode 100644 index b31fa6c429..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDActionManager.java +++ /dev/null @@ -1,148 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CommandStack; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.Viewer; -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.ui.internal.XMLUIMessages; -import org.eclipse.wst.xml.ui.internal.actions.EditAttributeAction; -import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class XSDActionManager extends XMLNodeActionManager { - - private CommandStack commandStack; - - public XSDActionManager(IStructuredModel model, Viewer viewer) { - super(model, viewer); - } - - public void setCommandStack(CommandStack commandStack) { - this.commandStack = commandStack; - } - - protected Action createAddCDataSectionAction(Node parent, int index) - { - return null; - } - - protected Action createAddPCDataAction(Node parent, CMDataType dataType, int index) { - return null; - } - - - protected void contributeAddDocumentChildActions(IMenuManager menu, Document document, int ic, int vc) { - } - - protected void contributeEditGrammarInformationActions(IMenuManager menu, Node node) { - } - - protected void contributePIAndCommentActions(IMenuManager menu, Document document, int index) { - } - - protected void contributePIAndCommentActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) { - } - - protected void contributeTextNodeActions(IMenuManager menu, Element parentElement, CMElementDeclaration parentEd, int index) { - super.contributeTextNodeActions(menu, parentElement, parentEd, index); - } - - 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); //$NON-NLS-1$ //$NON-NLS-2$ - } else { - action = new AddNodeAction(ad, parent, -1); - } - - WrapperCommand command = new WrapperCommand(action, parent, ad); - WrapperAction wrapperAction = new WrapperAction(command); - return wrapperAction; - } - - class WrapperAction extends Action - { - WrapperCommand command; - - public WrapperAction(WrapperCommand command) - { - super(); - this.command = command; - } - - public String getText() - { - return command.getAction().getText(); - } - - public void run() - { - // Some editors may not use a command stack - if (commandStack != null) - { - commandStack.execute(command); - } - else - { - command.execute(); - } - } - } - - class WrapperCommand extends Command - { - Action action; - Element parent; - CMAttributeDeclaration ad; - public WrapperCommand(Action action, Element parent, CMAttributeDeclaration ad) - { - super(); - this.action = action; - this.parent = parent; - this.ad = ad; - } - - public String getLabel() - { - return action.getText(); - } - - public Action getAction() - { - return action; - } - - public void execute() - { - action.run(); - } - - public void undo() { - -// ((Element)parent).removeAttribute(ad.getAttrName()); - - getModel().getUndoManager().undo(); - - } - - - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAnyElementContentsSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAnyElementContentsSection.java deleted file mode 100644 index 63e4898bd9..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAnyElementContentsSection.java +++ /dev/null @@ -1,251 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.Iterator; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDProcessContents; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.util.XSDConstants; - -public class XSDAnyElementContentsSection extends MultiplicitySection -{ - CCombo namespaceCombo; - CCombo processContentsCombo; - - private String[] namespaceComboValues = { "", //$NON-NLS-1$ - "##any", //$NON-NLS-1$ - "##other", //$NON-NLS-1$ - "##targetNamespace", //$NON-NLS-1$ - "##local" //$NON-NLS-1$ - }; - - /** - * - */ - public XSDAnyElementContentsSection() - { - super(); - } - - protected void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridData data = new GridData(); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 2; - composite.setLayout(gridLayout); - - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - CLabel namespaceLabel = getWidgetFactory().createCLabel(composite, XSDConstants.NAMESPACE_ATTRIBUTE); - namespaceLabel.setLayoutData(data); - - namespaceCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - namespaceCombo.setLayoutData(data); - namespaceCombo.setItems(namespaceComboValues); - namespaceCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(namespaceCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ANYELEMENT__NAMESPACE); - - CLabel processContentsLabel = getWidgetFactory().createCLabel(composite, XSDConstants.PROCESSCONTENTS_ATTRIBUTE); - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - processContentsLabel.setLayoutData(data); - - processContentsCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - processContentsCombo.setLayoutData(data); - Iterator list = XSDProcessContents.VALUES.iterator(); - processContentsCombo.add(""); //$NON-NLS-1$ - while (list.hasNext()) - { - processContentsCombo.add(((XSDProcessContents) list.next()).getName()); - } - processContentsCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(processContentsCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ANYELEMENT__PROCESSCONTENTS); - - // ------------------------------------------------------------------ - // min property - // ------------------------------------------------------------------ - - getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_MINOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - minCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - minCombo.setLayoutData(data); - minCombo.add("0"); //$NON-NLS-1$ - minCombo.add("1"); //$NON-NLS-1$ - applyAllListeners(minCombo); - minCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(minCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ANYELEMENT__MIN_OCCURENCE); - - // ------------------------------------------------------------------ - // max property - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_MAXOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - maxCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - maxCombo.setLayoutData(data); - maxCombo.add("0"); //$NON-NLS-1$ - maxCombo.add("1"); //$NON-NLS-1$ - maxCombo.add("unbounded"); //$NON-NLS-1$ - applyAllListeners(maxCombo); - maxCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(maxCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ANYELEMENT__MAX_OCCURENCE); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - setListenerEnabled(false); - namespaceCombo.setText(""); //$NON-NLS-1$ - processContentsCombo.setText(""); //$NON-NLS-1$ - if (input != null) - { - if (input instanceof XSDWildcard) - { - XSDWildcard wildcard = (XSDWildcard) input; - if (wildcard.isSetLexicalNamespaceConstraint()) - { - namespaceCombo.setText(wildcard.getStringLexicalNamespaceConstraint()); - } - else - { - namespaceCombo.setText(""); - } - if (wildcard.isSetProcessContents()) - { - XSDProcessContents pc = wildcard.getProcessContents(); - processContentsCombo.setText(pc.getName()); - } - - if (wildcard.eContainer() instanceof XSDParticle) - { - minCombo.setEnabled(!isReadOnly); - maxCombo.setEnabled(!isReadOnly); - } - else - { - minCombo.setEnabled(false); - maxCombo.setEnabled(false); - } - } - } - refreshMinMax(); - setListenerEnabled(true); - } - - public boolean shouldUseExtraSpace() - { - return false; - } - - public void doWidgetSelected(SelectionEvent e) - { - XSDConcreteComponent concreteComponent = (XSDConcreteComponent) input; - if (concreteComponent instanceof XSDWildcard) - { - XSDWildcard wildcard = (XSDWildcard) concreteComponent; - if (e.widget == namespaceCombo) - { - String newValue = namespaceCombo.getText(); - boolean removeAttribute = false; - if (newValue.length() == 0) - { - removeAttribute = true; - } - // TODO use commands - // beginRecording(XSDEditorPlugin.getXSDString("_UI_NAMESPACE_CHANGE"), - // element); //$NON-NLS-1$ - if (removeAttribute) - { - wildcard.unsetLexicalNamespaceConstraint(); - } - else - { - wildcard.setStringLexicalNamespaceConstraint(newValue); - } - // endRecording(element); - } - else if (e.widget == processContentsCombo) - { - String newValue = processContentsCombo.getText(); - boolean removeAttribute = false; - if (newValue.length() == 0) - { - removeAttribute = true; - } - // beginRecording(XSDEditorPlugin.getXSDString("_UI_PROCESSCONTENTS_CHANGE"), - // element); //$NON-NLS-1$ - if (removeAttribute) - { - wildcard.unsetProcessContents(); - } - else - { - wildcard.setProcessContents(XSDProcessContents.get(processContentsCombo.getItem(processContentsCombo.getSelectionIndex()))); - } - // endRecording(element); - } - } - super.doWidgetSelected(e); - } - - public void dispose() - { - if (minCombo != null && !minCombo.isDisposed()) - minCombo.removeSelectionListener(this); - if (maxCombo != null && !maxCombo.isDisposed()) - maxCombo.removeSelectionListener(this); - super.dispose(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java deleted file mode 100644 index 994a41449a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeDeclarationSection.java +++ /dev/null @@ -1,399 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.dialogs.NewTypeDialog; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDAttributeDeclarationSection extends RefactoringSection -{ - protected Text nameText; - protected CCombo typeCombo, usageCombo; - protected String typeName = ""; //$NON-NLS-1$ - boolean isAttributeReference; - - public XSDAttributeDeclarationSection() - { - super(); - } - - protected void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - String typeLabel = Messages.UI_LABEL_TYPE; //$NON-NLS-1$ - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - // ------------------------------------------------------------------ - // NameLabel - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel nameLabel = getWidgetFactory().createCLabel(composite, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_NAME); - nameLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // NameText - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - nameText.setLayoutData(data); - applyAllListeners(nameText); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(nameText, - XSDEditorCSHelpIds.GENERAL_TAB__ATTRIBUTE__NAME); - - // ------------------------------------------------------------------ - // Refactor/rename hyperlink - // ------------------------------------------------------------------ - createRenameHyperlink(composite); - - // ------------------------------------------------------------------ - // typeLabel - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, typeLabel); //$NON-NLS-1$ - - // ------------------------------------------------------------------ - // typeCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - typeCombo = getWidgetFactory().createCCombo(composite); - typeCombo.setLayoutData(data); - typeCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(typeCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ATTRIBUTE__TYPE); - - // dummy - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - - // ------------------------------------------------------------------ - // UsageLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel useLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_USAGE")); - useLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // UsageCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - usageCombo = getWidgetFactory().createCCombo(composite); - usageCombo.setLayoutData(data); - usageCombo.addSelectionListener(this); - usageCombo.add(""); - usageCombo.add("required"); //$NON-NLS-1$ - usageCombo.add("optional"); //$NON-NLS-1$ - usageCombo.add("prohibited"); //$NON-NLS-1$ - usageCombo.addSelectionListener(this); - - // dummy - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - } - - private void fillTypesCombo() - { - IEditorPart editor = getActiveEditor(); - XSDTypeReferenceEditManager manager = (XSDTypeReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class); - ComponentSpecification[] items = manager.getQuickPicks(); - - typeCombo.removeAll(); - typeCombo.add(Messages._UI_ACTION_BROWSE); - typeCombo.add(Messages._UI_ACTION_NEW); - for (int i = 0; i < items.length; i++) - { - typeCombo.add(items[i].getName()); - } - - XSDAttributeDeclaration namedComponent = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration(); - XSDTypeDefinition namedComponentType = namedComponent.getType(); - if (namedComponentType != null) - { - String currentTypeName = namedComponentType.getQName(xsdSchema); // no prefix - ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName, manager); - if (ret == null) //not in quickPick - typeCombo.add(currentTypeName); - } - } - - private ComponentSpecification getComponentSpecFromQuickPickForValue(String value, ComponentReferenceEditManager editManager) - { - if (editManager != null) - { - ComponentSpecification[] quickPicks = editManager.getQuickPicks(); - if (quickPicks != null) - { - for (int i=0; i < quickPicks.length; i++) - { - ComponentSpecification componentSpecification = quickPicks[i]; - if (value.equals(componentSpecification.getName())) - { - return componentSpecification; - } - } - } - } - return null; - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - - setListenerEnabled(false); - - // refresh name - - nameText.setText(""); //$NON-NLS-1$ - if (input instanceof XSDAttributeDeclaration) - { - XSDAttributeDeclaration namedComponent = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration(); - - String name = namedComponent.getName(); - if (name != null) - { - nameText.setText(name); - } - } - - // refresh type - - typeCombo.setText(""); //$NON-NLS-1$ - if (input != null) - { - if (input instanceof XSDAttributeDeclaration) - { - XSDAttributeDeclaration xsdAttribute = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration(); - isAttributeReference = ((XSDAttributeDeclaration)input).isAttributeDeclarationReference(); - XSDTypeDefinition typeDef = xsdAttribute.getTypeDefinition(); - boolean isAnonymous = xsdAttribute.getAnonymousTypeDefinition() != null; - - if (isAnonymous) - { - typeCombo.setText("**anonymous**"); //$NON-NLS-1$ - } - else - { - fillTypesCombo(); - if (typeDef != null) - { - typeName = typeDef.getQName(xsdSchema); - if (typeName == null) - { - typeName = ""; //$NON-NLS-1$ - } - typeCombo.setText(typeName); - } - else - { - typeCombo.setText(Messages.UI_NO_TYPE); //$NON-NLS-1$ - } - } - - usageCombo.setText(""); - usageCombo.setEnabled(!xsdAttribute.isGlobal()); - - Element element = xsdAttribute.getElement(); - boolean hasUseAttribute = false; - if (element != null) - { - hasUseAttribute = element.hasAttribute(XSDConstants.USE_ATTRIBUTE); - if (hasUseAttribute) - { - String usage = element.getAttribute(XSDConstants.USE_ATTRIBUTE); - usageCombo.setText(usage); - } - } - } - } - - setListenerEnabled(true); - } - - public boolean shouldUseExtraSpace() - { - return false; - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == typeCombo) - { - IEditorPart editor = getActiveEditor(); - if (editor == null) return; - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class); - - String selection = typeCombo.getText(); - ComponentSpecification newValue; - IComponentDialog dialog= null; - if ( selection.equals(Messages._UI_ACTION_BROWSE)) - { - dialog = manager.getBrowseDialog(); - ((XSDSearchListDialogDelegate) dialog).showComplexTypes(false); - } - else if ( selection.equals(Messages._UI_ACTION_NEW)) - { - dialog = manager.getNewDialog(); - ((NewTypeDialog) dialog).allowComplexType(false); - } - - if (dialog != null) - { - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - manager.modifyComponentReference(input, newValue); - } - else{ - typeCombo.setText(typeName); - } - } - else //use the value from selected quickPick item - { - newValue = getComponentSpecFromQuickPickForValue(selection, manager); - if (newValue != null) - manager.modifyComponentReference(input, newValue); - } - } - else if (e.widget == usageCombo) - { - XSDAttributeDeclaration xsdAttribute = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration(); - String newValue = usageCombo.getText(); - Element element = xsdAttribute.getElement(); - if (element != null) - { - if (newValue.length() == 0) - element.removeAttribute(XSDConstants.USE_ATTRIBUTE); - else - element.setAttribute(XSDConstants.USE_ATTRIBUTE, newValue); - } - } - super.doWidgetSelected(e); - } - - protected void doHandleEvent(Event event) - { - super.doHandleEvent(event); - if (event.widget == nameText) - { - if (!nameText.getEditable()) - return; - - String newValue = nameText.getText().trim(); - if (input instanceof XSDAttributeDeclaration) - { - XSDAttributeDeclaration namedComponent = ((XSDAttributeDeclaration) input).getResolvedAttributeDeclaration(); - - if (!validateSection()) - return; - - Command command = null; - - // Make sure an actual name change has taken place - String oldName = namedComponent.getName(); - if (!newValue.equals(oldName)) - { - command = new UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ACTION_RENAME, namedComponent, newValue); - } - - if (command != null && getCommandStack() != null) - { - getCommandStack().execute(command); - } - - if (isAttributeReference) - { - XSDAttributeDeclaration attrRef = (XSDAttributeDeclaration)input; - String qname = attrRef.getResolvedAttributeDeclaration().getQName(); - attrRef.getElement().setAttribute(XSDConstants.REF_ATTRIBUTE, qname); - -// TypesHelper helper = new TypesHelper(xsdSchema); -// List items = new ArrayList(); -// items = helper.getGlobalElements(); -// items.add(0, ""); -// componentNameCombo.setItems((String [])items.toArray(new String[0])); -// -// refreshRefCombo(); - } - - } - } - } - - protected boolean validateSection() - { - if (nameText == null || nameText.isDisposed()) - return true; - - setErrorMessage(null); - - String name = nameText.getText().trim(); - - // validate against NCName - if (name.length() < 1 || !XMLChar.isValidNCName(name)) - { - setErrorMessage(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ERROR_INVALID_NAME); - return false; - } - - return true; - } - - public void dispose() - { - if (nameText != null && !nameText.isDisposed()) - removeListeners(nameText); - if (typeCombo != null && !typeCombo.isDisposed()) - typeCombo.removeSelectionListener(this); - super.dispose(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeGroupDefinitionSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeGroupDefinitionSection.java deleted file mode 100644 index 7a077ff288..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDAttributeGroupDefinitionSection.java +++ /dev/null @@ -1,284 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -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.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDAttributeGroupDefinitionSection extends RefactoringSection -{ - protected Text nameText; - protected CCombo refCombo; - boolean isReference; - - public XSDAttributeGroupDefinitionSection() - { - super(); - } - - protected void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - if (isReference) - { - // ------------------------------------------------------------------ - // Ref Label - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel refLabel = getWidgetFactory().createCLabel(composite, XSDConstants.REF_ATTRIBUTE + ":"); //$NON-NLS-1$ - refLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // Ref Combo - // ------------------------------------------------------------------ - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - refCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - refCombo.addSelectionListener(this); - refCombo.setLayoutData(data); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(refCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ATTRIBUTEGROUP_REFS__REF); - } - else - { - // ------------------------------------------------------------------ - // NameLabel - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel nameLabel = getWidgetFactory().createCLabel(composite, Messages._UI_LABEL_NAME); - nameLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // NameText - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - nameText.setLayoutData(data); - applyAllListeners(nameText); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(nameText, - XSDEditorCSHelpIds.GENERAL_TAB__ATTRIBUTEGROUP__NAME); - - // ------------------------------------------------------------------ - // Refactor/rename hyperlink - // ------------------------------------------------------------------ - createRenameHyperlink(composite); - } - } - - public void refresh() - { - super.refresh(); - - if (isReadOnly) - { - composite.setEnabled(false); - } - else - { - composite.setEnabled(true); - } - - setListenerEnabled(false); - - XSDNamedComponent namedComponent = (XSDNamedComponent)input; - - if (isReference) - { - Element element = namedComponent.getElement(); - if (element != null) - { - String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE); - if (attrValue == null) - { - attrValue = ""; //$NON-NLS-1$ - } - refCombo.setText(attrValue); - } - } - else - { - // refresh name - nameText.setText(""); //$NON-NLS-1$ - - String name = namedComponent.getName(); - if (name != null) - { - nameText.setText(name); - } - } - setListenerEnabled(true); - } - - public void setInput(IWorkbenchPart part, ISelection selection) - { - super.setInput(part, selection); - init(); - relayout(); - - if (isReference) - { - TypesHelper helper = new TypesHelper(xsdSchema); - List items = new ArrayList(); - items = helper.getGlobalAttributeGroups(); - items.add(0, ""); //$NON-NLS-1$ - refCombo.setItems((String [])items.toArray(new String[0])); - } - } - - protected void relayout() - { - Composite parentComposite = composite.getParent(); - parentComposite.getParent().setRedraw(false); - - if (parentComposite != null && !parentComposite.isDisposed()) - { - Control[] children = parentComposite.getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].dispose(); - } - } - - // Now initialize the new handler - createContents(parentComposite); - parentComposite.getParent().layout(true, true); - - // Now turn painting back on - parentComposite.getParent().setRedraw(true); - refresh(); - } - - protected void init() - { - if (input instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition group = (XSDAttributeGroupDefinition) input; - isReference = group.isAttributeGroupDefinitionReference(); - } - } - - public void doHandleEvent(Event event) - { - super.doHandleEvent(event); - if (event.widget == nameText) - { - String newValue = nameText.getText().trim(); - if (input instanceof XSDNamedComponent) - { - XSDNamedComponent namedComponent = (XSDNamedComponent) input; - if (!validateSection()) - return; - - Command command = null; - - // Make sure an actual name change has taken place - String oldName = namedComponent.getName(); - if (!newValue.equals(oldName)) - { - command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue); - } - - if (command != null && getCommandStack() != null) - { - getCommandStack().execute(command); - } - // doReferentialIntegrityCheck(namedComponent, newValue); - } - } - } - - protected boolean validateSection() - { - if (nameText == null || nameText.isDisposed()) - return true; - - setErrorMessage(null); - - String name = nameText.getText().trim(); - - // validate against NCName - if (name.length() < 1 || !XMLChar.isValidNCName(name)) - { - setErrorMessage(Messages._UI_ERROR_INVALID_NAME); - return false; - } - - return true; - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == refCombo) - { - String newValue = refCombo.getText(); - if (input instanceof XSDNamedComponent) - { - XSDNamedComponent namedComponent = (XSDNamedComponent)input; - Element element = namedComponent.getElement(); - - if (namedComponent instanceof XSDAttributeGroupDefinition) - { - element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue); - } - } - } - super.doWidgetSelected(e); - } - - - public void dispose() - { - if (nameText != null && !nameText.isDisposed()) - removeListeners(nameText); - super.dispose(); - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeAdvancedSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeAdvancedSection.java deleted file mode 100644 index 0e5cb73286..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeAdvancedSection.java +++ /dev/null @@ -1,221 +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 - *******************************************************************************/ - -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeValueCommand; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; - -public class XSDComplexTypeAdvancedSection extends AbstractSection -{ - private static final String EMPTY = ""; //$NON-NLS-1$ - private static final String FALSE = "false"; //$NON-NLS-1$ - private static final String TRUE = "true"; //$NON-NLS-1$ - protected CCombo blockCombo; - protected CCombo finalCombo; - - private String finalValues[] = { EMPTY, XSDConstants.RESTRICTION_ELEMENT_TAG, //$NON-NLS-1$ - XSDConstants.EXTENSION_ELEMENT_TAG, "#" + XSDConstants.ALL_ELEMENT_TAG }; //$NON-NLS-1$ - - private String blockValues[] = { EMPTY, XSDConstants.RESTRICTION_ELEMENT_TAG, //$NON-NLS-1$ - XSDConstants.EXTENSION_ELEMENT_TAG, "#" + XSDConstants.ALL_ELEMENT_TAG }; //$NON-NLS-1$ - - private String abstractValues[] = { EMPTY, TRUE, FALSE }; // TODO use some - // external string - // here instead - private CCombo abstractCombo; - - protected void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - composite.setLayout(gridLayout); - - // ------------------------------------------------------------------ - // BlockLabel - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - // TODO Should be a translatable string here - CLabel blockLabel = getWidgetFactory().createCLabel(composite, XSDConstants.BLOCK_ATTRIBUTE + ":"); - blockLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // BlockCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - blockCombo = getWidgetFactory().createCCombo(composite); - blockCombo.setLayoutData(data); - blockCombo.setEditable(false); - - blockCombo.setItems(blockValues); - blockCombo.addSelectionListener(this); - - // ------------------------------------------------------------------ - // FinalLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - // TODO Should be a translatable string here - CLabel finalLabel = getWidgetFactory().createCLabel(composite, XSDConstants.FINAL_ATTRIBUTE + ":"); - finalLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // FinalCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - finalCombo = getWidgetFactory().createCCombo(composite); - finalCombo.setLayoutData(data); - finalCombo.setEditable(false); - - finalCombo.setItems(finalValues); - finalCombo.addSelectionListener(this); - - // ------------------------------------------------------------------ - // AbstractLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - // TODO Should be a translatable string here - CLabel abstractLabel = getWidgetFactory().createCLabel(composite, XSDConstants.ABSTRACT_ATTRIBUTE + ":"); - abstractLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // FinalCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - abstractCombo = getWidgetFactory().createCCombo(composite); - abstractCombo.setLayoutData(data); - abstractCombo.setEditable(false); - - abstractCombo.setItems(abstractValues); - abstractCombo.addSelectionListener(this); - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == blockCombo) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input; - String value = blockCombo.getText(); - - UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(complexType.getElement(), XSDConstants.BLOCK_ATTRIBUTE, value); - command.setDeleteIfEmpty(true); - getCommandStack().execute(command); - } - else if (e.widget == finalCombo) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input; - String value = finalCombo.getText(); - - UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(complexType.getElement(), XSDConstants.FINAL_ATTRIBUTE, value); - command.setDeleteIfEmpty(true); - getCommandStack().execute(command); - } - else if (e.widget == abstractCombo) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input; - String value = abstractCombo.getText(); - - if (value.equals(EMPTY)) - complexType.getElement().removeAttribute(XSDConstants.ABSTRACT_ATTRIBUTE); - else - { - if (value.equals(TRUE)) - complexType.setAbstract(true); - else if (value.equals(FALSE)) - complexType.setAbstract(false); - } - } - } - - public void refresh() - { - super.refresh(); - - setListenerEnabled(false); - try - { - if (input instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input; - - if (complexType.getContainer() instanceof XSDSchema) - { - composite.setEnabled(!isReadOnly); - } - else - { - composite.setEnabled(false); - } - - String blockAttValue = complexType.getElement().getAttribute(XSDConstants.BLOCK_ATTRIBUTE); - if (blockAttValue != null) - { - blockCombo.setText(blockAttValue); - } - else - { - blockCombo.setText(EMPTY); - } - - String finalAttValue = complexType.getElement().getAttribute(XSDConstants.FINAL_ATTRIBUTE); - if (finalAttValue != null) - { - finalCombo.setText(finalAttValue); - } - else - { - finalCombo.setText(EMPTY); - } - - if (complexType.getElement().hasAttribute(XSDConstants.ABSTRACT_ATTRIBUTE)) - { - boolean absAttValue = complexType.isAbstract(); - if (absAttValue) - abstractCombo.setText(TRUE); - else - abstractCombo.setText(FALSE); - } - else - { - abstractCombo.setText(EMPTY); - } - } - } - catch (Exception e) - { - } - setListenerEnabled(true); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java deleted file mode 100644 index b5e1de43b1..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDComplexTypeSection.java +++ /dev/null @@ -1,357 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -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.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateComplexTypeDerivationBy; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDDerivationMethod; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; - -public class XSDComplexTypeSection extends RefactoringSection implements SelectionListener -{ - protected Text nameText; - protected CCombo baseTypeCombo; - protected CCombo derivedByCombo; - private String derivedByChoicesComboValues[] = { "", XSDConstants.RESTRICTION_ELEMENT_TAG, XSDConstants.EXTENSION_ELEMENT_TAG }; //$NON-NLS-1$ - - public XSDComplexTypeSection() - { - super(); - } - - /** - * Contents of the property tab - * - * NameLabel NameText DummyLabel BaseTypeLabel BaseTypeCombo BaseTypeButton - * DerivedByLabel DerivedByCombo - */ - public void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - // ------------------------------------------------------------------ - // NameLabel - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel nameLabel = getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_NAME); - nameLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // NameText - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - nameText.setLayoutData(data); - applyAllListeners(nameText); - PlatformUI.getWorkbench().getHelpSystem().setHelp(nameText, - XSDEditorCSHelpIds.GENERAL_TAB__COMPLEX_TYPE__NAME); - - // ------------------------------------------------------------------ - // Refactor/rename hyperlink - // ------------------------------------------------------------------ - createRenameHyperlink(composite); - - // ------------------------------------------------------------------ - // BaseTypeLabel - // ------------------------------------------------------------------ - - getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_INHERIT_FROM); //$NON-NLS-1$ - - // ------------------------------------------------------------------ - // BaseTypeCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - baseTypeCombo = getWidgetFactory().createCCombo(composite); - baseTypeCombo.setEditable(false); - baseTypeCombo.setLayoutData(data); - baseTypeCombo.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(baseTypeCombo, - XSDEditorCSHelpIds.GENERAL_TAB__COMPLEX_TYPE__INHERIT_FROM); - - - // ------------------------------------------------------------------ - // Spacer label - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, ""); - - // ------------------------------------------------------------------ - // DerivedByLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - CLabel derivedByLabel = getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_INHERIT_BY); //$NON-NLS-1$ - derivedByLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // DerivedByCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - derivedByCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - derivedByCombo.setLayoutData(data); - derivedByCombo.setItems(derivedByChoicesComboValues); - derivedByCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(derivedByCombo, - XSDEditorCSHelpIds.GENERAL_TAB__COMPLEX_TYPE__INHERIT_BY); - - // ------------------------------------------------------------------ - // Spacer label - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, ""); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - super.refresh(); - if (Display.getCurrent() == null) - return; - - setListenerEnabled(false); - - try - { - nameText.setText(""); //$NON-NLS-1$ - baseTypeCombo.setText(""); //$NON-NLS-1$ - fillTypesCombo(); - - if (input instanceof XSDComplexTypeDefinition) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input; - String name = complexType.getName(); - if (name == null) - name = ""; //$NON-NLS-1$ - - boolean isAnonymousType = name.equals("") ? true : false; //$NON-NLS-1$ - if (isAnonymousType) - { - nameText.setText("**anonymous**"); //$NON-NLS-1$ - nameText.setEditable(false); - } - else - { - nameText.setText(name); - nameText.setEditable(true); - } - - XSDTypeDefinition baseTypeDefinition = complexType.getBaseTypeDefinition(); - String baseType = ""; //$NON-NLS-1$ - if (baseTypeDefinition != null) - { - baseType = baseTypeDefinition.getName(); - if (baseType == null) - { - baseType = ""; //$NON-NLS-1$ - } - else if (baseType.equals("anyType")) - { - baseType = ""; //$NON-NLS-1$ - } - } - baseTypeCombo.setText(baseType); - - derivedByCombo.setText(""); //$NON-NLS-1$ - int derivationMethod = complexType.getDerivationMethod().getValue(); - if (derivationMethod == XSDDerivationMethod.EXTENSION) - { - derivedByCombo.setText(XSDConstants.EXTENSION_ELEMENT_TAG); - } - else if (derivationMethod == XSDDerivationMethod.RESTRICTION) - { - derivedByCombo.setText(XSDConstants.RESTRICTION_ELEMENT_TAG); - } - } - - } - finally - { - setListenerEnabled(true); - } - } - - /** - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(SelectionEvent) - */ - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == baseTypeCombo) - { - IEditorPart editor = getActiveEditor(); - if (editor == null) return; - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class); - - String selection = baseTypeCombo.getText(); - ComponentSpecification newValue; - IComponentDialog dialog= null; - if ( selection.equals(Messages._UI_ACTION_BROWSE)) - { - dialog = manager.getBrowseDialog(); - } - else if ( selection.equals(Messages._UI_ACTION_NEW)) - { - dialog = manager.getNewDialog(); - } - - if (dialog != null) - { - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - manager.modifyComponentReference(input, newValue); - } - else - { - refresh(); - } - } - } - else if (e.widget == derivedByCombo) - { - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input; - String value = derivedByCombo.getText(); - Command command = new UpdateComplexTypeDerivationBy(complexType, value); - - if (getCommandStack() != null) - { - getCommandStack().execute(command); - } - } - super.doWidgetSelected(e); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace() - */ - public boolean shouldUseExtraSpace() - { - return false; - } - - public void dispose() - { - super.dispose(); - } - - public void doHandleEvent(Event event) - { - super.doHandleEvent(event); - if (event.widget == nameText) - { - if (!nameText.getEditable()) - return; - - String newValue = nameText.getText().trim(); - if (input instanceof XSDNamedComponent) - { - XSDNamedComponent namedComponent = (XSDNamedComponent) input; - - if (!validateSection()) - return; - - Command command = null; - - // Make sure an actual name change has taken place - String oldName = namedComponent.getName(); - if (!newValue.equals(oldName)) - { - command = new UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ACTION_RENAME, namedComponent, newValue); - } - - if (command != null && getCommandStack() != null) - { - getCommandStack().execute(command); - } - // doReferentialIntegrityCheck(namedComponent, newValue); - } - } - } - - protected boolean validateSection() - { - if (nameText == null || nameText.isDisposed()) - return true; - - setErrorMessage(null); - - String name = nameText.getText().trim(); - - // validate against NCName - if (name.length() < 1 || !XMLChar.isValidNCName(name)) - { - setErrorMessage(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ERROR_INVALID_NAME); - return false; - } - - return true; - } - - private void fillTypesCombo() - { - baseTypeCombo.removeAll(); - baseTypeCombo.add(Messages._UI_ACTION_BROWSE); - baseTypeCombo.add(Messages._UI_ACTION_NEW); - // Add the current Type of this attribute if needed - XSDComplexTypeDefinition complexType = (XSDComplexTypeDefinition) input; - XSDTypeDefinition baseType = complexType.getBaseType(); - if (baseType != null && baseType.getQName() != null) - { - String currentTypeName = baseType.getQName(xsdSchema); //no prefix - if (currentTypeName != null && !currentTypeName.equals("anyType")) - baseTypeCombo.add(currentTypeName); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java deleted file mode 100644 index 53ad36f1d5..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationAdvancedSection.java +++ /dev/null @@ -1,367 +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 - *******************************************************************************/ - -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.jface.window.Window; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Event; -import org.eclipse.ui.IEditorPart; -import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeValueCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDSubstitutionGroupEditManager; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDElementDeclarationAdvancedSection extends AbstractSection -{ - private static final String EMPTY = ""; //$NON-NLS-1$ - private static final String FALSE = "false"; //$NON-NLS-1$ - private static final String TRUE = "true"; //$NON-NLS-1$ - protected CCombo blockCombo; - protected CCombo finalCombo; - protected CCombo abstractCombo; - protected CCombo substGroupCombo; - - private String blockValues[] = { EMPTY, "#" + XSDConstants.ALL_ELEMENT_TAG, //$NON-NLS-1$ - XSDConstants.EXTENSION_ELEMENT_TAG, XSDConstants.RESTRICTION_ELEMENT_TAG, - "substitution" }; //$NON-NLS-1$ - - private String finalValues[] = { EMPTY, "#" + XSDConstants.ALL_ELEMENT_TAG, XSDConstants.EXTENSION_ELEMENT_TAG, //$NON-NLS-1$ - XSDConstants.RESTRICTION_ELEMENT_TAG }; //$NON-NLS-1$ - - private String abstractValues[] = { EMPTY, TRUE, FALSE }; // TODO use some external string here instead - - protected void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - composite.setLayout(gridLayout); - - // ------------------------------------------------------------------ - // AbstractLabel - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - // TODO Should be a translatable string here - CLabel abstractLabel = getWidgetFactory().createCLabel(composite, XSDConstants.ABSTRACT_ATTRIBUTE + ":"); - abstractLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // AbstractCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - abstractCombo = getWidgetFactory().createCCombo(composite); - abstractCombo.setLayoutData(data); - abstractCombo.setEditable(false); - - abstractCombo.setItems(abstractValues); - abstractCombo.addSelectionListener(this); - - // ------------------------------------------------------------------ - // BlockLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - // TODO Should be a translatable string here - CLabel blockLabel = getWidgetFactory().createCLabel(composite, XSDConstants.BLOCK_ATTRIBUTE + ":"); - blockLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // BlockCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - blockCombo = getWidgetFactory().createCCombo(composite); - blockCombo.setLayoutData(data); - blockCombo.setEditable(false); - - blockCombo.setItems(blockValues); - blockCombo.addSelectionListener(this); - - // ------------------------------------------------------------------ - // FinalLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - // TODO Should be a translatable string here - CLabel finalLabel = getWidgetFactory().createCLabel(composite, XSDConstants.FINAL_ATTRIBUTE + ":"); - finalLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // FinalCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - finalCombo = getWidgetFactory().createCCombo(composite); - finalCombo.setLayoutData(data); - finalCombo.setEditable(false); - - finalCombo.setItems(finalValues); - finalCombo.addSelectionListener(this); - - // ------------------------------------------------------------------ - // Substitution Group Label - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - - // TODO Should be a translatable string here - CLabel subGroupLabel = getWidgetFactory().createCLabel(composite, XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE + ":"); - subGroupLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // Substitution Group Combo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - substGroupCombo = getWidgetFactory().createCCombo(composite); - substGroupCombo.setLayoutData(data); - substGroupCombo.setEditable(true); - substGroupCombo.addSelectionListener(this); - applyAllListeners(substGroupCombo); - } - - public void doHandleEvent(Event e) - { - if (e.widget == substGroupCombo) - { - XSDElementDeclaration eleDec = (XSDElementDeclaration) input; - String value = substGroupCombo.getText(); - String oldValue = eleDec.getElement().getAttribute(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE); - if (oldValue == null) - oldValue = EMPTY; - if (value.equals(oldValue)) - return; - - UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(eleDec.getElement(), XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE, value); - command.setDeleteIfEmpty(true); - getCommandStack().execute(command); - } - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == blockCombo) - { - XSDElementDeclaration eleDec = (XSDElementDeclaration) input; - String value = blockCombo.getText(); - - UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(eleDec.getElement(), XSDConstants.BLOCK_ATTRIBUTE, value); - command.setDeleteIfEmpty(true); - getCommandStack().execute(command); - } - else if (e.widget == finalCombo) - { - XSDElementDeclaration eleDec = (XSDElementDeclaration) input; - String value = finalCombo.getText(); - - UpdateAttributeValueCommand command = new UpdateAttributeValueCommand(eleDec.getElement(), XSDConstants.FINAL_ATTRIBUTE, value); - command.setDeleteIfEmpty(true); - getCommandStack().execute(command); - } - else if (e.widget == abstractCombo) - { - XSDElementDeclaration eleDec = (XSDElementDeclaration) input; - String value = abstractCombo.getText(); - - if (value.equals(EMPTY)) - eleDec.getElement().removeAttribute(XSDConstants.ABSTRACT_ATTRIBUTE); - else - { - if (value.equals(TRUE)) - eleDec.setAbstract(true); - else if (value.equals(FALSE)) - eleDec.setAbstract(false); - } - } - else if (e.widget == substGroupCombo) - { - IEditorPart editor = getActiveEditor(); - if (editor == null) return; - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDSubstitutionGroupEditManager.class); - - String selection = substGroupCombo.getText(); - ComponentSpecification newValue; - IComponentDialog dialog= null; - if ( selection.equals(Messages._UI_ACTION_BROWSE)) - { - dialog = manager.getBrowseDialog(); - } - else if ( selection.equals(Messages._UI_ACTION_NEW)) - { - dialog = manager.getNewDialog(); - } - - if (dialog != null) - { - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - manager.modifyComponentReference(input, newValue); - } - else - { - substGroupCombo.setText(""); - } - } - else //use the value from selected quickPick item - { - newValue = getComponentSpecFromQuickPickForValue(selection, manager); - if (newValue != null) - manager.modifyComponentReference(input, newValue); - } - } - } - - public void refresh() - { - super.refresh(); - fillSubstitutionGroupCombo(); - setListenerEnabled(false); - try - { - if (input instanceof XSDElementDeclaration) - { - XSDElementDeclaration eleDec = (XSDElementDeclaration) input; - - composite.setEnabled(!isReadOnly); - if (eleDec.getContainer() instanceof XSDSchema) // global element - { - abstractCombo.setEnabled(true); - finalCombo.setEnabled(true); - substGroupCombo.setEnabled(true); - } - else - { - abstractCombo.setEnabled(false); - finalCombo.setEnabled(false); - substGroupCombo.setEnabled(false); - } - - Element element = eleDec.getElement(); - String blockAttValue = element.getAttribute(XSDConstants.BLOCK_ATTRIBUTE); - if (blockAttValue != null) - { - blockCombo.setText(blockAttValue); - } - else - { - blockCombo.setText(EMPTY); - } - - String finalAttValue = element.getAttribute(XSDConstants.FINAL_ATTRIBUTE); - if (finalAttValue != null) - { - finalCombo.setText(finalAttValue); - } - else - { - finalCombo.setText(EMPTY); - } - - if (element.hasAttribute(XSDConstants.ABSTRACT_ATTRIBUTE)) - { - boolean absAttValue = eleDec.isAbstract(); - if (absAttValue) - abstractCombo.setText(TRUE); - else - abstractCombo.setText(FALSE); - } - else - abstractCombo.setText(EMPTY); - - if (element.hasAttribute(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE)) - { - substGroupCombo.setText(element.getAttribute(XSDConstants.SUBSTITUTIONGROUP_ATTRIBUTE)); - } - else - { - substGroupCombo.setText(EMPTY); - } - } - } - catch (Exception e) - { - } - setListenerEnabled(true); - } - - private void fillSubstitutionGroupCombo() - { - IEditorPart editor = getActiveEditor(); - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDSubstitutionGroupEditManager.class); - ComponentSpecification[] items = manager.getQuickPicks(); - - substGroupCombo.removeAll(); - substGroupCombo.add(Messages._UI_ACTION_BROWSE); - substGroupCombo.add(Messages._UI_ACTION_NEW); - for (int i = 0; i < items.length; i++) - { - substGroupCombo.add(items[i].getName()); - } - // Add the current substitution group if needed - XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getSubstitutionGroupAffiliation(); - if (namedComponent != null) - { - ComponentSpecification ret = getComponentSpecFromQuickPickForValue(namedComponent.getName(),manager); - if (ret == null) - { - substGroupCombo.add(namedComponent.getQName(xsdSchema)); - } - } - } - - private ComponentSpecification getComponentSpecFromQuickPickForValue(String value, ComponentReferenceEditManager editManager) - { - if (editManager != null) - { - ComponentSpecification[] quickPicks = editManager.getQuickPicks(); - if (quickPicks != null) - { - for (int i=0; i < quickPicks.length; i++) - { - ComponentSpecification componentSpecification = quickPicks[i]; - if (value != null && value.equals(componentSpecification.getName())) - { - return componentSpecification; - } - } - } - } - return null; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java deleted file mode 100644 index a44cbc3c1b..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDElementDeclarationSection.java +++ /dev/null @@ -1,583 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -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.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.dialogs.NewTypeDialog; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDElementReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDElementDeclarationSection extends MultiplicitySection -{ - protected Text nameText; - protected CCombo typeCombo; - protected CCombo componentNameCombo; - boolean isElementReference; - protected String typeName = ""; //$NON-NLS-1$ - - private XSDTypeDefinition typeDefinition; - - public XSDElementDeclarationSection() - { - super(); - } - - /** - * Contents of the property tab - */ - public void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - TabbedPropertySheetWidgetFactory factory = getWidgetFactory(); - - String typeLabel = Messages.UI_LABEL_TYPE; //$NON-NLS-1$ - - GridData data = new GridData(); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - // ------------------------------------------------------------------ - // NameLabel - // ------------------------------------------------------------------ - - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel nameLabel = factory.createCLabel(composite, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_NAME); - nameLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // NameText - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - nameText.setLayoutData(data); - applyAllListeners(nameText); - PlatformUI.getWorkbench().getHelpSystem().setHelp(nameText, - XSDEditorCSHelpIds.GENERAL_TAB__ELEMENT__NAME); - - // ------------------------------------------------------------------ - // Refactor/rename hyperlink - // ------------------------------------------------------------------ - createRenameHyperlink(composite); - - // ------------------------------------------------------------------ - // Ref Label - // ------------------------------------------------------------------ - if (isElementReference) - { - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel refLabel = getWidgetFactory().createCLabel(composite, org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_LABEL_REFERENCE); - refLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // Ref Combo - // ------------------------------------------------------------------ - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - componentNameCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - componentNameCombo.addSelectionListener(this); - componentNameCombo.setLayoutData(data); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(componentNameCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ELEMENT__REFERENCE); - - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - } - - // ------------------------------------------------------------------ - // typeLabel - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, typeLabel); - - // ------------------------------------------------------------------ - // typeCombo - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - typeCombo = getWidgetFactory().createCCombo(composite); //$NON-NLS-1$ - typeCombo.setEditable(false); - typeCombo.setLayoutData(data); - typeCombo.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(typeCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ELEMENT__TYPE); - - // ------------------------------------------------------------------ - // DummyLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - - // ------------------------------------------------------------------ - // min property - // ------------------------------------------------------------------ - - getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_MINOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - minCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - minCombo.setLayoutData(data); - minCombo.add("0"); //$NON-NLS-1$ - minCombo.add("1"); //$NON-NLS-1$ - applyAllListeners(minCombo); - minCombo.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(minCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ELEMENT__MIN_OCCURENCE); - - // ------------------------------------------------------------------ - // DummyLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - - // ------------------------------------------------------------------ - // max property - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_MAXOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - maxCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - maxCombo.setLayoutData(data); - maxCombo.add("0"); //$NON-NLS-1$ - maxCombo.add("1"); //$NON-NLS-1$ - maxCombo.add("unbounded"); //$NON-NLS-1$ - applyAllListeners(maxCombo); - maxCombo.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(maxCombo, - XSDEditorCSHelpIds.GENERAL_TAB__ELEMENT__MAX_OCCURENCE); - } - - public void setInput(IWorkbenchPart part, ISelection selection) - { - super.setInput(part, selection); - setListenerEnabled(false); - init(); - relayout(); - - setListenerEnabled(true); - } - - protected void init() - { - if (input instanceof XSDElementDeclaration) - { - XSDElementDeclaration xsdElementDeclaration = (XSDElementDeclaration) input; - isElementReference = xsdElementDeclaration.isElementDeclarationReference(); - - typeDefinition = xsdElementDeclaration.getResolvedElementDeclaration().getTypeDefinition(); - } - } - - private void fillTypesCombo() - { - IEditorPart editor = getActiveEditor(); - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class); - ComponentSpecification[] items = manager.getQuickPicks(); - - typeCombo.removeAll(); - typeCombo.add(Messages._UI_ACTION_BROWSE); - typeCombo.add(Messages._UI_ACTION_NEW); - for (int i = 0; i < items.length; i++) - { - typeCombo.add(items[i].getName()); - } - // Add the current Type of this element if needed - XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getResolvedElementDeclaration(); - XSDTypeDefinition td = namedComponent.getType(); - if (td != null) - { - String currentTypeName = td.getQName(xsdSchema); - if (currentTypeName == null) // anonymous type - currentTypeName = "**Anonymous**"; - ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName,manager); - if (ret == null && currentTypeName != null) //not in quickPick - { - typeCombo.add(currentTypeName); - } - } - } - - private ComponentSpecification getComponentSpecFromQuickPickForValue(String value, ComponentReferenceEditManager editManager) - { - if (editManager != null) - { - ComponentSpecification[] quickPicks = editManager.getQuickPicks(); - if (quickPicks != null) - { - for (int i=0; i < quickPicks.length; i++) - { - ComponentSpecification componentSpecification = quickPicks[i]; - if (value != null && value.equals(componentSpecification.getName())) - { - return componentSpecification; - } - } - } - } - return null; - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - setListenerEnabled(false); - - super.refresh(); - - XSDElementDeclaration xsdElementDeclaration = ((XSDElementDeclaration) input).getResolvedElementDeclaration(); - - // refresh name - nameText.setText(""); //$NON-NLS-1$ - typeCombo.setText(""); //$NON-NLS-1$ - String name = xsdElementDeclaration.getName(); - if (name != null) - { - nameText.setText(name); - } - - if (isElementReference) - { - refreshRefCombo(); - } - - // refresh type - if (input != null) - { - if (input instanceof XSDElementDeclaration) - { - boolean isAnonymous = xsdElementDeclaration.getAnonymousTypeDefinition() != null; - //XSDTypeDefinition typeDef = XSDUtils.getResolvedType(xsdElementDeclaration); - XSDTypeDefinition typeDef = xsdElementDeclaration.getResolvedElementDeclaration().getTypeDefinition(); - - if (typeDef != null) - typeName = typeDef.getQName(xsdSchema); - - if (typeName == null) - { - typeName = ""; //$NON-NLS-1$ - } - - fillTypesCombo(); - if (isAnonymous) - { - typeCombo.setText("**Anonymous**"); - typeName = "**Anonymous**"; - } - else - { - if (typeDefinition != null) - { - typeCombo.setText(typeName); - } - else - { - typeCombo.setText(Messages.UI_NO_TYPE); //$NON-NLS-1$ - } - } - - maxCombo.setEnabled(!xsdElementDeclaration.isGlobal() || isElementReference); - minCombo.setEnabled(!xsdElementDeclaration.isGlobal() || isElementReference); - } - } - - // refresh min max - refreshMinMax(); - - setListenerEnabled(true); - - } - - public boolean shouldUseExtraSpace() - { - return false; - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == typeCombo) - { - IEditorPart editor = getActiveEditor(); - if (editor == null) return; - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class); - - String selection = typeCombo.getText(); - ComponentSpecification newValue; - IComponentDialog dialog= null; - if ( selection.equals(Messages._UI_ACTION_BROWSE)) - { - dialog = manager.getBrowseDialog(); - ((XSDSearchListDialogDelegate) dialog).showComplexTypes(true); - } - else if ( selection.equals(Messages._UI_ACTION_NEW)) - { - dialog = manager.getNewDialog(); - ((NewTypeDialog) dialog).allowComplexType(true); - } - - if (dialog != null) - { - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - manager.modifyComponentReference(input, newValue); - } - else - { - typeCombo.setText(typeName ); - } - } - else //use the value from selected quickPick item - { - newValue = getComponentSpecFromQuickPickForValue(selection, manager); - if (newValue != null) - manager.modifyComponentReference(input, newValue); - } - } - else if (e.widget == componentNameCombo) - { - IEditorPart editor = getActiveEditor(); - if (editor == null) return; - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDElementReferenceEditManager.class); - - String selection = componentNameCombo.getText(); - ComponentSpecification newValue; - IComponentDialog dialog= null; - if ( selection.equals(Messages._UI_ACTION_BROWSE)) - { - dialog = manager.getBrowseDialog(); - } - else if ( selection.equals(Messages._UI_ACTION_NEW)) - { - dialog = manager.getNewDialog(); - } - - if (dialog != null) - { - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - manager.modifyComponentReference(input, newValue); - } - else - { - componentNameCombo.setText(""); - } - } - else //use the value from selected quickPick item - { - newValue = getComponentSpecFromQuickPickForValue(selection, manager); - if (newValue != null) - manager.modifyComponentReference(input, newValue); - } - - } - else if (e.widget == maxCombo) - { - updateMaxAttribute(); - } - else if (e.widget == minCombo) - { - updateMinAttribute(); - } - } - - protected void relayout() - { - Composite parentComposite = composite.getParent(); - parentComposite.getParent().setRedraw(false); - - if (parentComposite != null && !parentComposite.isDisposed()) - { - Control[] children = parentComposite.getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].dispose(); - } - } - - // Now initialize the new handler - createContents(parentComposite); - parentComposite.getParent().layout(true, true); - - // Now turn painting back on - parentComposite.getParent().setRedraw(true); - refresh(); - } - - public void doHandleEvent(Event event) - { - super.doHandleEvent(event); - if (event.widget == nameText) - { - String newValue = nameText.getText().trim(); - if (input instanceof XSDElementDeclaration) - { - XSDElementDeclaration namedComponent = ((XSDElementDeclaration) input).getResolvedElementDeclaration(); - if (!validateSection()) - return; - - Command command = null; - - // Make sure an actual name change has taken place - String oldName = namedComponent.getName(); - if (!newValue.equals(oldName)) - { - command = new UpdateNameCommand(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ACTION_RENAME, namedComponent, newValue); - } - - if (command != null && getCommandStack() != null) - { - getCommandStack().execute(command); - } - - // doReferentialIntegrityCheck(namedComponent, newValue); - } - } - } - - protected boolean validateSection() - { - if (nameText == null || nameText.isDisposed()) - return true; - - setErrorMessage(null); - - String name = nameText.getText().trim(); - - // validate against NCName - if (name.length() < 1 || !XMLChar.isValidNCName(name)) - { - setErrorMessage(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ERROR_INVALID_NAME); - return false; - } - - return true; - } - - public void dispose() - { - if (componentNameCombo != null && !componentNameCombo.isDisposed()) - componentNameCombo.removeSelectionListener(this); - if (minCombo != null && !minCombo.isDisposed()) - minCombo.removeSelectionListener(this); - if (maxCombo != null && !maxCombo.isDisposed()) - maxCombo.removeSelectionListener(this); - if (typeCombo != null && !typeCombo.isDisposed()) - typeCombo.removeSelectionListener(this); - if (nameText != null && !nameText.isDisposed()) - removeListeners(nameText); - super.dispose(); - } - - protected void refreshRefCombo() - { - componentNameCombo.setText(""); //$NON-NLS-1$ - fillElementsCombo(); - } - - private void fillElementsCombo() - { - IEditorPart editor = getActiveEditor(); - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDElementReferenceEditManager.class); - - componentNameCombo.removeAll(); - componentNameCombo.add(Messages._UI_ACTION_BROWSE); - componentNameCombo.add(Messages._UI_ACTION_NEW); - ComponentSpecification[] quickPicks = manager.getQuickPicks(); - if (quickPicks != null) - { - for (int i=0; i < quickPicks.length; i++) - { - ComponentSpecification componentSpecification = quickPicks[i]; - componentNameCombo.add(componentSpecification.getName()); - } - } - ComponentSpecification[] history = manager.getHistory(); - if (history != null) - { - for (int i=0; i < history.length; i++) - { - ComponentSpecification componentSpecification = history[i]; - componentNameCombo.add(componentSpecification.getName()); - } - } - - XSDElementDeclaration namedComponent = (XSDElementDeclaration) input; - Element element = namedComponent.getElement(); - if (element != null) - { - String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE); - if (attrValue == null) - { - attrValue = ""; //$NON-NLS-1$ - } - ComponentSpecification ret = getComponentSpecFromQuickPickForValue(attrValue, manager); - if (ret == null) - { - componentNameCombo.add(attrValue); - } - componentNameCombo.setText(attrValue); - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java deleted file mode 100644 index 48e7c7d897..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSection.java +++ /dev/null @@ -1,979 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.math.BigDecimal; -import java.math.BigInteger; - -import org.eclipse.gef.commands.Command; -import org.eclipse.gef.commands.CompoundCommand; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.FontData; -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.Event; -import org.eclipse.swt.widgets.Group; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.xsd.ui.internal.common.commands.ChangeToLocalSimpleTypeCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNumericBoundsFacetCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateStringLengthFacetCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateXSDWhiteSpaceFacetCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDFeature; -import org.eclipse.xsd.XSDLengthFacet; -import org.eclipse.xsd.XSDMaxExclusiveFacet; -import org.eclipse.xsd.XSDMaxFacet; -import org.eclipse.xsd.XSDMaxInclusiveFacet; -import org.eclipse.xsd.XSDMaxLengthFacet; -import org.eclipse.xsd.XSDMinExclusiveFacet; -import org.eclipse.xsd.XSDMinFacet; -import org.eclipse.xsd.XSDMinInclusiveFacet; -import org.eclipse.xsd.XSDMinLengthFacet; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDWhiteSpace; -import org.eclipse.xsd.XSDWhiteSpaceFacet; -import org.eclipse.xsd.util.XSDConstants; - -public class XSDFacetSection extends AbstractSection -{ - private String minLengthString, maxLengthString, titleString; - Font titleFont; - CLabel title; - Label minLengthLabel; - Text minLengthText; - Label maxLengthLabel; - Text maxLengthText; - Group simpleTypeModifierGroup; - String simpleTypeModifierGroupTitle = ""; //$NON-NLS-1$ - Button collapseWhitespaceButton; - Button useEnumerationsButton, usePatternsButton; - Button minimumInclusiveCheckbox; - Button maximumInclusiveCheckbox; - boolean isNumericBaseType; - private XSDTypeDefinition typeDefinition; - private XSDSimpleTypeDefinition xsdSimpleTypeDefinition; - private XSDSimpleTypeDefinition currentPrimitiveType, previousPrimitiveType; - private XSDElementDeclaration xsdElementDeclaration; - private XSDAttributeDeclaration xsdAttributeDeclaration; - private XSDFeature xsdFeature; - boolean hasMaxMinFacets; - - SpecificConstraintsWidget constraintsWidget; - - public XSDFacetSection() - { - super(); - } - - protected void createContents(Composite parent) - { - TabbedPropertySheetWidgetFactory factory = getWidgetFactory(); - composite = factory.createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 1; - composite.setLayout(gridLayout); - - title = factory.createCLabel(composite, ""); //$NON-NLS-1$ - FontData fontData = composite.getFont().getFontData()[0]; - title.setFont(JFaceResources.getFontRegistry().getBold(fontData.getName())); - title.setText(titleString + (isReadOnly ? " - " + Messages._UI_LABEL_READONLY : "")); //$NON-NLS-1$ //$NON-NLS-2$ - - Composite facetComposite = factory.createComposite(composite, SWT.FLAT); - - GridData data = new GridData(); - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 2; - facetComposite.setLayout(gridLayout); - data.grabExcessVerticalSpace = true; - data.grabExcessHorizontalSpace = true; - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - facetComposite.setLayoutData(data); - - data = new GridData(); - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - - simpleTypeModifierGroup = getWidgetFactory().createGroup(facetComposite, simpleTypeModifierGroupTitle); - GridLayout groupGrid = new GridLayout(); - groupGrid.marginTop = 0; - groupGrid.marginBottom = 0; - groupGrid.numColumns = 1; - simpleTypeModifierGroup.setLayoutData(data); - simpleTypeModifierGroup.setLayout(groupGrid); - - Composite simpleTypeModifierComposite = getWidgetFactory().createFlatFormComposite(simpleTypeModifierGroup); - data = new GridData(); - data.grabExcessVerticalSpace = true; - data.verticalAlignment = GridData.FILL; - data.horizontalAlignment = GridData.FILL; - - GridLayout grid = new GridLayout(); - grid.marginTop = 0; - grid.marginBottom = 0; - grid.numColumns = 3; - simpleTypeModifierComposite.setLayout(grid); - simpleTypeModifierComposite.setLayoutData(data); - if (hasMaxMinFacets) - { - boolean isLinux = java.io.File.separator.equals("/"); - minLengthLabel = factory.createLabel(simpleTypeModifierComposite, minLengthString); - minLengthText = factory.createText(simpleTypeModifierComposite, ""); //$NON-NLS-1$ - if (isLinux) - { - minLengthText.addListener(SWT.Modify, customListener); - minLengthText.addListener(SWT.KeyDown, customListener); - } - else - applyAllListeners(minLengthText); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(minLengthText, - XSDEditorCSHelpIds.CONSTRAINTS_TAB__MINIMUM_LENGTH); - - GridData minGridData = new GridData(); - minGridData.widthHint = 100; - minLengthText.setLayoutData(minGridData); - minimumInclusiveCheckbox = factory.createButton(simpleTypeModifierComposite, Messages._UI_LABEL_INCLUSIVE, SWT.CHECK); - minimumInclusiveCheckbox.addSelectionListener(this); - - maxLengthLabel = factory.createLabel(simpleTypeModifierComposite, maxLengthString); - maxLengthText = factory.createText(simpleTypeModifierComposite, ""); //$NON-NLS-1$ - if (isLinux) - { - maxLengthText.addListener(SWT.Modify, customListener); - maxLengthText.addListener(SWT.KeyDown, customListener); - } - else - applyAllListeners(maxLengthText); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(maxLengthText, - XSDEditorCSHelpIds.CONSTRAINTS_TAB__MAXIMUM_LENGTH); - - GridData maxGridData = new GridData(); - maxGridData.widthHint = 100; - maxLengthText.setLayoutData(maxGridData); - - maximumInclusiveCheckbox = factory.createButton(simpleTypeModifierComposite, Messages._UI_LABEL_INCLUSIVE, SWT.CHECK); - maximumInclusiveCheckbox.addSelectionListener(this); - - minimumInclusiveCheckbox.setVisible(isNumericBaseType); - maximumInclusiveCheckbox.setVisible(isNumericBaseType); - } - collapseWhitespaceButton = factory.createButton(simpleTypeModifierComposite, Messages._UI_LABEL_COLLAPSE_WHITESPACE, SWT.CHECK); - collapseWhitespaceButton.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(collapseWhitespaceButton, - XSDEditorCSHelpIds.CONSTRAINTS_TAB__COLLAPSE_WHITESPACE); - - Group specificValueConstraintsGroup = factory.createGroup(facetComposite, Messages._UI_LABEL_SPECIFIC_CONSTRAINT_VALUES); - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 2; - specificValueConstraintsGroup.setLayout(gridLayout); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - specificValueConstraintsGroup.setLayoutData(data); - - Composite compositeForButtons = factory.createFlatFormComposite(specificValueConstraintsGroup); - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.verticalSpacing = 1; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 1; - compositeForButtons.setLayout(gridLayout); - data = new GridData(); - data.verticalAlignment = GridData.BEGINNING; - compositeForButtons.setLayoutData(data); - - factory.createCLabel(compositeForButtons, Messages._UI_LABEL_RESTRICT_VALUES_BY); -// useDefinedValuesButton = factory.createButton(compositeForButtons, "Only permit certain values", SWT.CHECK); -// useDefinedValuesButton.addSelectionListener(this); - - Composite compositeForRadioButtons = factory.createFlatFormComposite(compositeForButtons); - gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginLeft = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 1; - compositeForRadioButtons.setLayout(gridLayout); - useEnumerationsButton = factory.createButton(compositeForRadioButtons, Messages._UI_LABEL_ENUMERATIONS, SWT.RADIO); - useEnumerationsButton.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(useEnumerationsButton, - XSDEditorCSHelpIds.CONSTRAINTS_TAB__ENUMERATIONS); - usePatternsButton = factory.createButton(compositeForRadioButtons, Messages._UI_LABEL_PATTERNS, SWT.RADIO); - usePatternsButton.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(usePatternsButton, - XSDEditorCSHelpIds.CONSTRAINTS_TAB__PATTERNS); - - constraintsWidget = new SpecificConstraintsWidget(specificValueConstraintsGroup, factory, (input instanceof XSDFeature) ? (XSDFeature)input : null, xsdSimpleTypeDefinition, this); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.grabExcessVerticalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.verticalAlignment = GridData.FILL; - constraintsWidget.getControl().setLayoutData(data); - PlatformUI.getWorkbench().getHelpSystem().setHelp(constraintsWidget.getControl(), - XSDEditorCSHelpIds.CONSTRAINTS_TAB__NO_LABEL); - } - - public void doSetInput() - { - setInput(getPart(), getSelection()); - } - - public void setInput(IWorkbenchPart part, ISelection selection) - { - super.setInput(part, selection); - init(); - - XSDSchema schemaOfType = null; - - if (!isReadOnly) - { - schemaOfType = xsdSimpleTypeDefinition.getSchema(); - } - if (schemaOfType == owningEditor.getAdapter(XSDSchema.class)) - { - isReadOnly = false; - } - else - { - if (!XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(xsdSimpleTypeDefinition.getTargetNamespace())) - isReadOnly = true; - } - if (hasMaxMinFacets) - { - title.setText(titleString + (isReadOnly ? " - " + Messages._UI_LABEL_READONLY : "")); //$NON-NLS-1$ //$NON-NLS-2$ - } - relayout(); - constraintsWidget.setCommandStack(getCommandStack()); - } - - protected void init() - { - hasMaxMinFacets = false; - try - { - updateInput(); - - if (xsdSimpleTypeDefinition != null) - { - XSDSimpleTypeDefinition targetST = xsdSimpleTypeDefinition; - - while (!XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(targetST.getTargetNamespace()) && targetST != null) - { - targetST = targetST.getBaseTypeDefinition(); - } - - minLengthString = ""; //$NON-NLS-1$ - maxLengthString = ""; //$NON-NLS-1$ - if (targetST.getValidFacets().contains("length")) //$NON-NLS-1$ - { - minLengthString = Messages._UI_LABEL_MINIMUM_LENGTH; - maxLengthString = Messages._UI_LABEL_MAXIMUM_LENGTH; - simpleTypeModifierGroupTitle = Messages._UI_LABEL_CONSTRAINTS_ON_LENGTH_OF + targetST.getName(); - isNumericBaseType = false; - hasMaxMinFacets = true; - } - else if (targetST.getValidFacets().contains("maxInclusive")) //$NON-NLS-1$ - { - simpleTypeModifierGroupTitle = Messages._UI_LABEL_CONSTRAINTS_ON_VALUE_OF + targetST.getName(); - minLengthString = Messages._UI_LABEL_MINIMUM_VALUE; - maxLengthString = Messages._UI_LABEL_MAXIMUM_VALUE; - isNumericBaseType = true; - hasMaxMinFacets = true; - } - else - { - simpleTypeModifierGroupTitle = Messages._UI_LABEL_CONTRAINTS_ON + (targetST != null ? targetST.getName() : "anyType"); //$NON-NLS-1$ - } - } - } - catch(Exception e) - { - } - } - - private void updateInput() - { - previousPrimitiveType = currentPrimitiveType; - if (input instanceof XSDFeature) - { - xsdFeature = (XSDFeature) input; - typeDefinition = xsdFeature.getResolvedFeature().getType(); - XSDTypeDefinition anonymousTypeDefinition = null; - if (xsdFeature instanceof XSDElementDeclaration) - { - xsdElementDeclaration = (XSDElementDeclaration)xsdFeature; - anonymousTypeDefinition = xsdElementDeclaration.getResolvedElementDeclaration().getAnonymousTypeDefinition(); - } - else if (xsdFeature instanceof XSDAttributeDeclaration) - { - xsdAttributeDeclaration = (XSDAttributeDeclaration)xsdFeature; - anonymousTypeDefinition = xsdAttributeDeclaration.getResolvedAttributeDeclaration().getAnonymousTypeDefinition(); - } - - if (typeDefinition instanceof XSDSimpleTypeDefinition) - { - xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) typeDefinition; - } - - if (anonymousTypeDefinition instanceof XSDSimpleTypeDefinition) - { - xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition)anonymousTypeDefinition; - } - - if (xsdSimpleTypeDefinition != null) - { - if (!XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(xsdSimpleTypeDefinition.getTargetNamespace())) - { - XSDSimpleTypeDefinition basePrimitiveType = xsdSimpleTypeDefinition.getBaseTypeDefinition(); - String basePrimitiveTypeString = basePrimitiveType != null ? basePrimitiveType.getName() : ""; - currentPrimitiveType = basePrimitiveType; - titleString = Messages._UI_LABEL_TYPE + (anonymousTypeDefinition != null ? "(" + xsdFeature.getResolvedFeature().getName() + "Type)" : xsdSimpleTypeDefinition.getName()) + " , " + Messages._UI_LABEL_BASE + ": " + basePrimitiveTypeString; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ - } - else - { - currentPrimitiveType = xsdSimpleTypeDefinition; - titleString = Messages._UI_LABEL_TYPE + (anonymousTypeDefinition != null ? "(" + xsdFeature.getResolvedFeature().getName() + "Type)" : xsdSimpleTypeDefinition.getName()); - } - } - } - else if (input instanceof XSDSimpleTypeDefinition) - { - xsdSimpleTypeDefinition = (XSDSimpleTypeDefinition) input; - currentPrimitiveType = xsdSimpleTypeDefinition; - titleString = Messages._UI_LABEL_TYPE + (xsdSimpleTypeDefinition.getName() == null ? "(localType)" : xsdSimpleTypeDefinition.getName()) + " , " + Messages._UI_LABEL_BASE + ": " + xsdSimpleTypeDefinition.getBaseTypeDefinition().getName(); //$NON-NLS-1$ //$NON-NLS-2$ - } - } - - public void refresh() - { - super.refresh(); - init(); - - if (currentPrimitiveType != previousPrimitiveType) - { - relayout(); - } - - setListenerEnabled(false); - - XSDWhiteSpaceFacet whitespaceFacet = xsdSimpleTypeDefinition.getWhiteSpaceFacet(); - if (whitespaceFacet != null) - { - if (xsdSimpleTypeDefinition.getFacetContents().contains(whitespaceFacet)) - { - if (XSDWhiteSpace.COLLAPSE_LITERAL.equals(whitespaceFacet.getValue())) - { - if (!XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(xsdSimpleTypeDefinition.getTargetNamespace())) - { - collapseWhitespaceButton.setSelection(true); - } - else - { - collapseWhitespaceButton.setSelection(false); - } - } - } - } - - if (hasMaxMinFacets && !minLengthLabel.isDisposed() && !maxLengthLabel.isDisposed()) - { - minLengthLabel.setText(minLengthString); - maxLengthLabel.setText(maxLengthString); - - if (!isNumericBaseType) - refreshStringLength(); - else - refreshValueLengths(); - } - - if (xsdSimpleTypeDefinition.getEnumerationFacets().size() > 0) - { - usePatternsButton.setSelection(false); - useEnumerationsButton.setSelection(true); - constraintsWidget.setConstraintKind(SpecificConstraintsWidget.ENUMERATION); - constraintsWidget.addButton.setEnabled(true); - } - else if (xsdSimpleTypeDefinition.getPatternFacets().size() > 0) - { - usePatternsButton.setSelection(true); - useEnumerationsButton.setSelection(false); - constraintsWidget.setConstraintKind(SpecificConstraintsWidget.PATTERN); - constraintsWidget.addButton.setEnabled(false); - } - else - { - usePatternsButton.setSelection(false); - useEnumerationsButton.setSelection(true); - constraintsWidget.setConstraintKind(SpecificConstraintsWidget.ENUMERATION); - constraintsWidget.addButton.setEnabled(true); - } - constraintsWidget.setInput(xsdSimpleTypeDefinition); - - setListenerEnabled(true); - } - - protected void relayout() - { - Composite parent = composite.getParent(); - parent.getParent().setRedraw(false); - - if (parent != null && !parent.isDisposed()) - { - Control[] children = parent.getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].dispose(); - } - } - createContents(parent); - parent.getParent().layout(true, true); - parent.getParent().setRedraw(true); - refresh(); - } - - public void dispose() - { - if (titleFont != null && !titleFont.isDisposed()) - titleFont.dispose(); - titleFont = null; - - if (minimumInclusiveCheckbox != null && !minimumInclusiveCheckbox.isDisposed()) - minimumInclusiveCheckbox.removeSelectionListener(this); - if (maximumInclusiveCheckbox != null && !maximumInclusiveCheckbox.isDisposed()) - maximumInclusiveCheckbox.removeSelectionListener(this); - - if (collapseWhitespaceButton != null && !collapseWhitespaceButton.isDisposed()) - collapseWhitespaceButton.removeSelectionListener(this); - - if (maxLengthText != null && !maxLengthText.isDisposed()) - removeListeners(maxLengthText); - if (minLengthText != null && !minLengthText.isDisposed()) - removeListeners(minLengthText); - - super.dispose(); - } - - public void refreshStringLength() - { - XSDMinLengthFacet minLengthFacet = xsdSimpleTypeDefinition.getMinLengthFacet(); - XSDMaxLengthFacet maxLengthFacet = xsdSimpleTypeDefinition.getMaxLengthFacet(); - XSDLengthFacet lengthFacet = xsdSimpleTypeDefinition.getLengthFacet(); - - try - { - if (minLengthFacet != null) - { - int minLengthValue = minLengthFacet.getValue(); - if (minLengthValue >= 0 && minLengthFacet.getRootContainer() == xsdSchema) - { - minLengthText.setText(Integer.toString(minLengthValue)); - } - else - { - minLengthText.setText(""); //$NON-NLS-1$ - } - } - if (maxLengthFacet != null) - { - int maxLength = maxLengthFacet.getValue(); - if (maxLength >= 0 && maxLengthFacet.getRootContainer() == xsdSchema) - { - maxLengthText.setText(Integer.toString(maxLength)); - } - else - { - maxLengthText.setText(""); //$NON-NLS-1$ - } - } - if (lengthFacet != null) - { - int length = lengthFacet.getValue(); - if (length >= 0 && lengthFacet.getRootContainer() == xsdSchema) - { - minLengthText.setText(Integer.toString(length)); - maxLengthText.setText(Integer.toString(length)); - } - } - } - catch (Exception e) - { - - } - - } - - public void refreshValueLengths() - { - XSDSimpleTypeDefinition type = xsdSimpleTypeDefinition; - XSDMinFacet minFacet = type.getMinFacet(); - XSDMaxFacet maxFacet = type.getMaxFacet(); - - minimumInclusiveCheckbox.removeSelectionListener(this); - maximumInclusiveCheckbox.removeSelectionListener(this); - try - { - minimumInclusiveCheckbox.setSelection(false); - minimumInclusiveCheckbox.setEnabled(false); - if (minFacet != null && minFacet.getRootContainer() == xsdSchema) - { - if (minFacet.getElement().getLocalName().equals(XSDConstants.MINEXCLUSIVE_ELEMENT_TAG) || - minFacet.getElement().getLocalName().equals(XSDConstants.MININCLUSIVE_ELEMENT_TAG)) - { - minLengthText.setText(minFacet.getLexicalValue()); - minimumInclusiveCheckbox.setSelection(minFacet.isInclusive()); - minimumInclusiveCheckbox.setEnabled(true); - } - else - { - minLengthText.setText(""); //$NON-NLS-1$ - } - } - - maximumInclusiveCheckbox.setSelection(false); - maximumInclusiveCheckbox.setEnabled(false); - if (maxFacet != null && maxFacet.getRootContainer() == xsdSchema) - { - if (maxFacet.getElement().getLocalName().equals(XSDConstants.MAXEXCLUSIVE_ELEMENT_TAG) || - maxFacet.getElement().getLocalName().equals(XSDConstants.MAXINCLUSIVE_ELEMENT_TAG)) - { - maxLengthText.setText(maxFacet.getLexicalValue()); - maximumInclusiveCheckbox.setSelection(maxFacet.isInclusive()); - maximumInclusiveCheckbox.setEnabled(true); - } - else - { - maxLengthText.setText(""); //$NON-NLS-1$ - } - } - } - finally - { - minimumInclusiveCheckbox.addSelectionListener(this); - maximumInclusiveCheckbox.addSelectionListener(this); - } - } - - protected void doHandleEvent(Event event) - { - super.doHandleEvent(event); - Command command = null; - boolean doUpdateMax = false, doUpdateMin = false; - boolean doSetInput = false; - - String minValue = minLengthText.getText().trim(); - String maxValue = maxLengthText.getText().trim(); - - XSDLengthFacet lengthFacet = xsdSimpleTypeDefinition.getLengthFacet(); - XSDMinLengthFacet minLengthFacet = xsdSimpleTypeDefinition.getMinLengthFacet(); - XSDMaxLengthFacet maxLengthFacet = xsdSimpleTypeDefinition.getMaxLengthFacet(); - - XSDMinInclusiveFacet minInclusiveFacet = xsdSimpleTypeDefinition.getMinInclusiveFacet(); - XSDMinExclusiveFacet minExclusiveFacet = xsdSimpleTypeDefinition.getMinExclusiveFacet(); - XSDMaxInclusiveFacet maxInclusiveFacet = xsdSimpleTypeDefinition.getMaxInclusiveFacet(); - XSDMaxExclusiveFacet maxExclusiveFacet = xsdSimpleTypeDefinition.getMaxExclusiveFacet(); - - String currentMinInclusive = null, currentMinExclusive = null, currentMaxInclusive = null, currentMaxExclusive = null; - if (minInclusiveFacet != null) - { - currentMinInclusive = minInclusiveFacet.getLexicalValue(); - } - if (minExclusiveFacet != null) - { - currentMinExclusive = minExclusiveFacet.getLexicalValue(); - } - if (maxInclusiveFacet != null) - { - currentMaxInclusive = maxInclusiveFacet.getLexicalValue(); - } - if (maxExclusiveFacet != null) - { - currentMaxExclusive = maxExclusiveFacet.getLexicalValue(); - } - - - String currentLength = null, currentMin = null, currentMax = null; - if (lengthFacet != null) - { - currentLength = lengthFacet.getLexicalValue(); - } - if (minLengthFacet != null) - { - currentMin = minLengthFacet.getLexicalValue(); - } - if (maxLengthFacet != null) - { - currentMax = maxLengthFacet.getLexicalValue(); - } - - if (event.widget == minLengthText) - { - try - { - if (minValue.length() > 0) - { - if (!isNumericBaseType) - { - Number big = new BigInteger(minValue); - big.toString(); - if (minLengthFacet != null) - { - if (minValue.equals(currentMin) || minValue.equals(currentLength)) - return; - } - else - { - if (maxValue != null && minValue.equals(maxValue) && lengthFacet != null) - { - return; - } - } - } - else - { - if (xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("double").equals(xsdSimpleTypeDefinition) || //$NON-NLS-1$ - xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("float").equals(xsdSimpleTypeDefinition) || //$NON-NLS-1$ - xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("decimal").equals(xsdSimpleTypeDefinition)) //$NON-NLS-1$ - { - BigDecimal bigDecimal = new BigDecimal(minValue); - bigDecimal.toString(); - if ( (currentMinInclusive != null && minValue.equals(currentMinInclusive)) || - (currentMinExclusive != null && minValue.equals(currentMinExclusive)) ) - { - return; - } - } - else - { - Number big = new BigInteger(minValue); - big.toString(); - } - minimumInclusiveCheckbox.setEnabled(true); - } - } - else - { - if (!isNumericBaseType) - { - if (currentMin == null && currentLength == null) - return; - } - else - { - if (currentMinInclusive == null && minimumInclusiveCheckbox.getSelection()) - { - return; - } - else if (currentMinExclusive == null && !minimumInclusiveCheckbox.getSelection()) - { - return; - } - } - minimumInclusiveCheckbox.setEnabled(false); - minValue = null; - } - doUpdateMin = true; - } - catch (NumberFormatException e) - { - // TODO show error message - doUpdateMin = false; - } - } - if (event.widget == maxLengthText) - { - try - { - if (maxValue.length() > 0) - { - if (!isNumericBaseType) - { - Number big = new BigInteger(maxValue); - big.toString(); - if (maxLengthFacet != null) - { - if (maxValue.equals(currentMax) || maxValue.equals(currentLength)) - return; - } - else - { - if (minValue != null && maxValue.equals(minValue) && lengthFacet != null) - { - return; - } - } - } - else - { - if (xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("double").equals(xsdSimpleTypeDefinition) || //$NON-NLS-1$ - xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("float").equals(xsdSimpleTypeDefinition) || //$NON-NLS-1$ - xsdSchema.getSchemaForSchema().resolveSimpleTypeDefinition("decimal").equals(xsdSimpleTypeDefinition)) //$NON-NLS-1$ - { - BigDecimal bigDecimal = new BigDecimal(maxValue); - bigDecimal.toString(); - } - else - { - Number big = new BigInteger(maxValue); - big.toString(); - } - maximumInclusiveCheckbox.setEnabled(true); - } - } - else - { - if (!isNumericBaseType) - { - if (currentMax == null && currentLength == null) - return; - } - else - { - if (currentMaxInclusive == null && maximumInclusiveCheckbox.getSelection()) - { - return; - } - else if (currentMaxExclusive == null && !maximumInclusiveCheckbox.getSelection()) - { - return; - } - maximumInclusiveCheckbox.setEnabled(false); - } - maxValue = null; - } - - doUpdateMax = true; - } - catch (NumberFormatException e) - { - doUpdateMax = false; - // TODO show error message - } - } - - if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(xsdSimpleTypeDefinition.getTargetNamespace()) && (doUpdateMax || doUpdateMin)) - { - XSDSimpleTypeDefinition anonymousSimpleType = null; - CompoundCommand compoundCommand = new CompoundCommand(); - ChangeToLocalSimpleTypeCommand changeToAnonymousCommand = null; - if (input instanceof XSDFeature) - { - anonymousSimpleType = XSDCommonUIUtils.getAnonymousSimpleType((XSDFeature)input, xsdSimpleTypeDefinition); - if (anonymousSimpleType == null) - { - anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - anonymousSimpleType.setBaseTypeDefinition(xsdSimpleTypeDefinition); - - changeToAnonymousCommand = new ChangeToLocalSimpleTypeCommand(Messages._UI_ACTION_CONSTRAIN_LENGTH, (XSDFeature)input); - changeToAnonymousCommand.setAnonymousSimpleType(anonymousSimpleType); - compoundCommand.add(changeToAnonymousCommand); - doSetInput = true; - } - - if (!isNumericBaseType) - { - UpdateStringLengthFacetCommand updateCommand = new UpdateStringLengthFacetCommand("", anonymousSimpleType); //$NON-NLS-1$ - if (doUpdateMax) - { - updateCommand.setMax(maxValue); - } - if (doUpdateMin) - { - updateCommand.setMin(minValue); - } - compoundCommand.add(updateCommand); - } - else - { - UpdateNumericBoundsFacetCommand updateCommand = new UpdateNumericBoundsFacetCommand(Messages._UI_ACTION_UPDATE_BOUNDS, anonymousSimpleType, minimumInclusiveCheckbox.getSelection(), maximumInclusiveCheckbox.getSelection()); - if (doUpdateMax) - { - updateCommand.setMax(maxValue); - } - if (doUpdateMin) - { - updateCommand.setMin(minValue); - } - compoundCommand.add(updateCommand); - } - command = compoundCommand; - getCommandStack().execute(command); - } - else if (input instanceof XSDSimpleTypeDefinition) - { - if (!isNumericBaseType) - { - UpdateStringLengthFacetCommand updateCommand = new UpdateStringLengthFacetCommand("", xsdSimpleTypeDefinition); //$NON-NLS-1$ - if (doUpdateMax) - { - updateCommand.setMax(maxValue); - } - if (doUpdateMin) - { - updateCommand.setMin(minValue); - } - command = updateCommand; - } - else - { - UpdateNumericBoundsFacetCommand updateCommand = new UpdateNumericBoundsFacetCommand(Messages._UI_ACTION_UPDATE_BOUNDS, xsdSimpleTypeDefinition, minimumInclusiveCheckbox.getSelection(), maximumInclusiveCheckbox.getSelection()); - if (doUpdateMax) - { - updateCommand.setMax(maxValue); - } - if (doUpdateMin) - { - updateCommand.setMin(minValue); - } - command = updateCommand; - } - getCommandStack().execute(command); - } - } - else - { - if (!isNumericBaseType) - { - UpdateStringLengthFacetCommand updateCommand = new UpdateStringLengthFacetCommand("", xsdSimpleTypeDefinition); //$NON-NLS-1$ - if (doUpdateMax) - { - updateCommand.setMax(maxValue); - } - if (doUpdateMin) - { - updateCommand.setMin(minValue); - } - getCommandStack().execute(updateCommand); - } - else - { - UpdateNumericBoundsFacetCommand updateCommand = new UpdateNumericBoundsFacetCommand(Messages._UI_ACTION_UPDATE_BOUNDS, xsdSimpleTypeDefinition, minimumInclusiveCheckbox.getSelection(), maximumInclusiveCheckbox.getSelection()); - if (doUpdateMax) - { - updateCommand.setMax(maxValue); - } - if (doUpdateMin) - { - updateCommand.setMin(minValue); - } - getCommandStack().execute(updateCommand); - } - - } - if (doSetInput) - setInput(getPart(), getSelection()); - } - - public void widgetSelected(SelectionEvent e) - { - if (e.widget == collapseWhitespaceButton) - { - CompoundCommand compoundCommand = new CompoundCommand(); - XSDSimpleTypeDefinition anonymousSimpleType = null; - if (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(xsdSimpleTypeDefinition.getTargetNamespace())) - { - if (input instanceof XSDFeature) - { - anonymousSimpleType = XSDCommonUIUtils.getAnonymousSimpleType((XSDFeature)input, xsdSimpleTypeDefinition); - if (anonymousSimpleType == null) - { - anonymousSimpleType = XSDFactory.eINSTANCE.createXSDSimpleTypeDefinition(); - anonymousSimpleType.setBaseTypeDefinition(xsdSimpleTypeDefinition); - - ChangeToLocalSimpleTypeCommand changeToAnonymousCommand = new ChangeToLocalSimpleTypeCommand(Messages._UI_ACTION_CONSTRAIN_LENGTH, (XSDFeature)input); - changeToAnonymousCommand.setAnonymousSimpleType(anonymousSimpleType); - compoundCommand.add(changeToAnonymousCommand); - } - - UpdateXSDWhiteSpaceFacetCommand whiteSpaceCommand = new UpdateXSDWhiteSpaceFacetCommand(Messages._UI_ACTION_COLLAPSE_WHITESPACE, anonymousSimpleType, collapseWhitespaceButton.getSelection()); - compoundCommand.add(whiteSpaceCommand); - - getCommandStack().execute(compoundCommand); - } - setInput(getPart(), getSelection()); - } - else - { - UpdateXSDWhiteSpaceFacetCommand whiteSpaceCommand = new UpdateXSDWhiteSpaceFacetCommand(Messages._UI_ACTION_COLLAPSE_WHITESPACE, xsdSimpleTypeDefinition, collapseWhitespaceButton.getSelection()); - getCommandStack().execute(whiteSpaceCommand); - } - } - else if (e.widget == minimumInclusiveCheckbox) - { - String minValue = minLengthText.getText().trim(); - if (minValue.length() == 0) minValue = null; - - UpdateNumericBoundsFacetCommand updateCommand = new UpdateNumericBoundsFacetCommand(Messages._UI_ACTION_UPDATE_BOUNDS, xsdSimpleTypeDefinition, minimumInclusiveCheckbox.getSelection(), maximumInclusiveCheckbox.getSelection()); - updateCommand.setMin(minValue); - - if (minValue != null) - getCommandStack().execute(updateCommand); - } - else if (e.widget == maximumInclusiveCheckbox) - { - String maxValue = maxLengthText.getText().trim(); - if (maxValue.length() == 0) maxValue = null; - UpdateNumericBoundsFacetCommand updateCommand = new UpdateNumericBoundsFacetCommand(Messages._UI_ACTION_UPDATE_BOUNDS, xsdSimpleTypeDefinition, minimumInclusiveCheckbox.getSelection(), maximumInclusiveCheckbox.getSelection()); - updateCommand.setMax(maxValue); - if (maxValue != null) - getCommandStack().execute(updateCommand); - } - else if (e.widget == useEnumerationsButton) - { - constraintsWidget.addButton.setEnabled(true); - if (isListenerEnabled()) - constraintsWidget.setConstraintKind(SpecificConstraintsWidget.ENUMERATION); - } - else if (e.widget == usePatternsButton) - { - constraintsWidget.addButton.setEnabled(false); - if (isListenerEnabled()) - constraintsWidget.setConstraintKind(SpecificConstraintsWidget.PATTERN); - } - } - - public boolean shouldUseExtraSpace() - { - return true; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSectionFilter.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSectionFilter.java deleted file mode 100644 index bdc57c5a8d..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDFacetSectionFilter.java +++ /dev/null @@ -1,42 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.jface.viewers.IFilter; -import org.eclipse.xsd.XSDFeature; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; - -public class XSDFacetSectionFilter implements IFilter -{ - public boolean select(Object toTest) - { - if (toTest instanceof XSDFeature) - { - XSDTypeDefinition type = ((XSDFeature)toTest).getResolvedFeature().getType(); - if (type instanceof XSDSimpleTypeDefinition) - { - return true; - } - } - else if (toTest instanceof XSDSimpleTypeDefinition) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition)toTest; - if (st.eContainer() instanceof XSDSchema || - st.eContainer() instanceof XSDFeature) - { - return true; - } - } - return false; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java deleted file mode 100644 index 1c7df7ec9a..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDImportSection.java +++ /dev/null @@ -1,376 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.Map; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.core.resources.IFile; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.jface.wizard.WizardDialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Display; -import org.eclipse.swt.widgets.Event; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IFileEditorInput; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.ui.internal.viewers.ResourceFilter; -import org.eclipse.wst.common.uriresolver.internal.util.URIHelper; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.wst.xsd.ui.internal.wizards.XSDSelectIncludeFileWizard; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDImportSection extends SchemaLocationSection -{ - protected Text namespaceText, prefixText; - protected String oldPrefixValue; - - public XSDImportSection() - { - super(); - } - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - GridData data = new GridData(); - - // Create Schema Location Label - CLabel namespaceLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_NAMESPACE")); //$NON-NLS-1$ - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - namespaceLabel.setLayoutData(data); - - namespaceText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$ - namespaceText.setEditable(false); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - applyAllListeners(namespaceText); - namespaceText.setLayoutData(data); - - // ------------------------------------------------------------------ - // DummyLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - - CLabel prefixLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_PREFIX")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - prefixLabel.setLayoutData(data); - - prefixText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$ - prefixText.setEditable(true); - applyAllListeners(prefixText); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - prefixText.setLayoutData(data); - - // ------------------------------------------------------------------ - // DummyLabel - // ------------------------------------------------------------------ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - - // Create Schema Location Label - CLabel schemaLocationLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_LOCATION")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - schemaLocationLabel.setLayoutData(data); - - // Create Schema Location Text - schemaLocationText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$ - schemaLocationText.setEditable(true); - applyAllListeners(schemaLocationText); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - schemaLocationText.setLayoutData(data); - - // Create Wizard Button - wizardButton = getWidgetFactory().createButton(composite, "", SWT.NONE); //$NON-NLS-1$ - wizardButton.setImage(XSDEditorPlugin.getXSDImage("icons/browsebutton.gif")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - wizardButton.setLayoutData(data); - wizardButton.addSelectionListener(this); - - // error text - errorText = new StyledText(composite, SWT.FLAT); - errorText.setEditable(false); - errorText.setEnabled(false); - errorText.setText(""); //$NON-NLS-1$ - - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 3; - data.grabExcessHorizontalSpace = true; - errorText.setLayoutData(data); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(schemaLocationText, - XSDEditorCSHelpIds.GENERAL_TAB__IMPORT__SCHEMALOCATION); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(namespaceText, - XSDEditorCSHelpIds.GENERAL_TAB__IMPORT__NAMESPACE); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(prefixText, - XSDEditorCSHelpIds.GENERAL_TAB__IMPORT__PREFIX); - - } - - public void refresh() - { - setListenerEnabled(false); - - errorText.setText(""); - Element element = null; - if (input instanceof XSDImport) - { - element = ((XSDImport) input).getElement(); - - String namespace = element.getAttribute("namespace"); //$NON-NLS-1$ - String schemaLocation = element.getAttribute("schemaLocation"); //$NON-NLS-1$ - - TypesHelper helper = new TypesHelper(xsdSchema); - String prefix = helper.getPrefix(element.getAttribute(XSDConstants.NAMESPACE_ATTRIBUTE), false); - - if (namespace == null) - { - namespace = ""; //$NON-NLS-1$ - } - - if (prefix == null) - { - prefix = ""; //$NON-NLS-1$ - } - - if (schemaLocation == null) - { - schemaLocation = ""; //$NON-NLS-1$ - } - - namespaceText.setText(namespace); - prefixText.setText(prefix); - schemaLocationText.setText(schemaLocation); - oldPrefixValue = prefixText.getText(); - } - - setListenerEnabled(true); - } - - public void widgetSelected(SelectionEvent event) - { - if (event.widget == wizardButton) - { - setListenerEnabled(false); - Shell shell = Display.getCurrent().getActiveShell(); - - IFile currentIFile = ((IFileEditorInput) getActiveEditor().getEditorInput()).getFile(); - ViewerFilter filter = new ResourceFilter(new String[] { ".xsd" }, //$NON-NLS-1$ - new IFile[] { currentIFile }, null); - - XSDSelectIncludeFileWizard fileSelectWizard = new XSDSelectIncludeFileWizard(xsdSchema, false, XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_SCHEMA"), //$NON-NLS-1$ - XSDEditorPlugin.getXSDString("_UI_FILEDIALOG_SELECT_XML_DESC"), //$NON-NLS-1$ - filter, (IStructuredSelection) getSelection()); - - WizardDialog wizardDialog = new WizardDialog(shell, fileSelectWizard); - wizardDialog.create(); - wizardDialog.setBlockOnOpen(true); - int result = wizardDialog.open(); - - String value = schemaLocationText.getText(); - prefixText.removeListener(SWT.Modify, this); - if (result == Window.OK) - { - errorText.setText(""); - IFile selectedIFile = fileSelectWizard.getResultFile(); - String schemaFileString = value; - if (selectedIFile != null) - { - schemaFileString = URIHelper.getRelativeURI(selectedIFile.getLocation(), currentIFile.getLocation()); - } - else - { - schemaFileString = fileSelectWizard.getURL(); - } - - String namespace = fileSelectWizard.getNamespace(); - if (namespace == null) - namespace = ""; - - XSDSchema externalSchema = fileSelectWizard.getExternalSchema(); - handleSchemaLocationChange(schemaFileString, namespace, externalSchema); - } - setListenerEnabled(true); - prefixText.addListener(SWT.Modify, this); - } - } - - protected void handleSchemaLocationChange(String schemaFileString, String namespace, XSDSchema externalSchema) - { - if (input instanceof XSDImport) - { - XSDImport xsdImport = (XSDImport) input; - - xsdImport.setNamespace(namespace); - xsdImport.setSchemaLocation(schemaFileString); - xsdImport.setResolvedSchema(externalSchema); - - java.util.Map map = xsdSchema.getQNamePrefixToNamespaceMap(); - - // Referential integrity on old import - // How can we be sure that if the newlocation is the same as the - // oldlocation - // the file hasn't changed - -// XSDSchema referencedSchema = xsdImport.getResolvedSchema(); -// if (referencedSchema != null) -// { -// XSDExternalFileCleanup cleanHelper = new -// XSDExternalFileCleanup(referencedSchema); -// cleanHelper.visitSchema(xsdSchema); -// } - - Element schemaElement = xsdSchema.getElement(); - - // update the xmlns in the schema element first, and then update the - // import element next - // so that the last change will be in the import element. This keeps the - // selection - // on the import element - TypesHelper helper = new TypesHelper(externalSchema); - String prefix = helper.getPrefix(namespace, false); - - if (map.containsKey(prefix)) - { - prefix = null; - } - - if (prefix == null || (prefix != null && prefix.length() == 0)) - { - StringBuffer newPrefix = new StringBuffer("pref"); //$NON-NLS-1$ - int prefixExtension = 1; - while (map.containsKey(newPrefix.toString()) && prefixExtension < 100) - { - newPrefix = new StringBuffer("pref" + String.valueOf(prefixExtension)); - prefixExtension++; - } - prefix = newPrefix.toString(); - } - - if (namespace.length() > 0) - { - // if ns already in map, use its corresponding prefix - if (map.containsValue(namespace)) - { - TypesHelper typesHelper = new TypesHelper(xsdSchema); - prefix = typesHelper.getPrefix(namespace, false); - } - else - // otherwise add to the map - { - schemaElement.setAttribute("xmlns:" + prefix, namespace); - } - prefixText.setText(prefix); - } - else - { - prefixText.setText(""); - namespaceText.setText(""); - } - } - refresh(); - } - - public void doHandleEvent(Event event) - { - setErrorMessage(null); - super.doHandleEvent(event); - if (event.widget == prefixText) - { - String newPrefix = prefixText.getText(); - if (oldPrefixValue.equals(newPrefix) || !isValidSchemaLocation) - return; - Map map = xsdSchema.getQNamePrefixToNamespaceMap(); - String key = prefixText.getText(); - if (key.length() == 0) key = null; - - if (validatePrefix(newPrefix) && schemaLocationText.getText().trim().length() > 0) - { - if (map.containsKey(key)) - { - setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_LABEL_PREFIX_EXISTS")); - } - else - { - Element schemaElement = xsdSchema.getElement(); - - if (key != null) { - if (oldPrefixValue.length() == 0) - schemaElement.removeAttribute("xmlns"); - else - schemaElement.removeAttribute("xmlns:"+oldPrefixValue); - - schemaElement.setAttribute("xmlns:" + newPrefix, namespaceText.getText()); - } - else { - schemaElement.removeAttribute("xmlns:"+oldPrefixValue); - schemaElement.setAttribute("xmlns", namespaceText.getText()); - } - xsdSchema.updateElement(); - setErrorMessage(null); - oldPrefixValue = newPrefix; - } - } - else - { - setErrorMessage(XSDEditorPlugin.getXSDString("_ERROR_LABEL_INVALID_PREFIX")); - } - } - } - - public void aboutToBeHidden() - { - setErrorMessage(null); - super.aboutToBeHidden(); - } - - protected boolean validatePrefix(String prefix) - { - if (prefix.length() == 0) return true; - return XMLChar.isValidNCName(prefix); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java deleted file mode 100644 index 4e2a0557d6..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupDefinitionSection.java +++ /dev/null @@ -1,334 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.ArrayList; -import java.util.List; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -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.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDModelGroupDefinitionSection extends MultiplicitySection -{ - protected Text nameText; - protected CCombo componentNameCombo; - boolean isReference; - - public XSDModelGroupDefinitionSection() - { - super(); - } - - protected void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - if (isReference) - { - // ------------------------------------------------------------------ - // Ref Label - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel refLabel = getWidgetFactory().createCLabel(composite, XSDConstants.REF_ATTRIBUTE + ":"); //$NON-NLS-1$ - refLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // Ref Combo - // ------------------------------------------------------------------ - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 2; - - componentNameCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - componentNameCombo.addSelectionListener(this); - componentNameCombo.setLayoutData(data); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(componentNameCombo, - XSDEditorCSHelpIds.GENERAL_TAB__MODELGROUP_REFS__REF); - - // ------------------------------------------------------------------ - // min property - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, - org.eclipse.wst.xsd.ui.internal.editor.Messages.UI_LABEL_MINOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 2; - - minCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - minCombo.setLayoutData(data); - minCombo.add("0"); //$NON-NLS-1$ - minCombo.add("1"); //$NON-NLS-1$ - applyAllListeners(minCombo); - minCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(minCombo, - XSDEditorCSHelpIds.GENERAL_TAB__MODELGROUP__MIN_OCCURENCE); - - // ------------------------------------------------------------------ - // max property - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, - org.eclipse.wst.xsd.ui.internal.editor.Messages.UI_LABEL_MAXOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 2; - - maxCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - maxCombo.setLayoutData(data); - maxCombo.add("0"); //$NON-NLS-1$ - maxCombo.add("1"); //$NON-NLS-1$ - maxCombo.add("unbounded"); //$NON-NLS-1$ - applyAllListeners(maxCombo); - maxCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(maxCombo, - XSDEditorCSHelpIds.GENERAL_TAB__MODELGROUP__MAX_OCCURENCE); - - } - else - { - // ------------------------------------------------------------------ - // NameLabel - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel nameLabel = getWidgetFactory().createCLabel(composite, Messages._UI_LABEL_NAME); - nameLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // NameText - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - nameText.setLayoutData(data); - applyAllListeners(nameText); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(nameText, - XSDEditorCSHelpIds.GENERAL_TAB__MODELGROUP_DEFINITION__NAME); - - // ------------------------------------------------------------------ - // Refactor/rename hyperlink - // ------------------------------------------------------------------ - createRenameHyperlink(composite); - } - } - - public void refresh() - { - super.refresh(); - - if (isReadOnly) - { - composite.setEnabled(false); - } - else - { - composite.setEnabled(true); - } - - setListenerEnabled(false); - - XSDNamedComponent namedComponent = (XSDNamedComponent) input; - - if (isReference) - { - Element element = namedComponent.getElement(); - if (element != null) - { - String attrValue = element.getAttribute(XSDConstants.REF_ATTRIBUTE); - if (attrValue == null) - { - attrValue = ""; //$NON-NLS-1$ - } - componentNameCombo.setText(attrValue); - - // refresh min max - if (minCombo != null && maxCombo != null) - { - refreshMinMax(); - } - } - } - else - { - // refresh name - nameText.setText(""); //$NON-NLS-1$ - - String name = namedComponent.getName(); - if (name != null) - { - nameText.setText(name); - } - } - - setListenerEnabled(true); - } - - public void setInput(IWorkbenchPart part, ISelection selection) - { - super.setInput(part, selection); - init(); - relayout(); - - if (isReference) - { - TypesHelper helper = new TypesHelper(xsdSchema); - List items = new ArrayList(); - items = helper.getModelGroups(); - items.add(0, ""); //$NON-NLS-1$ - componentNameCombo.setItems((String [])items.toArray(new String[0])); - } - } - - protected void init() - { - if (input instanceof XSDModelGroupDefinition) - { - XSDModelGroupDefinition group = (XSDModelGroupDefinition) input; - isReference = group.isModelGroupDefinitionReference(); - } - } - - protected void relayout() - { - Composite parentComposite = composite.getParent(); - parentComposite.getParent().setRedraw(false); - - if (parentComposite != null && !parentComposite.isDisposed()) - { - Control[] children = parentComposite.getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].dispose(); - } - } - - // Now initialize the new handler - createContents(parentComposite); - parentComposite.getParent().layout(true, true); - - // Now turn painting back on - parentComposite.getParent().setRedraw(true); - refresh(); - } - - public void doHandleEvent(Event event) - { - super.doHandleEvent(event); - if (event.widget == nameText) - { - String newValue = nameText.getText().trim(); - if (input instanceof XSDNamedComponent) - { - XSDNamedComponent namedComponent = (XSDNamedComponent) input; - if (!validateSection()) - return; - - Command command = null; - - // Make sure an actual name change has taken place - String oldName = namedComponent.getName(); - if (!newValue.equals(oldName)) - { - command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue); - } - - if (command != null && getCommandStack() != null) - { - getCommandStack().execute(command); - } - // doReferentialIntegrityCheck(namedComponent, newValue); - } - } - } - - protected boolean validateSection() - { - if (nameText == null || nameText.isDisposed()) - return true; - - setErrorMessage(null); - - String name = nameText.getText().trim(); - - // validate against NCName - if (name.length() < 1 || !XMLChar.isValidNCName(name)) - { - setErrorMessage(Messages._UI_ERROR_INVALID_NAME); - return false; - } - - return true; - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == componentNameCombo) - { - String newValue = componentNameCombo.getText(); - if (input instanceof XSDNamedComponent) - { - XSDNamedComponent namedComponent = (XSDNamedComponent)input; - Element element = namedComponent.getElement(); - - if (namedComponent instanceof XSDModelGroupDefinition) - { - element.setAttribute(XSDConstants.REF_ATTRIBUTE, newValue); - } - } - } - super.doWidgetSelected(e); - } - - public void dispose() - { - if (nameText != null && !nameText.isDisposed()) - removeListeners(nameText); - super.dispose(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupSection.java deleted file mode 100644 index c695f7cd5f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDModelGroupSection.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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateContentModelCommand; -import org.eclipse.wst.xsd.ui.internal.editor.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.xsd.XSDCompositor; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; - -public class XSDModelGroupSection extends MultiplicitySection -{ - protected CCombo modelGroupCombo; - private String[] modelGroupComboValues = { "sequence", "choice", "all" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ - - public XSDModelGroupSection() - { - super(); - } - - public void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 2; - composite.setLayout(gridLayout); - - // ------------------------------------------------------------------ - // NameLabel - // ------------------------------------------------------------------ - GridData data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel nameLabel = getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_KIND); - nameLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // NameText - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - modelGroupCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - modelGroupCombo.setLayoutData(data); - modelGroupCombo.addSelectionListener(this); - modelGroupCombo.setItems(modelGroupComboValues); - PlatformUI.getWorkbench().getHelpSystem().setHelp(modelGroupCombo, - XSDEditorCSHelpIds.GENERAL_TAB__MODELGROUP__KIND); - - - // ------------------------------------------------------------------ - // min property - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_MINOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - minCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - minCombo.setLayoutData(data); - minCombo.add("0"); //$NON-NLS-1$ - minCombo.add("1"); //$NON-NLS-1$ - applyAllListeners(minCombo); - minCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(minCombo, - XSDEditorCSHelpIds.GENERAL_TAB__MODELGROUP__MIN_OCCURENCE); - - // ------------------------------------------------------------------ - // max property - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, Messages.UI_LABEL_MAXOCCURS); - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - maxCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - maxCombo.setLayoutData(data); - maxCombo.add("0"); //$NON-NLS-1$ - maxCombo.add("1"); //$NON-NLS-1$ - maxCombo.add("unbounded"); //$NON-NLS-1$ - applyAllListeners(maxCombo); - maxCombo.addSelectionListener(this); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(maxCombo, - XSDEditorCSHelpIds.GENERAL_TAB__MODELGROUP__MAX_OCCURENCE); - } - - - public void refresh() - { - super.refresh(); - - if (isReadOnly) - { - composite.setEnabled(false); - } - else - { - composite.setEnabled(true); - } - - setListenerEnabled(false); - - if (input != null) - { - if (input instanceof XSDModelGroup) - { - XSDModelGroup particle = (XSDModelGroup)input; - String modelType = particle.getCompositor().getName(); - modelGroupCombo.setText(modelType); - - minCombo.setEnabled(!(particle.eContainer() instanceof XSDModelGroupDefinition)); - maxCombo.setEnabled(!(particle.eContainer() instanceof XSDModelGroupDefinition)); - } - } - - refreshMinMax(); - - setListenerEnabled(true); - } - - public void doWidgetSelected(SelectionEvent e) - { - XSDModelGroup particle = (XSDModelGroup)input; - if (e.widget == modelGroupCombo) - { - XSDCompositor newValue = XSDCompositor.get(modelGroupCombo.getText()); - UpdateContentModelCommand command = new UpdateContentModelCommand(org.eclipse.wst.xsd.ui.internal.common.util.Messages._UI_ACTION_CHANGE_CONTENT_MODEL, particle, newValue); - getCommandStack().execute(command); - } - super.doWidgetSelected(e); - } - - public void dispose() - { - if (minCombo != null && !minCombo.isDisposed()) - minCombo.removeSelectionListener(this); - if (maxCombo != null && !maxCombo.isDisposed()) - maxCombo.removeSelectionListener(this); - super.dispose(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java deleted file mode 100644 index 649b7f6741..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSchemaSection.java +++ /dev/null @@ -1,314 +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 - * David Schneider, david.schneider@unisys.com - [142500] WTP properties pages fonts don't follow Eclipse preferences - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.Iterator; -import java.util.List; - -import org.eclipse.jface.dialogs.Dialog; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.custom.StyleRange; -import org.eclipse.swt.custom.StyledText; -import org.eclipse.swt.events.SelectionEvent; -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.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -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.core.internal.document.DocumentImpl; -import org.eclipse.wst.xsd.ui.internal.actions.XSDEditNamespacesAction; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNamespaceInformationCommand; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.nsedit.TargetNamespaceChangeHandler; -import org.eclipse.wst.xsd.ui.internal.util.TypesHelper; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; - -public class XSDSchemaSection extends AbstractSection -{ - IWorkbenchPart part; - Text prefixText; - Text targetNamespaceText; - Button editButton; - StyledText errorText; - Color red; - - /** - * - */ - public XSDSchemaSection() - { - super(); - } - - /** - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ITabbedPropertySection#createControls(org.eclipse.swt.widgets.Composite, - * org.eclipse.wst.common.ui.properties.internal.provisional.TabbedPropertySheetWidgetFactory) - */ - public void createContents(Composite parent) - { - composite = getWidgetFactory().createFlatFormComposite(parent); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 2; - composite.setLayout(gridLayout); - - GridData data = new GridData(); - - // Create Prefix Label - CLabel prefixLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_SCHEMA_PREFIX")); //$NON-NLS-1$ - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - prefixLabel.setLayoutData(data); - - // Create Prefix Text - prefixText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - prefixText.setLayoutData(data); - applyAllListeners(prefixText); - PlatformUI.getWorkbench().getHelpSystem().setHelp(prefixText, - XSDEditorCSHelpIds.GENERAL_TAB__SCHEMA__PREFIX); - - // Create TargetNamespace Label - CLabel targetNamespaceLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_TARGET_NAME_SPACE")); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - targetNamespaceLabel.setLayoutData(data); - - // Create TargetNamespace Text - targetNamespaceText = getWidgetFactory().createText(composite, "", SWT.NONE); //$NON-NLS-1$ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - targetNamespaceText.setLayoutData(data); - applyAllListeners(targetNamespaceText); - PlatformUI.getWorkbench().getHelpSystem().setHelp(targetNamespaceText, - XSDEditorCSHelpIds.GENERAL_TAB__SCHEMA__TARGETNAMESPACE); - - // Advanced Button - editButton = getWidgetFactory().createButton(composite, XSDEditorPlugin.getXSDString("_UI_SECTION_ADVANCED_ATTRIBUTES") + "...", SWT.PUSH); //$NON-NLS-1$ //$NON-NLS-2$ - data = new GridData(SWT.END, SWT.CENTER, true, false); - data.horizontalSpan = 2; - editButton.setLayoutData(data); - editButton.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(editButton, - XSDEditorCSHelpIds.GENERAL_TAB__SCHEMA__ADVANCED); - - // error text - errorText = new StyledText(composite, SWT.FLAT); - errorText.setEditable(false); - errorText.setEnabled(false); - errorText.setText(""); //$NON-NLS-1$ - data = new GridData(); - data.horizontalAlignment = GridData.FILL; - data.horizontalSpan = 2; - data.grabExcessHorizontalSpace = true; - errorText.setLayoutData(data); - Dialog.applyDialogFont(parent); - } - - /* - * @see org.eclipse.wst.common.ui.properties.internal.provisional.view.ITabbedPropertySection#refresh() - */ - public void refresh() - { - setListenerEnabled(false); - - Element element = xsdSchema.getElement(); - - if (element != null) - { - // Handle prefixText - TypesHelper helper = new TypesHelper(xsdSchema); - String aPrefix = helper.getPrefix(element.getAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE), false); - - if (aPrefix != null && aPrefix.length() > 0) - { - prefixText.setText(aPrefix); - } - else - { - prefixText.setText(""); //$NON-NLS-1$ - } - - // Handle TargetNamespaceText - String tns = element.getAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE); - if (tns != null && tns.length() > 0) - { - targetNamespaceText.setText(tns); - } - else - { - targetNamespaceText.setText(""); //$NON-NLS-1$ - } - errorText.setText(""); //$NON-NLS-1$ - } - setListenerEnabled(true); - } - - public void doHandleEvent(Event event) - { - errorText.setText(""); //$NON-NLS-1$ - String prefixValue = prefixText.getText(); - String tnsValue = targetNamespaceText.getText(); - - Element element = xsdSchema.getElement(); - TypesHelper helper = new TypesHelper(xsdSchema); - String currentPrefix = helper.getPrefix(element.getAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE), false); - String currentNamespace = xsdSchema.getTargetNamespace(); - - if (tnsValue.trim().length() == 0) - { - if (prefixValue.trim().length() > 0) - { - errorText.setText(XSDEditorPlugin.getXSDString("_ERROR_TARGET_NAMESPACE_AND_PREFIX")); //$NON-NLS-1$ - int length = errorText.getText().length(); - red = new Color(null, 255, 0, 0); - StyleRange style = new StyleRange(0, length, red, targetNamespaceText.getBackground()); - errorText.setStyleRange(style); - return; - } - } - - if (event.widget == prefixText) - { - // If the prefix is the same, just return. This may happen if the - // widget loses focus. - if (prefixValue.equals(currentPrefix)) - return; - updateNamespaceInfo(prefixValue, tnsValue); - } - else if (event.widget == targetNamespaceText) - { - // If the ns is the same, just return. This may happen if the - // widget loses focus. - if (tnsValue.equals(currentNamespace)) - return; - - DOMNamespaceInfoManager namespaceInfoManager = new DOMNamespaceInfoManager(); - List namespaceInfoList = namespaceInfoManager.getNamespaceInfoList(xsdSchema.getElement()); - - Element xsdSchemaElement = xsdSchema.getElement(); - DocumentImpl doc = (DocumentImpl) xsdSchemaElement.getOwnerDocument(); - - try - { - doc.getModel().beginRecording(this, XSDEditorPlugin.getXSDString("_UI_NAMESPACE_CHANGE")); - - if (tnsValue.trim().length() == 0 ) //remove the targetNamespace attribute - { - xsdSchemaElement.removeAttribute(XSDConstants.TARGETNAMESPACE_ATTRIBUTE); - return; - } - - // Now replace the namespace for the xmlns entry - for (Iterator i = namespaceInfoList.iterator(); i.hasNext();) - { - NamespaceInfo info = (NamespaceInfo) i.next(); - if (info.uri.equals(currentNamespace)) - { - info.uri = tnsValue; - } - } - - xsdSchema.setIncrementalUpdate(false); - // set the new xmlns entries - namespaceInfoManager.removeNamespaceInfo(element); - namespaceInfoManager.addNamespaceInfo(element, namespaceInfoList, false); - xsdSchema.setIncrementalUpdate(true); - - // set the targetNamespace attribute - xsdSchema.setTargetNamespace(tnsValue); - - TargetNamespaceChangeHandler targetNamespaceChangeHandler = new TargetNamespaceChangeHandler(xsdSchema, currentNamespace, tnsValue); - targetNamespaceChangeHandler.resolve(); - } - catch (Exception e) - { - - } - finally - { - try - { - xsdSchema.update(); - } - finally - { - doc.getModel().endRecording(this); - } - } - } - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == editButton) - { - XSDEditNamespacesAction nsAction = new XSDEditNamespacesAction(XSDEditorPlugin.getXSDString("_UI_ACTION_EDIT_NAMESPACES"), xsdSchema.getElement(), null, xsdSchema); //$NON-NLS-1$ - nsAction.run(); - refresh(); - } - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.wst.common.ui.properties.internal.provisional.ISection#shouldUseExtraSpace() - */ - public boolean shouldUseExtraSpace() - { - return true; - } - - private void updateNamespaceInfo(String newPrefix, String newTargetNamespace) - { - UpdateNamespaceInformationCommand command = new UpdateNamespaceInformationCommand("", xsdSchema, newPrefix, newTargetNamespace); - command.execute(); - } - - public void dispose() - { - if (prefixText != null && !prefixText.isDisposed()) - removeListeners(prefixText); - if (targetNamespaceText != null && !targetNamespaceText.isDisposed()) - removeListeners(targetNamespaceText); - - if (red != null) - { - red.dispose(); - red = null; - } - super.dispose(); - } - - /** - * @deprecated - */ - protected boolean validatePrefix(String prefix) - { - return true; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java deleted file mode 100644 index b17c3fdbd7..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDSimpleTypeSection.java +++ /dev/null @@ -1,752 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.apache.xerces.util.XMLChar; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.custom.CLabel; -import org.eclipse.swt.events.SelectionEvent; -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.Event; -import org.eclipse.swt.widgets.Text; -import org.eclipse.ui.IEditorPart; -import org.eclipse.ui.IWorkbenchPart; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.common.ui.internal.search.dialogs.ComponentSpecification; -import org.eclipse.wst.xsd.ui.internal.actions.CreateElementAction; -import org.eclipse.wst.xsd.ui.internal.actions.DOMAttribute; -import org.eclipse.wst.xsd.ui.internal.adt.edit.ComponentReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.adt.edit.IComponentDialog; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateNameCommand; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.dialogs.NewTypeDialog; -import org.eclipse.wst.xsd.ui.internal.editor.XSDComplexTypeBaseTypeEditManager; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.wst.xsd.ui.internal.editor.XSDTypeReferenceEditManager; -import org.eclipse.wst.xsd.ui.internal.editor.search.XSDSearchListDialogDelegate; -import org.eclipse.wst.xsd.ui.internal.util.XSDDOMHelper; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDVariety; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.ibm.icu.util.StringTokenizer; - -public class XSDSimpleTypeSection extends RefactoringSection -{ - protected Text nameText; - CCombo varietyCombo; - CCombo typesCombo; - CLabel typesLabel; - - XSDSimpleTypeDefinition memberTypeDefinition, itemTypeDefinition, baseTypeDefinition; - - public XSDSimpleTypeSection() - { - super(); - } - - protected void createContents(Composite parent) - { - TabbedPropertySheetWidgetFactory factory = getWidgetFactory(); - composite = factory.createFlatFormComposite(parent); - - GridData data = new GridData(); - - GridLayout gridLayout = new GridLayout(); - gridLayout.marginTop = 0; - gridLayout.marginBottom = 0; - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - - // ------------------------------------------------------------------ - // NameLabel - // ------------------------------------------------------------------ - - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - CLabel nameLabel = factory.createCLabel(composite, Messages._UI_LABEL_NAME); - nameLabel.setLayoutData(data); - - // ------------------------------------------------------------------ - // NameText - // ------------------------------------------------------------------ - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - nameText = getWidgetFactory().createText(composite, ""); //$NON-NLS-1$ - nameText.setLayoutData(data); - applyAllListeners(nameText); - PlatformUI.getWorkbench().getHelpSystem().setHelp(nameText, - XSDEditorCSHelpIds.GENERAL_TAB__SIMPLE_TYPE__NAME); - - - // ------------------------------------------------------------------ - // Refactor/rename hyperlink - // ------------------------------------------------------------------ - createRenameHyperlink(composite); - - // Variety Label - CLabel label = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_VARIETY")); //$NON-NLS-1$ - - // Variety Combo - data = new GridData(); - data.horizontalAlignment = GridData.HORIZONTAL_ALIGN_BEGINNING; - data.grabExcessHorizontalSpace = false; - label.setLayoutData(data); - - varietyCombo = getWidgetFactory().createCCombo(composite, SWT.FLAT); - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - - List list = XSDVariety.VALUES; - Iterator iter = list.iterator(); - while (iter.hasNext()) - { - varietyCombo.add(((XSDVariety) iter.next()).getName()); - } - varietyCombo.addSelectionListener(this); - varietyCombo.setLayoutData(data); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(varietyCombo, - XSDEditorCSHelpIds.GENERAL_TAB__SIMPLE_TYPE__VARIETY); - - - // ------------------------------------------------------------------ - // DummyLabel - // ------------------------------------------------------------------ - getWidgetFactory().createCLabel(composite, ""); //$NON-NLS-1$ - - // ------------------------------------------------------------------ - // Types Label - // ------------------------------------------------------------------ - typesLabel = getWidgetFactory().createCLabel(composite, XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES")); //$NON-NLS-1$ - - // ------------------------------------------------------------------ - // Types Combo - // ------------------------------------------------------------------ - typesCombo = getWidgetFactory().createCCombo(composite); - typesCombo.setEditable(false); - typesCombo.setLayoutData(data); - typesCombo.addSelectionListener(this); - - - data = new GridData(); - data.grabExcessHorizontalSpace = true; - data.horizontalAlignment = GridData.FILL; - typesCombo.setLayoutData(data); - - PlatformUI.getWorkbench().getHelpSystem().setHelp(typesCombo, - XSDEditorCSHelpIds.GENERAL_TAB__SIMPLE_TYPE__BASE_TYPE); - - } - - public void setInput(IWorkbenchPart part, ISelection selection) - { - super.setInput(part, selection); - relayout(); - } - - protected void relayout() - { - Composite parentComposite = composite.getParent(); - parentComposite.getParent().setRedraw(false); - - if (parentComposite != null && !parentComposite.isDisposed()) - { - Control[] children = parentComposite.getChildren(); - for (int i = 0; i < children.length; i++) - { - children[i].dispose(); - } - } - - // Now initialize the new handler - createContents(parentComposite); - parentComposite.getParent().layout(true, true); - - // Now turn painting back on - parentComposite.getParent().setRedraw(true); - refresh(); - } - - public void refresh() - { - super.refresh(); - - setListenerEnabled(false); - - nameText.setText(""); //$NON-NLS-1$ - varietyCombo.setText(""); //$NON-NLS-1$ - typesCombo.setText(""); //$NON-NLS-1$ - fillTypesCombo(); - typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON")); //$NON-NLS-1$ - - if (input instanceof XSDSimpleTypeDefinition) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; - String simpleTypeName = st.getName(); - if (simpleTypeName != null) - { - nameText.setText(simpleTypeName); - } - else - { - nameText.setText("**anonymous**"); //$NON-NLS-1$ - } - - String variety = st.getVariety().getName(); - int intVariety = st.getVariety().getValue(); - - if (variety != null) - { - varietyCombo.setText(variety); - if (intVariety == XSDVariety.ATOMIC) - { - baseTypeDefinition = st.getBaseTypeDefinition(); - String name = ""; //$NON-NLS-1$ - if (baseTypeDefinition != null) - { - name = baseTypeDefinition.getName(); - } - typesCombo.setText(name); - typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON")); //$NON-NLS-1$ - } - else if (intVariety == XSDVariety.LIST) - { - itemTypeDefinition = st.getItemTypeDefinition(); - String name = ""; //$NON-NLS-1$ - if (itemTypeDefinition != null) - { - name = itemTypeDefinition.getName(); - } - typesCombo.setText(name); - typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_ITEM_TYPE")); //$NON-NLS-1$ - } - else if (intVariety == XSDVariety.UNION) - { - List memberTypesList = st.getMemberTypeDefinitions(); - StringBuffer sb = new StringBuffer(); - for (Iterator i = memberTypesList.iterator(); i.hasNext();) - { - XSDSimpleTypeDefinition typeObject = (XSDSimpleTypeDefinition) i.next(); - String name = typeObject.getQName(); - if (name != null) - { - sb.append(name); - if (i.hasNext()) - { - sb.append(" "); //$NON-NLS-1$ - } - } - } - String memberTypes = sb.toString(); - typesCombo.setText(memberTypes); - typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES")); //$NON-NLS-1$ - } - } - } - setListenerEnabled(true); - - } - - public void doWidgetSelected(SelectionEvent e) - { - if (e.widget == typesCombo) - { - IEditorPart editor = getActiveEditor(); - if (editor == null) return; - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDComplexTypeBaseTypeEditManager.class); - - String selection = typesCombo.getText(); - ComponentSpecification newValue; - IComponentDialog dialog= null; - if ( selection.equals(org.eclipse.wst.xsd.ui.internal.editor.Messages._UI_ACTION_BROWSE)) - { - dialog = manager.getBrowseDialog(); - ((XSDSearchListDialogDelegate) dialog).showComplexTypes(false); - } - else if ( selection.equals(org.eclipse.wst.xsd.ui.internal.editor.Messages._UI_ACTION_NEW)) - { - dialog = manager.getNewDialog(); - ((NewTypeDialog) dialog).allowComplexType(false); - } - - if (dialog != null) - { - if (dialog.createAndOpen() == Window.OK) - { - newValue = dialog.getSelectedComponent(); - manager.modifyComponentReference(input, newValue); - } - } - else //use the value from selected quickPick item - { - newValue = getComponentSpecFromQuickPickForValue(selection, manager); - if (newValue != null) - manager.modifyComponentReference(input, newValue); - } - } - else if (e.widget == varietyCombo) - { - if (input != null) - { - if (input instanceof XSDSimpleTypeDefinition) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; - Element parent = st.getElement(); - - String variety = varietyCombo.getText(); - if (variety.equals(XSDVariety.ATOMIC_LITERAL.getName())) - { - typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_BASE_TYPE_WITH_COLON")); //$NON-NLS-1$ - st.setVariety(XSDVariety.ATOMIC_LITERAL); - addCreateElementActionIfNotExist(XSDConstants.RESTRICTION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_RESTRICTION"), parent, null); //$NON-NLS-1$ - } - else if (variety.equals(XSDVariety.UNION_LITERAL.getName())) - { - typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES")); //$NON-NLS-1$ - st.setVariety(XSDVariety.UNION_LITERAL); - addCreateElementActionIfNotExist(XSDConstants.UNION_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_UNION"), parent, null); //$NON-NLS-1$ - } - else if (variety.equals(XSDVariety.LIST_LITERAL.getName())) - { - typesLabel.setText(XSDEditorPlugin.getXSDString("_UI_LABEL_ITEM_TYPE")); //$NON-NLS-1$ - st.setVariety(XSDVariety.LIST_LITERAL); - addCreateElementActionIfNotExist(XSDConstants.LIST_ELEMENT_TAG, XSDEditorPlugin.getXSDString("_UI_ACTION_ADD_LIST"), parent, null); //$NON-NLS-1$ - } - } - } - } -// else if (e.widget == button) -// { -// Shell shell = Display.getCurrent().getActiveShell(); -// Element element = ((XSDConcreteComponent) input).getElement(); -// Dialog dialog = null; -// String property = ""; -// Element secondaryElement = null; - -// IFile currentIFile = ((IFileEditorInput) getActiveEditor().getEditorInput()).getFile(); - - // issue (cs) need to move to common.ui's selection dialog -/* - XSDComponentSelectionProvider provider = new XSDComponentSelectionProvider(currentIFile, xsdSchema); - dialog = new XSDComponentSelectionDialog(shell, XSDEditorPlugin.getXSDString("_UI_LABEL_SET_TYPE"), provider); - provider.setDialog((XSDComponentSelectionDialog) dialog); -*/ -// if (input instanceof XSDSimpleTypeDefinition) -// { -// XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; -// Element simpleTypeElement = st.getElement(); -// if (st.getVariety() == XSDVariety.LIST_LITERAL) -// { -// Element listElement = (Element) itemTypeDefinition.getElement(); -// // dialog = new TypesDialog(shell, listElement, -// // XSDConstants.ITEMTYPE_ATTRIBUTE, xsdSchema); -// // dialog.showComplexTypes = false; -// provider.showComplexTypes(false); -// -// secondaryElement = listElement; -// property = XSDConstants.ITEMTYPE_ATTRIBUTE; -// } -// else if (st.getVariety() == XSDVariety.ATOMIC_LITERAL) -// { -// Element derivedByElement = (Element) baseTypeDefinition.getElement(); -// if (derivedByElement != null) -// { -// // dialog = new TypesDialog(shell, derivedByElement, -// // XSDConstants.BASE_ATTRIBUTE, xsdSchema); -// // dialog.showComplexTypes = false; -// provider.showComplexTypes(false); -// -// secondaryElement = derivedByElement; -// property = XSDConstants.BASE_ATTRIBUTE; -// } -// else -// { -// return; -// } -// } -// if (st.getVariety() == XSDVariety.UNION_LITERAL) -// { -// SimpleContentUnionMemberTypesDialog unionDialog = new SimpleContentUnionMemberTypesDialog(shell, st); -// unionDialog.setBlockOnOpen(true); -// unionDialog.create(); -// -// int result = unionDialog.open(); -// if (result == Window.OK) -// { -// String newValue = unionDialog.getResult(); -// // beginRecording(XSDEditorPlugin.getXSDString("_UI_LABEL_MEMBERTYPES_CHANGE"), -// // element); //$NON-NLS-1$ -// Element unionElement = memberTypeDefinition.getElement(); -// unionElement.setAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, newValue); -// -// if (newValue.length() > 0) -// { -// unionElement.setAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, newValue); -// } -// else -// { -// unionElement.removeAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE); -// } -// // endRecording(unionElement); -// refresh(); -// } -// return; -// } -// else -// { -// property = "type"; -// } -// } -// else -// { -// property = "type"; -// } - // beginRecording(XSDEditorPlugin.getXSDString("_UI_TYPE_CHANGE"), - // element); //$NON-NLS-1$ -// dialog.setBlockOnOpen(true); -// dialog.create(); -// int result = dialog.open(); -// -// if (result == Window.OK) -// { -// if (secondaryElement == null) -// { -// secondaryElement = element; -// } -// XSDSetTypeHelper helper = new XSDSetTypeHelper(currentIFile, xsdSchema); -// helper.setType(secondaryElement, property, ((XSDComponentSelectionDialog) dialog).getSelection()); - -// XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; -// st.setElement(element); -// updateSimpleTypeFacets();*/ -// } - // endRecording(element); -// } -// refresh(); - } - - public boolean shouldUseExtraSpace() - { - return false; - } - - // issue (cs) this method seems to be utilizing 'old' classes, can we reimplement? - // (e.g. ChangeElementAction, XSDDOMHelper, etc) - protected boolean addCreateElementActionIfNotExist(String elementTag, String label, Element parent, Node relativeNode) - { - XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; - List attributes = new ArrayList(); - String reuseType = null; - - // beginRecording(XSDEditorPlugin.getXSDString("_UI_LABEL_VARIETY_CHANGE"), - // parent); //$NON-NLS-1$ - if (elementTag.equals(XSDConstants.RESTRICTION_ELEMENT_TAG)) - { - Element listNode = getFirstChildNodeIfExists(parent, XSDConstants.LIST_ELEMENT_TAG, false); - if (listNode != null) - { - reuseType = listNode.getAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE); - XSDDOMHelper.removeNodeAndWhitespace(listNode); - } - - Element unionNode = getFirstChildNodeIfExists(parent, XSDConstants.UNION_ELEMENT_TAG, false); - if (unionNode != null) - { - String memberAttr = unionNode.getAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE); - if (memberAttr != null) - { - StringTokenizer stringTokenizer = new StringTokenizer(memberAttr); - reuseType = stringTokenizer.nextToken(); - } - XSDDOMHelper.removeNodeAndWhitespace(unionNode); - } - - if (reuseType == null) - { - reuseType = getBuiltInStringQName(); - } - attributes.add(new DOMAttribute(XSDConstants.BASE_ATTRIBUTE, reuseType)); - st.setItemTypeDefinition(null); - } - else if (elementTag.equals(XSDConstants.LIST_ELEMENT_TAG)) - { - Element restrictionNode = getFirstChildNodeIfExists(parent, XSDConstants.RESTRICTION_ELEMENT_TAG, false); - if (restrictionNode != null) - { - reuseType = restrictionNode.getAttribute(XSDConstants.BASE_ATTRIBUTE); - XSDDOMHelper.removeNodeAndWhitespace(restrictionNode); - } - Element unionNode = getFirstChildNodeIfExists(parent, XSDConstants.UNION_ELEMENT_TAG, false); - if (unionNode != null) - { - String memberAttr = unionNode.getAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE); - if (memberAttr != null) - { - StringTokenizer stringTokenizer = new StringTokenizer(memberAttr); - reuseType = stringTokenizer.nextToken(); - } - XSDDOMHelper.removeNodeAndWhitespace(unionNode); - } - attributes.add(new DOMAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE, reuseType)); - } - else if (elementTag.equals(XSDConstants.UNION_ELEMENT_TAG)) - { - Element listNode = getFirstChildNodeIfExists(parent, XSDConstants.LIST_ELEMENT_TAG, false); - if (listNode != null) - { - reuseType = listNode.getAttribute(XSDConstants.ITEMTYPE_ATTRIBUTE); - XSDDOMHelper.removeNodeAndWhitespace(listNode); - } - Element restrictionNode = getFirstChildNodeIfExists(parent, XSDConstants.RESTRICTION_ELEMENT_TAG, false); - if (restrictionNode != null) - { - reuseType = restrictionNode.getAttribute(XSDConstants.BASE_ATTRIBUTE); - XSDDOMHelper.removeNodeAndWhitespace(restrictionNode); - } - attributes.add(new DOMAttribute(XSDConstants.MEMBERTYPES_ATTRIBUTE, reuseType)); - st.setItemTypeDefinition(null); - } - - if (getFirstChildNodeIfExists(parent, elementTag, false) == null) - { - Action action = addCreateElementAction(elementTag, label, attributes, parent, relativeNode); - action.run(); - } - - st.setElement(parent); - st.updateElement(); - // endRecording(parent); - return true; - } - - protected Action addCreateElementAction(String elementTag, String label, List attributes, Element parent, Node relativeNode) - { - CreateElementAction action = new CreateElementAction(label); - action.setElementTag(elementTag); - action.setAttributes(attributes); - action.setParentNode(parent); - action.setRelativeNode(relativeNode); - return action; - } - - protected Element getFirstChildNodeIfExists(Node parent, String elementTag, boolean isRef) - { - NodeList children = parent.getChildNodes(); - Element targetNode = null; - for (int i = 0; i < children.getLength(); i++) - { - Node child = children.item(i); - if (child != null && child instanceof Element) - { - if (XSDDOMHelper.inputEquals(child, elementTag, isRef)) - { - targetNode = (Element) child; - break; - } - } - } - return targetNode; - } - - protected String getBuiltInStringQName() - { - String stringName = "string"; //$NON-NLS-1$ - - if (xsdSchema != null) - { - String schemaForSchemaPrefix = xsdSchema.getSchemaForSchemaQNamePrefix(); - if (schemaForSchemaPrefix != null && schemaForSchemaPrefix.length() > 0) - { - String prefix = xsdSchema.getSchemaForSchemaQNamePrefix(); - if (prefix != null && prefix.length() > 0) - { - stringName = prefix + ":" + stringName; //$NON-NLS-1$ - } - } - } - return stringName; - } - -// private void updateSimpleTypeFacets() -// { -// XSDSimpleTypeDefinition st = (XSDSimpleTypeDefinition) input; -// Element simpleTypeElement = st.getElement(); -// Element derivedByElement = baseTypeDefinition.getElement(); -// if (derivedByElement != null) -// { -// List nodesToRemove = new ArrayList(); -// NodeList childList = derivedByElement.getChildNodes(); -// int length = childList.getLength(); -// for (int i = 0; i < length; i++) -// { -// Node child = childList.item(i); -// if (child instanceof Element) -// { -// Element elementChild = (Element) child; -// if (!(elementChild.getLocalName().equals("pattern") || elementChild.getLocalName().equals("enumeration") || //$NON-NLS-1$ //$NON-NLS-2$ -// XSDDOMHelper.inputEquals(elementChild, XSDConstants.SIMPLETYPE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals(elementChild, XSDConstants.ANNOTATION_ELEMENT_TAG, false) -// || XSDDOMHelper.inputEquals(elementChild, XSDConstants.ATTRIBUTE_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals(elementChild, XSDConstants.ATTRIBUTE_ELEMENT_TAG, true) -// || XSDDOMHelper.inputEquals(elementChild, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, false) || XSDDOMHelper.inputEquals(elementChild, XSDConstants.ATTRIBUTEGROUP_ELEMENT_TAG, true) || XSDDOMHelper.inputEquals(elementChild, -// XSDConstants.ANYATTRIBUTE_ELEMENT_TAG, false))) -// { -// nodesToRemove.add(child); -// } -// } -// } -// Iterator iter = nodesToRemove.iterator(); -// while (iter.hasNext()) -// { -// Element facetToRemove = (Element) iter.next(); -// String facetName = facetToRemove.getLocalName(); -// Iterator it = st.getValidFacets().iterator(); -// boolean doRemove = true; -// while (it.hasNext()) -// { -// String aValidFacet = (String) it.next(); -// if (aValidFacet.equals(facetName)) -// { -// doRemove = false; -// break; -// } -// } -// if (doRemove) -// { -// XSDDOMHelper.removeNodeAndWhitespace(facetToRemove); -// } -// } -// } -// } - - // TODO: Common this up with element declaration - public void doHandleEvent(Event event) - { - if (event.widget == nameText) - { - String newValue = nameText.getText().trim(); - if (input instanceof XSDNamedComponent) - { - XSDNamedComponent namedComponent = (XSDNamedComponent)input; - if (!validateSection()) - return; - - Command command = null; - - // Make sure an actual name change has taken place - String oldName = namedComponent.getName(); - if (!newValue.equals(oldName)) - { - command = new UpdateNameCommand(Messages._UI_ACTION_RENAME, namedComponent, newValue); - } - - if (command != null && getCommandStack() != null) - { - getCommandStack().execute(command); - } - - } - } - } - - protected boolean validateSection() - { - if (nameText == null || nameText.isDisposed()) - return true; - - setErrorMessage(null); - - String name = nameText.getText().trim(); - - // validate against NCName - if (name.length() < 1 || !XMLChar.isValidNCName(name)) - { - setErrorMessage(Messages._UI_ERROR_INVALID_NAME); - return false; - } - - return true; - } - - - private void fillTypesCombo() - { - typesCombo.removeAll(); - - IEditorPart editor = getActiveEditor(); - ComponentReferenceEditManager manager = (ComponentReferenceEditManager)editor.getAdapter(XSDTypeReferenceEditManager.class); - ComponentSpecification[] items = manager.getQuickPicks(); - - typesCombo.add(org.eclipse.wst.xsd.ui.internal.adt.editor.Messages._UI_ACTION_BROWSE); - typesCombo.add(org.eclipse.wst.xsd.ui.internal.editor.Messages._UI_ACTION_NEW); - - for (int i = 0; i < items.length; i++) - { - typesCombo.add(items[i].getName()); - } - - // Add the current Type of this attribute if needed - XSDSimpleTypeDefinition simpleType = (XSDSimpleTypeDefinition) input; - XSDTypeDefinition baseType = simpleType.getBaseType(); - if (baseType != null && baseType.getQName() != null) - { - String currentTypeName = baseType.getQName(xsdSchema); //no prefix - ComponentSpecification ret = getComponentSpecFromQuickPickForValue(currentTypeName,manager); - if (ret == null && currentTypeName != null) //not in quickPick - { - typesCombo.add(currentTypeName); - } - } - } - - // TODO: common this up with XSDElementDeclarationSection - private ComponentSpecification getComponentSpecFromQuickPickForValue(String value, ComponentReferenceEditManager editManager) - { - if (editManager != null) - { - ComponentSpecification[] quickPicks = editManager.getQuickPicks(); - if (quickPicks != null) - { - for (int i=0; i < quickPicks.length; i++) - { - ComponentSpecification componentSpecification = quickPicks[i]; - if (value != null && value.equals(componentSpecification.getName())) - { - return componentSpecification; - } - } - } - } - return null; - } - - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDTableTreeViewer.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDTableTreeViewer.java deleted file mode 100644 index 0b04e7b5aa..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/XSDTableTreeViewer.java +++ /dev/null @@ -1,126 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections; - -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.action.MenuManager; -import org.eclipse.jface.action.Separator; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Menu; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeContentProvider; -import org.eclipse.wst.xml.ui.internal.tabletree.XMLTableTreeViewer; -import org.w3c.dom.Element; - -public class XSDTableTreeViewer extends XMLTableTreeViewer -{ - - String filter = ""; //$NON-NLS-1$ - - class XSDActionMenuListener implements IMenuListener - { - public void menuAboutToShow(IMenuManager menuManager) - { - // used to disable NodeSelection listening while running NodeAction - // XSDActionManager nodeActionManager = new XSDActionManager(fModel, - // XSDTableTreeViewer.this); - // nodeActionManager.setCommandStack(commandStack); - // nodeActionManager.fillContextMenu(menuManager, getSelection()); - - // used to disable NodeSelection listening while running NodeAction - // XMLNodeActionManager nodeActionManager = new - // XMLNodeActionManager(((IDOMDocument) getInput()).getModel(), - // XMLTableTreeViewer.this) { - if (getInput() != null) - { - XSDActionManager nodeActionManager = new XSDActionManager(((IDOMDocument) (((Element) getInput()).getOwnerDocument())).getModel(), XSDTableTreeViewer.this); - // nodeActionManager.setCommandStack(commandStack); - nodeActionManager.fillContextMenu(menuManager, getSelection()); - } - - } - } - - public XSDTableTreeViewer(Composite parent) - { - super(parent); - // treeExtension.setCellModifier(null); - getTree().setLinesVisible(true); - - // treeExtension = new XMLTreeExtension(getTree()); - - // Reassign the content provider - XMLTableTreeContentProvider provider = new MyContentProvider(); - // provider.addViewer(this); - - setContentProvider(provider); - setLabelProvider(provider); - - // setViewerSelectionManager(new ViewerSelectionManagerImpl(null)); - } - - protected Object getRoot() - { - return super.getRoot(); - } - - public void setFilter(String filter) - { - this.filter = filter; - } - - protected void createContextMenu() - { - // TODO Verify if this is okay to override the MenuManager - MenuManager contextMenu = new MenuManager("#PopUp"); //$NON-NLS-1$ - contextMenu.add(new Separator("additions")); //$NON-NLS-1$ - contextMenu.setRemoveAllWhenShown(true); - - // This is the line we have to modify - contextMenu.addMenuListener(new XSDActionMenuListener()); - Menu menu = contextMenu.createContextMenu(getControl()); - getControl().setMenu(menu); - } - - boolean added = false; - - class MyContentProvider extends XMLTableTreeContentProvider - { - - // public Object[] getChildren(Object element) { - // - // if (!added) { - // if (element instanceof Element) { - // added = true; - // Element elem = (Element)element; - // if (elem instanceof INodeNotifier) { - // viewerNotifyingAdapterFactory.adapt((INodeNotifier) elem); - // } - // // return new Object[] {elem}; - // } - // } - // return super.getChildren(element); - // } - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - added = false; - if (oldInput instanceof Element) - oldInput = ((Element) oldInput).getOwnerDocument(); - - if (newInput instanceof Element) - newInput = ((Element) newInput).getOwnerDocument(); - super.inputChanged(viewer, oldInput, newInput); - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddExtensionsComponentDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddExtensionsComponentDialog.java deleted file mode 100644 index 8d4aef3a2c..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddExtensionsComponentDialog.java +++ /dev/null @@ -1,778 +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.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.StringTokenizer; - -import org.apache.xerces.dom.DocumentImpl; -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.DoubleClickEvent; -import org.eclipse.jface.viewers.IDoubleClickListener; -import org.eclipse.jface.viewers.ILabelProvider; -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.LabelProvider; -import org.eclipse.jface.viewers.SelectionChangedEvent; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.jface.viewers.TableViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; -import org.eclipse.swt.graphics.Cursor; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.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.MessageBox; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Table; -import org.eclipse.swt.widgets.TableItem; -import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.dialogs.SelectionDialog; -import org.eclipse.wst.xsd.contentmodel.internal.XSDImpl; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDSchema; -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class AddExtensionsComponentDialog extends SelectionDialog implements ISelectionChangedListener, SelectionListener -{ - protected static final Image DEFAULT_ELEMENT_ICON = XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"); //$NON-NLS-1$ - protected static final Image DEFAULT_ATTRIBUTE_ICON = XSDEditorPlugin.getXSDImage("icons/XSDAttribute.gif"); //$NON-NLS-1$ - - /** A temporary Document in which we create temporary DOM element for each element in the - * Element view. (required by LabelProvider) */ - protected static Document tempDoc = new DocumentImpl(); - - Button addButton, removeButton, editButton; - - public AddExtensionsComponentDialog(Shell parent, ExtensionsSchemasRegistry schemaRegistry) - { - super(parent); - setTitle(Messages._UI_ACTION_ADD_EXTENSION_COMPONENTS); - setShellStyle(SWT.APPLICATION_MODAL | SWT.RESIZE | SWT.CLOSE); - } - - private List fInput; - - private TableViewer categoryTableViewer, elementTableViewer; - private ArrayList existingNames; - - private ViewerFilter elementTableViewerFilter; - private SpecificationForExtensionsSchema currentExtCategory; - private HashMap specToComponentsList = new HashMap(); - private IPreferenceStore prefStore; - - public void setInput(List input) - { - this.fInput = input; - } - - public SpecificationForExtensionsSchema getSelectedCategory(){ - return currentExtCategory; - } - - public void setInitialCategorySelection(SpecificationForExtensionsSchema spec){ - currentExtCategory = spec; - } - - protected IStructuredContentProvider getCategoryContentProvider() - { - return new CategoryContentProvider(); - } - - protected Control createDialogArea(Composite container) - { - Composite parent = (Composite) super.createDialogArea(container); - - Composite categoryComposite = new Composite(parent, SWT.NONE); - GridLayout gl = new GridLayout(); - gl.numColumns = 2; - gl.marginHeight = 0; - gl.marginWidth = 0; - GridData data = new GridData(GridData.FILL_BOTH); - categoryComposite.setLayoutData(data); - categoryComposite.setLayout(gl); - - Label label = new Label(categoryComposite, SWT.LEFT); - label.setText(Messages._UI_LABEL_EXTENSION_CATEGORIES); - - new Label(categoryComposite, SWT.NONE); - - categoryTableViewer = new TableViewer(categoryComposite, getTableStyle()); - categoryTableViewer.setContentProvider(getCategoryContentProvider()); - categoryTableViewer.setLabelProvider(new CategoryLabelProvider()); - categoryTableViewer.setInput(fInput); - categoryTableViewer.addSelectionChangedListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(categoryTableViewer.getControl(), XSDEditorCSHelpIds.ADD_EXTENSIONS_COMPONENTS__EXTENSION_CATEGORIES); - - GridData gd = new GridData(GridData.FILL_BOTH); - Table table = categoryTableViewer.getTable(); - table.setLayoutData(gd); - table.setFont(container.getFont()); - - Composite buttonComposite = new Composite(categoryComposite, SWT.NONE); - gl = new GridLayout(); - gl.makeColumnsEqualWidth = true; - gl.numColumns = 1; - data = new GridData(); - data.horizontalAlignment = SWT.FILL; - buttonComposite.setLayoutData(data); - buttonComposite.setLayout(gl); - - addButton = new Button(buttonComposite, SWT.PUSH); - addButton.setText(Messages._UI_LABEL_ADD_WITH_DOTS); - addButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - addButton.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(addButton, - XSDEditorCSHelpIds.ADD_EXTENSIONS_COMPONENTS__ADD); - - removeButton = new Button(buttonComposite, SWT.PUSH); - removeButton.setText(Messages._UI_LABEL_DELETE); - removeButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - removeButton.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(removeButton, - XSDEditorCSHelpIds.ADD_EXTENSIONS_COMPONENTS__DELETE); - - - editButton = new Button(buttonComposite, SWT.PUSH); - editButton.setText(Messages._UI_LABEL_EDIT); - editButton.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); - editButton.addSelectionListener(this); - PlatformUI.getWorkbench().getHelpSystem().setHelp(editButton, - XSDEditorCSHelpIds.ADD_EXTENSIONS_COMPONENTS__EDIT); - - - List initialSelection = getInitialElementSelections(); - if (initialSelection != null) - categoryTableViewer.setSelection(new StructuredSelection(initialSelection)); - - Label elementLabel = new Label(categoryComposite, SWT.LEFT); - elementLabel.setText(Messages._UI_LABEL_AVAILABLE_COMPONENTS_TO_ADD); - - new Label(categoryComposite, SWT.NONE); - - elementTableViewer = new TableViewer(categoryComposite, getTableStyle()); - elementTableViewer.setContentProvider(new ElementContentProvider()); - elementTableViewer.setLabelProvider(new ElementLabelProvider()); - elementTableViewer.setInput(null); - elementTableViewer.addDoubleClickListener(new IDoubleClickListener() - { - public void doubleClick(DoubleClickEvent event) - { - okPressed(); - } - }); - if ( elementTableViewerFilter != null){ - elementTableViewer.addFilter(elementTableViewerFilter); - } - - gd = new GridData(GridData.FILL_BOTH); - table = elementTableViewer.getTable(); - table.setLayoutData(gd); - table.setFont(container.getFont()); - - elementTableViewer.addSelectionChangedListener(new ISelectionChangedListener() { - public void selectionChanged(SelectionChangedEvent event) { - getButton(IDialogConstants.OK_ID).setEnabled(true); - } - }); - PlatformUI.getWorkbench().getHelpSystem().setHelp(elementTableViewer.getControl(), XSDEditorCSHelpIds.ADD_EXTENSIONS_COMPONENTS__AVAILABLE_COMPONENTS_TO_ADD); - - return parent; - } - - public void create() - { - super.create(); - if (categoryTableViewer.getTable().getItemCount() > 0) - { - categoryTableViewer.getTable().select(0); - - StructuredSelection structuredSelection; - if (currentExtCategory != null){ - structuredSelection = new StructuredSelection(currentExtCategory); - } - else{ - structuredSelection = - new StructuredSelection(categoryTableViewer.getElementAt(0)); - } - - categoryTableViewer.setSelection(structuredSelection); - } - - // Setup the list of category names that already exist - // and contructs the XSDSchema for each category - existingNames = new ArrayList(); - TableItem[] categories = categoryTableViewer.getTable().getItems(); - for (int i = 0; i < categories.length; i++ ){ - existingNames.add(categories[i].getText()); - - SpecificationForExtensionsSchema spec = - (SpecificationForExtensionsSchema) categories[i].getData(); - XSDSchema schema = getASISchemaModel(spec); - - if (schema == null) - { - continue; - } - - List components = buildInput(schema); - specToComponentsList.put(spec, components); - - // mark category as gray/empty if applicable - Object[] remains = components.toArray(); - if ( elementTableViewerFilter != null) - remains = elementTableViewerFilter.filter(elementTableViewer, - elementTableViewer.getTable(), remains); - if ( remains.length == 0) - { - categories[i].setForeground( - getShell().getDisplay().getSystemColor(SWT.COLOR_GRAY)); - } - } - - getButton(IDialogConstants.OK_ID).setEnabled(false); - } - - public void addElementsTableFilter(ViewerFilter filter){ - elementTableViewerFilter = filter; - } - - public void setPrefStore(IPreferenceStore prefStore) - { - this.prefStore = prefStore; - } - - protected Point getInitialSize() - { - return getShell().computeSize(400, 300); - } - - /** - * Return the style flags for the table viewer. - * - * @return int - */ - protected int getTableStyle() - { - return SWT.SINGLE | SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER; - } - - /* - * Overrides method from Dialog - */ - protected void okPressed() - { - // Build a list of selected children. - getShell().setCursor(new Cursor(getShell().getDisplay(), SWT.CURSOR_WAIT)); - IStructuredSelection elementSelection = (IStructuredSelection) elementTableViewer.getSelection(); - IStructuredSelection categorySelection = (IStructuredSelection) categoryTableViewer.getSelection(); - List result = new ArrayList(); - result.add(elementSelection.getFirstElement()); - result.add(categorySelection.getFirstElement()); - if (elementSelection.getFirstElement() != null) - { - setResult(result); - } - else - { - setResult(null); - } - super.okPressed(); - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetSelected(SelectionEvent e) - { - if (e.widget == addButton) - { - AddNewCategoryDialog addNewCategoryDialog - = new AddNewCategoryDialog(getShell()); - - addNewCategoryDialog.setUnavailableCategoryNames(existingNames); - - if ( addNewCategoryDialog.open() == Window.OK ){ - SpecificationForExtensionsSchema schemaSpec = - new SpecificationForExtensionsSchema(); - schemaSpec.setDisplayName(addNewCategoryDialog.getNewCategoryName() ); - schemaSpec.setLocation(addNewCategoryDialog.getCategoryLocation() ); - schemaSpec.setSourceHint(addNewCategoryDialog.getSource()); - schemaSpec.setFromCatalog(addNewCategoryDialog.getFromCatalog() ); - - fInput.add(schemaSpec); - existingNames.add(schemaSpec.getDisplayName()); - - // refresh without updating labels of existing TableItems - categoryTableViewer.refresh(false); - - categoryTableViewer.setSelection(new StructuredSelection(schemaSpec)); - getButton(IDialogConstants.OK_ID).setEnabled(false); - - storeSpecInPref(schemaSpec); // must store after selection changed is called ie. 2 lines above (trung) - } - } - else if (e.widget == removeButton) - { - TableItem[] selections = categoryTableViewer.getTable().getSelection(); - for (int i =0; i < selections.length; i++){ - SpecificationForExtensionsSchema spec = - (SpecificationForExtensionsSchema) selections[i].getData(); - - fInput.remove(spec ); - existingNames.remove(spec.getDisplayName()); - specToComponentsList.remove(spec); - - removeFromPref(spec); - } - categoryTableViewer.refresh(false); - - elementTableViewer.setInput(null); - elementTableViewer.refresh(); - - // TODO auto select either the prev category, the next category or the first category in the Table - getButton(IDialogConstants.OK_ID).setEnabled(false); - } - else if (e.widget == editButton) - { - // use this dialog not for adding but for editing purpose. - AddNewCategoryDialog dialog = new AddNewCategoryDialog(getShell(), Messages._UI_LABEL_EDIT_CATEGORY); - - TableItem[] selections = categoryTableViewer.getTable().getSelection(); - if (selections.length == 0) - return; - - SpecificationForExtensionsSchema spec = (SpecificationForExtensionsSchema) selections[0].getData(); - - String displayName = spec.getDisplayName(); - - dialog.setCategoryName(displayName ); - dialog.setFromCatalog(spec.isFromCatalog() ); - dialog.setSource(spec.getSourceHint() ); - dialog.setCategoryLocation(spec.getLocation() ); - - specToComponentsList.remove(spec); - dialog.setUnavailableCategoryNames(existingNames); - - if ( dialog.open() == Window.OK){ - existingNames.remove(displayName); - String newDisplayName = dialog.getNewCategoryName(); - - spec.setDisplayName(newDisplayName); - spec.setLocation(dialog.getCategoryLocation()); - spec.setSourceHint(dialog.getSource()); - spec.setFromCatalog(dialog.getFromCatalog()); - spec.setNamespaceURI(null); - - existingNames.add(newDisplayName); - - categoryTableViewer.update(spec, null); - refreshElementsViewer(spec); - - editSpecInPref(displayName, spec); - } - } - } - -/* - * (non-Javadoc) - * - * @see org.eclipse.swt.events.SelectionListener#widgetDefaultSelected(org.eclipse.swt.events.SelectionEvent) - */ - public void widgetDefaultSelected(SelectionEvent event) - { - - } - - public void selectionChanged(SelectionChangedEvent event) - { - if (event.getSource() == categoryTableViewer) - { - ISelection selection = event.getSelection(); - if (selection instanceof StructuredSelection) - { - Object obj = ((StructuredSelection) selection).getFirstElement(); - if (obj instanceof SpecificationForExtensionsSchema) - { - SpecificationForExtensionsSchema spec = (SpecificationForExtensionsSchema) obj; - currentExtCategory = spec; - refreshElementsViewer(spec); - - if ( spec.isDefautSchema() ){ - editButton.setEnabled(false); - removeButton.setEnabled(false); - } - else{ - editButton.setEnabled(true); - removeButton.setEnabled(true); - } - - getButton(IDialogConstants.OK_ID).setEnabled(false); - } - } - } - } - - private void refreshElementsViewer(SpecificationForExtensionsSchema spec) { - List components = (List) specToComponentsList.get(spec); - if ( components != null){ - elementTableViewer.setInput(components); - return; - } - - XSDSchema xsdSchema = getASISchemaModel(spec); - - if (xsdSchema == null){ - MessageBox errDialog = new MessageBox(getShell(), SWT.ICON_ERROR); - errDialog.setText(Messages._UI_ERROR_INVALID_CATEGORY); - // TODO (trung) I was forced to use a String in Messages to make the error clearer - // When we are back to development phase, use another string: "Extension Category: " - // not "Extension Categories:" + " " like we are using here - errDialog.setMessage(Messages._UI_LABEL_EXTENSION_CATEGORIES + " " + spec.getDisplayName() //$NON-NLS-1$ - + "\n" //$NON-NLS-1$ - + Messages._UI_ERROR_FILE_CANNOT_BE_PARSED - + "\n" + Messages._UI_ERROR_VALIDATE_THE_FILE); //$NON-NLS-1$ - errDialog.open(); - - elementTableViewer.setInput(new ArrayList(0)); - return; - } - - components = buildInput(xsdSchema); - specToComponentsList.put(spec, components); - - List allItems = buildInput(xsdSchema); - if ( allItems == null ) - return; - elementTableViewer.setInput(allItems); - } - - private static List buildInput(XSDSchema xsdSchema) - { - if ( xsdSchema ==null ) - return null; - - List elements = xsdSchema.getElementDeclarations(); - List attributes = xsdSchema.getAttributeDeclarations(); - String targetNamespace = xsdSchema.getTargetNamespace(); - - // For safety purpose: We don't append 'attributes' to 'elements' - // ArrayStoreException(or similar one) may occur - List allItems = new ArrayList(attributes.size() + elements.size()); - - { - // getElementDeclarations returns a lot of elements from import - // statement, we - // only add non-imported elements here. (trung) - for (int i = 0; i < elements.size(); i++) - { - XSDElementDeclaration currentElement = (XSDElementDeclaration) elements.get(i); - if (currentElement.getTargetNamespace() != null) - { - if (currentElement.getTargetNamespace().equals(targetNamespace)) - allItems.add(currentElement); - } - else - { - if (targetNamespace == null) - allItems.add(currentElement); - } - } - // getAttributeDeclarations also returns a lot of elements from - // import statement, we - // only add non-imported elements here. (trung) - for (int i = 0; i < attributes.size(); i++) - { - XSDAttributeDeclaration currentAttribute = (XSDAttributeDeclaration) attributes.get(i); - if (currentAttribute.getTargetNamespace() != null) - { - if (currentAttribute.isGlobal() && currentAttribute.getTargetNamespace().equals(targetNamespace)) - allItems.add(currentAttribute); - } - else - { - if (targetNamespace == null) - allItems.add(currentAttribute); - } - } - } - return allItems; - } - - - private static XSDSchema getASISchemaModel(SpecificationForExtensionsSchema extensionsSchemaSpec) - { - String location = extensionsSchemaSpec.getLocation(); - if ( location == null) - return null; - XSDSchema xsdSchema = XSDImpl.buildXSDModel(location); - - // now that the .xsd file is read, we can retrieve the namespace of this xsd file - // and set the namespace for 'properties' - if ( extensionsSchemaSpec.getNamespaceURI() == null){ - extensionsSchemaSpec.setNamespaceURI( xsdSchema.getTargetNamespace()); - } - - return xsdSchema; - } - - private void storeSpecInPref(SpecificationForExtensionsSchema schemaSpec) { - if (prefStore == null) - return; - - String currentValue = prefStore.getString(ExtensionsSchemasRegistry.USER_ADDED_EXT_SCHEMAS); - String specDesc = " " + "\t" + schemaSpec.getDisplayName() + "\t"+ - schemaSpec.getNamespaceURI() + "\t" + schemaSpec.getLocation() + "\t" + - schemaSpec.isDefautSchema() + "\t" + schemaSpec.getSourceHint() + "\t" + - schemaSpec.isFromCatalog(); - currentValue += specDesc + "\n"; - - prefStore.setValue(ExtensionsSchemasRegistry.USER_ADDED_EXT_SCHEMAS, - currentValue); - } - - private void editSpecInPref(String displayName, SpecificationForExtensionsSchema newSpec) { - if (prefStore == null) - return; - - String newValue = ""; - String currentValue = prefStore.getString(ExtensionsSchemasRegistry.USER_ADDED_EXT_SCHEMAS); - StringTokenizer tokenizer = new StringTokenizer(currentValue, "\n"); - - while (tokenizer.hasMoreTokens()) - { - String oneSpecDesc = tokenizer.nextToken(); - // get the Display name - StringTokenizer _tokenizer_2 = new StringTokenizer(oneSpecDesc, "\t"); - _tokenizer_2.nextToken(); - String dName = _tokenizer_2.nextToken(); - - if ( dName.equals(displayName ) ) - { - oneSpecDesc = " " + "\t" + newSpec.getDisplayName() + "\t"+ - newSpec.getNamespaceURI() + "\t" + newSpec.getLocation() + "\t" + - newSpec.isDefautSchema() + "\t" + newSpec.getSourceHint() + "\t" + - newSpec.isFromCatalog(); - } - - newValue += oneSpecDesc + "\n"; - } - prefStore.setValue(ExtensionsSchemasRegistry.USER_ADDED_EXT_SCHEMAS, newValue); - - } - - private void removeFromPref(SpecificationForExtensionsSchema spec) { - if (prefStore == null) - return; - - String newValue = ""; - String currentValue = prefStore.getString(ExtensionsSchemasRegistry.USER_ADDED_EXT_SCHEMAS); - StringTokenizer tokenizer = new StringTokenizer(currentValue, "\n"); - - while (tokenizer.hasMoreTokens()) - { - String oneSpecDesc = tokenizer.nextToken(); - // get the Display name - StringTokenizer _tokenizer_2 = new StringTokenizer(oneSpecDesc, "\t"); - _tokenizer_2.nextToken(); - String dName = _tokenizer_2.nextToken(); - - if ( dName.equals(spec.getDisplayName() ) ) - continue; - newValue += oneSpecDesc + "\n"; - } - prefStore.setValue(ExtensionsSchemasRegistry.USER_ADDED_EXT_SCHEMAS, newValue); - } - -static class CategoryContentProvider implements IStructuredContentProvider - { - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) - { - SpecificationForExtensionsSchema[] extensionsSchemaSpecs = null; - try - { - List inputList = (List) inputElement; - extensionsSchemaSpecs = (SpecificationForExtensionsSchema[]) inputList.toArray(new SpecificationForExtensionsSchema[0]); - } - catch (Exception e) - { - } - return extensionsSchemaSpecs; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() - { - // Do nothing - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - // Do nothing - - } - } - - static class CategoryLabelProvider extends LabelProvider - { - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) - { - return XSDEditorPlugin.getXSDImage("icons/appinfo_category.gif"); //$NON-NLS-1$ - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) - { - if (element instanceof SpecificationForExtensionsSchema) - return ((SpecificationForExtensionsSchema) element).getDisplayName(); - - return super.getText(element); - } - } - - static class ElementContentProvider implements IStructuredContentProvider - { - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object) - */ - public Object[] getElements(Object inputElement) - { - if (inputElement instanceof List) - { - return ((List) inputElement).toArray(); - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#dispose() - */ - public void dispose() - { - // Do nothing - - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse.jface.viewers.Viewer, - * java.lang.Object, java.lang.Object) - */ - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - // Do nothing - - } - } - - class ElementLabelProvider extends LabelProvider - { - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ILabelProvider#getImage(java.lang.Object) - */ - public Image getImage(Object element) - { - if ( element instanceof XSDElementDeclaration){ - - // Workaround trick: (trung) we create a temporary Dom element and put it in the label provider - // to get the image. - String namespace = ((XSDElementDeclaration) element).getSchema().getTargetNamespace(); - String name = ((XSDElementDeclaration) element).getName(); - Element tempElement = tempDoc.createElementNS(namespace, name); - ILabelProvider lp = XSDEditorPlugin.getDefault().getNodeCustomizationRegistry().getLabelProvider(namespace); - if (lp != null){ - Image img = lp.getImage(tempElement); - - if (img != null){ - return img; - } - } - return DEFAULT_ELEMENT_ICON; - } - else if ( element instanceof XSDAttributeDeclaration){ - return DEFAULT_ATTRIBUTE_ICON; - } - return null; - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.jface.viewers.ILabelProvider#getText(java.lang.Object) - */ - public String getText(Object element) - { - if (element instanceof XSDElementDeclaration) - return ((XSDElementDeclaration) element).getName(); - if (element instanceof XSDAttributeDeclaration ) - return ((XSDAttributeDeclaration) element).getName(); - return super.getText(element); - } - } - - public boolean close() - { - return super.close(); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddNewCategoryDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddNewCategoryDialog.java deleted file mode 100644 index 8c369ff8ad..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/AddNewCategoryDialog.java +++ /dev/null @@ -1,385 +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.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.List; - -import org.eclipse.core.resources.IFile; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.MenuManager; -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.custom.CLabel; -import org.eclipse.swt.events.ModifyEvent; -import org.eclipse.swt.events.ModifyListener; -import org.eclipse.swt.events.SelectionAdapter; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.graphics.Point; -import org.eclipse.swt.graphics.Rectangle; -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.Menu; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.ToolBar; -import org.eclipse.swt.widgets.ToolItem; -import org.eclipse.ui.PlatformUI; -import org.eclipse.wst.common.ui.internal.dialogs.SelectSingleFileDialog; -import org.eclipse.wst.xsd.ui.internal.common.util.Messages; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorCSHelpIds; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; - -public class AddNewCategoryDialog extends Dialog -{ - - private static final String SCHEMA_LABEL = Messages._UI_LABEL_SCHEMA; - private static final String NAME_LABEL = Messages._UI_LABEL_NAME; - private String dialogTitle = Messages._UI_LABEL_ADD_CATEGORY; - - protected MenuManager browseMenu; - protected Label name; - protected Text nameText; - protected Label schema; - protected CLabel schemaDisplayer; - protected ToolBar browseToolBar; - protected ToolItem browseItem; - - protected List invalidNames; - - // TODO (cs) rename this field to extensionSchemaLocation in WTP 2.0 - protected String appInfoSchemaLocation; - protected String categoryName; - protected CLabel errDisplayer; - protected boolean isCategoryNameValid; - protected boolean fromCatalog; - - private boolean canOK =false; - - /** Either the location if come from workspace or namespace if come from - * XML Catalog */ - protected String source; - - public AddNewCategoryDialog(Shell parentShell) - { - super(parentShell); - } - - public AddNewCategoryDialog(Shell parentShell, String dialogTitle) - { - super(parentShell); - this.dialogTitle = dialogTitle; - } - - /** - * receive a List of names which have already been added to the category list - * - * @param unavailNames - * Array of unvailable names - */ - public void setUnavailableCategoryNames(List unavailNames) - { - invalidNames = unavailNames; - } - - public String getNewCategoryName() - { - return categoryName.trim(); - } - - public String getCategoryLocation() - { - return appInfoSchemaLocation; - } - - public void setCategoryLocation(String s){ - appInfoSchemaLocation = s; - } - - /** @deprecated */ - public SpecificationForExtensionsSchema getExtensionsSchemaSpec(){ - SpecificationForExtensionsSchema schemaSpec = new SpecificationForExtensionsSchema(); - schemaSpec.setDisplayName(getNewCategoryName()); - schemaSpec.setLocation(getCategoryLocation()); - - return schemaSpec; - } - - public void setCategoryName(String categoryName) { - this.categoryName = categoryName; - } - - public boolean getFromCatalog() { - return fromCatalog; - } - - public void setFromCatalog(boolean b){ - fromCatalog = b; - } - - public String getSource() - { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - protected Control createButtonBar(Composite parent) - { - Control result = super.createButtonBar(parent); - getButton(IDialogConstants.OK_ID).setEnabled(canOK); - return result; - } - - // redudant method to improve speed (according to the compiler) - protected Button getButton(int id) { - return super.getButton(id); - } - - protected Control createDialogArea(Composite parent) - { - getShell().setText(dialogTitle); - - Composite mainComposite = (Composite) super.createDialogArea(parent); - GridLayout layout = new GridLayout(3, false); - layout.marginTop = 10; - mainComposite.setLayout(layout); - mainComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); - GridData data = new GridData(); - data.widthHint = 400; - - mainComposite.setLayoutData(data); - - // Line 1, name - name = new Label(mainComposite, SWT.NONE); - name.setText(NAME_LABEL); - - nameText = new Text(mainComposite, SWT.BORDER | SWT.SINGLE); - nameText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - if (categoryName != null) - nameText.setText(categoryName); - PlatformUI.getWorkbench().getHelpSystem().setHelp(nameText, - XSDEditorCSHelpIds.ADD_CATEGORY__NAME); - - Button hidden = new Button(mainComposite, SWT.NONE); - hidden.setVisible(false); - - // Line 2, schema - schema = new Label(mainComposite, SWT.NONE); - schema.setText(SCHEMA_LABEL); - - schemaDisplayer = new CLabel(mainComposite, SWT.BORDER | SWT.SINGLE); - schemaDisplayer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - if (source != null) - { - if (fromCatalog) - schemaDisplayer.setImage( - XSDEditorPlugin.getXSDImage("icons/xmlcatalog_obj.gif")); //$NON-NLS-1$ - else - schemaDisplayer.setImage( - XSDEditorPlugin.getXSDImage("icons/XSDFile.gif")); //$NON-NLS-1$ - schemaDisplayer.setText(source); - - } - PlatformUI.getWorkbench().getHelpSystem().setHelp(schemaDisplayer, - XSDEditorCSHelpIds.ADD_CATEGORY__SCHEMA); - - if (categoryName != null && source != null) - canOK = true; - - browseToolBar = new ToolBar(mainComposite, SWT.FLAT); - browseItem = new ToolItem(browseToolBar, SWT.NONE); - // TODO: Should be able to get the image from the XML plugin. Don't need - // to copy to XSDEditor icons folder like this. - browseItem.setImage(XSDEditorPlugin.getXSDImage("icons/appinfo_browse.gif")); //$NON-NLS-1$ - - browseMenu = new MenuManager(); - - BrowseInWorkspaceAction browseInWorkspace = new BrowseInWorkspaceAction(); - browseMenu.add(browseInWorkspace); - - BrowseCatalogAction browseCatalog = new BrowseCatalogAction(); - browseMenu.add(browseCatalog); - - browseItem.addSelectionListener(new SelectionAdapter() - { - public void widgetSelected(SelectionEvent e) - { - Menu menu = browseMenu.createContextMenu(getShell()); - Rectangle bounds = browseItem.getBounds(); - Point topLeft = new Point(bounds.x, bounds.y + bounds.height); - topLeft = browseToolBar.toDisplay(topLeft); - menu.setLocation(topLeft.x, topLeft.y); - menu.setVisible(true); - } - }); - - // Composite errComp = new Composite(mainComposite, SWT.NONE); - // errComp.setBackground(org.eclipse.draw2d.ColorConstants.white); - // errComp.setLayout(new GridLayout()); - errDisplayer = new CLabel(mainComposite, SWT.FLAT); - // errDisplayer.setText("abd"); - GridData gd = new GridData(GridData.FILL_BOTH); - gd.grabExcessHorizontalSpace = true; - gd.horizontalSpan = 3; - errDisplayer.setLayoutData(gd); - - // errComp.setLayoutData(gd); - // errDisplayer.setLayoutData(gd); - // errMsgContainer.setContent(errDisplayer); - - nameText.addModifyListener(new ModifyListener() - { - // track the nameText and enable/disable the OK button accordingly - public void modifyText(ModifyEvent e) - { - categoryName = nameText.getText(); - - // name is in the invalid List - if (invalidNames != null) - { - if (invalidNames.contains(categoryName.trim())) - { - isCategoryNameValid = false; - - getButton(IDialogConstants.OK_ID).setEnabled(false); - errDisplayer.setText(Messages._UI_ERROR_NAME_ALREADY_USED); - errDisplayer.setImage(XSDEditorPlugin.getXSDImage("icons/error_st_obj.gif")); //$NON-NLS-1$ - return; - } - } - // name is empty string - if (categoryName.equals("")) //$NON-NLS-1$ - { - isCategoryNameValid = false; - - getButton(IDialogConstants.OK_ID).setEnabled(false); - errDisplayer.setText(""); //$NON-NLS-1$ - errDisplayer.setImage(null); - return; - } - - /* - * Enable the Ok button if the location field AND the name field are not - * empty - */ - if (!categoryName.equals("")) //$NON-NLS-1$ - { - isCategoryNameValid = true; - errDisplayer.setText(""); //$NON-NLS-1$ - errDisplayer.setImage(null); - } - if (!appInfoSchemaLocation.equals("")) //$NON-NLS-1$ - { - getButton(IDialogConstants.OK_ID).setEnabled(true); - } - } - }); - - return parent; - } - - protected void okPressed() - { - super.okPressed(); - } - - protected class BrowseInWorkspaceAction extends Action - { - private static final String XSD_FILE_EXTENSION = ".xsd"; //$NON-NLS-1$ - - public BrowseInWorkspaceAction() - { - super(Messages._UI_ACTION_BROWSE_WORKSPACE); - } - - public void run() - { - SelectSingleFileDialog dialog = new SelectSingleFileDialog(getShell(), null, true); - dialog.addFilterExtensions(new String[] { XSD_FILE_EXTENSION }); - dialog.create(); - dialog.setTitle(Messages._UI_LABEL_SELECT_XSD_FILE); - dialog.setMessage(Messages._UI_DESCRIPTION_CHOOSE_XSD_FILE); - - if (dialog.open() == Window.OK) - { - IFile appInfoSchemaFile = dialog.getFile(); - if (appInfoSchemaFile != null) - { - // remove leading slash from the value to avoid the - // whole leading slash ambiguity problem - String uri = appInfoSchemaFile.getFullPath().toString(); - while (uri.startsWith("/") || uri.startsWith("\\")) { //$NON-NLS-1$ //$NON-NLS-2$ - uri = uri.substring(1); - } - appInfoSchemaLocation = uri.toString(); - source = uri; - fromCatalog = false; - - appInfoSchemaLocation = "file://" + Platform.getLocation().toString() + "/" + appInfoSchemaLocation; //$NON-NLS-1$ //$NON-NLS-2$ - // TODO... be careful how we construct the location - // UNIX related issues here - - schemaDisplayer.setImage(XSDEditorPlugin.getXSDImage("icons/XSDFile.gif")); //$NON-NLS-1$ - schemaDisplayer.setText(uri); - - // Enable the OK button if we should.. - if (isCategoryNameValid) - { - getButton(IDialogConstants.OK_ID).setEnabled(true); - errDisplayer.setText(""); //$NON-NLS-1$ - errDisplayer.setImage(null); - } - } - } - } - } - - protected class BrowseCatalogAction extends Action - { - public BrowseCatalogAction() - { - super(Messages._UI_ACTION_BROWSE_CATALOG); - } - - public void run() - { - SelectFromCatalogDialog dialog = new SelectFromCatalogDialog(getShell()); - // dialog.open(); - if (dialog.open() == Window.OK) - { - appInfoSchemaLocation = dialog.getCurrentSelectionLocation(); - source = dialog.getCurrentSelectionNamespace(); - fromCatalog = true; - - schemaDisplayer.setImage(XSDEditorPlugin.getXSDImage("icons/xmlcatalog_obj.gif")); //$NON-NLS-1$ - schemaDisplayer.setText(dialog.getCurrentSelectionNamespace()); - - // Enable the OK button if we should.. - if (isCategoryNameValid && !appInfoSchemaLocation.equals("")) //$NON-NLS-1$ - { - getButton(IDialogConstants.OK_ID).setEnabled(true); - errDisplayer.setText(""); //$NON-NLS-1$ - errDisplayer.setImage(null); - } - } - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/CategoryProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/CategoryProvider.java deleted file mode 100644 index a3eb64a376..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/CategoryProvider.java +++ /dev/null @@ -1,81 +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.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.ArrayList; -import java.util.List; - -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; - -public class CategoryProvider -{ - private ICatalog systemCatalog; - - public CategoryProvider() - { - - } - - /** - * Extenders should implement and return a list of - * SpecificationForExtensionsSchema - * @return - */ - public List getCategories() - { - return new ArrayList(); - } - - /** - * Helper method to find the physical location of the schema - * in the XML Catalog - * @param namespaceURI - * @return physical location of the schema - */ - public String locateFileUsingCatalog(String namespaceURI) - { - retrieveCatalog(); - - ICatalogEntry[] entries = systemCatalog.getCatalogEntries(); - for (int i = 0; i < entries.length; i++) - { - if (entries[i].getKey().equals(namespaceURI)) - return entries[i].getURI(); - } - - return null; - } - - private void retrieveCatalog() - { - if (systemCatalog != null) - return; - - 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.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) - { - systemCatalog = referencedCatalog; - } - } - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionDetailsContentProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionDetailsContentProvider.java deleted file mode 100644 index c759d927ee..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionDetailsContentProvider.java +++ /dev/null @@ -1,201 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import java.text.Collator; -import java.util.Arrays; -import java.util.Collection; -import java.util.Comparator; -import java.util.HashMap; -import java.util.Iterator; -import java.util.List; -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.modelquery.ModelQuery; -import org.eclipse.wst.xml.core.internal.modelquery.ModelQueryUtil; -import org.eclipse.wst.xml.ui.internal.tabletree.TreeContentHelper; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.DefaultListNodeEditorConfiguration; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.NodeCustomizationRegistry; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.NodeEditorConfiguration; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.NodeEditorProvider; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; - -public class DOMExtensionDetailsContentProvider implements ExtensionDetailsContentProvider -{ - private static final Object[] EMPTY_ARRAY = {}; - private static final String[] EMPTY_STRING_ARRAY = {}; - private static final String XMLNS = "xmlns"; //$NON-NLS - private static final String TEXT_NODE_KEY = "text()"; //$NON-NLS - - public Object[] getItems(Object input) - { - HashMap resultMap = new HashMap(); - if (input instanceof Element) - { - Element element = (Element) input; - - // here we compute items for the attributes that physically in the document - // - NamedNodeMap attributes = element.getAttributes(); - for (int i = 0; i < attributes.getLength(); i++) - { - Attr attr = (Attr) attributes.item(i); - if (!XMLNS.equals(attr.getName()) && !XMLNS.equals(attr.getPrefix())) //$NON-NLS-1$ //$NON-NLS-2$ - { - resultMap.put(attr.getName(), DOMExtensionItem.createItemForElementAttribute(element, attr)); - } - } - - // here we compute an item for the text node that is physically in the document - // - String textNodeValue = new TreeContentHelper().getNodeValue(element); - if (textNodeValue != null) - { - resultMap.put(TEXT_NODE_KEY, DOMExtensionItem.createItemForElementText(element)); - } - - ModelQuery modelQuery = ModelQueryUtil.getModelQuery(element.getOwnerDocument()); - if (modelQuery != null) - { - CMElementDeclaration ed = modelQuery.getCMElementDeclaration(element); - if (ed != null) - { - // here we compute items for the attributes that may be added to the document according to the grammar - // - List list = modelQuery.getAvailableContent(element, ed, ModelQuery.INCLUDE_ATTRIBUTES); - for (Iterator i = list.iterator(); i.hasNext(); ) - { - CMAttributeDeclaration ad = (CMAttributeDeclaration)i.next(); - if (ad != null && resultMap.get(ad.getNodeName()) == null) - { - resultMap.put(ad.getNodeName(), DOMExtensionItem.createItemForElementAttribute(element, ad)); - } - } - if (resultMap.get(TEXT_NODE_KEY) == null) - { - // here we compute an item for the text node that may be added to the document according to the grammar - // - int contentType = ed.getContentType(); - if (contentType == CMElementDeclaration.PCDATA || contentType == CMElementDeclaration.MIXED) - { - resultMap.put(TEXT_NODE_KEY, DOMExtensionItem.createItemForElementText(element)); - } - } - } - } - Collection collection = resultMap.values(); - // initialize the editor information for each item - // - for (Iterator i = collection.iterator(); i.hasNext();) - { - initPropertyEditorConfiguration((DOMExtensionItem) i.next()); - } - DOMExtensionItem[] items = new DOMExtensionItem[collection.size()]; - resultMap.values().toArray(items); - - // here we sort the list alphabetically - // - if (items.length > 0) - { - Comparator comparator = new Comparator() - { - public int compare(Object arg0, Object arg1) - { - DOMExtensionItem a = (DOMExtensionItem)arg0; - DOMExtensionItem b = (DOMExtensionItem)arg1; - - // begin special case to ensure 'text nodes' come last - if (a.isTextValue() && !b.isTextValue()) - { - return 1; - } - else if (b.isTextValue() && !a.isTextValue()) - { - return -1; - } - // end special case - else - { - return Collator.getInstance().compare(a.getName(), b.getName()); - } - } - }; - Arrays.sort(items, comparator); - } - return items; - } - else if (input instanceof Attr) - { - Attr attr = (Attr) input; - DOMExtensionItem item = DOMExtensionItem.createItemForAttributeText(attr.getOwnerElement(), attr); - DOMExtensionItem[] items = {item}; - return items; - } - return EMPTY_ARRAY; - } - - public String getName(Object item) - { - if (item instanceof DOMExtensionItem) - { - return ((DOMExtensionItem) item).getName(); - } - return ""; //$NON-NLS-1$ - } - - public String getValue(Object item) - { - if (item instanceof DOMExtensionItem) - { - return ((DOMExtensionItem) item).getValue(); - } - return ""; //$NON-NLS-1$ - } - - public String[] getPossibleValues(Object item) - { - if (item instanceof DOMExtensionItem) - { - return ((DOMExtensionItem) item).getPossibleValues(); - } - return EMPTY_STRING_ARRAY; - } - - protected void initPropertyEditorConfiguration(DOMExtensionItem item) - { - String namespace = item.getNamespace(); - String name = item.getName(); - String parentName = item.getParentName(); - NodeEditorConfiguration configuration = null; - if (namespace != null) - { - // TODO (cs) remove reference to XSDEditorPlugin... make generic - // perhaps push down the xml.ui ? - // - NodeCustomizationRegistry registry = XSDEditorPlugin.getDefault().getNodeCustomizationRegistry(); - NodeEditorProvider provider= registry.getNodeEditorProvider(namespace); - if (provider != null) - { - configuration = provider.getNodeEditorConfiguration(parentName, name); - if (configuration != null) - { - configuration.setParentNode(item.getParentNode()); - if (item.getNode() != null) - { - configuration.setNode(item.getNode()); - } - } - } - } - String[] values = item.getPossibleValues(); - if (values != null && values.length > 1) - { - configuration = new DefaultListNodeEditorConfiguration(values); - } - - // Note that it IS expected that the configaration may be null - // - item.setPropertyEditorConfiguration(configuration); - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItem.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItem.java deleted file mode 100644 index d34a07d8c5..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItem.java +++ /dev/null @@ -1,216 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; -import org.eclipse.gef.commands.Command; -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.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.tabletree.TreeContentHelper; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateAttributeValueCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.UpdateTextValueCommand; -import org.w3c.dom.Attr; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -class DOMExtensionItem extends ExtensionItem -{ - private final static int KIND_ELEMENT_ATTR = 1; - private final static int KIND_ELEMENT_TEXT = 2; - private final static int KIND_ELEMENT_CMATTRIBUTE = 3; - private final static int KIND_ATTR_TEXT = 4; - int kind; - Attr attribute; - Element parent; - CMNode cmNode; - - private DOMExtensionItem(int kind, Element parent, Attr node, CMNode cmNode) - { - this.kind = kind; - this.parent = parent; - this.attribute = node; - this.cmNode = cmNode; - } - - public boolean isTextValue() - { - return kind == KIND_ELEMENT_TEXT || kind == KIND_ATTR_TEXT; - } - - static DOMExtensionItem createItemForElementText(Element parent) - { - return new DOMExtensionItem(KIND_ELEMENT_TEXT, parent, null, null); - } - - static DOMExtensionItem createItemForElementAttribute(Element parent, Attr attribute) - { - return new DOMExtensionItem(KIND_ELEMENT_ATTR, parent, attribute, null); - } - - static DOMExtensionItem createItemForElementAttribute(Element parent, CMAttributeDeclaration ad) - { - if (ad == null) - { - System.out.println("null!"); - } - return new DOMExtensionItem(KIND_ELEMENT_CMATTRIBUTE, parent, null, ad); - } - - static DOMExtensionItem createItemForAttributeText(Element parent, Attr attribute) - { - return new DOMExtensionItem(KIND_ATTR_TEXT, parent, attribute, null); - } - - public String getName() - { - String result = null; - switch (kind) - { - case KIND_ATTR_TEXT : { - result = "value"; - break; - } - case KIND_ELEMENT_ATTR : { - result = attribute.getName(); - break; - } - case KIND_ELEMENT_CMATTRIBUTE : { - CMAttributeDeclaration ad = (CMAttributeDeclaration) cmNode; - result = ad.getNodeName(); - break; - } - case KIND_ELEMENT_TEXT : { - result = "text value"; - break; - } - } - return result != null ? result : ""; - } - - public String getValue() - { - switch (kind) - { - case KIND_ATTR_TEXT : - case KIND_ELEMENT_ATTR : { - // note intentional fall-thru!! - return attribute.getNodeValue(); - } - case KIND_ELEMENT_CMATTRIBUTE : { - // CS : one would think that we'd just need to return "" here - // but after editing a item of this kind and giving it value - // the list of item's doesn't get recomputed.. so we need to trick - // one of these items to behave like the KIND_ELEMENT_ATTR case - // - String value = parent.getAttribute(cmNode.getNodeName()); - return (value != null) ? value : ""; - } - case KIND_ELEMENT_TEXT : { - return new TreeContentHelper().getElementTextValue(parent); - } - } - return ""; - } - - - public String[] getPossibleValues() - { - String[] result = {}; - - switch (kind) - { - case KIND_ATTR_TEXT : - case KIND_ELEMENT_ATTR : { - // note intentional fall-thru!! - ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument()); - if (modelQuery != null) - { - CMAttributeDeclaration ad = modelQuery.getCMAttributeDeclaration(attribute); - if (ad != null) - { - result = modelQuery.getPossibleDataTypeValues(parent, ad); - } - } - break; - } - case KIND_ELEMENT_CMATTRIBUTE : { - ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument()); - if (modelQuery != null && cmNode != null) - { - result = modelQuery.getPossibleDataTypeValues(parent, cmNode); - } - break; - } - case KIND_ELEMENT_TEXT : { - ModelQuery modelQuery = ModelQueryUtil.getModelQuery(parent.getOwnerDocument()); - if (modelQuery != null) - { - CMElementDeclaration ed = modelQuery.getCMElementDeclaration(parent); - if (ed != null) - { - result = modelQuery.getPossibleDataTypeValues(parent, ed); - } - } - break; - } - } - return result; - } - - public Command getUpdateValueCommand(String newValue) - { - switch (kind) - { - case KIND_ATTR_TEXT : - case KIND_ELEMENT_ATTR : { - // note intentional fall-thru!! - return new UpdateAttributeValueCommand(parent, attribute.getNodeName(), newValue, true); - } - case KIND_ELEMENT_CMATTRIBUTE : { - final CMAttributeDeclaration ad = (CMAttributeDeclaration) cmNode; - return new UpdateAttributeValueCommand(parent, ad.getAttrName(), newValue, true); - } - case KIND_ELEMENT_TEXT : { - return new UpdateTextValueCommand(parent, newValue); - } - } - return null; - } - - public String getNamespace() - { - String namespace = null; - if (kind == KIND_ATTR_TEXT) - { - namespace = attribute.getNamespaceURI(); - } - else if (parent != null) - { - namespace = parent.getNamespaceURI(); - } - return namespace; - } - - public Node getParentNode() - { - Node parentNode = null; - if (attribute != null) - { - parentNode = attribute.getOwnerElement(); - } - else if (parent != null) - { - parentNode = parent; - } - return parentNode; - } - - public String getParentName() - { - Node parentNode = getParentNode(); - return parentNode != null ? parentNode.getLocalName() : ""; - } - - public Node getNode() - { - return attribute; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemEditManager.java deleted file mode 100644 index d069b8f838..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemEditManager.java +++ /dev/null @@ -1,40 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -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.Widget; - - -/** - * @deprecated - */ -public class DOMExtensionItemEditManager implements ExtensionItemEditManager -{ - public void handleEdit(Object item, Widget widget) - { - } - - public Control createCustomButtonControl(Composite composite, Object item) - { - Button button = new Button(composite, SWT.NONE); - button.setText("..."); //$NON-NLS-1$ - return button; - } - - public Control createCustomTextControl(Composite composite, Object item) - { - return null; - } - - public String getButtonControlStyle(Object object) - { - return ExtensionItemEditManager.STYLE_NONE; - } - - public String getTextControlStyle(Object object) - { - return ExtensionItemEditManager.STYLE_NONE; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemMenuListener.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemMenuListener.java deleted file mode 100644 index 1c8bcf55d9..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionItemMenuListener.java +++ /dev/null @@ -1,117 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.ArrayList; -import java.util.List; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IMenuListener; -import org.eclipse.jface.action.IMenuManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.TreeViewer; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; -import org.eclipse.wst.xml.core.internal.contentmodel.CMElementDeclaration; -import org.eclipse.wst.xml.core.internal.contentmodel.modelquery.ModelQuery; -import org.eclipse.wst.xml.core.internal.document.ElementImpl; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.ui.internal.contentoutline.XMLNodeActionManager; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class DOMExtensionItemMenuListener implements IMenuListener -{ - TreeViewer treeViewer; - - public DOMExtensionItemMenuListener(TreeViewer treeViewer) - { - this.treeViewer = treeViewer; - } - - public void menuAboutToShow(IMenuManager manager) - { - manager.removeAll(); - ISelection selection = treeViewer.getSelection(); - if (selection instanceof IStructuredSelection) - { - IStructuredSelection structuredSelection = (IStructuredSelection) selection; - if (structuredSelection.getFirstElement() instanceof ElementImpl) - { - ElementImpl elementImpl = (ElementImpl) structuredSelection.getFirstElement(); - IDOMDocument domDocument = (IDOMDocument) elementImpl.getOwnerDocument(); - InternalNodeActionManager actionManager = new InternalNodeActionManager(domDocument.getModel(), treeViewer); - actionManager.fillContextMenu(manager, structuredSelection); - } - } - } - - - class InternalNodeActionManager extends XMLNodeActionManager - { - public InternalNodeActionManager(IStructuredModel model, Viewer viewer) - { - super(model, viewer); - } - - public void contributeActions(IMenuManager menu, List selection) - { - //menu.add(new Action("there"){}); - try - { - 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() == 1) - { - Node node = (Node) selection.get(0); - // contribute add child actions - contributeAddChildActions(menu, node, ic, vc); - } - if (selection.size() > 0) - { - implicitlySelectedNodeList = getSelectedNodes(selection, true); - // contribute delete actions - contributeDeleteActions(menu, implicitlySelectedNodeList, ic, vc); - } - } - catch(Exception e) - { - menu.add(new Action(e.getMessage()){}); - } - /* - if (selection.size() > 0) - { - // contribute replace actions - contributeReplaceActions(menu, implicitlySelectedNodeList, ic, vc); - }*/ - } - - 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; - MyMenuManager newMenu = new MyMenuManager("New"){ - public boolean isVisible() { return true; } - };//$NON-NLS-1$ - newMenu.setVisible(true); - menu.add(newMenu); - - CMElementDeclaration ed = modelQuery.getCMElementDeclaration(element); - if (ed != null) - { - List modelQueryActionList = new ArrayList(); - // add insert child node actions - // - modelQueryActionList = new ArrayList(); - modelQuery.getInsertActions(element, ed, -1, ic, vc, modelQueryActionList); - addActionHelper(newMenu, modelQueryActionList); - } - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeContentProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeContentProvider.java deleted file mode 100644 index 4f2d62c1c4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeContentProvider.java +++ /dev/null @@ -1,73 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.ArrayList; -import java.util.Collections; -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.w3c.dom.Element; -import org.w3c.dom.Node; - -public class DOMExtensionTreeContentProvider implements ITreeContentProvider, INodeAdapter -{ - protected String facet; - protected Viewer viewer; - - public void inputChanged(Viewer viewer, Object oldInput, Object newInput) - { - this.viewer = viewer; - } - - public Object[] getChildren(Object parentElement) - { - if (parentElement instanceof Element) - { - Element element = (Element)parentElement; - ArrayList list = new ArrayList(); - for (Node node = element.getFirstChild(); node != null; node = node.getNextSibling()) - { - if (node.getNodeType() == Node.ELEMENT_NODE) - { - list.add(node); - } - } - return list.toArray(); - } - return Collections.EMPTY_LIST.toArray(); - } - - public boolean hasChildren(Object element) - { - Object[] children = getChildren(element); - return children.length > 0; - } - - public Object getParent(Object element) - { - return null; - } - - public java.lang.Object[] getElements(java.lang.Object inputElement) - { - return getChildren(inputElement); - } - - public void dispose() - { - } - - public void notifyChanged(INodeNotifier notifier, int eventType, Object changedFeature, Object oldValue, Object newValue, int pos) - { - if (viewer != null) - { - viewer.refresh(); - } - } - - public boolean isAdapterForType(Object type) - { - // this method is not used - return false; - } -} \ No newline at end of file diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeLabelProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeLabelProvider.java deleted file mode 100644 index 55e7854426..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/DOMExtensionTreeLabelProvider.java +++ /dev/null @@ -1,78 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.NodeCustomizationRegistry; -import org.eclipse.wst.xsd.ui.internal.editor.XSDEditorPlugin; -import org.w3c.dom.Attr; -import org.w3c.dom.DOMException; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.Text; - -public class DOMExtensionTreeLabelProvider extends LabelProvider -{ - protected static final Image DEFAULT_ELEMENT_ICON = XSDEditorPlugin.getXSDImage("icons/XSDElement.gif"); //$NON-NLS-1$ - protected static final Image DEFAULT_ATTR_ICON = XSDEditorPlugin.getXSDImage("icons/XSDAttribute.gif"); //$NON-NLS-1$ - - public DOMExtensionTreeLabelProvider() - { - } - - public Image getImage(Object element) - { - NodeCustomizationRegistry registry = XSDEditorPlugin.getDefault().getNodeCustomizationRegistry(); - if (element instanceof Element) - { - Element domElement = (Element) element; - String namespace = domElement.getNamespaceURI(); - if (namespace != null) - { - ILabelProvider lp = registry.getLabelProvider(namespace); - if (lp != null) - { - Image img = lp.getImage(domElement); - if (img != null) - return img; - } - } - return DEFAULT_ELEMENT_ICON; - } - if (element instanceof Attr) - return DEFAULT_ATTR_ICON; - return null; - } - - public String getText(Object input) - { - if (input instanceof Element) - { - Element domElement = (Element) input; - String textVal = ""; - - if (domElement.hasChildNodes()) - { - Node node = domElement.getChildNodes().item(0); - if (node instanceof Text) - { - Text textNode = (Text) node; - try - { - if (!textNode.getNodeValue().contains("\n")) - textVal = " [" + textNode.getNodeValue() + "]"; - } - catch (DOMException e) - { - textVal = ""; - } - } - } - return domElement.getLocalName() + textVal; - } - if ( input instanceof Attr){ - return ((Attr) input).getLocalName(); - } - return ""; //$NON-NLS-1$ - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsContentProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsContentProvider.java deleted file mode 100644 index 254d105ce4..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsContentProvider.java +++ /dev/null @@ -1,9 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -public interface ExtensionDetailsContentProvider -{ - Object[] getItems(Object input); - String getName(Object item); - String getValue(Object item); - String[] getPossibleValues(Object item); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsViewer.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsViewer.java deleted file mode 100644 index e352bf0d10..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionDetailsViewer.java +++ /dev/null @@ -1,269 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import org.eclipse.draw2d.ColorConstants; -import org.eclipse.gef.commands.Command; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.Viewer; -import org.eclipse.swt.SWT; -import org.eclipse.swt.custom.CCombo; -import org.eclipse.swt.events.FocusEvent; -import org.eclipse.swt.events.FocusListener; -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.swt.widgets.Label; -import org.eclipse.swt.widgets.Text; -import org.eclipse.swt.widgets.Widget; -import org.eclipse.ui.views.properties.tabbed.TabbedPropertySheetWidgetFactory; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.DialogNodeEditorConfiguration; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.ListNodeEditorConfiguration; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.NodeEditorConfiguration; - -public class ExtensionDetailsViewer extends Viewer -{ - private final static String ITEM_DATA = "ITEM_DATA"; //$NON-NLS-1$ - private final static String EDITOR_CONFIGURATION_DATA = "EDITOR_CONFIGURATION_DATA"; //$NON-NLS-1$ - - Composite control; - Composite composite; - ExtensionDetailsContentProvider contentProvider; - TabbedPropertySheetWidgetFactory widgetFactory; - InternalControlListener internalControlListener; - - public ExtensionDetailsViewer(Composite parent, TabbedPropertySheetWidgetFactory widgetFactory) - { - this.widgetFactory = widgetFactory; - control = widgetFactory.createComposite(parent); - internalControlListener = new InternalControlListener(); - control.setLayout(new GridLayout()); - } - public Control getControl() - { - return control; - } - - - public Object getInput() - { - // TODO Auto-generated method stub - return null; - } - - public ISelection getSelection() - { - // TODO Auto-generated method stub - return null; - } - - public void refresh() - { - Control[] children = composite.getChildren(); - for (int i = 0; i < children.length; i++) - { - Control control = children[i]; - if (control instanceof Text) - { - ExtensionItem item = (ExtensionItem)control.getData(ITEM_DATA); - String value = contentProvider.getValue(item); - ((Text)control).setText(value); - } - } - } - - private void createTextOrComboControl(ExtensionItem item, Composite composite) - { - Control control = null; - String value = contentProvider.getValue(item); - NodeEditorConfiguration editorConfiguration = item.getPropertyEditorConfiguration(); - - if (editorConfiguration != null && hasStyle(editorConfiguration, NodeEditorConfiguration.STYLE_COMBO)) - { - ListNodeEditorConfiguration configuration = (ListNodeEditorConfiguration)editorConfiguration; - CCombo combo = widgetFactory.createCCombo(composite); - combo.setText(value); - Object[] values = configuration.getValues(item); - LabelProvider labelProvider = configuration.getLabelProvider(); - for (int j = 0; j < values.length; j++) - { - Object o = values[j]; - String displayName = labelProvider != null ? - labelProvider.getText(o) : - o.toString(); - combo.add(displayName); - } - control = combo; - } - if (control == null) - { - Text text = widgetFactory.createText(composite,value); - control = text; - } - control.setData(ITEM_DATA, item); - control.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - control.addFocusListener(internalControlListener); - } - - private void createButtonControl(ExtensionItem item, Composite composite) - { - NodeEditorConfiguration editorConfiguration = item.getPropertyEditorConfiguration(); - if (editorConfiguration != null && hasStyle(editorConfiguration, NodeEditorConfiguration.STYLE_DIALOG)) - { - DialogNodeEditorConfiguration configuration = (DialogNodeEditorConfiguration)editorConfiguration; - Button button = new Button(composite, SWT.NONE); - GridData gridData = new GridData(); - gridData.heightHint = 17; - button.setLayoutData(gridData); - button.addSelectionListener(internalControlListener); - button.setData(ITEM_DATA, item); - button.setData(EDITOR_CONFIGURATION_DATA, configuration); - String text = configuration.getButonText(); - if (text != null) - { - button.setText(text); //$NON-NLS-1$ - } - button.setImage(configuration.getButtonImage()); - } - else - { - Control placeHolder = new Label(composite, SWT.NONE); - placeHolder.setVisible(false); - placeHolder.setEnabled(false); - placeHolder.setLayoutData(new GridData()); - } - } - - public void setInput(Object input) - { - // TODO (cs) add assertions - // - if (contentProvider == null) - return; - - if (composite != null) - {/* - for (Iterator i = controlsThatWeAreListeningTo.iterator(); i.hasNext(); ) - { - Control control = (Control)i.next(); - if (control != null) - { - control.removeFocusListener(internalFocusListener); - } - } */ - composite.dispose(); - } - - composite = widgetFactory.createComposite(control); - composite.setBackground(ColorConstants.white); - GridLayout gridLayout = new GridLayout(); - gridLayout.numColumns = 3; - composite.setLayout(gridLayout); - composite.setLayoutData(new GridData(GridData.FILL_BOTH)); - - Object[] items = contentProvider.getItems(input); - - for (int i = 0; i < items.length; i++) - { - ExtensionItem item = (ExtensionItem)items[i]; - String name = contentProvider.getName(item); - Label label = widgetFactory.createLabel(composite, name + ":"); //$NON-NLS-1$ - label.setLayoutData(new GridData()); - createTextOrComboControl(item, composite); - createButtonControl(item, composite); - } - control.layout(true); - } - - private boolean hasStyle(NodeEditorConfiguration configuration, int style) - { - return (configuration.getStyle() & style) != 0; - } - - - public void setSelection(ISelection selection, boolean reveal) - { - // TODO Auto-generated method stub - - } - public ExtensionDetailsContentProvider getContentProvider() - { - return contentProvider; - } - public void setContentProvider(ExtensionDetailsContentProvider contentProvider) - { - this.contentProvider = contentProvider; - } - - private void applyEdit(ExtensionItem item, Widget widget) - { - if (item != null) - { - String value = null; - if (widget instanceof Text) - { - Text text = (Text)widget; - value = text.getText(); - } - else if (widget instanceof CCombo) - { - CCombo combo = (CCombo)widget; - int index = combo.getSelectionIndex(); - if (index != -1) - { - value = combo.getItem(index); - } - } - if (value != null) - { - Command command = item.getUpdateValueCommand(value); - if (command != null) - { - // TODO (cs) add command stack handling stuff - command.execute(); - } - } - } - } - - class InternalControlListener implements FocusListener, SelectionListener - { - public void widgetSelected(SelectionEvent e) - { - // for button controls we handle selection events - // - Object item = e.widget.getData(EDITOR_CONFIGURATION_DATA); - if (item instanceof DialogNodeEditorConfiguration) - { - DialogNodeEditorConfiguration dialogNodeEditorConfiguration = (DialogNodeEditorConfiguration)item; - dialogNodeEditorConfiguration.invokeDialog(); - //applyEdit((ExtensionItem)item, e.widget); - } - } - - public void widgetDefaultSelected(SelectionEvent e) - { - // do nothing - } - - public void focusGained(FocusEvent e) - { - } - - public void focusLost(FocusEvent e) - { - // apply edits for text and combo box controls - // via the focusLost event - // TODO (cs) handle explict ENTER key - // - Object item = e.widget.getData(ITEM_DATA); - if (item instanceof ExtensionItem) - { - applyEdit((ExtensionItem)item, e.widget); - } - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItem.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItem.java deleted file mode 100644 index 2b4d880de3..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItem.java +++ /dev/null @@ -1,21 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import org.eclipse.gef.commands.Command; -import org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom.NodeEditorConfiguration; - -public abstract class ExtensionItem -{ - NodeEditorConfiguration propertyEditorConfiguration; - - public NodeEditorConfiguration getPropertyEditorConfiguration() - { - return propertyEditorConfiguration; - } - - public void setPropertyEditorConfiguration(NodeEditorConfiguration propertyEditorConfiguration) - { - this.propertyEditorConfiguration = propertyEditorConfiguration; - } - - public abstract Command getUpdateValueCommand(String newValue); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemEditManager.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemEditManager.java deleted file mode 100644 index 7c03187184..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemEditManager.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.swt.widgets.Widget; - -/** - * @deprecated - */ -public interface ExtensionItemEditManager -{ - public final static String STYLE_NONE = "none"; //$NON-NLS-1$ - public final static String STYLE_TEXT = "text"; //$NON-NLS-1$ - public final static String STYLE_COMBO = "combo"; //$NON-NLS-1$ - public final static String STYLE_CUSTOM = "custom"; //$NON-NLS-1$ - - void handleEdit(Object item, Widget widget); - String getTextControlStyle(Object item); - String getButtonControlStyle(Object item); - Control createCustomTextControl(Composite composite, Object item); - Control createCustomButtonControl(Composite composite, Object item); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemFilter.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemFilter.java deleted file mode 100644 index c64970c383..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionItemFilter.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import org.eclipse.xsd.XSDConcreteComponent; - -// cs: This interface is intended to suppliment the NodeFilter class -// that can be specified via the customization extensions point. -// When the initial list of a category's objects is displayed -// we'll use a NodeFilter to prune the list. If the NodeFilter -// implements this interface we'll call this interface's isApplicableContext -// method instead of the NodeFilter's DOM node based method. This provides -// are a more convenient interface for clients who are only interested in -// filter the list presented via the AddExtensionComponentDialog. -// See the class ExtensionsSection for more details. -// -public interface ExtensionItemFilter -{ - public boolean isApplicableContext(XSDConcreteComponent parent, XSDConcreteComponent candidate); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionsSchemasRegistry.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionsSchemasRegistry.java deleted file mode 100644 index 6c98ddd3bb..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/ExtensionsSchemasRegistry.java +++ /dev/null @@ -1,361 +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.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; -import java.util.StringTokenizer; - -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.viewers.ILabelProvider; -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.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand; -import org.w3c.dom.Element; - -public class ExtensionsSchemasRegistry -{ - public static final String USER_ADDED_EXT_SCHEMAS = "USER-ADDED-EXT-SCHEMAS"; // TODO externalize - private static final String LOCATION_PREFIX = "platform:/plugin/"; //$NON-NLS-1$ - public static final String DESCRIPTION = "description"; //$NON-NLS-1$ - public static final String DISPLAYNAME = "displayName"; //$NON-NLS-1$ - public static final String NAMESPACEURI = "namespaceURI"; //$NON-NLS-1$ - public static final String XSDFILEURL = "xsdFileURL"; //$NON-NLS-1$ - public static final String LABELPROVIDER = "labelProviderClass"; //$NON-NLS-1$ - public static final String ADD_COMMAND_CLASS = "addCommandClass"; //$NON-NLS-1$ - public static final String DELETE_COMMAND_CLASS = "deleteCommandClass"; //$NON-NLS-1$ - public static final String CATEGORY_PROVIDER_CLASS = "class"; //$NON-NLS-1$ - - protected IPreferenceStore prefStore; - protected String extensionId; - - protected ArrayList nsURIProperties, categoryProviderList; - private ICatalog systemCatalog; - private String deprecatedExtensionId; - - public ExtensionsSchemasRegistry(String appinfo_extensionid) - { - extensionId = appinfo_extensionid; - } - - public void __internalSetDeprecatedExtensionId(String deprecatedId) - { - deprecatedExtensionId = deprecatedId; - } - - public void setPrefStore(IPreferenceStore store) - { - prefStore = store; - } - - public List getAllExtensionsSchemasContribution() - { - // If we read the registry, then let's not do it again. - if (nsURIProperties != null) - { - return nsURIProperties; - } - - nsURIProperties = new ArrayList(); - categoryProviderList = new ArrayList(); - - getAllExtensionsSchemasContribution(extensionId); - if (deprecatedExtensionId != null) - { - getAllExtensionsSchemasContribution(deprecatedExtensionId); - } - - // get user-added schemas stored in preference - if (prefStore != null) - { - String value = prefStore.getString(USER_ADDED_EXT_SCHEMAS); - StringTokenizer tokenizer = new StringTokenizer(value, "\n"); - - while ( tokenizer.hasMoreTokens() ) - { - nsURIProperties.add( new SpecificationForExtensionsSchema( tokenizer.nextToken() ) ); - } - } - - return nsURIProperties; - } - - private List getAllExtensionsSchemasContribution(String id) - { - IConfigurationElement[] asiPropertiesList = Platform.getExtensionRegistry().getConfigurationElementsFor(id); - - boolean hasASIProperties = (asiPropertiesList != null) && (asiPropertiesList.length > 0); - - if (hasASIProperties) - { - for (int i = 0; i < asiPropertiesList.length; i++) - { - IConfigurationElement asiPropertiesElement = asiPropertiesList[i]; - String elementName = asiPropertiesElement.getName(); - - if ("category".equals(elementName)) - { - String description = asiPropertiesElement.getAttribute(DESCRIPTION); - String displayName = asiPropertiesElement.getAttribute(DISPLAYNAME); - String namespaceURI = asiPropertiesElement.getAttribute(NAMESPACEURI); - String xsdFileURL = asiPropertiesElement.getAttribute(XSDFILEURL); - String labelProviderClass = asiPropertiesElement.getAttribute(LABELPROVIDER); - String addCommandClass = asiPropertiesElement.getAttribute(ADD_COMMAND_CLASS); - String deleteCommandClass = asiPropertiesElement.getAttribute(DELETE_COMMAND_CLASS); - - if (displayName == null) - { - // If there is no display name, force the user - // to manually create a name. Therefore, we ignore entry without - // a display name. - continue; - } - - if (xsdFileURL == null) - { - xsdFileURL = locateFileUsingCatalog(namespaceURI); - } - - SpecificationForExtensionsSchema extensionsSchemaSpec = createEntry(); - extensionsSchemaSpec.setDescription(description); - extensionsSchemaSpec.setDisplayName(displayName); - extensionsSchemaSpec.setNamespaceURI(namespaceURI); - extensionsSchemaSpec.setDefautSchema(); - - String pluginId = asiPropertiesElement.getDeclaringExtension().getContributor().getName(); - - if (labelProviderClass != null) - { - ILabelProvider labelProvider = null; - try - { - Class theClass = Platform.getBundle(pluginId).loadClass(labelProviderClass); - if (theClass != null) - { - labelProvider = (ILabelProvider) theClass.newInstance(); - if (labelProvider != null) - { - extensionsSchemaSpec.setLabelProvider(labelProvider); - } - } - } - catch (Exception e) - { - - } - } - - if (addCommandClass != null) - { - try - { - ExtensibleAddExtensionCommand addCommand = (ExtensibleAddExtensionCommand)asiPropertiesElement.createExecutableExtension(ADD_COMMAND_CLASS); - if (addCommand != null) - { - extensionsSchemaSpec.setExtensibleAddExtensionCommand(addCommand); - } - } - catch (Exception e) - { - } - } - - if (deleteCommandClass != null) - { - try - { - ExtensibleRemoveExtensionNodeCommand deleteCommand = (ExtensibleRemoveExtensionNodeCommand)asiPropertiesElement.createExecutableExtension(DELETE_COMMAND_CLASS); - if (deleteCommand != null) - { - extensionsSchemaSpec.setExtensibleRemoveExtensionNodeCommand(deleteCommand); - } - } - catch (Exception e) - { - } - } - - extensionsSchemaSpec.setLocation(LOCATION_PREFIX + pluginId + "/" + xsdFileURL); //$NON-NLS-1$ - - nsURIProperties.add(extensionsSchemaSpec); - - } - else if ("categoryProvider".equals(elementName)) - { - String categoryProviderClass = asiPropertiesElement.getAttribute(CATEGORY_PROVIDER_CLASS); - - if (categoryProviderClass != null) - { - try - { - CategoryProvider categoryProvider = (CategoryProvider)asiPropertiesElement.createExecutableExtension(CATEGORY_PROVIDER_CLASS); - if (categoryProvider != null) - { - categoryProviderList.add(categoryProvider); - } - } - catch (Exception e) - { - } - } - - } - - } - - } - - return nsURIProperties; - } - - public ExtensibleAddExtensionCommand getAddExtensionCommand(String namespace) - { - // Didn't retrieve the config elements yet. - if (nsURIProperties == null) - { - getAllExtensionsSchemasContribution(); - } - - for (Iterator i = nsURIProperties.iterator(); i.hasNext(); ) - { - SpecificationForExtensionsSchema spec = (SpecificationForExtensionsSchema)i.next(); - String nsURI = spec.getNamespaceURI(); - if (nsURI != null && nsURI.equals(namespace)) - { - return spec.getExtensibleAddExtensionCommand(); - } - } - - for (Iterator i = categoryProviderList.iterator(); i.hasNext(); ) - { - CategoryProvider categoryProvider = (CategoryProvider)i.next(); - for (Iterator j = categoryProvider.getCategories().iterator(); j.hasNext(); ) - { - SpecificationForExtensionsSchema spec = (SpecificationForExtensionsSchema) j.next(); - String namespaceURI = spec.getNamespaceURI(); - if (namespaceURI != null && namespaceURI.equals(namespace)) - { - return spec.getExtensibleAddExtensionCommand(); - } - } - } - - return null; - } - - public ExtensibleRemoveExtensionNodeCommand getRemoveExtensionNodeCommand(String namespace) - { - // Didn't retrieve the config elements yet. - if (nsURIProperties == null) - { - getAllExtensionsSchemasContribution(); - } - - for (Iterator i = nsURIProperties.iterator(); i.hasNext(); ) - { - SpecificationForExtensionsSchema spec = (SpecificationForExtensionsSchema)i.next(); - String nsURI = spec.getNamespaceURI(); - if (nsURI != null && nsURI.equals(namespace)) - { - return spec.getExtensibleRemoveExtensionNodeCommand(); - } - } - - for (Iterator i = categoryProviderList.iterator(); i.hasNext(); ) - { - CategoryProvider categoryProvider = (CategoryProvider)i.next(); - for (Iterator j = categoryProvider.getCategories().iterator(); j.hasNext(); ) - { - SpecificationForExtensionsSchema spec = (SpecificationForExtensionsSchema) j.next(); - String namespaceURI = spec.getNamespaceURI(); - if (namespaceURI != null && namespaceURI.equals(namespace)) - { - return spec.getExtensibleRemoveExtensionNodeCommand(); - } - } - } - - return null; - } - - public List getCategoryProviders() - { - if (nsURIProperties == null) - { - getAllExtensionsSchemasContribution(); - } - - return categoryProviderList; - } - - /** - * @deprecated - */ - public ILabelProvider getLabelProvider(Element element) - { - return null; - } - - public SpecificationForExtensionsSchema createEntry() - { - return new SpecificationForExtensionsSchema(); - } - - /** - * Returns the String location for the schema with the given namespaceURI by - * looking at the XML catalog. We look only in the plugin specified entries of - * the catalog. - * - * @param namespaceURI - * @return String representing the location of the schema. - */ - private String locateFileUsingCatalog(String namespaceURI) - { - retrieveCatalog(); - - ICatalogEntry[] entries = systemCatalog.getCatalogEntries(); - for (int i = 0; i < entries.length; i++) - { - if (entries[i].getKey().equals(namespaceURI)) - return entries[i].getURI(); - } - - return null; - } - - private void retrieveCatalog() - { - if (systemCatalog != null) - return; - - 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.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) - { - systemCatalog = referencedCatalog; - } - } - } - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SelectFromCatalogDialog.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SelectFromCatalogDialog.java deleted file mode 100644 index 1f2737a523..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SelectFromCatalogDialog.java +++ /dev/null @@ -1,212 +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.xsd.ui.internal.common.properties.sections.appinfo; - -import org.eclipse.jface.dialogs.Dialog; -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.viewers.Viewer; -import org.eclipse.jface.viewers.ViewerFilter; -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.Group; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.wst.xml.core.internal.XMLCorePlugin; -import org.eclipse.wst.xml.core.internal.catalog.CatalogSet; -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.catalog.XMLCatalogEntriesView; -import org.eclipse.wst.xml.ui.internal.catalog.XMLCatalogEntryDetailsView; -import org.eclipse.wst.xml.ui.internal.catalog.XMLCatalogMessages; -import org.eclipse.wst.xml.ui.internal.catalog.XMLCatalogTreeViewer; - -public class SelectFromCatalogDialog extends Dialog -{ - - private ICatalog workingUserCatalog; - private ICatalog userCatalog; - private ICatalog defaultCatalog; - private XMLCatalogEntriesView catalogEntriesView; - private ICatalog systemCatalog; - - private String currentSelectionLocation; - private String currentSelectionNamespace; - - public SelectFromCatalogDialog(Shell parentShell) - { - super(parentShell); - - 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.SYSTEM_CATALOG_ID.equals(referencedCatalog.getId())) - { - systemCatalog = referencedCatalog; - } - else if (XMLCorePlugin.USER_CATALOG_ID.equals(referencedCatalog.getId())) - { - userCatalog = referencedCatalog; - } - } - } - } - - protected Control createDialogArea(Composite parent) - { - // we create a working copy of the 'User Settings' for the Catalog - // that we can modify - CatalogSet tempCatalogSet = new CatalogSet(); - workingUserCatalog = tempCatalogSet.lookupOrCreateCatalog("working", ""); //$NON-NLS-1$ //$NON-NLS-2$ - - // TODO: add entries from the nested catalogs as well - workingUserCatalog.addEntriesFromCatalog(userCatalog); - - Composite composite = new Composite(parent, SWT.NULL); - composite.setLayout(new GridLayout()); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.heightHint = 500; - composite.setLayoutData(gridData); - createCatalogEntriesView(composite); - createCatalogDetailsView(composite); - - return composite; - } - - protected void createCatalogEntriesView(Composite parent) - { - Group group = new Group(parent, SWT.NONE); - group.setLayout(new GridLayout()); - GridData gridData = new GridData(GridData.FILL_BOTH); - gridData.widthHint = 370; - group.setLayoutData(gridData); - group.setText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES); - group.setToolTipText(XMLCatalogMessages.UI_LABEL_USER_ENTRIES_TOOL_TIP); - - /* - * create a subclass of XMLCatalogEntriesView which suppresses - the - * creation of 'Add', 'Edit', 'Delete' buttons - any method involving the - * above buttons - */ - catalogEntriesView = new XMLCatalogEntriesView(group, workingUserCatalog, systemCatalog) - { - protected void createButtons(Composite parent) - { - } - - protected void updateWidgetEnabledState() - { - } - - }; - - // Only XML Schema entry is selectable - catalogEntriesView.setLayoutData(gridData); - XMLCatalogTreeViewer catalogTreeViewer = ((XMLCatalogTreeViewer) catalogEntriesView.getViewer()); - catalogTreeViewer.resetFilters(); - - catalogTreeViewer.addFilter(new XMLCatalogTableViewerFilter(new String[] { ".xsd" })); - } - - // Bug in the filter of the XML plugin, have to give a correct version here - // TODO: Waiting for the fix to be commited to XML plugin and - // be used by constellation - private class XMLCatalogTableViewerFilter extends ViewerFilter - { - private static final String W3_XMLSCHEMA_NAMESPACE = "http://www.w3.org/2001/"; - protected String[] extensions; - - public XMLCatalogTableViewerFilter(String[] extensions1) - { - this.extensions = extensions1; - } - - 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 the extension is correct and the namespace indicates - // that this entry is not the W3 XML Schema - if (catalogEntry.getURI().endsWith(extensions[i]) && !catalogEntry.getKey().startsWith(W3_XMLSCHEMA_NAMESPACE)) - { - result = true; - break; - } - } - } - else if (element.equals(XMLCatalogTreeViewer.PLUGIN_SPECIFIED_ENTRIES_OBJECT) || element.equals(XMLCatalogTreeViewer.USER_SPECIFIED_ENTRIES_OBJECT)) - { - return true; - } - return result; - } - } - - protected void createCatalogDetailsView(Composite parent) - { - Group detailsGroup = new Group(parent, SWT.NONE); - detailsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - detailsGroup.setLayout(new GridLayout()); - detailsGroup.setText(XMLCatalogMessages.UI_LABEL_DETAILS); - final XMLCatalogEntryDetailsView detailsView = new XMLCatalogEntryDetailsView(detailsGroup); - ISelectionChangedListener listener = new ISelectionChangedListener() - { - public void selectionChanged(SelectionChangedEvent event) - { - ISelection selection = event.getSelection(); - Object selectedObject = (selection instanceof IStructuredSelection) ? ((IStructuredSelection) selection).getFirstElement() : null; - if (selectedObject instanceof ICatalogEntry) - { - ICatalogEntry entry = (ICatalogEntry) selectedObject; - detailsView.setCatalogElement(entry); - currentSelectionLocation = entry.getURI(); - currentSelectionNamespace = entry.getKey(); - } - else - { - detailsView.setCatalogElement((ICatalogEntry) null); - currentSelectionLocation = ""; - currentSelectionNamespace = ""; - } - } - }; - catalogEntriesView.getViewer().addSelectionChangedListener(listener); - } - - public String getCurrentSelectionLocation() - { - return currentSelectionLocation; - } - - public String getCurrentSelectionNamespace() - { - return currentSelectionNamespace; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SpecificationForExtensionsSchema.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SpecificationForExtensionsSchema.java deleted file mode 100644 index e68e220f6f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/SpecificationForExtensionsSchema.java +++ /dev/null @@ -1,177 +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.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.StringTokenizer; - -import org.eclipse.jface.viewers.ILabelProvider; -import org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleAddExtensionCommand; -import org.eclipse.wst.xsd.ui.internal.common.commands.ExtensibleRemoveExtensionNodeCommand; - -public class SpecificationForExtensionsSchema -{ - private String description; - private String displayName; - private String namespaceURI; - private String location; - private ILabelProvider labelProvider; - private boolean isDefaultSchema = false; - private ExtensibleAddExtensionCommand addCommand; - private ExtensibleRemoveExtensionNodeCommand removeCommand; - - /** - * Either the workspace-relative path of the xsd file or the namespace - * of the xsd file (if it come from the Catalog) - */ - private String sourceHint; - private boolean fromCatalog; - - public SpecificationForExtensionsSchema() - { - super(); - } - - public SpecificationForExtensionsSchema(String desc) { - StringTokenizer tokenizer = new StringTokenizer(desc, "\t"); - - // we must be sure that each 'desc' contains info in correct format - // no error checking here - description = tokenizer.nextToken(); - displayName = tokenizer.nextToken(); - namespaceURI = tokenizer.nextToken(); - location = tokenizer.nextToken(); - isDefaultSchema = tokenizer.nextToken().equals("true"); - sourceHint = tokenizer.nextToken(); - fromCatalog = tokenizer.nextToken().equals("true"); - } - -/** - * @return Returns the description. - */ - public String getDescription() - { - return description; - } - - /** - * @param description - * The description to set. - */ - public void setDescription(String description) - { - this.description = description; - } - - /** - * @return Returns the displayName. - */ - public String getDisplayName() - { - return displayName; - } - - /** - * @param name - * The displayName to set. - */ - public void setDisplayName(String displayName) - { - this.displayName = displayName; - } - - /** - * @return Returns the namespaceURI. - */ - public String getNamespaceURI() - { - return namespaceURI; - } - - /** - * @param namespaceURI - * The namespaceURI to set. - */ - public void setNamespaceURI(String namespaceURI) - { - this.namespaceURI = namespaceURI; - } - - /** - * @return Returns the location of the xsd file. - */ - public String getLocation() - { - return location; - } - - /** - * @param location - * The location to be set - */ - public void setLocation(String location) - { - this.location = location; - } - - public ILabelProvider getLabelProvider() - { - return labelProvider; - } - - public void setLabelProvider(ILabelProvider labelProvider) - { - this.labelProvider = labelProvider; - } - - public ExtensibleAddExtensionCommand getExtensibleAddExtensionCommand() - { - return addCommand; - } - - public void setExtensibleAddExtensionCommand(ExtensibleAddExtensionCommand addCommand) - { - this.addCommand = addCommand; - } - - public ExtensibleRemoveExtensionNodeCommand getExtensibleRemoveExtensionNodeCommand() - { - return removeCommand; - } - - public void setExtensibleRemoveExtensionNodeCommand(ExtensibleRemoveExtensionNodeCommand removeCommand) - { - this.removeCommand = removeCommand; - } - - public boolean isDefautSchema(){ - return isDefaultSchema ; - } - - public void setDefautSchema(){ - isDefaultSchema = true; - } - - public void setSourceHint(String s){ - sourceHint = s; - } - - public String getSourceHint(){ - return sourceHint; - } - - public boolean isFromCatalog() { - return fromCatalog; - } - - public void setFromCatalog(boolean fromCatalog) { - this.fromCatalog = fromCatalog; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/XSDExtensionTreeContentProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/XSDExtensionTreeContentProvider.java deleted file mode 100644 index bf08f11095..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/XSDExtensionTreeContentProvider.java +++ /dev/null @@ -1,109 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.Iterator; -import java.util.List; -import org.eclipse.wst.xsd.ui.internal.common.util.XSDCommonUIUtils; -import org.eclipse.xsd.XSDAnnotation; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; -import org.w3c.dom.NamedNodeMap; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class XSDExtensionTreeContentProvider extends DOMExtensionTreeContentProvider -{ - public Object[] getElements(Object inputElement) - { - if (inputElement instanceof XSDConcreteComponent) - { - XSDConcreteComponent component = (XSDConcreteComponent) inputElement; - List elementsAndAttributes = new ArrayList(); - XSDAnnotation xsdAnnotation = XSDCommonUIUtils.getInputXSDAnnotation(component, false); - if (xsdAnnotation != null) - { - // Bug 137856 - Extension page of properties shouldn't display imported elements - // Added this if statement - if (xsdAnnotation.getSchema() == component.getSchema()) - { - List appInfoList = xsdAnnotation.getApplicationInformation(); - Element appInfoElement = null; - if (appInfoList.size() > 0) - { - appInfoElement = (Element) appInfoList.get(0); - } - if (appInfoElement != null) - { - for (Iterator it = appInfoList.iterator(); it.hasNext();) - { - Object obj = it.next(); - if (obj instanceof Element) - { - Element appInfo = (Element) obj; - NodeList nodeList = appInfo.getChildNodes(); - int length = nodeList.getLength(); - for (int i = 0; i < length; i++) - { - Node node = nodeList.item(i); - if (node instanceof Element) - { - elementsAndAttributes.add(node); - } - } - } - } - - /** Construct attributes list */ - NamedNodeMap attributes = appInfoElement.getAttributes(); - if (attributes != null) - { - // String defaultNamespace = - // (String)component.getSchema().getQNamePrefixToNamespaceMap().get(""); - int length = attributes.getLength(); - for (int i = 0; i < length; i++) - { - Node oneAttribute = attributes.item(i); - if (!isXmlnsAttribute(oneAttribute)) - { - String namespace = oneAttribute.getNamespaceURI(); - boolean isExtension = true; - if (namespace == null && oneAttribute.getPrefix() == null) - { - isExtension = false; - } - else if (!XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(namespace)) - { - isExtension = true; - } - if (isExtension) - { - elementsAndAttributes.add(oneAttribute); - } - } - } - } - } - } - } - return elementsAndAttributes.toArray(); - } - return Collections.EMPTY_LIST.toArray(); - } - - private static boolean isXmlnsAttribute(Node attribute) - { - String prefix = attribute.getPrefix(); - if (prefix != null) - { - // this handle the xmlns:foo="blah" case - return "xmlns".equals(prefix); //$NON-NLS-1$ - } - else - { - // this handles the xmlns="blah" case - return "xmlns".equals(attribute.getNodeName()); //$NON-NLS-1$ - } - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DefaultListNodeEditorConfiguration.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DefaultListNodeEditorConfiguration.java deleted file mode 100644 index ce45be897f..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DefaultListNodeEditorConfiguration.java +++ /dev/null @@ -1,17 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom; - - -public class DefaultListNodeEditorConfiguration extends ListNodeEditorConfiguration -{ - private String[] values; - - public DefaultListNodeEditorConfiguration(String[] values) - { - this.values = values; - } - - public Object[] getValues(Object propertyObject) - { - return values; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DialogNodeEditorConfiguration.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DialogNodeEditorConfiguration.java deleted file mode 100644 index 675c274729..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/DialogNodeEditorConfiguration.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom; - -import org.eclipse.swt.graphics.Image; - -public abstract class DialogNodeEditorConfiguration extends NodeEditorConfiguration -{ - public int getStyle() - { - return STYLE_DIALOG; - } - - public String getButonText() - { - return null; - } - - public Image getButtonImage() - { - return null; - } - - public abstract void invokeDialog(); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/ListNodeEditorConfiguration.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/ListNodeEditorConfiguration.java deleted file mode 100644 index 613396ee74..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/ListNodeEditorConfiguration.java +++ /dev/null @@ -1,25 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom; - -import org.eclipse.jface.viewers.LabelProvider; - -public abstract class ListNodeEditorConfiguration extends NodeEditorConfiguration -{ - private LabelProvider labelProvider; - - public LabelProvider getLabelProvider() - { - return labelProvider; - } - - public int getStyle() - { - return STYLE_COMBO; - } - - public void setLabelProvider(LabelProvider labelProvider) - { - this.labelProvider = labelProvider; - } - - public abstract Object[] getValues(Object propertyObject); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeCustomizationRegistry.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeCustomizationRegistry.java deleted file mode 100644 index ca321b1970..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeCustomizationRegistry.java +++ /dev/null @@ -1,157 +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.xsd.ui.internal.common.properties.sections.appinfo.custom; - -import java.util.HashMap; -import org.eclipse.core.runtime.IConfigurationElement; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.viewers.ILabelProvider; - -public class NodeCustomizationRegistry -{ - private static final String NAMESPACE = "namespace"; //$NON-NLS-1$ - private static final String LABEL_PROVIDER_CLASS_ATTRIBUTE_NAME = "labelProviderClass"; - private static final String NODE_EDITOR_PROVIDER_CLASS_ATTRIBUTE_NAME = "nodeEditorProviderClass"; //$NON-NLS-1$ - private static final String FILTER_CLASS_ATTRIBUTE_NAME = "filterClass"; - - - protected String extensionId; - protected HashMap map; - - public NodeCustomizationRegistry(String propertyEditorExtensionId) - { - extensionId = "org.eclipse.wst.xsd.ui.extensibilityNodeCustomizations";//propertyEditorExtensionId; - } - - private class Descriptor - { - IConfigurationElement configurationElement; - NodeEditorProvider nodeEditorProvider; - NodeFilter nodeFilter; - boolean nodeEditorProviderFailedToLoad = false; - boolean labelProviderFailedToLoad = false; - boolean nodeFilterFailedToLoad = false; - - Descriptor(IConfigurationElement element) - { - this.configurationElement = element; - } - - NodeEditorProvider lookupOrCreateNodeEditorProvider() - { - if (nodeEditorProvider == null && !nodeEditorProviderFailedToLoad) - { - try - { - nodeEditorProvider = (NodeEditorProvider)configurationElement.createExecutableExtension(NODE_EDITOR_PROVIDER_CLASS_ATTRIBUTE_NAME); - } - catch (Exception e) - { - nodeEditorProviderFailedToLoad = true; - } - } - return nodeEditorProvider; - } - - ILabelProvider createLabelProvider() - { - if (!labelProviderFailedToLoad) - { - try - { - return (ILabelProvider)configurationElement.createExecutableExtension(LABEL_PROVIDER_CLASS_ATTRIBUTE_NAME); - } - catch (Exception e) - { - labelProviderFailedToLoad = true; - } - } - return null; - } - - public NodeFilter getNodeFilter() - { - if (!nodeEditorProviderFailedToLoad) - { - try - { - nodeFilter = (NodeFilter)configurationElement.createExecutableExtension(FILTER_CLASS_ATTRIBUTE_NAME); - } - catch (Exception e) - { - nodeEditorProviderFailedToLoad = true; - } - } - return nodeFilter; - } - } - - - private HashMap initMap() - { - HashMap theMap = new HashMap(); - IConfigurationElement[] extensions = Platform.getExtensionRegistry().getConfigurationElementsFor("org.eclipse.wst.xsd.ui.extensibilityNodeCustomizations"); - for (int i = 0; i < extensions.length; i++) - { - IConfigurationElement configurationElement = extensions[i]; - String namespace = configurationElement.getAttribute(NAMESPACE); - if (namespace != null) - { - theMap.put(namespace, new Descriptor(configurationElement)); - } - } - return theMap; - } - - private Descriptor getDescriptor(String namespace) - { - map = null; - if (namespace != null) - { - if (map == null) - { - map = initMap(); - } - return (Descriptor)map.get(namespace); - } - return null; - } - - public NodeEditorProvider getNodeEditorProvider(String namespace) - { - Descriptor descriptor = getDescriptor(namespace); - if (descriptor != null) - { - return descriptor.lookupOrCreateNodeEditorProvider(); - } - return null; - } - - public ILabelProvider getLabelProvider(String namespace) - { - Descriptor descriptor = getDescriptor(namespace); - if (descriptor != null) - { - return descriptor.createLabelProvider(); - } - return null; - } - - public NodeFilter getNodeFilter(String namespace) - { - Descriptor descriptor = getDescriptor(namespace); - if (descriptor != null) - { - return descriptor.getNodeFilter(); - } - return null; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorConfiguration.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorConfiguration.java deleted file mode 100644 index 114565b8a6..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorConfiguration.java +++ /dev/null @@ -1,33 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom; - -import org.w3c.dom.Node; - -public abstract class NodeEditorConfiguration -{ - public final static int STYLE_NONE = 0; - public final static int STYLE_TEXT = 1; - public final static int STYLE_COMBO = 2; - public final static int STYLE_DIALOG = 4; - - public abstract int getStyle(); - - private Node node; - private Node parentNode; - - public Node getNode() - { - return node; - } - public void setNode(Node node) - { - this.node = node; - } - public Node getParentNode() - { - return parentNode; - } - public void setParentNode(Node parentNode) - { - this.parentNode = parentNode; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorProvider.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorProvider.java deleted file mode 100644 index f34bcfac31..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeEditorProvider.java +++ /dev/null @@ -1,8 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom; - - -public abstract class NodeEditorProvider -{ - public abstract NodeEditorConfiguration getNodeEditorConfiguration(String parentName, String nodeName); - //public abstract NodeEditorConfiguration getNodeEditorConfiguration(Node node); -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeFilter.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeFilter.java deleted file mode 100644 index 377ad256d1..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/properties/sections/appinfo/custom/NodeFilter.java +++ /dev/null @@ -1,11 +0,0 @@ -package org.eclipse.wst.xsd.ui.internal.common.properties.sections.appinfo.custom; - -import org.w3c.dom.Node; - -public class NodeFilter -{ - public boolean isApplicableContext(Node parentNode, int nodeType, String namespace, String name) - { - return true; - } -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/Messages.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/Messages.java deleted file mode 100644 index b91c7784c7..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/Messages.java +++ /dev/null @@ -1,113 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.util; - -import org.eclipse.osgi.util.NLS; - -public class Messages extends NLS -{ - static - { - NLS.initializeMessages("org.eclipse.wst.xsd.ui.internal.common.util.messages", Messages.class); //$NON-NLS-1$ - } - - public Messages() - { - super(); - } - - public static String _UI_ACTION_OPEN_IN_NEW_EDITOR; - public static String _UI_ACTION_ADD_ATTRIBUTE_GROUP; - public static String _UI_ACTION_ADD_ATTRIBUTE_GROUP_REF; - public static String _UI_ACTION_ADD_ATTRIBUTE_GROUP_DEFINITION; - public static String _UI_ACTION_ADD_GROUP_REF; - public static String _UI_ACTION_ADD_GROUP; - public static String _UI_ACTION_DELETE; - public static String _UI_ACTION_ADD_COMPLEX_TYPE; - public static String _UI_ACTION_ADD_ATTRIBUTE; - public static String _UI_ACTION_ADD_SIMPLE_TYPE; - public static String _UI_ACTION_UPDATE_ELEMENT_REFERENCE; - public static String _UI_LABEL_NO_ITEMS_SELECTED; - public static String _UI_ACTION_ADD; - public static String _UI_ACTION_ADD_WITH_DOTS; - public static String _UI_ACTION_EDIT_WITH_DOTS; - public static String _UI_ACTION_CHANGE_PATTERN; - public static String _UI_ACTION_ADD_ENUMERATION; - public static String _UI_ACTION_ADD_PATTERN; - public static String _UI_ACTION_ADD_ENUMERATIONS; - public static String _UI_ACTION_DELETE_CONSTRAINTS; - public static String _UI_ACTION_DELETE_PATTERN; - public static String _UI_ACTION_DELETE_ENUMERATION; - public static String _UI_ACTION_SET_ENUMERATION_VALUE; - public static String _UI_LABEL_PATTERN; - public static String _UI_ACTION_CHANGE_MAXIMUM_OCCURRENCE; - public static String _UI_ERROR_INVALID_VALUE_FOR_MAXIMUM_OCCURRENCE; - public static String _UI_ACTION_CHANGE_MINIMUM_OCCURRENCE; - public static String _UI_ACTION_ADD_APPINFO_ELEMENT; - public static String _UI_ACTION_ADD_APPINFO_ATTRIBUTE; - public static String _UI_ACTION_DELETE_APPINFO_ELEMENT; - public static String _UI_ACTION_DELETE_APPINFO_ATTRIBUTE; - public static String _UI_ACTION_CHANGE_CONTENT_MODEL; - public static String _UI_ACTION_RENAME; - public static String _UI_ERROR_INVALID_NAME; - public static String _UI_LABEL_NAME; - public static String _UI_LABEL_REFERENCE; - public static String _UI_ACTION_UPDATE_MAXIMUM_OCCURRENCE; - public static String _UI_ACTION_UPDATE_MINIMUM_OCCURRENCE; - public static String _UI_LABEL_READONLY; - public static String _UI_LABEL_INCLUSIVE; - public static String _UI_LABEL_COLLAPSE_WHITESPACE; - public static String _UI_LABEL_SPECIFIC_CONSTRAINT_VALUES; - public static String _UI_LABEL_RESTRICT_VALUES_BY; - public static String _UI_LABEL_ENUMERATIONS; - public static String _UI_LABEL_PATTERNS; - public static String _UI_LABEL_MINIMUM_LENGTH; - public static String _UI_LABEL_MAXIMUM_LENGTH; - public static String _UI_LABEL_CONSTRAINTS_ON_LENGTH_OF; - public static String _UI_LABEL_CONSTRAINTS_ON_VALUE_OF; - public static String _UI_LABEL_MINIMUM_VALUE; - public static String _UI_LABEL_MAXIMUM_VALUE; - public static String _UI_LABEL_CONTRAINTS_ON; - public static String _UI_LABEL_TYPE; - public static String _UI_ACTION_CONSTRAIN_LENGTH; - public static String _UI_ACTION_UPDATE_BOUNDS; - public static String _UI_ACTION_COLLAPSE_WHITESPACE; - public static String _UI_LABEL_BASE; - public static String _UI_ERROR_INVALID_FILE; - public static String _UI_LABEL_EXTENSIONS; - public static String _UI_ACTION_ADD_EXTENSION_COMPONENT; - public static String _UI_ACTION_DELETE_EXTENSION_COMPONENT; - public static String _UI_LABEL_UP; - public static String _UI_LABEL_DOWN; - public static String _UI_LABEL_EXTENSION_DETAILS; - public static String _UI_ACTION_ADD_DOCUMENTATION; - public static String _UI_ACTION_ADD_EXTENSION_COMPONENTS; - public static String _UI_LABEL_EXTENSION_CATEGORIES; - public static String _UI_LABEL_ADD_WITH_DOTS; - public static String _UI_LABEL_DELETE; - public static String _UI_LABEL_EDIT; - public static String _UI_LABEL_AVAILABLE_COMPONENTS_TO_ADD; - public static String _UI_LABEL_EDIT_CATEGORY; - public static String _UI_ERROR_INVALID_CATEGORY; - public static String _UI_ERROR_FILE_CANNOT_BE_PARSED; - public static String _UI_ERROR_VALIDATE_THE_FILE; - public static String _UI_LABEL_SCHEMA; - public static String _UI_LABEL_ADD_CATEGORY; - public static String _UI_ERROR_NAME_ALREADY_USED; - public static String _UI_ACTION_BROWSE_WORKSPACE; - public static String _UI_LABEL_SELECT_XSD_FILE; - public static String _UI_DESCRIPTION_CHOOSE_XSD_FILE; - public static String _UI_ACTION_BROWSE_CATALOG; - public static String _UI_ACTION_ADD_ANY_ELEMENT; - public static String _UI_ACTION_ADD_ANY_ATTRIBUTE; - public static String _UI_ACTION_SET_BASE_TYPE; - public static String _UI_TOOLTIP_RENAME_REFACTOR; -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java deleted file mode 100644 index 508c6df020..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/XSDCommonUIUtils.java +++ /dev/null @@ -1,510 +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 - *******************************************************************************/ -package org.eclipse.wst.xsd.ui.internal.common.util; - -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.swt.graphics.Image; -import org.eclipse.wst.sse.core.internal.format.IStructuredFormatProcessor; -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.format.FormatProcessorXML; -import org.eclipse.wst.xsd.ui.internal.adt.design.ImageOverlayDescriptor; -import org.eclipse.xsd.XSDAnnotation; -import org.eclipse.xsd.XSDAttributeDeclaration; -import org.eclipse.xsd.XSDAttributeGroupDefinition; -import org.eclipse.xsd.XSDAttributeUse; -import org.eclipse.xsd.XSDComplexTypeContent; -import org.eclipse.xsd.XSDComplexTypeDefinition; -import org.eclipse.xsd.XSDConcreteComponent; -import org.eclipse.xsd.XSDElementDeclaration; -import org.eclipse.xsd.XSDFacet; -import org.eclipse.xsd.XSDFactory; -import org.eclipse.xsd.XSDFeature; -import org.eclipse.xsd.XSDIdentityConstraintDefinition; -import org.eclipse.xsd.XSDImport; -import org.eclipse.xsd.XSDInclude; -import org.eclipse.xsd.XSDModelGroup; -import org.eclipse.xsd.XSDModelGroupDefinition; -import org.eclipse.xsd.XSDNamedComponent; -import org.eclipse.xsd.XSDNotationDeclaration; -import org.eclipse.xsd.XSDParticle; -import org.eclipse.xsd.XSDRedefine; -import org.eclipse.xsd.XSDSchema; -import org.eclipse.xsd.XSDSimpleTypeDefinition; -import org.eclipse.xsd.XSDTypeDefinition; -import org.eclipse.xsd.XSDWildcard; -import org.eclipse.xsd.XSDXPathDefinition; -import org.eclipse.xsd.util.XSDConstants; -import org.w3c.dom.Element; -import org.w3c.dom.Node; - -public class XSDCommonUIUtils -{ - public XSDCommonUIUtils() - { - super(); - } - - public static Image getUpdatedImage(XSDConcreteComponent input, Image baseImage, boolean isReadOnly) - { - XSDAnnotation xsdAnnotation = getInputXSDAnnotation(input, false); - - if (xsdAnnotation != null) - { - if (xsdAnnotation.getApplicationInformation().size() > 0) - { - ImageOverlayDescriptor ovr = new ImageOverlayDescriptor(baseImage, isReadOnly); - Image newImage = ovr.getImage(); - return newImage; - } - } - return baseImage; - } - - public static XSDAnnotation getInputXSDAnnotation(XSDConcreteComponent input, boolean createIfNotExist) - { - XSDAnnotation xsdAnnotation = null; - XSDFactory factory = XSDFactory.eINSTANCE; - if (input instanceof XSDAttributeDeclaration) - { - XSDAttributeDeclaration xsdComp = (XSDAttributeDeclaration) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDAttributeGroupDefinition) - { - XSDAttributeGroupDefinition xsdComp = (XSDAttributeGroupDefinition) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDElementDeclaration) - { - XSDElementDeclaration xsdComp = (XSDElementDeclaration) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDNotationDeclaration) - { - XSDNotationDeclaration xsdComp = (XSDNotationDeclaration) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDXPathDefinition) - { - XSDXPathDefinition xsdComp = (XSDXPathDefinition) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDModelGroup) - { - XSDModelGroup xsdComp = (XSDModelGroup) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDModelGroupDefinition) - { - XSDModelGroupDefinition xsdComp = (XSDModelGroupDefinition) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDIdentityConstraintDefinition) - { - XSDIdentityConstraintDefinition xsdComp = (XSDIdentityConstraintDefinition) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDWildcard) - { - XSDWildcard xsdComp = (XSDWildcard) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDSchema) - { - XSDSchema xsdComp = (XSDSchema) input; - List list = xsdComp.getAnnotations(); - if (list.size() > 0) - { - xsdAnnotation = (XSDAnnotation) list.get(0); - } - else - { - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - if (xsdComp.getContents() != null) - { - xsdComp.getContents().add(0, xsdAnnotation); - } - } - } - return xsdAnnotation; - } - else if (input instanceof XSDFacet) - { - XSDFacet xsdComp = (XSDFacet) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDTypeDefinition) - { - XSDTypeDefinition xsdComp = (XSDTypeDefinition) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDInclude) - { - XSDInclude xsdComp = (XSDInclude) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDImport) - { - XSDImport xsdComp = (XSDImport) input; - xsdAnnotation = xsdComp.getAnnotation(); - if (createIfNotExist && xsdAnnotation == null) - { - xsdAnnotation = factory.createXSDAnnotation(); - xsdComp.setAnnotation(xsdAnnotation); - } - } - else if (input instanceof XSDRedefine) - { - XSDRedefine xsdComp = (XSDRedefine) input; - List list = xsdComp.getAnnotations(); - if (list.size() > 0) - { - xsdAnnotation = (XSDAnnotation) list.get(0); - } - else - { - if (createIfNotExist && xsdAnnotation == null) - { - // ? - } - } - return xsdAnnotation; - } - else if (input instanceof XSDAnnotation) - { - xsdAnnotation = (XSDAnnotation) input; - } - - if (createIfNotExist) - { - formatAnnotation(xsdAnnotation); - } - - return xsdAnnotation; - } - - private static void formatAnnotation(XSDAnnotation annotation) - { - Element element = annotation.getElement(); - formatChild(element); - } - - public static void formatChild(Node child) - { - if (child instanceof IDOMNode) - { - IDOMModel model = ((IDOMNode) child).getModel(); - try - { - // tell the model that we are about to make a big model change - model.aboutToChangeModel(); - - IStructuredFormatProcessor formatProcessor = new FormatProcessorXML(); - formatProcessor.formatNode(child); - } - finally - { - // tell the model that we are done with the big model change - model.changedModel(); - } - } - } - - public static String createUniqueElementName(String prefix, List elements) - { - ArrayList usedNames = new ArrayList(); - for (Iterator i = elements.iterator(); i.hasNext();) - { - usedNames.add(getDisplayName((XSDNamedComponent) i.next())); - } - - int i = 1; - String testName = prefix; - while (usedNames.contains(testName)) - { - testName = prefix + i++; - } - return testName; - } - - public static String getDisplayName(XSDNamedComponent component) - { - if (component instanceof XSDTypeDefinition) - return getDisplayNameFromXSDType((XSDTypeDefinition) component); - - if (component instanceof XSDFeature) - { - XSDFeature feature = (XSDFeature) component; - if (feature.getName() != null) - return feature.getName(); - else if (feature.getResolvedFeature() != null && feature.getResolvedFeature().getName() != null) - return feature.getResolvedFeature().getName(); - } - - return component.getName(); - - } - - public static String getDisplayNameFromXSDType(XSDTypeDefinition type) - { - return getDisplayNameFromXSDType(type, true); - } - - public static String getDisplayNameFromXSDType(XSDTypeDefinition type, boolean returnPrimitiveParents) - { - if (type == null) - return null; - - if (type.getName() == null || type.getName().length() == 0) - { - if (returnPrimitiveParents && isPrimitiveType(type)) - { - return getDisplayNameFromXSDType(type.getBaseType()); - } - - EObject container = type.eContainer(); - - while (container != null) - { - if (container instanceof XSDNamedComponent && ((XSDNamedComponent) container).getName() != null) - { - return ((XSDNamedComponent) container).getName(); - } - container = container.eContainer(); - } - return null; - } - else - return type.getName(); - } - - public static boolean isPrimitiveType(XSDTypeDefinition type) - { - if (type instanceof XSDComplexTypeDefinition) - return false; - - XSDTypeDefinition baseType = null; - if (type != null) - { - baseType = type.getBaseType(); - XSDTypeDefinition origType = baseType; // KC: although invalid, we need to - // prevent cycles and to avoid an - // infinite loop - while (baseType != null && !XSDConstants.isAnySimpleType(baseType) && !XSDConstants.isAnyType(baseType) && origType != baseType) - { - type = baseType; - baseType = type.getBaseType(); - } - baseType = type; - } - else - { - return false; - } - - return (XSDConstants.SCHEMA_FOR_SCHEMA_URI_2001.equals(baseType.getTargetNamespace())); - } - - public static XSDSimpleTypeDefinition getAnonymousSimpleType(XSDFeature input, XSDSimpleTypeDefinition xsdSimpleTypeDefinition) - { - XSDSimpleTypeDefinition anonymousSimpleType = null; - XSDTypeDefinition localType = null; - - if (input instanceof XSDElementDeclaration) - { - localType = ((XSDElementDeclaration) input).getAnonymousTypeDefinition(); - } - else if (input instanceof XSDAttributeDeclaration) - { - localType = ((XSDAttributeDeclaration) input).getAnonymousTypeDefinition(); - } - - if (localType instanceof XSDSimpleTypeDefinition) - { - anonymousSimpleType = (XSDSimpleTypeDefinition) localType; - } - return anonymousSimpleType; - } - - public static List getChildElements(XSDModelGroup group) - { - List children = new ArrayList(); - if (group == null) return children; - for (Iterator i = group.getContents().iterator(); i.hasNext();) - { - XSDParticle next = (XSDParticle) i.next(); - if (next.getContent() instanceof XSDFeature) - { - children.add(next.getContent()); - } - else if (next.getTerm() instanceof XSDModelGroup) - { - children.addAll(getChildElements((XSDModelGroup) next.getTerm())); - } - } - return children; - } - - public static List getAllAttributes(XSDComplexTypeDefinition xsdComplexType) - { - List attributes = getChildElements(xsdComplexType); - attributes.addAll(getChildAttributes(xsdComplexType)); - - return attributes; - } - - public static List getAllAttributes(XSDModelGroupDefinition xsdModelGroupDefinition) - { - List attributes = getChildElements(xsdModelGroupDefinition); - - return attributes; - } - - public static List getInheritedAttributes(XSDComplexTypeDefinition ct) - { - List attrs = new ArrayList(); - XSDTypeDefinition parent = ct.getBaseTypeDefinition(); - if (parent != null && parent instanceof XSDComplexTypeDefinition && ct.isSetDerivationMethod()) - { - attrs.addAll(getAllAttributes((XSDComplexTypeDefinition) parent)); - if (! ct.isCircular()) attrs.addAll(getInheritedAttributes((XSDComplexTypeDefinition) parent)); - } - - return attrs; - } - - public static List getChildElements(XSDComplexTypeDefinition ct) - { - return getChildElements(getModelGroup(ct)); - } - - public static List getChildElements(XSDModelGroupDefinition xsdModelGroupDefinition) - { - return getChildElements(xsdModelGroupDefinition.getModelGroup()); - } - - public static XSDModelGroup getModelGroup(XSDComplexTypeDefinition cType) - { - XSDParticle particle = cType.getComplexType(); - - if (particle == null || particle.eContainer() != cType) - return null; - - Object particleContent = particle.getContent(); - XSDModelGroup group = null; - - if (particleContent instanceof XSDModelGroupDefinition) - group = ((XSDModelGroupDefinition) particleContent).getResolvedModelGroupDefinition().getModelGroup(); - else if (particleContent instanceof XSDModelGroup) - group = (XSDModelGroup) particleContent; - - if (group == null) - return null; - - if (group.getContents().isEmpty() || group.eResource() != cType.eResource()) - { - XSDComplexTypeContent content = cType.getContent(); - if (content instanceof XSDParticle) - group = (XSDModelGroup) ((XSDParticle) content).getContent(); - } - - return group; - } - - public static List getChildAttributes(XSDComplexTypeDefinition ct) - { - EList attrContents = ct.getAttributeContents(); - List attrs = new ArrayList(); - for (int i = 0; i < attrContents.size(); i++) - { - Object next = attrContents.get(i); - - if (next instanceof XSDAttributeUse) - { - attrs.add(((XSDAttributeUse) next).getContent().getResolvedAttributeDeclaration()); - } - else if (next instanceof XSDAttributeGroupDefinition) - { - //XSDAttributeGroupDefinition attrGroup = (XSDAttributeGroupDefinition) next; - } - } - return attrs; - } - -} diff --git a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/messages.properties b/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/messages.properties deleted file mode 100644 index 7dc29a6523..0000000000 --- a/bundles/org.eclipse.wst.xsd.ui/src-common/org/eclipse/wst/xsd/ui/internal/common/util/messages.properties +++ /dev/null @@ -1,96 +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 -############################################################################### -_UI_ACTION_OPEN_IN_NEW_EDITOR=Open In New Editor -_UI_ACTION_DELETE_CONSTRAINTS=Delete Constraints -_UI_ACTION_DELETE_ENUMERATION=Delete Enumeration -_UI_ACTION_DELETE_APPINFO_ELEMENT=Delete AppInfo Element -_UI_ACTION_DELETE_APPINFO_ATTRIBUTE=Delete AppInfo Attribute -_UI_ACTION_DELETE_EXTENSION_COMPONENT=Delete Extension Component -_UI_ACTION_ADD_ATTRIBUTE_GROUP=Add Attribute Group -_UI_ACTION_ADD_APPINFO_ELEMENT=Add AppInfo Element -_UI_ACTION_ADD_ATTRIBUTE=Add Attribute -_UI_ACTION_ADD_GROUP_REF=Add Group Ref -_UI_ACTION_ADD_ANY_ELEMENT=Add An&y -_UI_ACTION_ADD_ANY_ATTRIBUTE=Add Any Attribute -_UI_ACTION_ADD_WITH_DOTS=Add... -_UI_ACTION_UPDATE_BOUNDS=Update bounds -_UI_ACTION_ADD_COMPLEX_TYPE=Add Complex Type -_UI_ACTION_ADD_ENUMERATIONS=Add Enumerations -_UI_ACTION_ADD_DOCUMENTATION=Add Documentation -_UI_ACTION_CONSTRAIN_LENGTH=Constrain length -_UI_ACTION_BROWSE_WORKSPACE=Workspace -_UI_LABEL_NO_ITEMS_SELECTED=No items selected -_UI_LABEL_EXTENSION_DETAILS=Extension Details -_UI_LABEL_EXTENSION_CATEGORIES=Extension Categories: -_UI_LABEL_COLLAPSE_WHITESPACE=Collapse whitespace -_UI_LABEL_RESTRICT_VALUES_BY=Restrict values by: -_UI_LABEL_MINIMUM_LENGTH=Minimum length: -_UI_LABEL_MAXIMUM_LENGTH=Maximum length: -_UI_LABEL_SELECT_XSD_FILE=Select XSD file -_UI_LABEL_CONSTRAINTS_ON_VALUE_OF=Constraints on value of -_UI_ACTION_ADD_SIMPLE_TYPE=Add Simple Type -_UI_ACTION_EDIT_WITH_DOTS=Edit... -_UI_ACTION_CHANGE_PATTERN=Change pattern -_UI_ACTION_ADD_ENUMERATION=Add Enumeration -_UI_ACTION_DELETE_PATTERN=Delete Pattern -_UI_ACTION_BROWSE_CATALOG=Catalog -_UI_ACTION_ADD_GROUP=Add Group -_UI_ACTION_ADD_PATTERN=Add pattern -_UI_ACTION_SET_BASE_TYPE=Set Base Type -_UI_ERROR_INVALID_NAME=Invalid name -_UI_ERROR_INVALID_FILE=Invalid file -_UI_ERROR_INVALID_CATEGORY=Invalid Category -_UI_ACTION_DELETE=Delete -_UI_ACTION_ADD=Add -_UI_ACTION_RENAME=Rename -_UI_LABEL_PATTERN=Pattern -_UI_LABEL_PATTERNS=Patterns -_UI_LABEL_NAME=Name: -_UI_LABEL_TYPE=Type: -_UI_LABEL_BASE=Base -_UI_LABEL_UP=Up -_UI_LABEL_DOWN=Down -_UI_LABEL_DELETE=Delete -_UI_LABEL_SCHEMA=Schema: -_UI_LABEL_EDIT=Edit -_UI_LABEL_REFERENCE=Reference: -_UI_LABEL_READONLY=ReadOnly -_UI_LABEL_INCLUSIVE=Inclusive -_UI_LABEL_ENUMERATIONS=Enumerations -_UI_LABEL_EXTENSIONS=Extensions -_UI_LABEL_MINIMUM_VALUE=Minimum value: -_UI_LABEL_MAXIMUM_VALUE=Maximum value: -_UI_LABEL_CONTRAINTS_ON=Constraints on -_UI_LABEL_ADD_WITH_DOTS=Add... -_UI_LABEL_ADD_CATEGORY=Add Category -_UI_LABEL_EDIT_CATEGORY=Edit Category -_UI_ACTION_ADD_ATTRIBUTE_GROUP_REF=Add Attribute Group Ref -_UI_ACTION_ADD_EXTENSION_COMPONENT=Add Extension Component -_UI_ACTION_ADD_EXTENSION_COMPONENTS=Add Extension Components -_UI_LABEL_CONSTRAINTS_ON_LENGTH_OF=Constraints on length of -_UI_ACTION_ADD_APPINFO_ATTRIBUTE=Add AppInfo Attribute -_UI_ACTION_SET_ENUMERATION_VALUE=Set Enumeration Value -_UI_ACTION_UPDATE_ELEMENT_REFERENCE=Update Element Reference -_UI_ACTION_UPDATE_MAXIMUM_OCCURRENCE=Update Maximum Occurrence -_UI_ACTION_UPDATE_MINIMUM_OCCURRENCE=Update Minimum Occurrence -_UI_ACTION_CHANGE_MAXIMUM_OCCURRENCE=Change Maximum Occurrence -_UI_ACTION_CHANGE_MINIMUM_OCCURRENCE=Change Minimum Occurrence -_UI_LABEL_SPECIFIC_CONSTRAINT_VALUES=Specific constraint values -_UI_LABEL_AVAILABLE_COMPONENTS_TO_ADD=Available components to Add: -_UI_ACTION_CHANGE_CONTENT_MODEL=Change Content Model -_UI_ERROR_FILE_CANNOT_BE_PARSED=The xsd file of the selected category cannot be parsed. -_UI_DESCRIPTION_CHOOSE_XSD_FILE=Choose an XSD file containing schema for your extensible components -_UI_ERROR_VALIDATE_THE_FILE=Please validate the file. -_UI_ERROR_NAME_ALREADY_USED=The name is already being used. -_UI_ACTION_COLLAPSE_WHITESPACE=Collapse whitespace -_UI_ACTION_ADD_ATTRIBUTE_GROUP_DEFINITION=Add Attribute Group Definition -_UI_ERROR_INVALID_VALUE_FOR_MAXIMUM_OCCURRENCE=Invalid value for maximum occurrence -_UI_TOOLTIP_RENAME_REFACTOR=Click here to invoke the Rename refactoring. -- cgit v1.2.3